Commit a97a06c0

a97a06c03173Merged

Yukihiro "Matz" Matsumoto <[email protected]> · 6 months ago · 1 file · ~1 modified

Description

fix(make): regen-expected passes .args and skips on Ruby failure (#795, #796)

Two related issues with the regen-expected target -- same recipe, same per-test loop:

  • #795: the test runner reads test/.rb.args (when present) for the per-test ARGV, but regen-expected ran Ruby without that file, so the captured expected output was wrong for any test whose output depended on ARGV (test/argv_gc.rb being the canonical example).
  • #796: when REF_RUBY failed (timeout, crash, missing extension), the recipe wrote the empty / partial output to .expected anyway. Subsequent make test would compare against the broken file and silently pass or fail against garbage.

Fix: capture args from the .args file like the test recipe does, check Ruby's exit code, and only sed-write .expected when the run succeeded. On failure, print a warning and leave the existing .expected untouched.

Closes #795 Closes #796

Co-Authored-By: Claude Opus 4.7 [email protected]

Details

Commit
a97a06c03173
Parent
11cd3db1ae58

MakefilemodifiedView file

@@ -469,13 +469,21 @@
469469 regen-expected: $(EXPECTED_FILES)
470470
471471 test/%.rb.expected: test/%.rb
472- @$(TIMEOUT10) $(REF_RUBY) $< >[email protected] 2>/dev/null; \
472+ @args=""; \
473+ if [ -f "$<.args" ]; then args=$$(cat "$<.args"); fi; \
474+ $(TIMEOUT10) $(REF_RUBY) $< $$args >[email protected] 2>/dev/null; \
473475 rc=$$?; \
474476 if [ $$rc -ne 0 ] && [ "$(REF_RUBY)" != "ruby" ]; then \
475- $(TIMEOUT10) ruby $< >[email protected] 2>/dev/null; \
477+ $(TIMEOUT10) ruby $< $$args >[email protected] 2>/dev/null; \
478+ rc=$$?; \
476479 fi; \
477- LC_ALL=C sed 's/\r$$//' [email protected] > $@; \
480+ if [ $$rc -ne 0 ]; then \
481+ echo "regen-expected: $< failed (rc=$$rc); skipping" >&2; \
482+ rm -f [email protected]; \
483+ else \
484+ LC_ALL=C sed 's/\r$$//' [email protected] > $@; \
485+ rm -f [email protected]; \
486+ fi
479487
480488 bench: spinel_parse$(EXE) $(SP_RT_LIB) spinel_analyze$(EXE) spinel_codegen$(EXE)
481489 @if [ -z "$(TIMEOUT_BIN)" ]; then echo "Note: no 'timeout' command found; running without time limits."; fi