44# This folder will be saved by circleci and available after test runs.
55
66set -e
7- # Enable '**' support
7+ # Enable '**' support
88shopt -s globstar
99
1010TEST_RESULTS_DIR=results
@@ -19,13 +19,36 @@ if [[ ${#TEST_RESULT_DIRS[@]} -eq 0 ]]; then
1919 exit 0
2020fi
2121
22+ function get_source_file () {
23+ file_path=" ${RESULT_XML_FILE%% " /build" * } "
24+ file_path=" ${file_path/# " $WORKSPACE_DIR " \/ / } /src"
25+ if ! [[ $RESULT_XML_FILE == * " #" * ]]; then
26+ class=" ${RESULT_XML_FILE% .xml} "
27+ class=" ${class##* " TEST-" } "
28+ class=" ${class##* " ." } "
29+ common_root=$( grep -rl " class $class " " $file_path " | head -n 1)
30+ while IFS= read -r line; do
31+ while [[ $line != " $common_root " * ]]; do
32+ common_root=$( dirname " $common_root " )
33+ if [[ " $common_root " == " $common_root /.." ]]; then
34+ break
35+ fi
36+ done
37+ done < <( grep -rl " class $class " " $file_path " )
38+ file_path=" $common_root "
39+ fi
40+ }
41+
2242echo " Saving test results:"
2343while IFS= read -r -d ' ' RESULT_XML_FILE
2444do
2545 echo -n " - $RESULT_XML_FILE "
2646 AGGREGATED_FILE_NAME=$( echo " $RESULT_XML_FILE " | rev | cut -d " /" -f 1,2,5 | rev | tr " /" " _" )
2747 echo -n " as $AGGREGATED_FILE_NAME "
2848 cp " $RESULT_XML_FILE " " $TEST_RESULTS_DIR /$AGGREGATED_FILE_NAME "
49+ # Insert file attribute to testcase XML nodes
50+ get_source_file
51+ sed -i " /<testcase/ s|\(time=\" [^\" ]*\" \)|\1 file=\" $file_path \" |g" " $TEST_RESULTS_DIR /$AGGREGATED_FILE_NAME "
2952 # Replace Java Object hashCode by marker in testcase XML nodes to get stable test names
3053 sed -i ' /<testcase/ s/@[0-9a-f]\{5,\}/@HASHCODE/g' " $TEST_RESULTS_DIR /$AGGREGATED_FILE_NAME "
3154 # Replace random port numbers by marker in testcase XML nodes to get stable test names
0 commit comments