-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcoverage.sh
More file actions
39 lines (31 loc) · 915 Bytes
/
coverage.sh
File metadata and controls
39 lines (31 loc) · 915 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/bin/bash
set -e # exit on error
# generates lcov.info
forge coverage --report lcov
# Foundry uses relative paths but Hardhat uses absolute paths.
# Convert absolute paths to relative paths for consistency.
sed -i -e 's/\/.*solidity.//g' lcov.info
# Merge lcov files
lcov \
--rc lcov_branch_coverage=1 \
--add-tracefile lcov.info \
--output-file merged-lcov.info
# Filter out node_modules, test, and mock files
lcov \
--rc lcov_branch_coverage=1 \
--remove merged-lcov.info \
--output-file filtered-lcov.info \
"*node_modules*" "*test*" "*mock*" "*scripts*" "*script*"
# Generate summary
lcov \
--rc lcov_branch_coverage=1 \
--list filtered-lcov.info
# Open more granular breakdown in browser
if [ $HTML_REPORT ]
then
genhtml \
--rc genhtml_branch_coverage=1 \
--output-directory coverage \
filtered-lcov.info
open coverage/index.html
fi