diff --git a/fec/Makefile b/fec/Makefile index 17c4f66..17626e4 100644 --- a/fec/Makefile +++ b/fec/Makefile @@ -4,7 +4,7 @@ CPPFLAGS ?= -Isrc SRC = src/arena.c src/diag.c src/lexer.c src/ast.c src/parser.c src/types.c src/check.c src/emit_c.c src/driver.c OBJ = $(SRC:.c=.o) -.PHONY: all clean test test-cli dos-build +.PHONY: all clean dos-build all: fec fec: $(OBJ) @@ -13,13 +13,6 @@ fec: $(OBJ) src/%.o: src/%.c $(CC) $(CFLAGS) $(CPPFLAGS) -c -o $@ $< -test: fec - @./tests/run-tests.sh - @sh ./tests/run-cli-tests.sh - -test-cli: fec - @sh ./tests/run-cli-tests.sh - dos-build: @echo "Run build-dos.bat inside FreeDOS/Open Watcom." diff --git a/fec/tests/run-cli-tests.sh b/fec/tests/run-cli-tests.sh deleted file mode 100644 index ddecda3..0000000 --- a/fec/tests/run-cli-tests.sh +++ /dev/null @@ -1,26 +0,0 @@ -#!/bin/sh -set -eu -root=$(CDPATH= cd -- "$(dirname "$0")/.." && pwd) -tmp=$(mktemp -d) -trap 'rm -rf "$tmp"' EXIT HUP INT TERM - -"$root"/fec --dump-tokens "$root"/tests/pass/basic.fe >"$tmp/tokens.out" -grep 'unit' "$tmp/tokens.out" >/dev/null -grep 'identifier' "$tmp/tokens.out" >/dev/null -grep 'eof' "$tmp/tokens.out" >/dev/null - -"$root"/fec --check "$root"/tests/m2/hello.fe >"$tmp/check.out" -if [ -s "$tmp/check.out" ]; then - echo "FAIL: --check produced stdout" - exit 1 -fi - -if "$root"/fec --check "$root"/tests/m2/bad-condition.fe >"$tmp/bad.out" 2>"$tmp/diag.out"; then - echo "FAIL: --check accepted invalid input" - exit 1 -fi -grep 'error:' "$tmp/diag.out" >/dev/null -grep '^ [0-9][0-9]* | ' "$tmp/diag.out" >/dev/null -grep ' | .*\^' "$tmp/diag.out" >/dev/null - -echo "CLI tests: token dump, check mode, and source diagnostics passed" diff --git a/fec/tests/run-tests.sh b/fec/tests/run-tests.sh deleted file mode 100644 index 9f159a7..0000000 --- a/fec/tests/run-tests.sh +++ /dev/null @@ -1,104 +0,0 @@ -#!/bin/sh -set -eu -root=$(CDPATH= cd -- "$(dirname "$0")/.." && pwd) -ok=0 -for f in "$root"/std/*.fe; do - [ -f "$f" ] || continue - "$root"/fec --dump-ast "$f" >/dev/null || { echo "FAIL: $f"; exit 1; } - ok=$((ok+1)) -done -for f in "$root"/tests/pass/*.fe; do - [ -f "$f" ] || continue - "$root"/fec --dump-ast "$f" >/dev/null || { echo "FAIL: $f"; exit 1; } - ok=$((ok+1)) -done -for f in "$root"/tests/fail/*.fe; do - [ -f "$f" ] || continue - if "$root"/fec --dump-ast "$f" >/dev/null 2>/dev/null; then echo "FAIL (accepted): $f"; exit 1; fi - ok=$((ok+1)) -done -echo "M1 tests: $ok cases passed" - -m2tmp=$(mktemp -d) -trap 'rm -rf "$m2tmp"' EXIT HUP INT TERM -"$root"/fec --emit-c "$root"/tests/m2/hello.fe -o "$m2tmp/hello.c" -${CC:-cc} -std=c89 -pedantic "$m2tmp/hello.c" -o "$m2tmp/hello" -"$m2tmp/hello" -"$root"/fec --target=bits16 --emit-c "$root"/tests/m2/hello.fe -o "$m2tmp/hello16.c" -${CC:-cc} -std=c89 -pedantic "$m2tmp/hello16.c" -o "$m2tmp/hello16" -"$m2tmp/hello16" -"$root"/fec --emit-c "$root"/tests/m2/cast-while.fe -o "$m2tmp/cast.c" -${CC:-cc} -std=c89 -pedantic "$m2tmp/cast.c" -o "$m2tmp/cast" -"$m2tmp/cast" -"$root"/fec --emit-c "$root"/tests/m2/scopes.fe -o "$m2tmp/scopes.c" -${CC:-cc} -std=c89 -pedantic "$m2tmp/scopes.c" -o "$m2tmp/scopes" -"$m2tmp/scopes" -for f in bad-condition bad-cast bad-assign bad-unknown bad-arity bad-types bad-return bad-uninit bad-void; do - if "$root"/fec --emit-c "$root"/tests/m2/$f.fe -o "$m2tmp/$f.c" >/dev/null 2>/dev/null; then - echo "FAIL (accepted M2 semantic error): $f.fe" - exit 1 - fi -done -echo "M2 tests: integer control-flow smoke passed" - -m3tmp=$(mktemp -d) -trap 'rm -rf "$m2tmp" "$m3tmp"' EXIT HUP INT TERM -for f in struct enum array arrayctx str for nested char; do - "$root"/fec --target=bits32 --emit-c "$root"/tests/m3/$f.fe -o "$m3tmp/$f.c" - ${CC:-cc} -std=c89 -pedantic "$m3tmp/$f.c" -o "$m3tmp/$f" - "$m3tmp/$f" -done -"$root"/fec --target=bits32 --emit-c "$root"/tests/m3/bounds.fe -o "$m3tmp/bounds.c" -${CC:-cc} -std=c89 -pedantic "$m3tmp/bounds.c" -o "$m3tmp/bounds" -if "$m3tmp/bounds"; then - echo "FAIL (bounds trap did not fire): tests/m3/bounds.fe" - exit 1 -fi -for f in badfld badmat badarr badcycle badstr badchar badfield badindex; do - if "$root"/fec --target=bits32 --emit-c "$root"/tests/m3/$f.fe -o "$m3tmp/$f.c" >/dev/null 2>/dev/null; then - echo "FAIL (accepted M3 semantic error): $f.fe" - exit 1 - fi -done -echo "M3 tests: structs, enums, arrays, slices, str, match, and bounds passed" - -m4tmp=$(mktemp -d) -trap 'rm -rf "$m2tmp" "$m3tmp" "$m4tmp"' EXIT HUP INT TERM -for f in format; do - "$root"/fec --target=bits32 --emit-c "$root"/tests/m4/$f.fe -o "$m4tmp/$f.c" - ${CC:-cc} -std=c89 -pedantic "$m4tmp/$f.c" -o "$m4tmp/$f" - "$m4tmp/$f" >"$m4tmp/$f.out" -done -for f in try-fprint; do - "$root"/fec --target=bits32 --emit-c "$root"/tests/m4/$f.fe -o "$m4tmp/$f.c" - ${CC:-cc} -std=c89 -pedantic "$m4tmp/$f.c" -o "$m4tmp/$f" - "$m4tmp/$f" -done -"$root"/fec --target=bits32 --emit-c "$root"/tests/m4/prop.fe -o "$m4tmp/prop.c" -cp "$root"/tests/m4/proptest.c "$m4tmp/proptest.c" -${CC:-cc} -std=c89 -pedantic "$m4tmp/proptest.c" -o "$m4tmp/prop" -"$m4tmp/prop" -for f in bad-arity bad-verb bad-runtime bad-type bad-try bad-writer; do - if "$root"/fec --target=bits32 --emit-c "$root"/tests/m4/$f.fe -o "$m4tmp/$f.c" >/dev/null 2>/dev/null; then - echo "FAIL (accepted M4 semantic error): $f.fe" - exit 1 - fi -done -for f in bad-many bad-open bad-cls; do - if "$root"/fec --target=bits32 --emit-c "$root"/tests/m4/$f.fe -o "$m4tmp/$f.c" >/dev/null 2>/dev/null; then - echo "FAIL (accepted M4 format-brace error): $f.fe" - exit 1 - fi -done -echo "M4 tests: formatting builtins passed" - -for f in defer owned; do - "$root"/fec --target=bits32 --emit-c "$root"/tests/m5/$f.fe -o "$m4tmp/m5-$f.c" -done -for f in bad-move bad-destroy; do - if "$root"/fec --target=bits32 --emit-c "$root"/tests/m5/$f.fe -o "$m4tmp/m5-$f.c" >/dev/null 2>/dev/null; then - echo "FAIL (accepted M5 ownership error): $f.fe" - exit 1 - fi -done -echo "M5 tests: owned move/defer checks passed"