-
Notifications
You must be signed in to change notification settings - Fork 133
/
run_tests
executable file
·219 lines (198 loc) · 6.58 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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
#!/bin/bash
echo 'Running RAVEN tests ...'
SCRIPT_NAME=`readlink $0`
if test -x "$SCRIPT_NAME";
then
SCRIPT_DIRNAME=`dirname $SCRIPT_NAME`
else
SCRIPT_DIRNAME=`dirname $0`
fi
SCRIPT_DIR=`(cd $SCRIPT_DIRNAME; pwd)`
TEST_SET=2 # 0 for normal tests, 1 for plugin tests, 2 for both
# source read ravenrc script
RAVEN_RC_SCRIPT=$SCRIPT_DIR/scripts/read_ravenrc.sh
RAVEN_RC_SCRIPT="${RAVEN_RC_SCRIPT//\\//}"
source $RAVEN_RC_SCRIPT
# set up installation manager
INSTALLATION_MANAGER=$(read_ravenrc "INSTALLATION_MANAGER")
# maybe skip loading the environment in .ravenrc
SKIP_LOAD_ENV=0
# read command-line arguments
ARGS=()
for A in "$@"; do
case $A in
--skip-conda)
INSTALLATION_MANAGER=PIP
;;
--skip-load-env)
SKIP_LOAD_ENV=1
;;
--raven)
TEST_SET=0
;;
--plugins)
TEST_SET=1
;;
--test_all)
TEST_SET=2
;;
--pedantic-checks)
;;
*)
ARGS+=("$A")
;;
esac
done
echo 'Loading libraries ...'
if [[ $SKIP_LOAD_ENV == 1 ]];
then
echo Using currently active python environment, with command $(which python)
PYTHON_COMMAND=$(which python)
elif [[ "$INSTALLATION_MANAGER" == "CONDA" ]];
then
source $SCRIPT_DIR/scripts/establish_conda_env.sh --load
echo Loaded conda environment, with command $(which python)
elif [[ "$INSTALLATION_MANAGER" == "PIP" ]];
then
source $SCRIPT_DIR/scripts/establish_conda_env.sh --load --installation-manager PIP
echo Loaded pip environment, with command $(which python)
else
echo No installation: $INSTALLATION_MANAGER
if [ -z $PYTHON_COMMAND ];
then
# check the RC file
PYTHON_COMMAND=$(read_ravenrc "PYTHON_COMMAND")
fi
fi
# pick tests to run
## test set 0 is normal raven tests
## test set 1 is plugins only tests
## test set 2 is both normal raven and plugins tests
if [[ $TEST_SET == 0 ]] || [[ $TEST_SET == 2 ]]; then
DO_RAVEN=0
else
DO_RAVEN=1
fi
if [[ $TEST_SET == 1 ]] || [[ $TEST_SET == 2 ]]; then
DO_PLUGINS=0
else
DO_PLUGINS=1
fi
for A in "$@"; do
case $A in
--library_report | --library-report)
$PYTHON_COMMAND $SCRIPT_DIR/scripts/library_report
exit
;;
esac
done
#Note that this is from the perspective of python, otherwise would be
# identical to $SCRIPT_DIR (which matters on windows, but not elsewhere)
RAVEN_DIR=`$PYTHON_COMMAND $SCRIPT_DIR/scripts/plugin_handler.py -r`
# run the tests
# success/fail storage
# Names of successful test sets are stored in "PASSED"
# Names of failed test sets are stored in "FAILED"
# Success of most recent test stored in "rc"
# Total number of failed test sets stored in "ALL_PASS"
# initialize vars in case no tests get run
ALL_PASS=0
PASSED=()
FAILED=()
if [[ $DO_RAVEN == 0 ]]; then
echo
echo "********************************************************************************"
echo
echo 'Running RAVEN tests ...'
echo "Python command: $PYTHON_COMMAND"
echo "Script directory: $SCRIPT_DIR"
$PYTHON_COMMAND $SCRIPT_DIR/rook/main.py --config-file=$SCRIPT_DIR/developer_tools/rook.ini "${ARGS[@]}"
# store return codes individually (rc) and combined (ALL_PASS)
rc=$?
ALL_PASS=$rc
if [[ $rc != 0 ]]; then
echo ' ... there were failed RAVEN tests!'
FAILED=( "${FAILED[@]}" "RAVEN" )
else
echo ' ... RAVEN tests passed successfully.'
PASSED=( "${PASSED[@]}" "RAVEN" )
fi # end "if passed"
# test the API for Plugins using the ExamplePlugin
## note this means the ExamplePlugin may be run both as a RAVEN test and as a plugin test
## this is desired for machinery testing; as a result the ExamplePlugin should be as
## lightweight as practical!
P=PluginAPI
LOCATION=$($PYTHON_COMMAND $SCRIPT_DIR/scripts/plugin_handler.py -f ExamplePlugin)/tests
echo
echo "********************************************************************************"
echo
echo Running $P tests ...
# get location of ExamplePlugin test dir
EXTRA="--test-dir $LOCATION --testers-dir $RAVEN_DIR/scripts/TestHarness/testers,$LOCATION/../src/Testers --add-non-default-run-types qsub"
$PYTHON_COMMAND $SCRIPT_DIR/rook/main.py $EXTRA "${ARGS[@]}"
# $PYTHON_COMMAND $SCRIPT_DIR/rook/main.py --test-dir $LOCATION --add-non-default-run-types qsub "${ARGS[@]}"
rc=$?
ALL_PASS=$(($ALL_PASS + $rc))
if [[ $rc != 0 ]]; then
echo ... there were failed $P tests!
FAILED=( "${FAILED[@]}" "$P" )
else
echo ... $P tests passed successfully.
PASSED=( "${PASSED[@]}" "$P" )
fi # end "if passed"
fi # end "if do raven"
# now do plugins
if [[ $DO_PLUGINS == 0 ]]; then
# Now run the plugin tests
echo 'Loading plugin tests ...'
PLUGINS=$($PYTHON_COMMAND $SCRIPT_DIR/scripts/plugin_handler.py -l)
for P in $PLUGINS; do
LOCATION=$($PYTHON_COMMAND $SCRIPT_DIR/scripts/plugin_handler.py -f $P)/tests
# TODO extend config to use RAVEN and PLUGIN config options without redoing all tests
echo
echo "********************************************************************************"
echo
echo Starting tests for plugin "$P" ...
# add RAVEN testers to plugin testers
EXTRA="--test-dir $LOCATION --testers-dir $RAVEN_DIR/scripts/TestHarness/testers,$LOCATION/../src/Testers --add-non-default-run-types qsub"
echo Running ROOK command: "$PYTHON_COMMAND $SCRIPT_DIR/rook/main.py $EXTRA ${ARGS[@]} ..."
{
# try
# this is copy/paste from line 175
# saving this entire command in a string variable causes problems when there are multi-word args using quotes (--arg="con tent") in ARGS
$PYTHON_COMMAND $SCRIPT_DIR/rook/main.py $EXTRA "${ARGS[@]}"
rc=$?
} || {
# catch
rc=1
}
ALL_PASS=$(($ALL_PASS + $rc))
if [[ $rc != 0 ]]; then
echo ... there were failed tests for plugin "$P"!
FAILED=( "${FAILED[@]}" "$P" )
else
echo Tests passed for plugin "$P".
PASSED=( "${PASSED[@]}" "$P" )
fi
done # finish "for each plugin"
fi # finish "if do plugins"
## FINISHED running tests
# report results
echo
echo "********************************************************************************"
echo
if [[ $ALL_PASS != 0 ]]; then
# if no tests were run, this should not be possible!
echo ... there were failed tests!
echo The following test sets passed: ${PASSED[@]}
echo The following test sets failed: ${FAILED[@]}
exit $ALL_PASS
else
# check if NO tests were run
if [ ${#PASSED[@]} -eq 0 ]; then
echo WARNING: no test sets were checked!
else
echo Tested sets: ${PASSED[@]}
fi
echo ... tests passed!
fi