diff --git a/coverage-tool/coverage-reporting/merge.py b/coverage-tool/coverage-reporting/merge.py index e3d9d65a63c8ebf9c6ff3948e74dd2a08bcc6000..3ab46f72877d3752ec5d3b1252401f72509198c1 100755 --- a/coverage-tool/coverage-reporting/merge.py +++ b/coverage-tool/coverage-reporting/merge.py @@ -129,16 +129,17 @@ if options.local_workspace is not None: info_files_to_merge[i])) info_lines = info_file.readlines() info_file.close() - common_prefix = os.path.normpath( - os.path.commonprefix([line[3:] for line in info_lines - if 'SF:' in line])) temp_file = 'temporary_' + str(i) + '.info' + parts = None with open(temp_file, "w+") as f: for line in info_lines: - cf = common_prefix - if os.path.basename(common_prefix) in file_groups[i]["locations"]: - cf = os.path.dirname(common_prefix) - f.write(line.replace(cf, options.local_workspace)) + if "SF" in line: + for location in file_groups[i]["locations"]: + if location in line: + parts = line[3:].partition(location) + line = line.replace(parts[0], options.local_workspace + "/") + break + f.write(line) info_files_to_merge[i] = temp_file # Replace info file to be merged i += 1 diff --git a/coverage-tool/coverage-reporting/merge.sh b/coverage-tool/coverage-reporting/merge.sh index 354dbc85f60c242a61221a08a8224189cd678ccc..8304487e05c4f9cadc3438092a7220e0c0cc1052 100755 --- a/coverage-tool/coverage-reporting/merge.sh +++ b/coverage-tool/coverage-reporting/merge.sh @@ -13,7 +13,7 @@ # files. #============================================================================== -set -e +set +x ################################################################# # Function to manipulate json objects. # The json object properties can be accessed through "." separated @@ -127,7 +127,7 @@ try: except Exception as ex: print(ex) EOT - cd - + cd - } ################################################################# @@ -161,7 +161,7 @@ get_file() { fname="$where.$extension" # Same filename as folder rm $where/$fname &>/dev/null || true wget -o error.log $_origin -O $where/$fname || ( - cat error.log && exit -1) + cat error.log && exit -1) cloned_file="$(get_abs_path $where/$fname)" elif [ "$_type" = '"bundle"' ];then # Check file exists at origin, i.e. was unbundled before @@ -170,10 +170,10 @@ get_file() { cloned_file="$(get_abs_path $where/$fname)" fi elif [ "$_type" = '"file"' ];then - if [[ "$_origin" = http* ]]; then - echo "$_origin looks like 'http' rather than 'file' please check..." - exit -1 - fi + if [[ "$_origin" = http* ]]; then + echo "$_origin looks like 'http' rather than 'file' please check..." + exit -1 + fi fname="$where.$extension" # Same filename as folder cp -f $_origin $where/$fname cloned_file="$(get_abs_path $where/$fname)" @@ -395,8 +395,8 @@ if [ -z "$merge_input_json_file" ]; then exit -1 fi if [ -z "$LOCAL_WORKSPACE" ] && [ $CLONE_SOURCES = true ]; then - echo "Need to define a local workspace folder to clone/copy sources!" - exit -1 + echo "Need to define a local workspace folder to clone/copy sources!" + exit -1 fi # Getting the script folder where other script files must reside, i.e # merge.py, clone_sources.py @@ -409,7 +409,7 @@ param_cloned="" get_info_json_files merge_files if [ $CLONE_SOURCES = true ];then - clone_repos $output_json_file + clone_repos $output_json_file fi # Generate branch coverage report genhtml --branch-coverage $output_coverage_file \