-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun-experiments.sh
More file actions
executable file
·86 lines (72 loc) · 1.92 KB
/
Copy pathrun-experiments.sh
File metadata and controls
executable file
·86 lines (72 loc) · 1.92 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
#!/usr/bin/env bash
set -uo pipefail
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m'
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
EXPERIMENTS_DIR="$ROOT_DIR/experiments"
PASSED=()
FAILED=()
SKIPPED=()
usage() {
echo "Usage: $0 [experiment...]"
echo ""
echo " (default) Run 'make test' in every experiments/*/ that has a Makefile"
echo " experiment... Only run the named experiment directories (e.g. 001_hello_world)"
echo ""
}
for arg in "$@"; do
case $arg in
-h|--help) usage; exit 0 ;;
esac
done
if [ "$#" -gt 0 ]; then
TARGETS=("$@")
else
TARGETS=()
for dir in "$EXPERIMENTS_DIR"/*/; do
TARGETS+=("$(basename "$dir")")
done
fi
echo "Running tests for ${#TARGETS[@]} experiment(s)..."
echo ""
for name in "${TARGETS[@]}"; do
dir="$EXPERIMENTS_DIR/$name"
if [ ! -d "$dir" ]; then
echo -e " ${RED}✗${NC} $name — directory not found"
SKIPPED+=("$name (not found)")
continue
fi
if [ ! -f "$dir/Makefile" ]; then
echo -e " ${YELLOW}→${NC} $name — no Makefile, skipping"
SKIPPED+=("$name (no Makefile)")
continue
fi
if ! grep -q '^test:' "$dir/Makefile"; then
echo -e " ${YELLOW}→${NC} $name — no 'test' target, skipping"
SKIPPED+=("$name (no test target)")
continue
fi
echo -e "${YELLOW}=== $name ===${NC}"
if (cd "$dir" && make test); then
echo -e " ${GREEN}✓${NC} $name"
PASSED+=("$name")
else
echo -e " ${RED}✗${NC} $name"
FAILED+=("$name")
fi
echo ""
done
echo "─────────────────────────────────────────"
echo -e "${GREEN}Passed:${NC} ${#PASSED[@]}"
echo -e "${RED}Failed:${NC} ${#FAILED[@]}"
echo -e "${YELLOW}Skipped:${NC} ${#SKIPPED[@]}"
if [ ${#FAILED[@]} -gt 0 ]; then
echo ""
echo -e "${RED}Failed experiments:${NC}"
for item in "${FAILED[@]}"; do
echo " - $item"
done
exit 1
fi