-
Notifications
You must be signed in to change notification settings - Fork 47
/
Copy pathcoverage.sh
executable file
·57 lines (49 loc) · 1.7 KB
/
coverage.sh
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/usr/bin/env bash
set -e # exit on error
rm -rf coverage
mkdir -p coverage
# Generate the Forge coverage report
forge clean
if [ "$CI" != "true" ]; then
forge coverage --report summary --report lcov --report-file coverage/lcov-forge.info
else
# FIXME: Temporarily workaround a CI issue
touch coverage/lcov-forge.info
fi
# Generate the Hardhat coverage report
yarn clean
yarn hardhat coverage --solcoverjs ./.solcover.js --temp artifacts --show-stack-traces --testfiles "test/**/*.ts"
mv coverage/lcov.info coverage/lcov-hardhat.info
# Make the Hardhat report paths relative for consistency with Forge coverage report
sed -i -e 's/\/.*\/kleros-v2\/contracts\///g' coverage/lcov-hardhat.info
# Merge the two reports
lcov \
--ignore-errors format \
--ignore-errors inconsistent \
--rc max_message_count=3 \
--rc derive_function_end_line=0 \
--rc branch_coverage=1 \
--add-tracefile coverage/lcov-hardhat.info \
--add-tracefile coverage/lcov-forge.info \
--output-file coverage/merged-lcov.info
# Filter out unnecessary contracts from the report
lcov \
--ignore-errors inconsistent \
--rc max_message_count=3 \
--rc branch_coverage=1 \
--rc derive_function_end_line=0 \
--remove coverage/merged-lcov.info \
--output-file coverage/filtered-lcov.info \
"../node_modules" "src/test" "src/token" "src/kleros-v1" "src/proxy/mock" "src/gateway/mock" "src/rng/mock"
# Open more granular breakdown in browser
if [ "$CI" != "true" ]; then
# Generate the HTML report
genhtml coverage/filtered-lcov.info \
--ignore-errors inconsistent \
--rc branch_coverage=1 \
--rc max_message_count=3 \
-o coverage \
--ignore-errors category \
--ignore-errors format
open coverage/index.html
fi