-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun_tests.sh
More file actions
executable file
·203 lines (172 loc) · 6.08 KB
/
Copy pathrun_tests.sh
File metadata and controls
executable file
·203 lines (172 loc) · 6.08 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
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
#!/usr/bin/env bash
# Test suite runner with different profiles
# Usage: ./run_tests.sh [PROFILE]
# See docs/FEASIBLE_TEST_SUITE.md for details
set -e
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
cd "$SCRIPT_DIR"
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m' # No Color
echo_success() { echo -e "${GREEN}✓${NC} $1"; }
echo_error() { echo -e "${RED}✗${NC} $1"; }
echo_info() { echo -e "${YELLOW}➜${NC} $1"; }
echo_header() { echo -e "${BLUE}═══${NC} $1 ${BLUE}═══${NC}"; }
# Function to run tests with a profile
run_tests() {
local profile=$1
local markers=$2
local description=$3
local expected_time=$4
echo ""
echo_header "$profile Tests"
echo_info "$description"
echo_info "Expected time: $expected_time"
echo "─────────────────────────────────────────────────────"
START_TIME=$(date +%s)
if PYTHONPATH=src pdm run python -m pytest $markers -v --tb=short; then
END_TIME=$(date +%s)
ELAPSED=$((END_TIME - START_TIME))
echo "─────────────────────────────────────────────────────"
echo_success "$profile tests PASSED in ${ELAPSED}s"
return 0
else
END_TIME=$(date +%s)
ELAPSED=$((END_TIME - START_TIME))
echo "─────────────────────────────────────────────────────"
echo_error "$profile tests FAILED after ${ELAPSED}s"
return 1
fi
}
# Parse command line arguments
PROFILE=${1:-"fast"}
case $PROFILE in
fast)
run_tests "FAST" "-m fast" \
"Unit tests only, no dataset loading" \
"~1 minute"
;;
medium)
run_tests "MEDIUM" "-m 'fast or medium'" \
"Fast + Medium tests (component tests with small data)" \
"~5-10 minutes"
;;
baseline)
run_tests "BASELINE" "-m baseline" \
"Critical baseline metrics validation" \
"~15-30 minutes"
;;
full)
run_tests "FULL" "" \
"All tests including slow integration tests" \
"~30-60 minutes"
;;
smoke)
run_tests "SMOKE" "tests/test_xml_parser.py tests/test_grid_initializer.py tests/test_xml_neighbor_topology.py" \
"Minimal validation for rapid feedback" \
"~1 minute"
;;
phase1)
run_tests "PHASE 1" "-m phase1" \
"Preprocessing and stripe enhancement" \
"~3-5 minutes"
;;
phase2)
run_tests "PHASE 2" "-m phase2" \
"Pairwise measurement and matching" \
"~5-8 minutes"
;;
phase3)
run_tests "PHASE 3" "-m phase3" \
"Sequential alignment" \
"~3-5 minutes"
;;
phase4)
run_tests "PHASE 4" "-m phase4" \
"Global optimization and fusion" \
"~5-8 minutes"
;;
phase5)
run_tests "PHASE 5" "-m phase5" \
"Coarse-fine hierarchical refinement" \
"~10-15 minutes"
;;
phase6)
run_tests "PHASE 6" "-m phase6" \
"Robustness orchestration" \
"~3-5 minutes"
;;
dataset1)
run_tests "DATASET 1" "-m dataset1" \
"Tests on DMI6000_20025-03-17" \
"~15-20 minutes"
;;
dataset2)
run_tests "DATASET 2" "-m dataset2" \
"Tests on DMI6000 2025-10-30" \
"~15-20 minutes"
;;
ci)
echo_header "CI PIPELINE"
echo_info "Running fast tests first, then medium if pass"
if run_tests "FAST" "-m fast" "Fast unit tests" "~1 minute"; then
run_tests "MEDIUM" "-m medium" "Medium component tests" "~5-10 minutes"
else
echo_error "Fast tests failed, skipping medium tests"
exit 1
fi
;;
pre-commit)
echo_header "PRE-COMMIT VALIDATION"
echo_info "Running fast + medium + critical baseline checks"
if ! run_tests "FAST" "-m fast" "Fast unit tests" "~1 minute"; then
echo_error "Fast tests failed"
exit 1
fi
if ! run_tests "MEDIUM" "-m medium" "Medium component tests" "~5-10 minutes"; then
echo_error "Medium tests failed"
exit 1
fi
echo ""
echo_header "CRITICAL CHECKS"
echo_info "Running must-pass integration tests"
pdm run pytest tests/test_microscopy_mosaic_stitcher.py::test_grid_layout_preservation -v
echo_success "All pre-commit checks passed"
;;
*)
echo_error "Unknown profile: $PROFILE"
echo ""
echo "Usage: $0 [PROFILE]"
echo ""
echo "Available profiles:"
echo ""
echo " ${GREEN}Development:${NC}"
echo " fast Fast unit tests (~1 min)"
echo " smoke Minimal smoke tests (~1 min)"
echo ""
echo " ${YELLOW}Pre-commit:${NC}"
echo " medium Fast + Medium tests (~5-10 min)"
echo " pre-commit Pre-commit validation (~10 min)"
echo ""
echo " ${RED}Pre-push/merge:${NC}"
echo " baseline Baseline regression tests (~15-30 min)"
echo " full All tests (~30-60 min)"
echo ""
echo " ${BLUE}Focused:${NC}"
echo " phase1-6 Tests for specific phase"
echo " dataset1 Tests for Dataset1 only"
echo " dataset2 Tests for Dataset2 only"
echo " ci CI pipeline (fast + medium)"
echo ""
echo "Default: fast"
echo ""
echo "See docs/FEASIBLE_TEST_SUITE.md for details"
exit 1
;;
esac
echo ""
echo_success "✓ Test suite completed successfully!"
echo ""