-
Notifications
You must be signed in to change notification settings - Fork 32
Expand file tree
/
Copy pathtest.sh
More file actions
executable file
·83 lines (73 loc) · 2 KB
/
Copy pathtest.sh
File metadata and controls
executable file
·83 lines (73 loc) · 2 KB
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
#!/usr/bin/env bash
#
# Usage:
# ./scripts/test.sh # Run tests on all Python versions
# ./scripts/test.sh 3.12 # Run tests on Python 3.12 only
# ./scripts/test.sh 3.11 3.12 # Run tests on Python 3.11 and 3.12
# ./scripts/test.sh --coverage # Run tests with coverage on all versions
# ./scripts/test.sh --ci # Run full CI checks (lint, type, tests)
# ./scripts/test.sh --fresh # Recreate virtual environments
#
# Additional pytest arguments can be passed after --, e.g.:
# ./scripts/test.sh 3.12 -- -k "test_sso" -v
set -e
# Check if uv is available
if ! command -v uv &>/dev/null; then
echo "Error: uv is not installed or not in PATH"
echo "Install uv: https://docs.astral.sh/uv/getting-started/installation/"
exit 1
fi
# Parse arguments
PYTHON_VERSIONS=()
NOX_ARGS=()
PYTEST_ARGS=()
SESSION="tests"
FRESH=false
PARSING_PYTEST_ARGS=false
for arg in "$@"; do
if [[ "$PARSING_PYTEST_ARGS" == true ]]; then
PYTEST_ARGS+=("$arg")
elif [[ "$arg" == "--" ]]; then
PARSING_PYTEST_ARGS=true
elif [[ "$arg" == "--coverage" ]]; then
SESSION="coverage"
elif [[ "$arg" == "--ci" ]]; then
SESSION="ci"
elif [[ "$arg" == "--fresh" ]]; then
FRESH=true
elif [[ "$arg" =~ ^3\.[0-9]+$ ]]; then
PYTHON_VERSIONS+=("$arg")
else
NOX_ARGS+=("$arg")
fi
done
# Build the nox command
CMD=(uv run nox -s)
if [[ ${#PYTHON_VERSIONS[@]} -gt 0 ]]; then
# Run specific Python versions
SESSIONS=""
for ver in "${PYTHON_VERSIONS[@]}"; do
if [[ -n "$SESSIONS" ]]; then
SESSIONS="$SESSIONS,"
fi
SESSIONS="${SESSIONS}${SESSION}-${ver}"
done
CMD+=("$SESSIONS")
else
# Run all versions
CMD+=("$SESSION")
fi
# Add fresh flag if requested
if [[ "$FRESH" == true ]]; then
CMD+=(--reuse-venv=never)
fi
# Add any additional nox args
if [[ ${#NOX_ARGS[@]} -gt 0 ]]; then
CMD+=("${NOX_ARGS[@]}")
fi
# Add pytest args if provided
if [[ ${#PYTEST_ARGS[@]} -gt 0 ]]; then
CMD+=(-- "${PYTEST_ARGS[@]}")
fi
echo "Running: ${CMD[*]}"
exec "${CMD[@]}"