code-coverage: add option to ignore errors on missing files
- Add options to ignore errors on genthml at the merge
stage for missing source code files.
Signed-off-by: Saul Romero <saul.romero@arm.com>
diff --git a/coverage-tool/coverage-reporting/clone_sources.py b/coverage-tool/coverage-reporting/clone_sources.py
index ec38acd..99c80ab 100644
--- a/coverage-tool/coverage-reporting/clone_sources.py
+++ b/coverage-tool/coverage-reporting/clone_sources.py
@@ -71,6 +71,7 @@
print(("WARNING!: Mismatch in git repo {}\nExpected {}, "
"Cloned {}").format(source['URL'], source['COMMIT'],
commit_id))
+ return True
elif source['type'] == "http":
if handler is not None:
return handler(source,
@@ -124,7 +125,7 @@
url = git["URL"]
commit_id = git["COMMIT"]
output_loc = os.path.join(output_dir, git["LOCATION"])
- cmd = "git clone {} {}".format(url, output_loc)
+ cmd = "rm -rf {1} || true;git clone {0} {1}".format(url, output_loc)
output = call_cmd(cmd)
if git['REFSPEC']:
call_cmd("cd {};git fetch -q origin {}".format(
diff --git a/coverage-tool/coverage-reporting/merge.sh b/coverage-tool/coverage-reporting/merge.sh
index 635b1f2..899a784 100755
--- a/coverage-tool/coverage-reporting/merge.sh
+++ b/coverage-tool/coverage-reporting/merge.sh
@@ -1,7 +1,7 @@
#!/usr/bin/env bash
##############################################################################
-# Copyright (c) 2020, ARM Limited and Contributors. All rights reserved.
+# Copyright (c) 2020-2025, ARM Limited and Contributors. All rights reserved.
#
# SPDX-License-Identifier: GPL-2.0-only
##############################################################################
@@ -374,6 +374,8 @@
echo "[-m <JSON filename>] JSON merged SCM sources. Defaults to ./merged_scm.json"
echo "[-c] Flag to download/copy the source files from the JSON merged SCM into the workspace directory."
echo "[-g] Flag to generate local reports for each info/json instance."
+ echo "[-i] Ignore errors on genhtml."
+ echo "[-d] Enable debug mode for the script."
echo "$help_message"
}
@@ -393,7 +395,12 @@
info_files=() # Array of info files
json_files=() # Array of configuration json files
list_of_merged_builds=()
-while getopts ":hj:o:l:w:i:cm:g" opt; do
+GENHTML_ARGS=""
+DEBUG_MODE=false
+genhtml_version=$(genhtml --version | rev | cut -d ' ' -f1 | rev | xargs)
+gen_major=$(echo "$genhtml_version" | cut -d '.' -f1)
+gen_minor=$(echo "$genhtml_version" | rev | cut -d '.' -f1 | rev)
+while getopts ":hj:o:l:w:idcm:g" opt; do
case ${opt} in
h )
usage
@@ -405,6 +412,12 @@
c )
CLONE_SOURCES=true
;;
+ d )
+ DEBUG_MODE=true
+ ;;
+ i )
+ GENHTML_ARGS="${GENHTML_ARGS} --ignore-errors $([ $gen_major = '2' ] && echo inconsistent || echo source)"
+ ;;
j )
merge_configuration_file=$OPTARG
;;
@@ -435,6 +448,7 @@
;;
esac
done
+[ $DEBUG_MODE = true ] && set -x || set +x
shift $((OPTIND -1))
if [ -z "$merge_configuration_file" ]; then
echo "Merged configuration file required."
@@ -452,7 +466,9 @@
merged_coverage_file="$(get_abs_path $merged_coverage_file)"
merged_json_file="$(get_abs_path $merged_json_file)"
param_cloned=""
-get_info_json_files
+set +x
+get_info_json_files # always disabled for debug
+[ $DEBUG_MODE = true ] && set -x || set +x
merge_files
if [ $CLONE_SOURCES = true ];then
clone_repos $merged_json_file
@@ -460,7 +476,7 @@
# Generate merged coverage report
merged_status=true
-genhtml --branch-coverage $merged_coverage_file \
+genhtml $GENHTML_ARGS --branch-coverage $merged_coverage_file \
--output-directory $LCOV_FOLDER
if [ $? -ne 0 ];then
merged_status=false