From cccdd6e2c89b45aa8999cb24dcf8aa0122a2a977 Mon Sep 17 00:00:00 2001 From: Hojun-Cho Date: Sat, 8 Aug 2026 04:10:52 +0900 Subject: [PATCH] make: per-file lang/library test targets in -w workdirs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit One phony target per test file so -jN parallelizes both suites, each file building in its own persistent workdir so only changed packages recompile. Tests always execute — the workdir caches builds, never results. Lang tests keep their exact historical invocation (no -I); library tests keep -I lib/ww. Warm -j4: test-library 19.0s -> 1.0s, test-lang 19.8s -> 2.0s. --- Makefile | 35 +++++++++++++++++++++++++---------- 1 file changed, 25 insertions(+), 10 deletions(-) diff --git a/Makefile b/Makefile index 1a734d7f..317906fc 100644 --- a/Makefile +++ b/Makefile @@ -434,17 +434,31 @@ test-compiler: $(WWFIXTURE_BIN) $(WRAPPER_TOOLS) $(COMPILER_WRAPPER_BINS) echo "compiler artifact $$t"; BIN=$(CURDIR)/$(BIN) $(CURDIR)/$$t; \ done -test-lang: $(BIN)/ww $(BIN)/w6c $(BIN)/w6a $(BIN)/w6l $(LIB)/libwwrt.a - @set -e; for f in $(wildcard test/lang/*_test.ww); do \ - echo "ww test $$f"; $(BIN)/ww test $$f; \ - done +# One phony target per language/library test file so `make -jN` +# parallelizes the suites, each in its own persistent -w workdir so only +# changed packages rebuild. Tests always execute — the workdir caches +# builds, never results. +LANG_TEST_FILES = $(wildcard test/lang/*_test.ww) +LANG_TEST_TARGETS = $(LANG_TEST_FILES:%=wwtest/%) +LIBRARY_TEST_TARGETS = $(LIBRARY_TESTS:%=wwtest/%) -test-library: $(BIN)/ww $(BIN)/w6c $(BIN)/w6a $(BIN)/w6l \ - $(LIB)/libwwrt.a $(BIN)/w6c_ww $(LIBRARY_STANDALONE_SOURCES) - @set -e; for f in $(LIBRARY_TESTS); do \ - echo "ww test $$f"; \ - $(BIN)/ww test -I $(CURDIR)/lib/ww $$f; \ - done +$(LANG_TEST_TARGETS): wwtest/%: $(BIN)/ww \ + $(BIN)/w6c $(BIN)/w6a $(BIN)/w6l $(LIB)/libwwrt.a + @echo "ww test $*" + @mkdir -p $(WWBUILD)/wwtest/$(subst /,_,$*) + @$(BIN)/ww test -w $(WWBUILD)/wwtest/$(subst /,_,$*) $* + +$(LIBRARY_TEST_TARGETS): wwtest/%: $(BIN)/ww \ + $(BIN)/w6c $(BIN)/w6a $(BIN)/w6l $(LIB)/libwwrt.a + @echo "ww test $*" + @mkdir -p $(WWBUILD)/wwtest/$(subst /,_,$*) + @$(BIN)/ww test -w $(WWBUILD)/wwtest/$(subst /,_,$*) \ + -I $(CURDIR)/lib/ww $* + +test-lang: $(LANG_TEST_TARGETS) + +test-library: $(LIBRARY_TEST_TARGETS) $(BIN)/w6c $(BIN)/w6c_ww \ + $(LIBRARY_STANDALONE_SOURCES) @set -e; for f in $(LIBRARY_STANDALONE_SOURCES); do \ echo "library compile c $$f"; \ $(CURDIR)/$(BIN)/w6c $(CURDIR)/$$f > /dev/null; \ @@ -807,6 +821,7 @@ nocc: .PHONY: all cstage wwstage wwfixture test-wwfixture-process test-wwfixture \ test test-unit test-compiler-smoke test-compiler test-package \ test-lang test-library test-commit test-lang-byteid \ + $(LANG_TEST_TARGETS) $(LIBRARY_TEST_TARGETS) \ test-data-byteid test-native-byteid test-byteid \ test-bootstrap-native test-bootstrap test-incremental \ test-platform test-all install clean bootstrap nocc bootstrap-snapshot