|
2 | 2 | set -e
|
3 | 3 | set -x
|
4 | 4 |
|
| 5 | +# Parse command line arguments |
| 6 | +OUTPUT_DIR="target/llvm-cov/html" |
| 7 | +while [[ $# -gt 0 ]]; do |
| 8 | + case $1 in |
| 9 | + --output-dir) |
| 10 | + OUTPUT_DIR="$2" |
| 11 | + shift 2 |
| 12 | + ;; |
| 13 | + *) |
| 14 | + echo "Unknown option: $1" |
| 15 | + echo "Usage: $0 [--output-dir OUTPUT_DIRECTORY]" |
| 16 | + exit 1 |
| 17 | + ;; |
| 18 | + esac |
| 19 | +done |
| 20 | + |
5 | 21 | # Check if we're in the root directory, if so change to fuzz
|
6 | 22 | if [ -d "fuzz" ]; then
|
7 | 23 | cd fuzz
|
@@ -32,11 +48,28 @@ if [ "$show_corpus_message" = true ]; then
|
32 | 48 | echo ""
|
33 | 49 | fi
|
34 | 50 |
|
| 51 | +# Create output directory if it doesn't exist |
| 52 | +mkdir -p "$OUTPUT_DIR" |
| 53 | + |
35 | 54 | export RUSTFLAGS="--cfg=fuzzing --cfg=secp256k1_fuzz --cfg=hashes_fuzz"
|
36 | 55 | # ignore anything in fuzz directory since we don't want coverage of targets
|
37 |
| -cargo llvm-cov --html --ignore-filename-regex "fuzz/" |
| 56 | +cargo llvm-cov --html --ignore-filename-regex "fuzz/" --output-dir "$OUTPUT_DIR" |
| 57 | + |
| 58 | +# Check if coverage report was generated successfully |
| 59 | +# The report is generated directly in $OUTPUT_DIR/html/index.html |
| 60 | +if [ ! -f "$OUTPUT_DIR/html/index.html" ]; then |
| 61 | + echo "Error: Failed to generate coverage report at $OUTPUT_DIR/html/index.html" |
| 62 | + # Debug: list what was actually created |
| 63 | + echo "Contents of $OUTPUT_DIR:" |
| 64 | + ls -la "$OUTPUT_DIR" || echo "Directory $OUTPUT_DIR does not exist" |
| 65 | + if [ -d "$OUTPUT_DIR/html" ]; then |
| 66 | + echo "Contents of $OUTPUT_DIR/html:" |
| 67 | + ls -la "$OUTPUT_DIR/html" |
| 68 | + fi |
| 69 | + exit 1 |
| 70 | +fi |
38 | 71 |
|
39 | 72 | echo ""
|
40 |
| -echo "Coverage report generated in target/llvm-cov/html/index.html" |
| 73 | +echo "Coverage report generated in $OUTPUT_DIR/html/index.html" |
41 | 74 |
|
42 | 75 |
|
0 commit comments