Skip to content

Commit a38a34d

Browse files
committed
Convert test output to XML on Evergreen
1 parent 51520e5 commit a38a34d

File tree

3 files changed

+374
-3
lines changed

3 files changed

+374
-3
lines changed

.evergreen/config.yml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,12 +102,20 @@ functions:
102102
script: |
103103
${PREPARE_SHELL}
104104
SWIFT_VERSION=${SWIFT_VERSION} \
105-
sh ${PROJECT_DIRECTORY}/.evergreen/run-tests.sh
105+
${PROJECT_DIRECTORY}/.evergreen/run-tests.sh
106+
107+
"upload test results":
108+
- command: attach.xunit_results
109+
params:
110+
file: ./src/testResults.xml
106111

107112
pre:
108113
- func: "fetch source"
109114
- func: "install swift"
110115

116+
post:
117+
- func: "upload test results"
118+
111119
tasks:
112120
- name: "test"
113121
commands:

.evergreen/run-tests.sh

100644100755
Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/bin/sh
1+
#!/bin/bash
22
set -o xtrace # Write all commands first to stderr
33
set -o errexit # Exit the script with error if any of the commands fail
44

@@ -7,6 +7,8 @@ PROJECT_DIRECTORY=${PROJECT_DIRECTORY:-$PWD}
77
SWIFT_VERSION=${SWIFT_VERSION:-5.2.4}
88
INSTALL_DIR="${PROJECT_DIRECTORY}/opt"
99
OS=$(uname -s | tr '[:upper:]' '[:lower:]')
10+
RAW_TEST_RESULTS="${PROJECT_DIRECTORY}/rawTestResults"
11+
XML_TEST_RESULTS="${PROJECT_DIRECTORY}/testResults.xml"
1012

1113
# enable swiftenv
1214
export SWIFTENV_ROOT="${INSTALL_DIR}/swiftenv"
@@ -24,5 +26,19 @@ swiftenv local $SWIFT_VERSION
2426
# build the driver
2527
swift build
2628

29+
# even if tests fail we want to parse the results, so disable errexit
30+
set +o errexit
31+
# propagate error codes in the following pipes
32+
set -o pipefail
33+
2734
# test the driver
28-
swift test --enable-test-discovery
35+
swift test --enable-test-discovery 2>&1 | tee ${RAW_TEST_RESULTS}
36+
37+
# save tests exit code
38+
EXIT_CODE=$?
39+
40+
# convert tests to XML
41+
cat ${RAW_TEST_RESULTS} | swift "${PROJECT_DIRECTORY}/etc/convert-test-results.swift" > ${XML_TEST_RESULTS}
42+
43+
# exit with exit code for running the tests
44+
exit $EXIT_CODE

0 commit comments

Comments
 (0)