Commit 721e58cb

721e58cbb1beMerged

Yusuke Endoh <[email protected]> · 6 months ago · 1 file · ~1 modified

Description

chore(test): add optcarrot integration target

make optcarrot clones https://github.com/mame/optcarrot.git's experiment/spinel branch into build/optcarrot, packs lib/optcarrot/*.rb into a single Ruby file via the upstream tools/pack-for-spinel.rb, compiles it through spinel, and verifies the binary's output contains fps: <num> and checksum: 59662 (the canonical 180-frame benchmark checksum for examples/Lan_Master.nes).

The clone is cached — re-runs reuse build/optcarrot so only the pack / compile / run cost is paid on each invocation.

Co-Authored-By: Claude Opus 4.7 (1M context) [email protected]

Details

Commit
721e58cbb1be
Parent
52b22e81cc1e

MakefilemodifiedView file

@@ -122,7 +122,7 @@
122122 CODEGEN_STAMP := build/stamps/spinel_codegen.rb.stamp
123123 PARSE_STAMP := build/stamps/spinel_parse.c.stamp
124124
125-.PHONY: all parse bootstrap codegen test retest clean-test-results regen-expected bench clean install uninstall deps
125+.PHONY: all parse bootstrap codegen test retest clean-test-results regen-expected bench optcarrot clean install uninstall deps
126126
127127 all: parse regexp spinel_codegen$(EXE)
128128
@@ -378,6 +378,34 @@
378378 echo "Benchmarks: $$pass pass, $$fail fail, $$err error, $$skip skip"; \
379379 if [ $$fail -ne 0 ] || [ $$err -ne 0 ]; then exit 1; fi
380380
381+# ---- Optcarrot integration test ----
382+#
383+# End-to-end pipeline: clone optcarrot's `experiment/spinel` branch,
384+# pack `lib/optcarrot/*.rb` into a single Ruby file via the upstream
385+# `tools/pack-for-spinel.rb`, compile through spinel, run the
386+# resulting binary against `examples/Lan_Master.nes`, and verify the
387+# output contains `fps: <num>` and `checksum: 59662` (the canonical
388+# 180-frame checksum for `--benchmark`).
389+
390+OPTCARROT_DIR := build/optcarrot
391+OPTCARROT_REPO := https://github.com/mame/optcarrot.git
392+OPTCARROT_BRANCH := experiment/spinel
393+
394+optcarrot: spinel_parse$(EXE) $(SP_RT_LIB) spinel_codegen$(EXE)
395+ @if [ ! -d $(OPTCARROT_DIR) ]; then \
396+ git clone --depth=1 --branch=$(OPTCARROT_BRANCH) $(OPTCARROT_REPO) $(OPTCARROT_DIR); \
397+ fi
398+ @ruby $(OPTCARROT_DIR)/tools/pack-for-spinel.rb > build/optcarrot-single.rb
399+ @./spinel build/optcarrot-single.rb -o build/optcarrot-single
400+ @out=$$($(TIMEOUT60) ./build/optcarrot-single 2>&1); \
401+ echo "$$out"; \
402+ if echo "$$out" | grep -qE "^fps: [0-9.]+$$" && echo "$$out" | grep -q "^checksum: 59662$$"; then \
403+ echo "Optcarrot: OK"; \
404+ else \
405+ echo "Optcarrot: FAIL — expected 'fps: <num>' and 'checksum: 59662'"; \
406+ exit 1; \
407+ fi
408+
381409 # ---- Install ----
382410
383411 PREFIX ?= /usr/local