1- #! /bin/sh
1+ #! /bin/bash
22set -o xtrace # Write all commands first to stderr
33set -o errexit # Exit the script with error if any of the commands fail
44
55# variables
66PROJECT_DIRECTORY=${PROJECT_DIRECTORY:- $PWD }
77MONGODB_URI=${MONGODB_URI:- " NO_URI_PROVIDED" }
8- SWIFT_VERSION=${SWIFT_VERSION:- 5.0.3 }
8+ SWIFT_VERSION=${SWIFT_VERSION:- 5.2.5 }
99INSTALL_DIR=" ${PROJECT_DIRECTORY} /opt"
1010TOPOLOGY=${TOPOLOGY:- single}
1111OS=$( uname -s | tr ' [:upper:]' ' [:lower:]' )
1212EXTRA_FLAGS=" -Xlinker -rpath -Xlinker ${INSTALL_DIR} /lib"
13+ RAW_TEST_RESULTS=" ${PROJECT_DIRECTORY} /rawTestResults"
14+ XML_TEST_RESULTS=" ${PROJECT_DIRECTORY} /testResults.xml"
15+ INSTALL_DEPS=${INSTALL_DEPS:- " false" }
1316
1417# ssl setup
1518SSL=${SSL:- nossl}
@@ -18,6 +21,13 @@ if [ "$SSL" != "nossl" ]; then
1821 export SSL_CA_FILE=" $DRIVERS_TOOLS /.evergreen/x509gen/ca.pem"
1922fi
2023
24+ # if dependencies were not installed separately, do so now.
25+ # this is used for continous matrix testing
26+ if [ " $INSTALL_DEPS " == " true" ]; then
27+ SWIFT_VERSION=${SWIFT_VERSION} \
28+ sh ${PROJECT_DIRECTORY} /.evergreen/install-dependencies.sh
29+ fi
30+
2131# enable swiftenv
2232export SWIFTENV_ROOT=" ${INSTALL_DIR} /swiftenv"
2333export PATH=" ${SWIFTENV_ROOT} /bin:$PATH "
@@ -35,4 +45,16 @@ swiftenv local $SWIFT_VERSION
3545swift build $EXTRA_FLAGS
3646
3747# test the driver
38- MONGODB_TOPOLOGY=${TOPOLOGY} MONGODB_URI=$MONGODB_URI swift test $EXTRA_FLAGS
48+ set +o errexit # even if tests fail we want to parse the results, so disable errexit
49+ set -o pipefail # propagate error codes in the following pipes
50+
51+ MONGODB_TOPOLOGY=${TOPOLOGY} MONGODB_URI=$MONGODB_URI swift test $EXTRA_FLAGS 2>&1 | tee ${RAW_TEST_RESULTS}
52+
53+ # save tests exit code
54+ EXIT_CODE=$?
55+
56+ # convert tests to XML
57+ cat ${RAW_TEST_RESULTS} | swift " ${PROJECT_DIRECTORY} /etc/convert-test-results.swift" > ${XML_TEST_RESULTS}
58+
59+ # exit with exit code for running the tests
60+ exit $EXIT_CODE
0 commit comments