| 
1 | 1 | #!/bin/bash  | 
2 |  | -set -e  | 
3 |  | -set -x  | 
 | 2 | +set -ex  | 
4 | 3 | 
 
  | 
5 | 4 | # Parse command line arguments  | 
6 | 5 | OUTPUT_DIR="coverage-report"  | 
 | 6 | +OUTPUT_CODECOV_JSON=0  | 
7 | 7 | while [[ $# -gt 0 ]]; do  | 
8 | 8 |     case $1 in  | 
9 | 9 |         --output-dir)  | 
10 | 10 |             OUTPUT_DIR="$2"  | 
11 | 11 |             shift 2  | 
12 | 12 |             ;;  | 
 | 13 | +		--output-codecov-json)  | 
 | 14 | +			OUTPUT_CODECOV_JSON=1  | 
 | 15 | +			shift 1  | 
 | 16 | +			;;  | 
13 | 17 |         *)  | 
14 | 18 |             echo "Unknown option: $1"  | 
15 | 19 |             echo "Usage: $0 [--output-dir OUTPUT_DIRECTORY]"  | 
@@ -54,34 +58,12 @@ mkdir -p "$OUTPUT_DIR"  | 
54 | 58 | export RUSTFLAGS="--cfg=fuzzing --cfg=secp256k1_fuzz --cfg=hashes_fuzz"  | 
55 | 59 | 
 
  | 
56 | 60 | # dont run this command when running in CI  | 
57 |  | -if [ "$CI" != "true" ] && [ "$GITHUB_ACTIONS" != "true" ]; then  | 
 | 61 | +if [ "$OUTPUT_CODECOV_JSON" = "0" ]; then  | 
58 | 62 |     cargo llvm-cov --html --ignore-filename-regex "fuzz/" --output-dir "$OUTPUT_DIR"  | 
59 |  | - | 
60 |  | -    # Check if coverage report was generated successfully  | 
61 |  | -    # The report is generated in $OUTPUT_DIR/html/index.html when using --html --output-dir  | 
62 |  | -    if [ ! -f "$OUTPUT_DIR/html/index.html" ]; then  | 
63 |  | -        echo "Error: Failed to generate coverage report at $OUTPUT_DIR/html/index.html"  | 
64 |  | -        echo "Contents of $OUTPUT_DIR:"  | 
65 |  | -        ls -la "$OUTPUT_DIR" || echo "Directory $OUTPUT_DIR does not exist"  | 
66 |  | -        if [ -d "$OUTPUT_DIR/html" ]; then  | 
67 |  | -            echo "Contents of $OUTPUT_DIR/html:"  | 
68 |  | -            ls -la "$OUTPUT_DIR/html"  | 
69 |  | -        fi  | 
70 |  | -        exit 1  | 
71 |  | -    fi  | 
72 | 63 |     echo "Coverage report generated in $OUTPUT_DIR/html/index.html"  | 
73 |  | -fi  | 
74 |  | - | 
75 |  | -# Generate codecov JSON format if running in CI environment  | 
76 |  | -if [ "$CI" = "true" ] || [ "$GITHUB_ACTIONS" = "true" ]; then  | 
77 |  | -    echo "CI environment detected, generating codecov JSON format..."  | 
 | 64 | +else  | 
78 | 65 |     cargo llvm-cov --codecov --ignore-filename-regex "fuzz/" --output-path "$OUTPUT_DIR/fuzz-codecov.json"  | 
79 |  | -      | 
80 |  | -    if [ -f "$OUTPUT_DIR/fuzz-codecov.json" ] && [[ "$OUTPUT_DIR" == *"target/"* ]]; then  | 
81 |  | -        TARGET_DIR="../target"  | 
82 |  | -        cp "$OUTPUT_DIR/fuzz-codecov.json" "$TARGET_DIR/fuzz-codecov.json"  | 
83 |  | -        echo "Fuzz codecov report copied to $TARGET_DIR/fuzz-codecov.json"  | 
84 |  | -    fi  | 
 | 66 | +    echo "Fuzz codecov report available at $OUTPUT_DIR/fuzz-codecov.json"  | 
85 | 67 | fi  | 
86 | 68 | 
 
  | 
87 | 69 | 
 
  | 
 | 
0 commit comments