diff --git a/mk/clean.mk b/mk/clean.mk index 1ed29ae90b18..49a5d2be55b0 100644 --- a/mk/clean.mk +++ b/mk/clean.mk @@ -25,7 +25,9 @@ clean: $(Q)rm -Rf $(foreach ext,out out.tmp \ stage0$(X) stage1$(X) stage2$(X) \ bc o s exe dSYM, \ - $(wildcard test/*/*.$(ext) test/bench/*/*.$(ext))) + $(wildcard test/*.$(ext) \ + test/*/*.$(ext) \ + test/bench/*/*.$(ext))) $(Q)rm -Rf $(foreach ext, \ aux cp fn ky log pdf html pg toc tp vr cps, \ $(wildcard doc/*.$(ext))) diff --git a/mk/tests.mk b/mk/tests.mk index d6f9483b7972..7f0c2731b308 100644 --- a/mk/tests.mk +++ b/mk/tests.mk @@ -138,6 +138,13 @@ ALL_TEST_SOURCES := $(TEST_CFAIL_SOURCES_STAGE0) \ $(TEST_RFAIL_SOURCES_STAGE2) \ $(TEST_RPASS_SOURCES_STAGE2) + +FT := run_pass_stage2 +FT_LIB := $(call CFG_LIB_NAME,$(FT)) +FT_DRIVER := $(FT)_driver +GENERATED += test/$(FT).rc test/$(FT_DRIVER).rs + + check-nocompile: $(TEST_CFAIL_OUTS_STAGE0) \ $(TEST_CFAIL_OUTS_STAGE1) \ $(TEST_CFAIL_OUTS_STAGE2) @@ -165,6 +172,9 @@ check: tidy \ $(TEST_RPASS_OUTS_STAGE2) $(TEST_RFAIL_OUTS_STAGE2) \ $(TEST_CFAIL_OUTS_STAGE2) +fast-check: tidy \ + test/$(FT_DRIVER).out + full-check: tidy \ $(TEST_RPASS_EXES_STAGE0) $(TEST_RFAIL_EXES_STAGE0) \ $(TEST_RPASS_OUTS_STAGE0) $(TEST_RFAIL_OUTS_STAGE0) \ @@ -182,6 +192,28 @@ compile-check: tidy \ $(TEST_RPASS_EXES_STAGE2) $(TEST_RFAIL_EXES_STAGE2) + +###################################################################### +# Fast-test rules +###################################################################### + +test/$(FT).rc test/$(FT_DRIVER).rs: $(TEST_RPASS_SOURCES_STAGE2) \ + $(S)src/etc/combine-tests.py + @$(call E, check: building combined stage2 test runner) + $(Q)$(S)src/etc/combine-tests.py + +stage2/lib/$(FT_LIB): test/$(FT).rc $(SREQ2) + @$(call E, compile_and_link: $@) + $(STAGE2) --shared -o $@ $< + +test/$(FT_DRIVER): test/$(FT_DRIVER).rs stage2/lib/$(FT_LIB) $(SREQ2) + @$(call E, compile_and_link: $@) + $(STAGE2) -o $@ $< + +test/$(FT_DRIVER).out: test/$(FT_DRIVER) $(SREQ2) + $(Q)$(call CFG_RUN_TEST, $<) | tee $@ + + ###################################################################### # Testing rules ###################################################################### diff --git a/src/etc/combine-tests.py b/src/etc/combine-tests.py new file mode 100755 index 000000000000..8abbed8dd6ee --- /dev/null +++ b/src/etc/combine-tests.py @@ -0,0 +1,66 @@ +#!/usr/bin/env python + +# this combines all the working run-pass tests into a single large crate so we +# can run it "fast": spawning zillions of windows processes is our major build +# bottleneck (and it doesn't hurt to run faster on other platforms as well). + +import sys, os, re + +def scrub(b): + if sys.version_info >= (3,) and type(b) == bytes: + return b.decode('ascii') + else: + return b + +src_dir = scrub(os.getenv("CFG_SRC_DIR")) +if not src_dir: + raise Exception("missing env var CFG_SRC_DIR") + +run_pass = os.path.join(src_dir, "src", "test", "run-pass") +stage2_tests = [] +take_args = {} + +for t in os.listdir(run_pass): + if t.endswith(".rs"): + f = open(os.path.join(run_pass, t)) + s = f.read() + if not ("xfail-stage2" in s): + stage2_tests.append(t) + if "main(vec[str] args)" in s: + take_args[t] = True + f.close() + +stage2_tests.sort() + +# add a .. prefix because we're about to write down into test/.. +parent_run_pass = os.path.join("..", run_pass); + + +c = open("test/run_pass_stage2.rc", "w") +i = 0 +c.write("// AUTO-GENERATED FILE: DO NOT EDIT\n") +c.write("#[link(name=\"run_pass_stage2\", vers=\"0.1\")];\n") +for t in stage2_tests: + c.write("mod t_%d = \"%s\";\n" + % (i, os.path.join(parent_run_pass, t))) + i += 1 +c.close() + + +d = open("test/run_pass_stage2_driver.rs", "w") +d.write("// AUTO-GENERATED FILE: DO NOT EDIT\n") +d.write("use std;\n") +d.write("use run_pass_stage2;\n") +d.write("import run_pass_stage2::*;\n") +d.write("fn main() {\n"); +d.write(" auto out = std::io::stdout();\n"); +i = 0 +for t in stage2_tests: + d.write(" out.write_str(\"run-pass [stage2]: %s\\n\");\n" + % os.path.join("test", "run-pass", t)) + if t in take_args: + d.write(" t_%d::main([\"arg0\"]);\n" % i) + else: + d.write(" t_%d::main();\n" % i) + i += 1 +d.write("}\n")