Skip to content

Commit

Permalink
test: contract coverage (#416)
Browse files Browse the repository at this point in the history
* test: create coverage script

* feat: add coverage to justfile

* chore: log when opening reports
  • Loading branch information
mayconamaroCW authored Mar 20, 2024
1 parent 6ba318b commit 48498ff
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 0 deletions.
49 changes: 49 additions & 0 deletions e2e-contracts/coverage-contracts.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#!/bin/bash
#
# Generate coverage info for the Solidity contracts.
#
source $(dirname $0)/_functions.sh

# ------------------------------------------------------------------------------
# Functions
# ------------------------------------------------------------------------------

# Generate a solidity coverage info.
coverage() {
repo=$1

if [ -d repos/$repo/coverage/ ]; then
log "Already generated coverage for $repo"
return
fi

log "Generating coverage: $repo"

# Enter the repository folder
cd repos/$repo

npx hardhat coverage

# Leave the repository folder
cd ../../
}

# ------------------------------------------------------------------------------
# Execution
# ------------------------------------------------------------------------------

# configure tools
asdf local solidity 0.8.16

# execute
coverage brlc-token
coverage brlc-periphery
coverage brlc-pix-cashier
coverage brlc-yield-streamer
coverage brlc-multisig
coverage compound-periphery

if [ -n "$1" ] && [ "$1" = "--html" ]; then
log "Opening coverage reports in your web browser..."
open repos/*/coverage/index.html
fi
10 changes: 10 additions & 0 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -411,3 +411,13 @@ contracts-test-int:
fi
npx hardhat test
exit $?

# Contracts: Run tests and generate coverage info. Use --html to open in browser.
contracts-coverage *args="":
cd e2e-contracts && ./coverage-contracts.sh {{args}}

# Contracts: Erase coverage info
contracts-coverage-erase:
#!/bin/bash
cd e2e-contracts/repos
rm -rf */coverage

0 comments on commit 48498ff

Please sign in to comment.