Skip to content

Commit 275ba6d

Browse files
authored
Update test coverage documentation (#4077)
1 parent e5c6386 commit 275ba6d

File tree

1 file changed

+16
-13
lines changed

1 file changed

+16
-13
lines changed

guide/src/wasm-bindgen-test/coverage.md

+16-13
Original file line numberDiff line numberDiff line change
@@ -68,21 +68,24 @@ crate_name=name_of_the_tested_crate_in_snake_case
6868
objects=()
6969
IFS=$'\n'
7070
for file in $(
71-
CARGO_HOST_RUSTFLAGS=--cfg=wasm_bindgen_unstable_test_coverage \
72-
RUSTFLAGS="-Cinstrument-coverage -Zno-profiler-runtime --emit=llvm-ir --cfg=wasm_bindgen_unstable_test_coverage" \
73-
cargo +nightly test -Ztarget-applies-to-host -Zhost-config --tests --no-run --message-format=json | \
74-
jq -r "select(.reason == \"compiler-artifact\") | (select(.target.kind == [\"test\"]) // select(.target.name == \"$crate_name\")) | .filenames[0]"
71+
CARGO_HOST_RUSTFLAGS=--cfg=wasm_bindgen_unstable_test_coverage \
72+
RUSTFLAGS="-Cinstrument-coverage -Zno-profiler-runtime --emit=llvm-ir --cfg=wasm_bindgen_unstable_test_coverage" \
73+
cargo +nightly test -Ztarget-applies-to-host -Zhost-config --tests --no-run --message-format=json | \
74+
jq -r "select(.reason == \"compiler-artifact\") | (select(.target.kind == [\"test\"]) // select(.target.name == \"$crate_name\")) | .filenames[0]"
7575
)
7676
do
77-
if [[ ${file##*.} == "rlib" ]]; then
78-
base=$(basename $file .rlib)
79-
file=$(dirname $file)/${base#"lib"}.ll
80-
else
81-
file=$(dirname $file)/$(basename $file .wasm).ll
82-
fi
83-
84-
perl -i -p0e 's/(^define.*?$).*?^}/$1\nstart:\n unreachable\n}/gms' $file
85-
perl -i -p0e 's/(^define( [^ ]+)*) range\(.*?\)/$1/gm' $file
77+
if [[ ${file##*.} == "rlib" ]]; then
78+
base=$(basename $file .rlib)
79+
file=$(dirname $file)/${base#"lib"}.ll
80+
else
81+
file=$(dirname $file)/$(basename $file .wasm).ll
82+
fi
83+
84+
perl -i -p0e 's/(^define.*?$).*?^}/$1\nstart:\n unreachable\n}/gms' $file
85+
counter=1
86+
while (( counter != 0 )); do
87+
counter=$(perl -i -p0e '$c+= s/(^(define|declare)(,? [^\n ]+)*),? range\(.*?\)/$1/gm; END{print "$c"}' $file)
88+
done
8689

8790
output = $(basename $file .ll).o
8891
clang-18 $input -Wno-override-module -c -o $output

0 commit comments

Comments
 (0)