Skip to content

Commit 7d420e7

Browse files
committed
Add configurable timeouts and parallelism to test script
Introduces environment variable overrides for test timeouts, max failures, and parallel workers in the run-test-evaluation.sh script. Updates pytest invocation to use these configurable values, improving CI flexibility and test performance.
1 parent 46599a3 commit 7d420e7

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

tests/inspect-ai/scripts/run-test-evaluation.sh

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,14 @@
22

33
set -e # Exit immediately if a command fails
44

5+
# CI fast-fail defaults (override via env)
6+
: "${SHINY_TEST_TIMEOUT_SECS:=10}" # App startup fast-fail (seconds)
7+
: "${PYTEST_PER_TEST_TIMEOUT:=60}" # Per-test timeout (seconds)
8+
: "${PYTEST_SUITE_TIMEOUT:=6m}" # Whole pytest run timeout
9+
: "${PYTEST_MAXFAIL:=1}" # Fail fast on first failure
10+
: "${PYTEST_XDIST_WORKERS:=auto}" # Parallel workers for pytest-xdist
11+
export SHINY_TEST_TIMEOUT_SECS
12+
513
# Function to log with timestamp
614
log_with_timestamp() {
715
echo "[$(date '+%Y-%m-%d %H:%M:%S')] $1"
@@ -39,14 +47,15 @@ do
3947
test_exit_code=0
4048
# Disable exit on error just for the pytest command to check the exit code
4149
set +e
42-
timeout 15m pytest tests/inspect-ai/apps \
50+
timeout "$PYTEST_SUITE_TIMEOUT" pytest tests/inspect-ai/apps \
51+
-n "$PYTEST_XDIST_WORKERS" --dist loadfile \
4352
--tb=short \
4453
--disable-warnings \
45-
--maxfail=2 \
54+
--maxfail="$PYTEST_MAXFAIL" \
4655
--junit-xml=test-results.xml \
4756
--durations=10 \
48-
--timeout=300 \
49-
--timeout-method=thread \
57+
--timeout="$PYTEST_PER_TEST_TIMEOUT" \
58+
--timeout-method=signal \
5059
-v || test_exit_code=$?
5160
# Re-enable exit on error immediately
5261
set -e

0 commit comments

Comments
 (0)