-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathtest.sh
executable file
·73 lines (53 loc) · 2.48 KB
/
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
62
63
64
65
66
67
68
69
70
71
72
73
#!/usr/bin/env bash
set -eEuo pipefail
source local_wk_setup.sh
# Using forkserver instead of spawn is faster. Fork should never be used due to potential deadlock problems.
export MULTIPROCESSING_DEFAULT_START_METHOD=forkserver
# Note that pytest should be executed via `python -m`, since
# this will ensure that the current directory is added to sys.path
# (which is standard python behavior). This is necessary so that the imports
# refer to the checked out (and potentially modified) code.
PYTEST="uv run --all-extras --python ${PYTHON_VERSION:-3.13} -m pytest --suppress-no-test-exit-code -vv"
# Within the tests folder is a binaryData folder of the local running webknossos instance. This folder is cleaned up before running the tests.
# This find command gets all directories in binaryData/Organization_X except for the l4_sample and e2006_knossos directories and deletes them.
find tests/binaryData/Organization_X -mindepth 1 -maxdepth 1 -type d ! -name 'l4_sample' ! -name 'e2006_knossos' -exec rm -rf {} +
if [ $# -gt 0 ] && [ "$1" = "--refresh-snapshots" ]; then
ensure_local_test_wk
rm -rf tests/cassettes
# Starts a proxy server in record mode on port 3000 and sets the HTTP_PROXY env var
proxay --mode record --host http://localhost:9000 --tapes-dir tests/cassettes &
PROXAY_PID=$!
shift
$PYTEST "-m" "use_proxay" "$@"
PYTEST_EXIT_CODE=$?
trap 'kill $PROXAY_PID' EXIT
stop_local_test_wk
exit $PYTEST_EXIT_CODE
elif [ $# -gt 0 ] && [ "$1" = "--add-snapshots" ]; then
ensure_local_test_wk
# Starts a proxy server in record mode on port 3000 and sets the HTTP_PROXY env var
proxay --mode record --host http://localhost:9000 --tapes-dir tests/cassettes &
PROXAY_PID=$!
shift
$PYTEST "-m" "use_proxay" "$@"
PYTEST_EXIT_CODE=$?
trap 'kill $PROXAY_PID' EXIT
stop_local_test_wk
exit $PYTEST_EXIT_CODE
elif [ $# -gt 0 ] && [ "$1" = "--debug-cassettes" ]; then
# This will start a proxay server in replay mode so that the stored cassettes can be used for debugging tests.
export_vars
proxay --mode replay --tapes-dir tests/cassettes &
PROXAY_PID=$!
echo "Proxay server is running in replay mode. Press Ctrl+C to stop."
trap 'kill $PROXAY_PID; exit' INT
wait $PROXAY_PID
else
export_vars
proxay --mode replay --tapes-dir tests/cassettes 2>&1 > /dev/null &
PROXAY_PID=$!
trap 'kill $PROXAY_PID' EXIT
$PYTEST "--timeout=360" "$@"
PYTEST_EXIT_CODE=$?
exit $PYTEST_EXIT_CODE
fi