-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest
More file actions
executable file
·78 lines (69 loc) · 2.68 KB
/
Copy pathtest
File metadata and controls
executable file
·78 lines (69 loc) · 2.68 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
#!/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")
# Provision ground-truth fixtures. They are NOT committed in this repo (they live
# in the sibling private repo ../validate_gui, kept out to avoid bloat / submodule
# detection). If the local dir is missing but the sibling has it, symlink so the
# CLI tests run against real samples. If neither is present, fixture-dependent CLI
# tests SKIP loudly (exit 77) rather than FAIL — see tests/cli/_lib.sh.
if [ ! -e ground_truth_examples ] && [ -d ../validate_gui/ground_truth_examples ]; then
ln -s ../validate_gui/ground_truth_examples ground_truth_examples
echo "=== Linked ground_truth_examples -> ../validate_gui/ground_truth_examples ==="
fi
# 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
cli_skipped=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")"
VALIDATE_BIN=./zig-out/bin/validate "$test_script" > /dev/null 2>&1
rc=$?
if [[ $rc -eq 0 ]]; then
echo " PASS: $test_name"
elif [[ $rc -eq 77 ]]; then
# Exit 77 = loud SKIP (e.g. ground-truth fixture not provisioned).
echo " SKIP: $test_name (fixture unavailable)"
((cli_skipped++)) || true
else
echo " FAIL: $test_name"
((cli_failures++)) || true
fi
fi
done
fi
if [[ $cli_skipped -gt 0 ]]; then
echo "=== $cli_skipped CLI test(s) SKIPPED (provision ../validate_gui for full coverage) ==="
fi
if [[ $cli_failures -gt 0 ]]; then
echo "=== $cli_failures CLI test(s) FAILED ==="
exit $cli_failures
fi
echo "=== All tests passed ==="