forked from xsuite/xsuite
-
Notifications
You must be signed in to change notification settings - Fork 0
/
run_tests.sh
41 lines (34 loc) · 1.12 KB
/
run_tests.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
#!/usr/bin/bash
# Expects the path to tests folder as the first argument
if [ $# -eq 0 ]; then
echo "No arguments provided. Please provide the path to the tests folder."
exit 1
fi
# Set the path to the reports folder
REPORTS_DIR="/opt/reports"
# Keep track of failures
STATUS=0
# If xtrack on Pyopencl context, run tests one by one, otherwise run normally
if [[ $XOBJECTS_TEST_CONTEXTS =~ "ContextPyopencl" ]] && [[ $* =~ xsuite/(xtrack|xpart|xfields) ]]; then
# Run tests one by one
pip install pytest-html-merger
for test_file in "$@"/test_*; do
TEST_NAME=$(basename "$test_file" .py) # strip path and extension
echo "Running test $TEST_NAME..."
pytest \
--color=yes \
--verbose \
--html="$REPORTS_DIR/report-$TEST_NAME.html" --self-contained-html \
"$test_file" || STATUS=1
done
echo "Generating report..."
pytest_html_merger -i "$REPORTS_DIR" -o "$REPORTS_DIR/report.html"
else
# Run tests normally if no Pyopencl context
pytest \
--color=yes \
--verbose \
--html="$REPORTS_DIR/report.html" --self-contained-html \
"$@" || STATUS=1
fi
exit $STATUS