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