diff --git a/coverage-tool/coverage-reporting/clone_sources.py b/coverage-tool/coverage-reporting/clone_sources.py index ec38acd4a4786fadc6fad91f34fb31a1067c9993..99c80abc86cc278f0ae2d9ab8ceb60b3656cb7b5 100644 --- a/coverage-tool/coverage-reporting/clone_sources.py +++ b/coverage-tool/coverage-reporting/clone_sources.py @@ -71,6 +71,7 @@ def skip_source(output_dir, source, handler=None): 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 @@ class CloneSources(object): 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 635b1f20a4c6f566858a95616bd7a0807f88e80b..1034b79612848171497db629a59c6f0db435baca 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 ############################################################################## @@ -365,6 +365,8 @@ help_message=$(cat < JSON configuration file (info and intermediate json filenames to be merged)." @@ -374,10 +376,11 @@ EOF echo "[-m ] 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" } - [ ${-/x} != ${-} ] && TRACING=true || TRACING=false LOCAL_WORKSPACE="" CLONE_SOURCES=false @@ -393,7 +396,13 @@ variables_file="./variables.sh" 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) +unset OPTIND +while getopts ":hj:o:l:w:idcm:g" opt; do case ${opt} in h ) usage @@ -405,6 +414,12 @@ while getopts ":hj:o:l:w:i:cm:g" opt; do 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 +450,7 @@ while getopts ":hj:o:l:w:i:cm:g" opt; do ;; esac done +[ $DEBUG_MODE = true ] && set -x || set +x shift $((OPTIND -1)) if [ -z "$merge_configuration_file" ]; then echo "Merged configuration file required." @@ -447,12 +463,15 @@ if [ -z "$LOCAL_WORKSPACE" ] && [ $CLONE_SOURCES = true ]; then fi # Getting the script folder where other qa-tools script files must reside, i.e # merge.py, clone_sources.py +mkdir -p "${LCOV_FOLDER}" DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" LCOV_FOLDER="$(get_abs_path $LCOV_FOLDER)" 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 +479,7 @@ fi # 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