Commit 573c514c
573c514cf9a4Merged
Yukihiro "Matz" Matsumoto <[email protected]> · 6 months ago · 1 file · ~1 modified
Description
build: prefer miniruby for test/bench reference, fall back to ruby
make test and make bench compared spinel output to system ruby.
On boxes with an older system Ruby (e.g. 3.2 vs the test using a Ruby
3.4 feature like it block param) the comparison would fail even
though the spinel-emitted binary was correct. matz's box has
miniruby (Ruby 4.1.0dev built with +PRISM) on PATH, which models
the latest semantics.
Add a REF_RUBY make variable that auto-detects miniruby and falls
back to ruby. The harness then runs the reference Ruby per file; if
it exits non-zero (the bootstrap miniruby can't load extension libs
like stringio), fall back to system ruby for that file. Net effect:
it/=>and other newer-Ruby tests pass under miniruby.- stringio / other extension-library tests still pass under ruby.
- Environments without miniruby (CI image, fresh checkouts) take
the existing direct-
rubypath — no behaviour change. - Override on the command line via
REF_RUBY=ruby make testto force the legacy behaviour.
After: make test reports 218/218 green locally (was 217/218 with
numbered_block_params spuriously failing on Ruby 3.2.3).
Co-Authored-By: Claude Opus 4.7 (1M context) [email protected]
Details
- Commit
- 573c514cf9a4
- Parent
- 69d70c813157
MakefilemodifiedView file
TIMEOUT10 := $(if $(TIMEOUT_BIN),$(TIMEOUT_BIN) 10,)TIMEOUT60 := $(if $(TIMEOUT_BIN),$(TIMEOUT_BIN) 60,)# Reference Ruby for `make test` / `make bench` output comparison.# Prefer `miniruby` (Ruby's bootstrap interpreter; matz's local copy is# 4.1.0dev with +PRISM, so newer features like `it` block param work)# when available; the test/bench harness falls back to `ruby` per-file# if miniruby exits non-zero — covers tests that `require` extension# libraries (stringio, etc.) which the bootstrap miniruby can't load.# Environments without miniruby use `ruby` directly. Override via# `REF_RUBY=ruby make test` if a specific primary is wanted.REF_RUBY ?= $(shell command -v miniruby >/dev/null 2>&1 && echo miniruby || echo ruby)# Prism library: prefer vendor/prism (fetched via `make deps`), then# fall back to the Prism gem if one is installed. Override by setting# PRISM_DIR=/path/to/prism on the command line. ./spinel_codegen$(EXE) /tmp/_sp_t.ast /tmp/_sp_t.c 2>/dev/null && \ $(CC) $(CFLAGS) -Werror $(SEC_FLAGS) -Ilib /tmp/_sp_t.c $(SP_RT_LIB) $(LDFLAGS) -lm $(GC_FLAGS) -o /tmp/_sp_t_bin$(EXE) 2>/dev/null; \ if [ $$? -eq 0 ]; then \ expected=$$($(TIMEOUT10) ruby "$$f" 2>/dev/null); \ expected=$$($(TIMEOUT10) $(REF_RUBY) "$$f" 2>/dev/null); \ if [ $$? -ne 0 ] && [ "$(REF_RUBY)" != "ruby" ]; then \ expected=$$($(TIMEOUT10) ruby "$$f" 2>/dev/null); \ fi; \ actual=$$($(TIMEOUT10) /tmp/_sp_t_bin$(EXE) 2>/dev/null); \ if [ "$$expected" = "$$actual" ]; then \ pass=$$((pass+1)); \ $(TIMEOUT10) ./spinel_codegen$(EXE) /tmp/_sp_b.ast /tmp/_sp_b.c 2>/dev/null && \ $(CC) $(CFLAGS) -Werror $(SEC_FLAGS) -Ilib /tmp/_sp_b.c $(SP_RT_LIB) $(LDFLAGS) -lm $(GC_FLAGS) -o /tmp/_sp_b_bin$(EXE) 2>/dev/null; \ if [ $$? -eq 0 ]; then \ expected=$$($(TIMEOUT60) ruby "$$f" 2>/dev/null); \ expected=$$($(TIMEOUT60) $(REF_RUBY) "$$f" 2>/dev/null); \ ruby_rc=$$?; \ if [ $$ruby_rc -ne 0 ] && [ "$(REF_RUBY)" != "ruby" ]; then \ expected=$$($(TIMEOUT60) ruby "$$f" 2>/dev/null); \ ruby_rc=$$?; \ fi; \ if [ $$ruby_rc -eq 124 ]; then \ echo "SKIP: $$bn (ruby timeout)"; skip=$$((skip+1)); \ else \