-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathlong-running-test.sh
executable file
·61 lines (61 loc) · 2.8 KB
/
long-running-test.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#!/bin/bash
set -eo pipefail
# variables
echo "+++ $([[ "$BUILDKITE" == 'true' ]] && echo ':evergreen_tree: ')Configuring Environment"
GIT_ROOT="$(dirname $BASH_SOURCE[0])/.."
[[ -z "$TEST" ]] && export TEST=$1
if [[ "$(uname)" == 'Linux' ]]; then
. /etc/os-release
if [[ "$ID" == 'centos' ]]; then
[[ -f /opt/rh/rh-python36/enable ]] && source /opt/rh/rh-python36/enable
fi
fi
cd $GIT_ROOT/build
# mongoDB
if [[ ! -z "$(pgrep mongod)" ]]; then
echo "+++ $([[ "$BUILDKITE" == 'true' ]] && echo ':leaves: ')Killing old MongoDB"
$(pgrep mongod | xargs kill -9) || :
fi
echo "+++ $([[ "$BUILDKITE" == 'true' ]] && echo ':leaves: ')Starting new MongoDB"
[[ ! -d ~/data/mongodb && ! -d mongodata ]] && mkdir mongodata
echo "$ mongod --fork --logpath $(pwd)/mongod.log $([[ -d ~/data/mongodb ]] && echo '--dbpath ~/data/mongodb' || echo "--dbpath $(pwd)/mongodata") $([[ -f ~/etc/mongod.conf ]] && echo '-f ~/etc/mongod.conf')"
eval mongod --fork --logpath $(pwd)/mongod.log $([[ -d ~/data/mongodb ]] && echo '--dbpath ~/data/mongodb' || echo "--dbpath $(pwd)/mongodata") $([[ -f ~/etc/mongod.conf ]] && echo '-f ~/etc/mongod.conf')
# tests
if [[ -z "$TEST" ]]; then # run all serial tests
# count tests
echo "+++ $([[ "$BUILDKITE" == 'true' ]] && echo ':microscope: ')Running Long-Running Tests"
TEST_COUNT=$(ctest -N -L long_running_tests | grep -i 'Total Tests: ' | cut -d ':' -f 2 | awk '{print $1}')
if [[ $TEST_COUNT > 0 ]]; then
echo "$TEST_COUNT tests found."
# run tests
set +e # defer ctest error handling to end
echo '$ ctest -L long_running_tests --output-on-failure -T Test'
ctest -L long_running_tests --output-on-failure -T Test
EXIT_STATUS=$?
echo 'Done running long-running tests.'
else
echo "+++ $([[ "$BUILDKITE" == 'true' ]] && echo ':no_entry: ')ERROR: No tests registered with ctest! Exiting..."
EXIT_STATUS='1'
fi
else # run specific serial test
# ensure test exists
echo "+++ $([[ "$BUILDKITE" == 'true' ]] && echo ':microscope: ')Running $TEST"
TEST_COUNT=$(ctest -N -R ^$TEST$ | grep -i 'Total Tests: ' | cut -d ':' -f 2 | awk '{print $1}')
if [[ $TEST_COUNT > 0 ]]; then
echo "$TEST found."
# run tests
set +e # defer ctest error handling to end
echo "$ ctest -R ^$TEST$ --output-on-failure -T Test"
ctest -R ^$TEST$ --output-on-failure -T Test
EXIT_STATUS=$?
echo "Done running $TEST."
else
echo "+++ $([[ "$BUILDKITE" == 'true' ]] && echo ':no_entry: ')ERROR: No tests matching \"$TEST\" registered with ctest! Exiting..."
EXIT_STATUS='1'
fi
fi
if [[ ! -z "$(pgrep mongod)" ]]; then
echo "+++ $([[ "$BUILDKITE" == 'true' ]] && echo ':leaves: ')Killing MongoDB"
$(pgrep mongod | xargs kill -9) || :
fi
exit $EXIT_STATUS