-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest
More file actions
executable file
·74 lines (62 loc) · 1.77 KB
/
test
File metadata and controls
executable file
·74 lines (62 loc) · 1.77 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
#!/usr/bin/env bash
if [[ -z "${VALIDATE_NIX:-}" ]]; then
exec env VALIDATE_NIX=1 nix develop -c "$0" "$@"
fi
set -euo pipefail
# Define glob function if not already a function (works with noglob environments)
# Check specifically for "function" since there may be a glob command in PATH
if [[ "$(type -t glob 2>/dev/null)" != "function" ]]; then
glob() {
# Temporarily enable globbing, expand pattern, restore state
local noglob_was_set=false
[[ $- == *f* ]] && noglob_was_set=true
set +f
local expanded=($@)
$noglob_was_set && set -f
printf '%s\n' "${expanded[@]}"
}
fi
unset LD
unset SDKROOT
echo "=== Running Zig tests ==="
set +e
zig_output=$(zig build test --summary all 2>&1)
zig_exit=$?
set -e
printf '%s\n' "$zig_output"
if [[ $zig_exit -ne 0 ]]; then
zig_failures=$(printf '%s\n' "$zig_output" | grep -oE '[0-9]+ failed' | awk '{sum+=$1} END {print sum+0}')
if [[ $zig_failures -eq 0 ]]; then
zig_failures=1
fi
echo "=== Zig tests FAILED ($zig_failures failures) ==="
exit $zig_failures
fi
zig_passed=$(echo "$zig_output" | grep -oE '[0-9]+/[0-9]+ tests passed' | head -1 || echo "? tests passed")
echo "=== Zig tests passed ($zig_passed) ==="
cli_failures=0
if [[ -d tests/cli ]]; then
echo "=== Building CLI for tests ==="
zig build -Doptimize=ReleaseFast
echo "=== Running CLI tests ==="
cli_tests_found=0
set +e
for test in $(glob tests/cli/*); do
if [[ -x "$test" ]]; then
((cli_tests_found++))
bash "$test"
rc=$?
cli_failures=$((cli_failures + rc))
fi
done
set -e
if [[ $cli_tests_found -eq 0 ]]; then
echo "=== ERROR: No CLI tests found (glob may have failed) ==="
exit 1
fi
if [[ $cli_failures -ne 0 ]]; then
echo "=== CLI tests FAILED ($cli_failures failures) ==="
exit $cli_failures
fi
echo "=== CLI tests passed ==="
fi