Skip to content

Commit 922d9f1

Browse files
committed
fuzz: fix coverage report to include library crates
Since cargo-llvm-cov 0.7.0, only workspace members are instrumented by default. Since the fuzz crate is a standalone workspace, library crates like lightning were not instrumented, and the coverage report was empty. Add --dep-coverage to instrument the library path dependencies. This alone is not sufficient for the report: --dep-coverage's report filtering only supports crates.io deps, not path deps (per a TODO in cargo-llvm-cov source). Add --no-default-ignore-filename-regex to include all instrumented code, then use a custom --ignore-filename-regex to exclude unwanted paths (cargo registry, rustup toolchains, fuzz harness). AI tools were used in preparing this commit.
1 parent 38a62c3 commit 922d9f1

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

contrib/generate_fuzz_coverage.sh

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,11 @@ mkdir -p "$OUTPUT_DIR"
5757

5858
# dont run this command when running in CI
5959
if [ "$OUTPUT_CODECOV_JSON" = "0" ]; then
60-
cargo llvm-cov --html --ignore-filename-regex "fuzz/" --output-dir "$OUTPUT_DIR"
60+
cargo llvm-cov --html \
61+
--dep-coverage lightning,lightning-invoice,lightning-liquidity,lightning-rapid-gossip-sync,lightning-persister \
62+
--no-default-ignore-filename-regex \
63+
--ignore-filename-regex "(\.cargo/registry|\.rustup/toolchains|/fuzz/)" \
64+
--output-dir "$OUTPUT_DIR"
6165
echo "Coverage report generated in $OUTPUT_DIR/html/index.html"
6266
else
6367
# Clean previous coverage artifacts to ensure a fresh run.
@@ -78,7 +82,10 @@ else
7882
fi
7983

8084
echo "Replaying imported corpus (if found) via tests to generate coverage..."
81-
cargo llvm-cov -j8 --codecov --ignore-filename-regex "fuzz/" \
85+
cargo llvm-cov -j8 --codecov \
86+
--dep-coverage lightning,lightning-invoice,lightning-liquidity,lightning-rapid-gossip-sync,lightning-persister \
87+
--no-default-ignore-filename-regex \
88+
--ignore-filename-regex "(\.cargo/registry|\.rustup/toolchains|/fuzz/)" \
8289
--output-path "$OUTPUT_DIR/fuzz-codecov.json" --tests
8390

8491
echo "Fuzz codecov report available at $OUTPUT_DIR/fuzz-codecov.json"

0 commit comments

Comments
 (0)