Skip to content

Commit

Permalink
adding main script to build and generate lcov files
Browse files Browse the repository at this point in the history
  • Loading branch information
jrmncos committed Aug 18, 2024
1 parent dbdeef1 commit ab6c619
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 18 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/coverage-examples.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,4 @@ jobs:
- name: Build examples
env:
RUSTFLAGS: '-C link-arg=-s'
run: bash ./examples/build_wasm_test_all.sh ${{ matrix.toolchain }}
run: cd ./examples && ./build_wasm_test_all.sh
43 changes: 26 additions & 17 deletions examples/build_wasm_test_all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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


0 comments on commit ab6c619

Please sign in to comment.