-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest
More file actions
executable file
·58 lines (50 loc) · 1.7 KB
/
test
File metadata and controls
executable file
·58 lines (50 loc) · 1.7 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
#!/usr/bin/env bash
# Run the full test suite via Nix (sandboxed, deterministic).
# Does NOT use `nix develop` to avoid host OS version detection issues.
set -u
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
cd "$SCRIPT_DIR"
# Detect system
system=$(nix eval --raw 'nixpkgs#system' 2>/dev/null || echo "aarch64-darwin")
# Reassemble any split-up large ground-truth fixtures before running tests.
# Files over GitHub's 100 MB limit are committed as .chunk.NNN pieces; the
# reassembly script cats them back together and sha256-verifies against a
# stored original.sha256. Idempotent — no-ops if the target is already present
# and its hash matches.
if [ -x scripts/reassemble-ground-truth ]; then
if ! scripts/reassemble-ground-truth; then
echo "=== Ground-truth reassembly FAILED ==="
exit 1
fi
fi
echo "=== Running Zig tests (nix build, sandboxed) ==="
if ! nix build ".#checks.${system}.test" 2>&1; then
echo "=== Zig tests FAILED ==="
exit 1
fi
echo "=== Zig tests passed ==="
# CLI tests need the built binary
echo "=== Building binary for CLI tests ==="
nix build 2>&1 || { echo "Build failed"; exit 1; }
mkdir -p zig-out/bin
cp -f result/bin/validate zig-out/bin/validate
cli_failures=0
if [[ -d tests/cli ]]; then
echo "=== Running CLI tests ==="
for test_script in tests/cli/*; do
if [[ -x "$test_script" ]]; then
test_name="$(basename "$test_script")"
if VALIDATE_BIN=./zig-out/bin/validate "$test_script" > /dev/null 2>&1; then
echo " PASS: $test_name"
else
echo " FAIL: $test_name"
((cli_failures++)) || true
fi
fi
done
fi
if [[ $cli_failures -gt 0 ]]; then
echo "=== $cli_failures CLI test(s) FAILED ==="
exit $cli_failures
fi
echo "=== All tests passed ==="