run_all.sh raw
1 #!/bin/bash
2 # Moxie full test suite. Runs all test suites and reports results.
3 set -euo pipefail
4
5 TESTDIR="$(cd "$(dirname "$0")" && pwd)"
6 MOXIE="${MOXIE:-./moxie}"
7 export MOXIE PATH="/usr/lib/llvm19/bin:$PATH"
8
9 total_pass=0
10 total_fail=0
11
12 run_suite() {
13 local name="$1"
14 local script="$2"
15 echo "╔══ $name ══╗"
16 if bash "$script"; then
17 total_pass=$((total_pass + 1))
18 else
19 total_fail=$((total_fail + 1))
20 fi
21 echo ""
22 }
23
24 # Cross-compilation smoke test: verify binaries are produced for each target.
25 cross_compile_check() {
26 local src="$TESTDIR/restrict/pass_valid_patterns.go"
27 local tmpdir=$(mktemp -d)
28 trap "rm -rf $tmpdir" RETURN
29
30 echo "╔══ Cross-compilation ══╗"
31 local pass=0
32 local fail=0
33
34 for target in linux/amd64 linux/arm64; do
35 local goos="${target%/*}"
36 local goarch="${target#*/}"
37 local bin="$tmpdir/${goos}_${goarch}"
38 if GOOS="$goos" GOARCH="$goarch" "$MOXIE" build -o "$bin" "$src" 2>/dev/null; then
39 local fmt=$(file "$bin" | grep -oP '(ELF|Mach-O)[^,]*' | head -1)
40 echo "OK $target ($fmt)"
41 pass=$((pass + 1))
42 else
43 echo "FAIL $target: compilation failed"
44 fail=$((fail + 1))
45 fi
46 done
47
48 echo ""
49 echo "=== Cross-compile: $pass passed, $fail failed ==="
50 [ "$fail" -eq 0 ]
51 }
52
53 run_suite "Restriction tests" "$TESTDIR/restrict/run.sh"
54 run_suite "Spawn tests" "$TESTDIR/spawn/run.sh"
55
56 if cross_compile_check; then
57 total_pass=$((total_pass + 1))
58 else
59 total_fail=$((total_fail + 1))
60 fi
61
62 echo ""
63 echo "════════════════════════════════════════"
64 echo " Suites: $total_pass passed, $total_fail failed"
65 echo "════════════════════════════════════════"
66 [ "$total_fail" -eq 0 ]
67