kcov: Filter out generated files, rename var

This commit is contained in:
wtfsck 2021-10-13 19:20:41 +02:00
parent fa50ba1a11
commit 54ba065ea8
1 changed files with 12 additions and 11 deletions

View File

@ -17,7 +17,7 @@ test_features=y
test_current=y test_current=y
test_msrv=y test_msrv=y
test_code_asm=y test_code_asm=y
test_cov=n gen_cov=n
kcov=kcov kcov=kcov
cov_out=$root_dir/cov-out cov_out=$root_dir/cov-out
@ -51,7 +51,7 @@ test_valid_invalid_instructions() {
# The C# code needs a formatter so add masm feature # The C# code needs a formatter so add masm feature
dotnet build -c:$configuration -p:IcedFeatureFlags="DECODER ENCODER OPCODE_INFO INSTR_INFO MASM" "$root_dir/src/csharp/Intel/IcedFuzzer/IcedFuzzer/IcedFuzzer.csproj" dotnet build -c:$configuration -p:IcedFeatureFlags="DECODER ENCODER OPCODE_INFO INSTR_INFO MASM" "$root_dir/src/csharp/Intel/IcedFuzzer/IcedFuzzer/IcedFuzzer.csproj"
if [ "$test_cov" = "y" ]; then if [ "$gen_cov" = "y" ]; then
release_flag= release_flag=
fzgt_output_dir=debug fzgt_output_dir=debug
else else
@ -183,8 +183,9 @@ build_features() {
cov_test() { cov_test() {
cov_test_dir=$1 cov_test_dir=$1
shift shift
if [ "$test_cov" = "y" ]; then if [ "$gen_cov" = "y" ]; then
$kcov --verify --exclude-pattern=/tests/,/test/,/test_utils/ --include-pattern=/iced-x86/ "$cov_out_rust_tmp/$cov_test_dir" "$@" # Don't include: tests, big generated files
"$kcov" --verify --exclude-pattern=/tests/,/test/,/test_utils/,fn_asm_impl.rs,fn_asm_pub.rs --include-pattern=/iced-x86/ "$cov_out_rust_tmp/$cov_test_dir" "$@"
else else
"$@" "$@"
fi fi
@ -193,7 +194,7 @@ cov_test() {
cargo_test_cov() { cargo_test_cov() {
cov_test_dir=$1 cov_test_dir=$1
shift shift
if [ "$test_cov" = "y" ]; then if [ "$gen_cov" = "y" ]; then
test_exe=$(cargo test --color always --no-run --message-format=json "$@" | grep -- '"name":"iced-x86"' | tail -1 | sed -e 's/.*"executable":"\([^"]\+\)".*/\1/') test_exe=$(cargo test --color always --no-run --message-format=json "$@" | grep -- '"name":"iced-x86"' | tail -1 | sed -e 's/.*"executable":"\([^"]\+\)".*/\1/')
if [ ! -x "$test_exe" ]; then if [ ! -x "$test_exe" ]; then
echo "Couldn't get the test executable name, got '$test_exe'" echo "Couldn't get the test executable name, got '$test_exe'"
@ -312,7 +313,7 @@ while [ "$#" -gt 0 ]; do
--test-features) test_features=y ;; --test-features) test_features=y ;;
--test-current) test_current=y ;; --test-current) test_current=y ;;
--test-msrv) test_msrv=y ;; --test-msrv) test_msrv=y ;;
--coverage) test_cov=y ;; --coverage) gen_cov=y ;;
--no-set-rustflags) set_rustflags=n ;; --no-set-rustflags) set_rustflags=n ;;
*) echo "Unknown arg: $1"; exit 1 ;; *) echo "Unknown arg: $1"; exit 1 ;;
@ -333,11 +334,11 @@ fi
echo "rustup show" echo "rustup show"
rustup show rustup show
if [ "$test_cov" = "y" ]; then if [ "$gen_cov" = "y" ]; then
mkdir -p "$cov_out" mkdir -p "$cov_out"
rm -rf "$cov_out_rust" "$cov_out_rust_merged" rm -rf "$cov_out_rust"
mkdir -p "$cov_out_rust_tmp" mkdir -p "$cov_out_rust_tmp"
$kcov --version "$kcov" --version
fi fi
if [ "$test_code_asm" = "y" ]; then if [ "$test_code_asm" = "y" ]; then
@ -370,6 +371,6 @@ if [ "$test_msrv" = "y" ]; then
build_test_msrv build_test_msrv
fi fi
if [ "$test_cov" = "y" ]; then if [ "$gen_cov" = "y" ]; then
$kcov --merge "$cov_out_rust_merged" "$cov_out_rust_tmp/"* "$kcov" --merge "$cov_out_rust_merged" "$cov_out_rust_tmp/"*
fi fi