Skip to content

Commit 966ef84

Browse files
fix(ci): Fix JUnit test case name uniqueness (#8024)
1 parent 107788f commit 966ef84

File tree

1 file changed

+20
-10
lines changed

1 file changed

+20
-10
lines changed

.circleci/collect_results.sh

+20-10
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,30 @@ set -e
77
#Enable '**' support
88
shopt -s globstar
99

10-
TEST_RESULTS_DIR=./results
11-
mkdir -p $TEST_RESULTS_DIR >/dev/null 2>&1
12-
10+
TEST_RESULTS_DIR=results
11+
WORKSPACE_DIR=workspace
1312
mkdir -p $TEST_RESULTS_DIR
13+
mkdir -p $WORKSPACE_DIR
1414

15-
mkdir -p workspace
16-
mapfile -t test_result_dirs < <(find workspace -name test-results -type d)
15+
mapfile -t TEST_RESULT_DIRS < <(find $WORKSPACE_DIR -name test-results -type d)
1716

18-
if [[ ${#test_result_dirs[@]} -eq 0 ]]; then
17+
if [[ ${#TEST_RESULT_DIRS[@]} -eq 0 ]]; then
1918
echo "No test results found"
2019
exit 0
2120
fi
2221

23-
echo "saving test results"
24-
find "${test_result_dirs[@]}" -name \*.xml -exec sh -c '
25-
file=$(echo "$0" | rev | cut -d "/" -f 1,2,5 | rev | tr "/" "_")
26-
cp "$0" "$1/$file"' {} $TEST_RESULTS_DIR \;
22+
echo "Saving test results:"
23+
while IFS= read -r -d '' RESULT_XML_FILE
24+
do
25+
echo -n "- $RESULT_XML_FILE"
26+
AGGREGATED_FILE_NAME=$(echo "$RESULT_XML_FILE" | rev | cut -d "/" -f 1,2,5 | rev | tr "/" "_")
27+
echo -n " as $AGGREGATED_FILE_NAME"
28+
cp "$RESULT_XML_FILE" "$TEST_RESULTS_DIR/$AGGREGATED_FILE_NAME"
29+
# Replace Java Object hashCode by marker in testcase XML nodes to get stable test names
30+
sed -i '/<testcase/ s/@[0-9a-f]\{5,\}/@HASHCODE/g' "$TEST_RESULTS_DIR/$AGGREGATED_FILE_NAME"
31+
if cmp -s "$RESULT_XML_FILE" "$TEST_RESULTS_DIR/$AGGREGATED_FILE_NAME"; then
32+
echo ""
33+
else
34+
echo " (hashCode replaced)"
35+
fi
36+
done < <(find "${TEST_RESULT_DIRS[@]}" -name \*.xml -print0)

0 commit comments

Comments
 (0)