Skip to content

Commit f2168c3

Browse files
committed
Update README.md and add test that it contains agave_tag.txt
1 parent 1de7a2a commit f2168c3

File tree

2 files changed

+23
-20
lines changed

2 files changed

+23
-20
lines changed

README.md

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,43 +2,29 @@
22

33
A wrapper around [`anchor test`] for computing test coverage
44

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).
66

77
## Steps to use
88

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].
1010

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:
2612

2713
```toml
2814
debug = true
2915
```
3016

3117
This tells Cargo to build with debug information.
3218

33-
4. Run `anchor-coverage` as follows:
19+
3. Run `anchor-coverage` as follows:
3420

3521
```sh
3622
anchor-coverage [ANCHOR_TEST_ARGS]...
3723
```
3824

3925
This will create an `sbf_trace_dir` directory with an LCOV file for each executable run.
4026

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:
4228

4329
```sh
4430
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
7864

7965
[Agave repository]: https://github.com/anza-xyz/agave
8066
[LLVM instrumentation-based coverage]: https://llvm.org/docs/CoverageMappingFormat.html
67+
[Releases]: https://github.com/trail-of-forks/sbpf-coverage/releases
8168
[`anchor test`]: https://www.anchor-lang.com/docs/references/cli#test
8269
[from source]: https://docs.anza.xyz/cli/install#building-from-source

tests/ci.rs

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
use assert_cmd::Command;
22
use regex::Regex;
3-
use std::{env::remove_var, ffi::OsStr, fs::read_to_string, path::Path};
3+
use std::{
4+
env::remove_var,
5+
ffi::OsStr,
6+
fs::{read, read_to_string},
7+
path::Path,
8+
};
49
use walkdir::WalkDir;
510

611
#[ctor::ctor]
@@ -88,6 +93,17 @@ fn no_package_lock_json() {
8893
}
8994
}
9095

96+
#[test]
97+
fn readme_contains_agave_tag() {
98+
let agave_tag = read_to_string("agave_tag.txt")
99+
.map(|s| s.trim_end().to_owned())
100+
.unwrap();
101+
let readme = read("README.md").unwrap();
102+
assert!(readme
103+
.windows(agave_tag.len())
104+
.any(|w| w == agave_tag.as_bytes()));
105+
}
106+
91107
#[test]
92108
fn readme_reference_links_are_sorted() {
93109
let re = Regex::new(r"^\[[^\]]*\]:").unwrap();

0 commit comments

Comments
 (0)