diff --git a/.circleci/collect_results.sh b/.circleci/collect_results.sh index dc6a0eb7682..214895e3257 100755 --- a/.circleci/collect_results.sh +++ b/.circleci/collect_results.sh @@ -4,7 +4,7 @@ # This folder will be saved by circleci and available after test runs. set -e -#Enable '**' support +# Enable '**' support shopt -s globstar TEST_RESULTS_DIR=results @@ -19,6 +19,26 @@ if [[ ${#TEST_RESULT_DIRS[@]} -eq 0 ]]; then exit 0 fi +function get_source_file () { + file_path="${RESULT_XML_FILE%%"/build"*}" + file_path="${file_path/#"$WORKSPACE_DIR"\//}/src" + if ! [[ $RESULT_XML_FILE == *"#"* ]]; then + class="${RESULT_XML_FILE%.xml}" + class="${class##*"TEST-"}" + class="${class##*"."}" + common_root=$(grep -rl "class $class" "$file_path" | head -n 1) + while IFS= read -r line; do + while [[ $line != "$common_root"* ]]; do + common_root=$(dirname "$common_root") + if [[ "$common_root" == "$common_root/.." ]]; then + break + fi + done + done < <(grep -rl "class $class" "$file_path") + file_path="$common_root" + fi +} + echo "Saving test results:" while IFS= read -r -d '' RESULT_XML_FILE do @@ -26,6 +46,9 @@ do AGGREGATED_FILE_NAME=$(echo "$RESULT_XML_FILE" | rev | cut -d "/" -f 1,2,5 | rev | tr "/" "_") echo -n " as $AGGREGATED_FILE_NAME" cp "$RESULT_XML_FILE" "$TEST_RESULTS_DIR/$AGGREGATED_FILE_NAME" + # Insert file attribute to testcase XML nodes + get_source_file + sed -i "/