Commit a6a41ca8
a6a41ca8f2fbMerged
Yukihiro "Matz" Matsumoto <[email protected]> · 5 months ago · 4 files · +2 added · ~2 modified
Description
Merge pull request #1419 from rubys/fix/1417-rbs-seed-nested-class
Fix #1417: match RBS seeds for module-nested classes
Details
- Commit
- a6a41ca8f2fb
- Parent
- bb161a5c2c88
- Merge parent
- 234522bfc1cd
MakefilemodifiedView file
@@ -38,7 +38,7 @@
3838
RBS_OBJ = $(patsubst $(RBS_DIR)/src/%.c,build/rbs/%.o,$(RBS_SRC))3939
RBS_LIB = build/librbs.a4040
41-
.PHONY: all parse legacy bootstrap codegen regexp rbs_extract rbs-test \41+
.PHONY: all parse legacy bootstrap codegen regexp rbs_extract rbs-test rbs-seed-test \4242
analyze-fail-test test test-run clean-test-results regen-rbs-expected \4343
regen-expected bench optcarrot gate check gate-legs gate-test gate-bench \4444
gate-optcarrot clean install uninstall deps@@ -270,9 +270,10 @@
270270
+@$(MAKE) --no-print-directory test-run271271
272272
# The actual run. rbs-test golden-checks the RBS extractor (cheap, C-only).273-
# analyze-fail (legacy-analyzer diagnostics) lives in legacy/ now and runs274-
# as part of `make gate`, not the hot `make test` loop.275-
test-run: rbs-test $(TEST_TARGETS)273+
# rbs-seed-test checks the seeds actually reach the analyzer (incl. nested274+
# classes, #1417). analyze-fail (legacy-analyzer diagnostics) lives in legacy/275+
# now and runs as part of `make gate`, not the hot `make test` loop.276+
test-run: rbs-test rbs-seed-test $(TEST_TARGETS)276277
@if [ -z "$(TIMEOUT_BIN)" ]; then echo "Note: no 'timeout' command found; running without time limits."; fi277278
@if [ -t 1 ]; then printf '\n'; fi278279
@pass=$$(grep -l '^PASS' build/test-results/*.ok 2>/dev/null | wc -l); \@@ -324,6 +325,31 @@
324325
done325326
endif326327
328+
# End-to-end --rbs seeding check (#1417). The extractor emits a module-nested329+
# class under its qualified name (`Outer_Box`), but the compiler's class table330+
# stores the leaf name (`Box`) + enclosing_class. seed_class_index must match331+
# the two so the seed reaches the class. The fixture's `@label` is declared332+
# `String?` but only ever assigned nil, so inference alone leaves it poly --333+
# only an applied seed pins it to a `const char *` field. The extractor must sit334+
# beside $(SPINEL) (main.c looks for it as a sibling), so copy it there first.335+
ifeq ($(wildcard $(RBS_INC)/rbs/parser.h),)336+
rbs-seed-test:337+
@echo "rbs-seed-test: skipped (vendor/rbs not fetched; run 'make deps')"338+
else339+
rbs-seed-test: $(SPINEL) spinel_rbs_extract$(EXE)340+
@cp -f spinel_rbs_extract$(EXE) $(dir $(SPINEL))spinel_rbs_extract$(EXE)341+
@tmp=$$(mktemp -d /tmp/spinel-rbsseed.XXXXXX); \342+
$(SPINEL) test/rbs-seed/nested_ivar.rb --rbs test/rbs-seed/sig \343+
-c --no-line-map -o "$$tmp/out.c" 2>/dev/null; \344+
ok=1; \345+
grep -Eq 'const char[[:space:]]+\*[[:space:]]*iv_label' "$$tmp/out.c" || ok=0; \346+
if grep -Eq 'sp_RbVal[[:space:]]+iv_label' "$$tmp/out.c"; then ok=0; fi; \347+
$(CC) -fsyntax-only -Ilib "$$tmp/out.c" 2>/dev/null || ok=0; \348+
rm -rf "$$tmp"; \349+
if [ $$ok -eq 1 ]; then echo "rbs-seed-test: pass"; \350+
else echo "rbs-seed-test: FAIL (#1417: module-nested-class seed not applied)"; exit 1; fi351+
endif352+
327353
# Analyze-fail fixtures test the legacy analyzer's rejection diagnostics;328354
# the recipe lives in legacy/Makefile. Thin delegator for `make gate`.329355
analyze-fail-test:src/analyze.cmodifiedView file
Loading diff…
test/rbs-seed/nested_ivar.rbaddedView file
Loading diff…
test/rbs-seed/sig/nested_ivar.rbsaddedView file
Loading diff…