Commit 11382b94

11382b94ec50Merged

fc-anjos <[email protected]> · 5 months ago · 26 files · +20 added · ~6 modified

Description

Add compile-time class-body declarations

Details

Commit
11382b94ec50
Parent
43dc1284130e

MakefilemodifiedView file

@@ -168,7 +168,7 @@
168168 COMPILER_HELPERS_STAMP := build/stamps/compiler_helpers.rb.stamp
169169 PARSE_STAMP := build/stamps/spinel_parse.c.stamp
170170
171-.PHONY: all parse bootstrap bootstrap-fixpoint fast-bootstrap codegen rbs_extract rbs-test regen-rbs-expected test retest fast-test clean-test-results regen-expected bench optcarrot gate check gate-legs gate-test gate-bench gate-optcarrot clean install uninstall deps FORCE
171+.PHONY: all parse bootstrap bootstrap-fixpoint fast-bootstrap codegen rbs_extract rbs-test analyze-fail-test regen-rbs-expected test retest fast-test clean-test-results regen-expected bench optcarrot gate check gate-legs gate-test gate-bench gate-optcarrot clean install uninstall deps FORCE
172172
173173 # `make all` includes spinel_rbs_extract when vendor/rbs has been
174174 # fetched (via `make deps`). Without vendor/rbs the extractor is
@@ -467,6 +467,7 @@
467467 # ---- Test ----
468468
469469 TESTS := $(wildcard test/*.rb)
470+ANALYZE_FAIL_TESTS := $(sort $(wildcard test/analyze_fail/*.rb))
470471 # Mode-incompatible tests: int_overflow_raises pins raise-mode semantics
471472 # (RangeError on overflow); under --int-overflow=promote the same code
472473 # auto-promotes to bigint and the expected output diverges by design.
@@ -484,7 +485,7 @@
484485 # `make test` is incremental via mtime tracking on .ok files;
485486 # `make retest` wipes them for a forced rerun. The rbs-test prereq
486487 # golden-checks the RBS extractor (cheap, runs every invocation).
487-test: rbs-test $(TEST_TARGETS)
488+test: rbs-test analyze-fail-test $(TEST_TARGETS)
488489 @if [ -z "$(TIMEOUT_BIN)" ]; then echo "Note: no 'timeout' command found; running without time limits."; fi
489490 @if [ -t 1 ]; then printf '\n'; fi
490491 @pass=$$(grep -l '^PASS' build/test-results/*.ok 2>/dev/null | wc -l); \
@@ -549,6 +550,45 @@
549550 done
550551 endif
551552
553+# Analyze-fail fixtures are intentionally rejected during the
554+# spinel_analyze phase. They cover semantic subset limits that should
555+# produce a stable diagnostic, not a generated binary.
556+analyze-fail-test: spinel_parse$(EXE) spinel_analyze$(EXE)
557+ @mkdir -p build/analyze-fail-results
558+ @fail=0; n=0; \
559+ for f in $(ANALYZE_FAIL_TESTS); do \
560+ n=$$((n+1)); \
561+ bn=$$(basename "$$f" .rb); \
562+ tmpdir=$$(mktemp -d /tmp/spinel-analyze-fail.XXXXXX); \
563+ ast=$$tmpdir/test.ast; ir=$$tmpdir/test.ir; err=$$tmpdir/analyze.err; \
564+ exp="$${f%.rb}.stderr.expected"; \
565+ if ! ./spinel_parse$(EXE) "$$f" "$$ast" >/dev/null 2>"$$tmpdir/parse.err"; then \
566+ echo "analyze-fail ERR: $$bn (parse failed)"; \
567+ cat "$$tmpdir/parse.err"; \
568+ fail=1; rm -rf "$$tmpdir"; continue; \
569+ fi; \
570+ if ./spinel_analyze$(EXE) "$$ast" "$$ir" >/dev/null 2>"$$err"; then \
571+ echo "analyze-fail FAIL: $$bn (analyze succeeded)"; \
572+ fail=1; rm -rf "$$tmpdir"; continue; \
573+ fi; \
574+ if [ ! -f "$$exp" ]; then \
575+ echo "analyze-fail ERR: $$bn missing $$exp"; \
576+ fail=1; rm -rf "$$tmpdir"; continue; \
577+ fi; \
578+ LC_ALL=C sed 's/\r$$//' "$$exp" > "$$tmpdir/expected.n"; \
579+ LC_ALL=C sed 's/\r$$//' "$$err" > "$$tmpdir/actual.n"; \
580+ if cmp -s "$$tmpdir/expected.n" "$$tmpdir/actual.n"; then \
581+ echo PASS > "build/analyze-fail-results/$$bn.ok"; \
582+ else \
583+ echo "analyze-fail FAIL: $$bn"; \
584+ diff -u "$$tmpdir/expected.n" "$$tmpdir/actual.n" || true; \
585+ fail=1; \
586+ fi; \
587+ rm -rf "$$tmpdir"; \
588+ done; \
589+ echo "Analyze-fail tests: $$n pass"; \
590+ if [ $$fail -ne 0 ]; then exit 1; fi
591+
552592 # The .ok target is the test's stamp; mtime tracking gives per-test
553593 # caching for free. Order-only spinel_parse$(EXE) / spinel_analyze$(EXE)
554594 # / spinel_codegen$(EXE) stop a bootstrap relink from invalidating every test.
@@ -597,7 +637,7 @@
597637 rm -rf "$$tmpdir"
598638
599639 clean-test-results:
600- @rm -rf build/test-results
640+ @rm -rf build/test-results build/analyze-fail-results
601641
602642 # ---- Expected-output regeneration ----
603643 # Capture each test's reference Ruby output into test/<name>.rb.expected.