P1.1: repo skeleton + sx build/test gate
Stand up the foundation every later step depends on: - Source layout: src/, src/infra/, tests/, examples/ (.gitkeep markers). - Makefile: `build` compiles the smoke program via $SX, `test` runs the runner over tests/**/*.sx, `publish-example` placeholder (real in P3.4). Compiler located via `SX ?= /Users/agra/projects/sx/zig-out/bin/sx`. - tests/run.sh: POSIX-sh runner; discovers tests/**/*.sx, runs each via `$SX run`, prints ok/FAIL, exits 0 only when all pass (errors on zero tests so the gate is never silently empty). - tests/smoke.sx: passing smoke test importing modules/std.sx — proves toolchain wiring end-to-end (std resolves via the binary's own location). - .gitignore: ignore build/ artifacts.
This commit is contained in:
41
tests/run.sh
Executable file
41
tests/run.sh
Executable file
@@ -0,0 +1,41 @@
|
||||
#!/bin/sh
|
||||
# Test runner — discovers every tests/**/*.sx, runs each via `$SX run`, and
|
||||
# reports per-test ok/FAIL. Exits 0 only when every test passes.
|
||||
#
|
||||
# A test passes iff `$SX run <file>` exits 0 (compile failures count as a
|
||||
# failure too). Each test program asserts its own invariants — e.g. via
|
||||
# process.assert — and exits non-zero on failure.
|
||||
#
|
||||
# Locate the compiler via SX (overridable); defaults to the sibling sx repo.
|
||||
set -u
|
||||
|
||||
SX="${SX:-/Users/agra/projects/sx/zig-out/bin/sx}"
|
||||
TESTS_DIR=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)
|
||||
|
||||
pass=0
|
||||
fail=0
|
||||
|
||||
# Test filenames follow the no-spaces convention, so word-splitting the
|
||||
# sorted find output is safe and keeps the loop in the current shell (so the
|
||||
# pass/fail counters survive).
|
||||
for t in $(find "$TESTS_DIR" -name '*.sx' -type f | sort); do
|
||||
name=${t#"$TESTS_DIR"/}
|
||||
if "$SX" run "$t" >/dev/null 2>&1; then
|
||||
printf ' %-44s ok\n' "$name"
|
||||
pass=$((pass + 1))
|
||||
else
|
||||
printf ' %-44s FAIL\n' "$name"
|
||||
fail=$((fail + 1))
|
||||
fi
|
||||
done
|
||||
|
||||
total=$((pass + fail))
|
||||
if [ "$total" -eq 0 ]; then
|
||||
echo "no tests found under $TESTS_DIR" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "------------------------------------------------"
|
||||
printf 'tests: %d pass: %d fail: %d\n' "$total" "$pass" "$fail"
|
||||
|
||||
[ "$fail" -eq 0 ]
|
||||
9
tests/smoke.sx
Normal file
9
tests/smoke.sx
Normal file
@@ -0,0 +1,9 @@
|
||||
// Smoke test: proves the sx toolchain is wired end-to-end from this repo —
|
||||
// the standard library import resolves, the program runs, and it exits 0.
|
||||
// The runner (tests/run.sh) treats a clean exit as `ok`.
|
||||
#import "modules/std.sx";
|
||||
|
||||
main :: () -> s32 {
|
||||
print("distribution smoke test: toolchain ok\n");
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user