4
4
# This folder will be saved by circleci and available after test runs.
5
5
6
6
set -e
7
- # Enable '**' support
7
+ # Enable '**' support
8
8
shopt -s globstar
9
9
10
10
TEST_RESULTS_DIR=results
@@ -19,13 +19,36 @@ if [[ ${#TEST_RESULT_DIRS[@]} -eq 0 ]]; then
19
19
exit 0
20
20
fi
21
21
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
+
22
42
echo " Saving test results:"
23
43
while IFS= read -r -d ' ' RESULT_XML_FILE
24
44
do
25
45
echo -n " - $RESULT_XML_FILE "
26
46
AGGREGATED_FILE_NAME=$( echo " $RESULT_XML_FILE " | rev | cut -d " /" -f 1,2,5 | rev | tr " /" " _" )
27
47
echo -n " as $AGGREGATED_FILE_NAME "
28
48
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 "
29
52
# Replace Java Object hashCode by marker in testcase XML nodes to get stable test names
30
53
sed -i ' /<testcase/ s/@[0-9a-f]\{5,\}/@HASHCODE/g' " $TEST_RESULTS_DIR /$AGGREGATED_FILE_NAME "
31
54
# Replace random port numbers by marker in testcase XML nodes to get stable test names
0 commit comments