|
2 | 2 |
|
3 | 3 | A wrapper around [`anchor test`] for computing test coverage |
4 | 4 |
|
5 | | -`anchor-coverage` requires a patched Solana test validator (see below). The patch is known to work with Agave commit [cd29142](https://github.com/anza-xyz/agave/commit/cd291424d3d71c1a3be0c2c919916dcaa272d162). |
| 5 | +`anchor-coverage` requires a patched `solana-test-validator` (see below). The patch is known to work with [Agave v3.0.6](https://github.com/anza-xyz/agave/tree/v3.0.6). |
6 | 6 |
|
7 | 7 | ## Steps to use |
8 | 8 |
|
9 | | -1. Clone the [Agave repository] and checkout the commit named above. |
| 9 | +1. Download, unzip, and untar a patched `solana-test-validator` from `sbpf-coverage`'s [Releases]. |
10 | 10 |
|
11 | | -2. Add the following to the `[patch.crates-io]` section near the end of Agave's Cargo.toml, and install Agave [from source]: |
12 | | - |
13 | | - ```toml |
14 | | - solana-sbpf = { git = "https://github.com/trail-of-forks/sbpf-coverage" } |
15 | | - ``` |
16 | | - |
17 | | - For Linux users, the following commands should suffice: |
18 | | - |
19 | | - ```sh |
20 | | - sed -i '/^\[patch\.crates-io\]$/a solana-sbpf = { git = "https://github.com/trail-of-forks/sbpf-coverage" }' Cargo.toml |
21 | | - ./scripts/cargo-install-all.sh . |
22 | | - export PATH=$PWD/bin:$PATH |
23 | | - ``` |
24 | | - |
25 | | -3. Add the following to the `[profile.release]` section of your Anchor project's root Cargo.toml: |
| 11 | +2. Add the following to the `[profile.release]` section of your Anchor project's root Cargo.toml: |
26 | 12 |
|
27 | 13 | ```toml |
28 | 14 | debug = true |
29 | 15 | ``` |
30 | 16 |
|
31 | 17 | This tells Cargo to build with debug information. |
32 | 18 |
|
33 | | -4. Run `anchor-coverage` as follows: |
| 19 | +3. Run `anchor-coverage` as follows: |
34 | 20 |
|
35 | 21 | ```sh |
36 | 22 | anchor-coverage [ANCHOR_TEST_ARGS]... |
37 | 23 | ``` |
38 | 24 |
|
39 | 25 | This will create an `sbf_trace_dir` directory with an LCOV file for each executable run. |
40 | 26 |
|
41 | | -5. Run the following command to generate and open an HTML coverage report: |
| 27 | +4. Run the following command to generate and open an HTML coverage report: |
42 | 28 |
|
43 | 29 | ```sh |
44 | 30 | genhtml --output-directory coverage sbf_trace_dir/*.lcov && open coverage/index.html |
@@ -78,5 +64,6 @@ The following is an example. The line with the assignment to `signer` is hit onl |
78 | 64 |
|
79 | 65 | [Agave repository]: https://github.com/anza-xyz/agave |
80 | 66 | [LLVM instrumentation-based coverage]: https://llvm.org/docs/CoverageMappingFormat.html |
| 67 | +[Releases]: https://github.com/trail-of-forks/sbpf-coverage/releases |
81 | 68 | [`anchor test`]: https://www.anchor-lang.com/docs/references/cli#test |
82 | 69 | [from source]: https://docs.anza.xyz/cli/install#building-from-source |
0 commit comments