diff --git a/.github/workflows/coverage-examples.yml b/.github/workflows/coverage-examples.yml index 7133e4d8a..8076e3949 100644 --- a/.github/workflows/coverage-examples.yml +++ b/.github/workflows/coverage-examples.yml @@ -57,4 +57,4 @@ jobs: - name: Build examples env: RUSTFLAGS: '-C link-arg=-s' - run: bash ./examples/build_wasm_test_all.sh ${{ matrix.toolchain }} \ No newline at end of file + run: cd ./examples && ./build_wasm_test_all.sh \ No newline at end of file diff --git a/examples/build_wasm_test_all.sh b/examples/build_wasm_test_all.sh index 9d2fb3dcd..7aded2a52 100755 --- a/examples/build_wasm_test_all.sh +++ b/examples/build_wasm_test_all.sh @@ -2,27 +2,36 @@ for d in "status-message" $(ls -d */ | grep -v -e "status-message\/$"); do if [ -d "$d" ]; then - if [ "$d" = "wasmcov-output/" ]; then - echo "Skipping $d" - continue - fi - if [ "$d" = "wasmcov/" ]; then - echo "Skipping $d" - continue - fi - if [ "$d" = "near_sandbox/" ]; then - echo "Skipping $d" - continue - fi - echo building $d; + echo "Processing directory $d" + echo "Building" cd $d; pwd - ./build.sh true - echo testing $d - cargo-wasmcov test --near=1.40.0 --wasmcov-dir /Users/jrmncos/forks/near-sdk-rs/examples/wasmcov - echo "Ending $d" + ./build.sh + echo "Testing" + cargo wasmcov test --near=1.40.0 cd .. + echo "End of processing of directory $d" fi done +echo "Merging .profraw files" +cargo wasmcov merge + +cd $WASMCOV_DIR +mkdir lcov + +for file in "$WASMCOV_DIR"/profdata/*.profdata; do + profdata_file_name=$(basename "$file") + # replacing '-' by '_' and changing extension .profdata by .o + object_file_name=$(echo "$base_name" | sed 's/-/_/g' | sed 's/.profdata$/.o/') + + lcov_file_name=$(echo "$base_name" | sed 's/-/_/g' | sed 's/.profdata$/.lcov/') + + echo "Base profdata: $profdata_file_name" + echo "Object file name: $object_file_name" + echo "Lcov file name: $lcov_file_name" + + llvm-cov export --instr-profile= "$WASMCOV_DIR/profdata/$profdata_file_name" "$WASMCOV_DIR/target/$object_file_name" > "$WASMCOV_DIR/lcov/$lcov_file_name" +done +