Skip to content

Commit

Permalink
test: added scripts for measuring the test coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
nickysn committed Nov 1, 2024
1 parent 8f462b3 commit 38e6e35
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 0 deletions.
4 changes: 4 additions & 0 deletions utils/test-coverage/0_cleanup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#! /bin/sh

rm noir_tests.profdata `find . -name "*.profraw"`
cargo clean
6 changes: 6 additions & 0 deletions utils/test-coverage/1_test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#! /bin/sh

set -e

export RUSTFLAGS="-C instrument-coverage"
cargo test
3 changes: 3 additions & 0 deletions utils/test-coverage/2_profdata.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#! /bin/sh

llvm-profdata merge -sparse `find . -name "*.profraw"` -o noir_tests.profdata
3 changes: 3 additions & 0 deletions utils/test-coverage/3_cov.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#! /bin/sh

llvm-cov show -Xdemangler=rustfilt target/debug/nargo -instr-profile=noir_tests.profdata -show-line-counts-or-regions -show-instantiations
28 changes: 28 additions & 0 deletions utils/test-coverage/README.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
This directory includes scripts that help measure the test coverage of Noir.

They should be run from the main directory of the repo like this:

utils/test-coverage/0_cleanup.sh
utils/test-coverage/1_test.sh
...
etc.

Short description of what each of these scripts does:

0_cleanup.sh:
Cleans up the files from a previous test coverage measurement.

1_test.sh:
Runs the testsuite with test coverage measurement enabled. Testsuite run is
about 8 times slower than normal. Produces lots of *.profraw files all over
the place. A typical test run produced: 6,966,994 KiB in 1331 files

2_profdata.sh:
Combines all the *.profraw files into a single file, called
'noir_tests.profdata'.

3_cov.sh:
Produces a test coverage report. What the test does is just an example. You
can use the command, called by the script and modify its parameters, to
produce all kinds of reports. For specific details, you should consult the
documentation for the llvm-cov command.

0 comments on commit 38e6e35

Please sign in to comment.