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.stamp169169
PARSE_STAMP := build/stamps/spinel_parse.c.stamp170170
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 FORCE171+
.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 FORCE172172
173173
# `make all` includes spinel_rbs_extract when vendor/rbs has been174174
# 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 semantics471472
# (RangeError on overflow); under --int-overflow=promote the same code472473
# 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 prereq486487
# 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."; fi489490
@if [ -t 1 ]; then printf '\n'; fi490491
@pass=$$(grep -l '^PASS' build/test-results/*.ok 2>/dev/null | wc -l); \@@ -549,6 +550,45 @@
549550
done550551
endif551552
553+
# Analyze-fail fixtures are intentionally rejected during the554+
# spinel_analyze phase. They cover semantic subset limits that should555+
# produce a stable diagnostic, not a generated binary.556+
analyze-fail-test: spinel_parse$(EXE) spinel_analyze$(EXE)557+
@mkdir -p build/analyze-fail-results558+
@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; fi591+
552592
# The .ok target is the test's stamp; mtime tracking gives per-test553593
# 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-results640+
@rm -rf build/test-results build/analyze-fail-results601641
602642
# ---- Expected-output regeneration ----603643
# Capture each test's reference Ruby output into test/<name>.rb.expected.README.mdmodifiedView file
Loading diff…
compiler_helpers.rbmodifiedView file
Loading diff…
docs/ANALYZE-IR.mdmodifiedView file
Loading diff…
spinel_analyze.rbmodifiedView file
Loading diff…
spinel_codegen.rbmodifiedView file
Loading diff…
test/analyze_fail/attributes_non_symbol.rbaddedView file
Loading diff…
test/analyze_fail/attributes_non_symbol.stderr.expectedaddedView file
Loading diff…
test/analyze_fail/dynamic_define_method.rbaddedView file
Loading diff…
test/analyze_fail/dynamic_define_method.stderr.expectedaddedView file
Loading diff…
test/analyze_fail/nonliteral_define_method_each.rbaddedView file
Loading diff…
test/analyze_fail/nonliteral_define_method_each.stderr.expectedaddedView file
Loading diff…
test/compile_time_attribute_singular.rbaddedView file
Loading diff…
test/compile_time_attribute_singular.rb.expectedaddedView file
Loading diff…
test/compile_time_attribute_wrapped_record.rbaddedView file
Loading diff…
test/compile_time_attribute_wrapped_record.rb.expectedaddedView file
Loading diff…
test/compile_time_attributes.rbaddedView file
Loading diff…
test/compile_time_attributes.rb.expectedaddedView file
Loading diff…
test/compile_time_define_method_direct.rbaddedView file
Loading diff…
test/compile_time_define_method_direct.rb.expectedaddedView file
Loading diff…
test/compile_time_define_method_int.rbaddedView file
Loading diff…
test/compile_time_define_method_int.rb.expectedaddedView file
Loading diff…
test/compile_time_define_method_predicates.rbaddedView file
Loading diff…
test/compile_time_define_method_predicates.rb.expectedaddedView file
Loading diff…
test/compile_time_define_method_strings.rbaddedView file
Loading diff…
test/compile_time_define_method_strings.rb.expectedaddedView file
Loading diff…