Skip to content

Commit 5b98b0f

Browse files
authored
SWIFT-400 Improve Evergreen test result output (#533)
1 parent 8c35196 commit 5b98b0f

File tree

4 files changed

+372
-5
lines changed

4 files changed

+372
-5
lines changed

.evergreen/config.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ functions:
122122
script: |
123123
${PREPARE_SHELL}
124124
sh ${DRIVERS_TOOLS}/.evergreen/stop-orchestration.sh
125+
125126
"upload-mo-artifacts":
126127
- command: shell.exec
127128
params:
@@ -152,7 +153,12 @@ functions:
152153
SSL=${SSL} \
153154
AUTH=${AUTH} \
154155
SWIFT_VERSION=${SWIFT_VERSION} \
155-
sh ${PROJECT_DIRECTORY}/.evergreen/run-tests.sh
156+
${PROJECT_DIRECTORY}/.evergreen/run-tests.sh
157+
158+
"upload test results":
159+
- command: attach.xunit_results
160+
params:
161+
file: ./src/testResults.xml
156162

157163
"run atlas tests":
158164
- command: shell.exec
@@ -199,6 +205,7 @@ pre:
199205
post:
200206
- func: "stop mongo-orchestration"
201207
- func: "upload-mo-artifacts"
208+
- func: "upload test results"
202209
- func: "cleanup"
203210

204211
tasks:

.evergreen/run-tests.sh

100644100755
Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
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

55
# variables
66
PROJECT_DIRECTORY=${PROJECT_DIRECTORY:-$PWD}
77
MONGODB_URI=${MONGODB_URI:-"NO_URI_PROVIDED"}
8-
SWIFT_VERSION=${SWIFT_VERSION:-5.0.3}
8+
SWIFT_VERSION=${SWIFT_VERSION:-5.1}
99
INSTALL_DIR="${PROJECT_DIRECTORY}/opt"
1010
TOPOLOGY=${TOPOLOGY:-single}
1111
OS=$(uname -s | tr '[:upper:]' '[:lower:]')
1212
EXTRA_FLAGS="-Xlinker -rpath -Xlinker ${INSTALL_DIR}/lib"
13+
RAW_TEST_RESULTS="${PROJECT_DIRECTORY}/rawTestResults"
14+
XML_TEST_RESULTS="${PROJECT_DIRECTORY}/testResults.xml"
1315

1416
# ssl setup
1517
SSL=${SSL:-nossl}
@@ -35,4 +37,16 @@ swiftenv local $SWIFT_VERSION
3537
swift build $EXTRA_FLAGS
3638

3739
# test the driver
38-
MONGODB_TOPOLOGY=${TOPOLOGY} MONGODB_URI=$MONGODB_URI swift test $EXTRA_FLAGS
40+
set +o errexit # even if tests fail we want to parse the results, so disable errexit
41+
set -o pipefail # propagate error codes in the following pipes
42+
43+
MONGODB_TOPOLOGY=${TOPOLOGY} MONGODB_URI=$MONGODB_URI swift test $EXTRA_FLAGS 2>&1 | tee ${RAW_TEST_RESULTS}
44+
45+
# save tests exit code
46+
EXIT_CODE=$?
47+
48+
# convert tests to XML
49+
cat ${RAW_TEST_RESULTS} | swift "${PROJECT_DIRECTORY}/etc/convert-test-results.swift" > ${XML_TEST_RESULTS}
50+
51+
# exit with exit code for running the tests
52+
exit $EXIT_CODE

.swiftlint.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ excluded:
5454
- Tests/LinuxMain.swift
5555
- Sources/MongoSwiftSync/Exports.swift
5656
- Sources/MongoSwift/MongoSwiftVersion.swift
57-
- etc
5857

5958
trailing_whitespace:
6059
ignores_comments: false

0 commit comments

Comments
 (0)