Skip to content

Commit

Permalink
Fix logic
Browse files Browse the repository at this point in the history
Signed-off-by: Arthur Chan <[email protected]>
  • Loading branch information
arthurscchan committed Nov 14, 2023
1 parent a9d8d7a commit 39d59c8
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion infra/base-images/base-runner/coverage
Original file line number Diff line number Diff line change
Expand Up @@ -459,17 +459,28 @@ elif [[ $FUZZING_LANGUAGE == "jvm" ]]; then
fi
done


# Check if TARGET_PACKAGE_PREFIX has been set and remove classes not
# in the target package prefix to exclude them in the resulting HTML
# report. By default, Jacoco includes all classes in the classes dump
# directory to the resulting HTML report. Removing classes not in target
# package could concentrate the result on small subset of class and
# decrease the noise from project dependencies.
for arg in $COVERAGE_EXTRA_ARGS
do
if [[ $arg == "TARGET_PACKAGE_PREFIX="* ]]
then
TARGET_PACKAGE_PREFIX=`echo $arg | cut -d= -f2`
fi
done

dir_to_remove=
have_target_package="NO"
# Duplicate classes_dir for dependency classes removal
reduced_classes_dir=$DUMPS_DIR/classes_reduced
rm -rf $reduced_classes_dir
cp -r $classes_dir $reduced_classes_dir

if [[ -n ${TARGET_PACKAGE_PREFIX:-} ]]
then
# Translate the colon separated target package prefix environment
Expand All @@ -486,10 +497,22 @@ elif [[ $FUZZING_LANGUAGE == "jvm" ]]; then
need_remove="YES"
for prefix in $package_prefix
do
if [[ "./$prefix" == "$dir"* ]]
prefix=$reduced_classes_dir/$prefix
if [[ "$dir" == "$prefix"* ]]
then
have_target_package="YES"
need_remove="NO"
else
while [[ "$prefix" != "$reduced_classes_dir" ]]
do
if [[ "$dir" == "$prefix" ]]
then
have_target_package="YES"
need_remove="NO"
break
fi
prefix=$(dirname $prefix)
done
fi
done
if [[ "$need_remove" == "YES" ]]
Expand Down

0 comments on commit 39d59c8

Please sign in to comment.