Skip to content

Commit 1dc7183

Browse files
committed
Add script to insert source file attributes to XML file testcases.
1 parent 0da31f6 commit 1dc7183

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

.circleci/collect_results.sh

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,33 @@ echo "Saving test results:"
2323
while IFS= read -r -d '' RESULT_XML_FILE
2424
do
2525
echo -n "- $RESULT_XML_FILE"
26+
27+
28+
# Get source file of XML file
29+
FILE_PATH="${RESULT_XML_FILE%%"build"*}"
30+
FILE="${RESULT_XML_FILE##*"TEST-"}"
31+
CLASS="${FILE%%".xml"*}"
32+
if [[ $CLASS == *"#"* ]]; then
33+
# NOTE: if the XML file is of a particular test case, the source file is set to the parent test directory of the file that the test case was run from
34+
SUBDIRS="src/test"
35+
else
36+
CLASS_FILE="${CLASS//./\/}"
37+
SUBDIRS="src/test/groovy/$CLASS_FILE.groovy"
38+
fi
39+
FILE_PATH+="$SUBDIRS"
40+
echo -n "$FILE_PATH"
41+
42+
2643
AGGREGATED_FILE_NAME=$(echo "$RESULT_XML_FILE" | rev | cut -d "/" -f 1,2,5 | rev | tr "/" "_")
2744
echo -n " as $AGGREGATED_FILE_NAME"
2845
cp "$RESULT_XML_FILE" "$TEST_RESULTS_DIR/$AGGREGATED_FILE_NAME"
46+
47+
48+
# Insert file attribute to testcase XML nodes
49+
# NOTE: this assumes the same source file to each test case of the XML
50+
sed -i "/<testcase/ s/\(time=\"[^\"]*\"\)/\1 file=$FILE_PATH/g" "$TEST_RESULTS_DIR/$AGGREGATED_FILE_NAME"
51+
52+
2953
# Replace Java Object hashCode by marker in testcase XML nodes to get stable test names
3054
sed -i '/<testcase/ s/@[0-9a-f]\{5,\}/@HASHCODE/g' "$TEST_RESULTS_DIR/$AGGREGATED_FILE_NAME"
3155
# Replace random port numbers by marker in testcase XML nodes to get stable test names

0 commit comments

Comments
 (0)