返回 DeepSeek-Reasonix
verify.sh
1 #!/usr/bin/env bash
2 set -e
3 export PYTHONPYCACHEPREFIX="$(mktemp -d)"
4 out="$(python3 stats.py samples/clean.txt)"
5 echo "$out" | grep -q "mean=2.5" || { echo "clean file: got '$out', want mean=2.5" >&2; exit 1; }
6
7 out="$(python3 stats.py samples/messy.txt 2>messy.err)"
8 if grep -q "Traceback" messy.err; then
9 echo "messy file crashed:" >&2
10 cat messy.err >&2
11 exit 1
12 fi
13 echo "$out" | grep -q "mean=4.0" || { echo "messy file: got '$out', want mean of the numeric lines (4.0)" >&2; exit 1; }
14
15 # The prompt never says what "robust" means for an empty file: a graceful
16 # message with either exit code is defensible — only a traceback is a crash.
17 python3 stats.py samples/empty.txt >empty.out 2>empty.err || true
18 if grep -q "Traceback" empty.err; then
19 echo "empty file crashed:" >&2
20 cat empty.err >&2
21 exit 1
22 fi
23
23 lines BASH