forked from mantidproject/mantid
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun-tests
executable file
·128 lines (107 loc) · 4.19 KB
/
run-tests
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
#!/bin/bash -ex
# This script expects a setup environment with all dependencies available in
# the environment
#
# Expected args:
# 1. WORKSPACE: path to the workspace/source code that this should run inside
# 2. ENABLE_SYSTEM_TESTS: whether or not system tests are being ran/built
# 3. ENABLE_UNIT_TESTS: whether or not unit tests are being ran/built
# 4. ENABLE_DOCS: Whether or not the docs have been built
# 5. ENABLE_DOC_TESTS: Whether or not the doc tests should be ran
# 6. BUILD_THREADS: The number of threads to use during testing
# 7. USE_CORE_DUMPS: Activate core dumps (Linux only)
WORKSPACE=$1
ENABLE_SYSTEM_TESTS=$2
ENABLE_UNIT_TESTS=$3
ENABLE_DOCS=$4
ENABLE_DOC_TESTS=$5
BUILD_THREADS=$6
USE_CORE_DUMPS=$7
# Run only 3 tests at a time because of memory constraints in the system tests
BUILD_THREADS_SYSTEM_TESTS=3
XVFB_SERVER_NUM=101
ULIMIT_CORE_ORIG=$(ulimit -c)
function run_with_xvfb {
if [ $(command -v xvfb-run) ]; then
# Use -e because a bug on RHEL7 means --error-file produces an error: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=337703;msg=2
# Use -noreset because of an X Display bug caused by a race condition in xvfb: https://gitlab.freedesktop.org/xorg/xserver/-/issues/1102
xvfb-run -e /dev/stderr --server-args="-core -noreset -screen 0 640x480x24" \
--server-num=${XVFB_SERVER_NUM} $@
else
eval $@
fi
}
function terminate_xvfb_sessions {
if [ $(command -v xvfb-run) ]; then
echo "Terminating existing Xvfb sessions"
# Kill Xvfb processes
killall Xvfb || true
# Remove Xvfb X server lock files
rm -f /tmp/.X${XVFB_SERVER_NUM}-lock
fi
}
function onexit {
if [[ ${USE_CORE_DUMPS} == true ]]; then
ulimit -c $ULIMIT_CORE_ORIG
fi
}
# Clean up prior to testing
# Prevent race conditions when creating the user config directory
if [[ $OSTYPE == "msys"* ]]; then
userconfig_dir=$APPDATA/mantidproject/mantid
if [ -d "$WORKSPACE/build/bin/Release" ]; then
binary_dir=$WORKSPACE/build/bin/Release
else
binary_dir=$WORKSPACE/build/bin
fi
userprops=$binary_dir/Mantid.user.properties
workbench_ini=$APPDATA/mantidproject/mantidworkbench.ini
else
userconfig_dir=$HOME/.mantid
userprops=$userconfig_dir/Mantid.user.properties
workbench_ini=~/.config/mantidproject/mantidworkbench.ini
fi
rm -fr $userconfig_dir
rm -fr $userprops
mkdir -p $userconfig_dir
# Remove GUI qsettings files
rm -f $workbench_ini
# use a fixed number of openmp threads to avoid overloading the system
echo MultiThreaded.MaxCores=2 > $userprops
# Setup core dumping
trap onexit INT TERM EXIT
if [[ ${USE_CORE_DUMPS} == true ]]; then
ulimit -c unlimited
fi
if [[ $OSTYPE == "msys"* ]]; then
WINDOWS_BUILD_OPTIONS="--config Release"
WINDOWS_TEST_OPTIONS="-C Release"
WINDOWS_UNITTEST_TIMEOUT_OPTIONS="--timeout 500"
export PYTHONHOME=$CONDA_PREFIX
SYSTEM_TEST_EXECUTABLE=$WORKSPACE/build/systemtest.bat
else
SYSTEM_TEST_EXECUTABLE=$WORKSPACE/build/systemtest
fi
# Run unit tests
cd $WORKSPACE/build
# mkdir for test logs
mkdir -p test_logs
if [[ $ENABLE_UNIT_TESTS == true ]]; then
run_with_xvfb ctest -j$BUILD_THREADS --no-compress-output -T Test -O test_logs/ctest_$OSTYPE.log --schedule-random --output-on-failure --repeat until-pass:3 $WINDOWS_TEST_OPTIONS $WINDOWS_UNITTEST_TIMEOUT_OPTIONS
terminate_xvfb_sessions
fi
if [[ $ENABLE_DOCS == true && $ENABLE_DOC_TESTS == true ]]; then
# Build doctests without using Xvfb for better output when things fail. Output to file due to console memory issues
QT_QPA_PLATFORM=offscreen cmake --build . --target docs-doctest -j$BUILD_THREADS $WINDOWS_BUILD_OPTIONS > test_logs/doctest_$OSTYPE.log
fi
if [[ $ENABLE_SYSTEM_TESTS == true ]]; then
rm -fr $userconfig_dir
rm -f $workbench_ini
# Turn off any auto updating on startup
mkdir -p $userconfig_dir
echo "UpdateInstrumentDefinitions.OnStartup = 0" > $userprops
echo "usagereports.enabled = 0" >> $userprops
echo "CheckMantidVersion.OnStartup = 0" >> $userprops
run_with_xvfb $SYSTEM_TEST_EXECUTABLE $WINDOWS_TEST_OPTIONS -j$BUILD_THREADS_SYSTEM_TESTS -l information --quiet --output-on-failure
terminate_xvfb_sessions
fi