Commit 93e1bc67
93e1bc678f01Merged
Yukihiro "Matz" Matsumoto <[email protected]> · 6 months ago · 1 file · ~1 modified
Description
build: regen-expected target + .expected fallback in test harness
Adds a regen-expected Make target that runs each test/*.rb under
the reference Ruby and writes the captured stdout to
test/.rb.expected (CRLF normalized).
The per-test .ok recipe now prefers test/.rb.expected when it exists, skipping the per-run Ruby invocation. When .expected is missing the recipe falls back to the existing Ruby path, so this commit is a no-op for behavior — the speedup arrives in the follow-up commit that actually checks in the .expected files.
Motivation: in CI, especially on Windows mingw64 ruby, hundreds of
ruby test/foo.rb invocations add up. Pre-computing the expected
output once and committing it to the repo lets CI skip Ruby
entirely for tests that have a .expected.
Co-Authored-By: Claude Opus 4.7 (1M context) [email protected]
Details
- Commit
- 93e1bc678f01
- Parent
- f8dd3556c646
MakefilemodifiedView file
PRISM_OBJ = $(patsubst $(PRISM_DIR)/src/%.c,build/prism/%.o,$(PRISM_SRC))PRISM_LIB = build/libprism.a.PHONY: all parse bootstrap codegen test test-run clean-test-results bench clean install uninstall deps.PHONY: all parse bootstrap codegen test test-run clean-test-results regen-expected bench clean install uninstall depsall: parse regexp spinel_codegen$(EXE) ./spinel_codegen$(EXE) "$$ast" "$$cfile" 2>/dev/null && \ $(CC) $(CFLAGS) -Werror $(SEC_FLAGS) -Ilib "$$cfile" $(SP_RT_LIB) $(LDFLAGS) -lm $(GC_FLAGS) -o "$$bin" 2>/dev/null; \ if [ $$? -eq 0 ]; then \ $(TIMEOUT10) $(REF_RUBY) "$<" >"$$exp" 2>/dev/null; \ ruby_rc=$$?; \ if [ $$ruby_rc -ne 0 ] && [ "$(REF_RUBY)" != "ruby" ]; then \ $(TIMEOUT10) ruby "$<" >"$$exp" 2>/dev/null; \ if [ -f "$<.expected" ]; then \ cp "$<.expected" "$$exp.n"; \ else \ $(TIMEOUT10) $(REF_RUBY) "$<" >"$$exp" 2>/dev/null; \ ruby_rc=$$?; \ if [ $$ruby_rc -ne 0 ] && [ "$(REF_RUBY)" != "ruby" ]; then \ $(TIMEOUT10) ruby "$<" >"$$exp" 2>/dev/null; \ fi; \ LC_ALL=C sed 's/\r$$//' "$$exp" >"$$exp.n"; \ fi; \ $(TIMEOUT10) "$$bin" >"$$act" 2>/dev/null; \ LC_ALL=C sed 's/\r$$//' "$$exp" >"$$exp.n"; \ LC_ALL=C sed 's/\r$$//' "$$act" >"$$act.n"; \ if cmp -s "$$exp.n" "$$act.n"; then \ echo PASS > "$@"; \clean-test-results: @rm -rf build/test-results# ---- Expected-output regeneration ----# Capture each test's reference Ruby output into test/<name>.rb.expected.# Once committed, the test target uses the .expected file directly and# skips the per-test ruby invocation — useful in CI where ruby's startup# (especially mingw64 ruby on Windows) adds up across hundreds of tests.# Regenerate after adding or modifying tests; commit the result.EXPECTED_FILES := $(patsubst test/%.rb,test/%.rb.expected,$(TESTS))regen-expected: $(EXPECTED_FILES)test/%.rb.expected: test/%.rb @$(TIMEOUT10) $(REF_RUBY) $< >[email protected] 2>/dev/null; \ rc=$$?; \ if [ $$rc -ne 0 ] && [ "$(REF_RUBY)" != "ruby" ]; then \ $(TIMEOUT10) ruby $< >[email protected] 2>/dev/null; \ fi; \ LC_ALL=C sed 's/\r$$//' [email protected] > $@; \ rm -f [email protected]bench: spinel_parse$(EXE) $(SP_RT_LIB) spinel_codegen$(EXE) @if [ -z "$(TIMEOUT_BIN)" ]; then echo "Note: no 'timeout' command found; running without time limits."; fi @total=$$(ls benchmark/*.rb | wc -l); \