-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun_tests.sh
More file actions
69 lines (60 loc) · 1.95 KB
/
run_tests.sh
File metadata and controls
69 lines (60 loc) · 1.95 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
#!/usr/bin/env bash
# PURPOSE: Run tests for campaign_kb, workflow_ui, and ObsidianVault scripts from repo root.
# DEPENDENCIES: pytest; run from arc_forge root.
# MODIFICATION NOTES: Unified test runner; --suite and --tail added per chunk_tasks_to_avoid_timeout plan.
set -e
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
FAILED=0
SUITE=""
TAIL=0
while [ $# -gt 0 ]; do
case "$1" in
--suite=*) SUITE="${1#--suite=}"; shift ;;
--suite) SUITE="$2"; shift 2 ;;
--tail=*) TAIL="${1#--tail=}"; shift ;;
--tail) TAIL="$2"; shift 2 ;;
*) shift ;;
esac
done
run_suite() {
local name="$1"
local dir="$2"
local extra="${3:-}"
local tail_lines="${4:-0}"
echo "===== $name ====="
if [ "$tail_lines" -gt 0 ]; then
local out ex=0
out=$(cd "$dir" && python -m pytest $extra -v --tb=short 2>&1) || ex=1
[ $ex -ne 0 ] && FAILED=1
echo "$out" | tail -n "$tail_lines"
echo "----- $name : $([ $ex -eq 0 ] && echo 'OK' || echo 'FAILED') -----"
else
if (cd "$dir" && python -m pytest $extra -v --tb=short 2>&1); then
echo "----- $name: OK -----"
else
echo "----- $name: FAILED -----"
FAILED=1
fi
fi
echo ""
}
echo "Unified test run (root: $ROOT)"
echo ""
run_ck=1; run_wu=1; run_sc=1
if [ -n "$SUITE" ]; then
run_ck=0; run_wu=0; run_sc=0
[ "$SUITE" = "campaign_kb" ] && run_ck=1
[ "$SUITE" = "workflow_ui" ] && run_wu=1
[ "$SUITE" = "scripts" ] && run_sc=1
fi
if [ $run_ck -eq 1 ] && [ -d "$ROOT/campaign_kb/tests" ]; then
run_suite "campaign_kb" "$ROOT/campaign_kb" "tests/" "$TAIL"
fi
if [ $run_wu -eq 1 ] && [ -d "$ROOT/ObsidianVault/workflow_ui/tests" ]; then
run_suite "workflow_ui" "$ROOT/ObsidianVault" "workflow_ui/tests/" "$TAIL"
fi
if [ $run_sc -eq 1 ] && [ -d "$ROOT/ObsidianVault/scripts/tests" ]; then
run_suite "ObsidianVault scripts" "$ROOT/ObsidianVault" "scripts/tests/" "$TAIL"
fi
[ $FAILED -eq 0 ] && echo "All suites passed." || echo "One or more suites failed."
exit $FAILED