Skip to content

Commit 5f896ed

Browse files
committed
Infra: Fix jvm coverage report
Signed-off-by: Arthur Chan <[email protected]>
1 parent edfa673 commit 5f896ed

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

infra/base-images/base-runner/coverage

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -457,6 +457,18 @@ elif [[ $FUZZING_LANGUAGE == "jvm" ]]; then
457457
then
458458
tempdir=$(mktemp -d)
459459
cd $tempdir && jar xvf $jar_file && cd -
460+
461+
# Remove class files that are not compiled from the java files found in $OUT/$SRC before copying
462+
find $tempdir -type f -name "*.class" | while read -r class_file; do
463+
relative_path=${class_file#$tempdir/}
464+
java_file_name=${relative_path%.class}.java
465+
if ! find $OUT$SRC -type f -name $(basename $java_file_name) | grep -q $java_file_name
466+
then
467+
echo "Removing: $class_file"
468+
rm -f "$class_file"
469+
fi
470+
done
471+
460472
cp -r $tempdir/* $classes_dir/
461473
rm -r $tempdir
462474
fi
@@ -473,6 +485,8 @@ elif [[ $FUZZING_LANGUAGE == "jvm" ]]; then
473485
# Remove all class files which have a dot in their file name which are normally
474486
# used to name a duplication of the legitimate class file.
475487
find $classes_dir/*/ -type f -name "*.*.class" | xargs rm -f
488+
# Clean up empty package directories
489+
# find $classes_dir -type d -empty -exec rmdir -p {} + 2>/dev/null
476490

477491
# Heuristically determine source directories based on Maven structure.
478492
# Always include the $SRC root as it likely contains the fuzzer sources.

0 commit comments

Comments
 (0)