Skip to content

Commit 4e5d32e

Browse files
committed
Add fast-check target that combines the stage2 run-pass suite into a single executable.
1 parent c796a8f commit 4e5d32e

File tree

3 files changed

+101
-1
lines changed

3 files changed

+101
-1
lines changed

mk/clean.mk

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@ clean:
2525
$(Q)rm -Rf $(foreach ext,out out.tmp \
2626
stage0$(X) stage1$(X) stage2$(X) \
2727
bc o s exe dSYM, \
28-
$(wildcard test/*/*.$(ext) test/bench/*/*.$(ext)))
28+
$(wildcard test/*.$(ext) \
29+
test/*/*.$(ext) \
30+
test/bench/*/*.$(ext)))
2931
$(Q)rm -Rf $(foreach ext, \
3032
aux cp fn ky log pdf html pg toc tp vr cps, \
3133
$(wildcard doc/*.$(ext)))

mk/tests.mk

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,13 @@ ALL_TEST_SOURCES := $(TEST_CFAIL_SOURCES_STAGE0) \
138138
$(TEST_RFAIL_SOURCES_STAGE2) \
139139
$(TEST_RPASS_SOURCES_STAGE2)
140140

141+
142+
FT := run_pass_stage2
143+
FT_LIB := $(call CFG_LIB_NAME,$(FT))
144+
FT_DRIVER := $(FT)_driver
145+
GENERATED += test/$(FT).rc test/$(FT_DRIVER).rs
146+
147+
141148
check-nocompile: $(TEST_CFAIL_OUTS_STAGE0) \
142149
$(TEST_CFAIL_OUTS_STAGE1) \
143150
$(TEST_CFAIL_OUTS_STAGE2)
@@ -165,6 +172,9 @@ check: tidy \
165172
$(TEST_RPASS_OUTS_STAGE2) $(TEST_RFAIL_OUTS_STAGE2) \
166173
$(TEST_CFAIL_OUTS_STAGE2)
167174

175+
fast-check: tidy \
176+
test/$(FT_DRIVER).out
177+
168178
full-check: tidy \
169179
$(TEST_RPASS_EXES_STAGE0) $(TEST_RFAIL_EXES_STAGE0) \
170180
$(TEST_RPASS_OUTS_STAGE0) $(TEST_RFAIL_OUTS_STAGE0) \
@@ -182,6 +192,28 @@ compile-check: tidy \
182192
$(TEST_RPASS_EXES_STAGE2) $(TEST_RFAIL_EXES_STAGE2)
183193

184194

195+
196+
######################################################################
197+
# Fast-test rules
198+
######################################################################
199+
200+
test/$(FT).rc test/$(FT_DRIVER).rs: $(TEST_RPASS_SOURCES_STAGE2) \
201+
$(S)src/etc/combine-tests.py
202+
@$(call E, check: building combined stage2 test runner)
203+
$(Q)$(S)src/etc/combine-tests.py
204+
205+
stage2/lib/$(FT_LIB): test/$(FT).rc $(SREQ2)
206+
@$(call E, compile_and_link: $@)
207+
$(STAGE2) --shared -o $@ $<
208+
209+
test/$(FT_DRIVER): test/$(FT_DRIVER).rs stage2/lib/$(FT_LIB) $(SREQ2)
210+
@$(call E, compile_and_link: $@)
211+
$(STAGE2) -o $@ $<
212+
213+
test/$(FT_DRIVER).out: test/$(FT_DRIVER) $(SREQ2)
214+
$(Q)$(call CFG_RUN_TEST, $<) | tee $@
215+
216+
185217
######################################################################
186218
# Testing rules
187219
######################################################################

src/etc/combine-tests.py

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
#!/usr/bin/env python
2+
3+
# this combines all the working run-pass tests into a single large crate so we
4+
# can run it "fast": spawning zillions of windows processes is our major build
5+
# bottleneck (and it doesn't hurt to run faster on other platforms as well).
6+
7+
import sys, os, re
8+
9+
def scrub(b):
10+
if sys.version_info >= (3,) and type(b) == bytes:
11+
return b.decode('ascii')
12+
else:
13+
return b
14+
15+
src_dir = scrub(os.getenv("CFG_SRC_DIR"))
16+
if not src_dir:
17+
raise Exception("missing env var CFG_SRC_DIR")
18+
19+
run_pass = os.path.join(src_dir, "src", "test", "run-pass")
20+
stage2_tests = []
21+
take_args = {}
22+
23+
for t in os.listdir(run_pass):
24+
if t.endswith(".rs"):
25+
f = open(os.path.join(run_pass, t))
26+
s = f.read()
27+
if not ("xfail-stage2" in s):
28+
stage2_tests.append(t)
29+
if "main(vec[str] args)" in s:
30+
take_args[t] = True
31+
f.close()
32+
33+
stage2_tests.sort()
34+
35+
# add a .. prefix because we're about to write down into test/..
36+
parent_run_pass = os.path.join("..", run_pass);
37+
38+
39+
c = open("test/run_pass_stage2.rc", "w")
40+
i = 0
41+
c.write("// AUTO-GENERATED FILE: DO NOT EDIT\n")
42+
c.write("#[link(name=\"run_pass_stage2\", vers=\"0.1\")];\n")
43+
for t in stage2_tests:
44+
c.write("mod t_%d = \"%s\";\n"
45+
% (i, os.path.join(parent_run_pass, t)))
46+
i += 1
47+
c.close()
48+
49+
50+
d = open("test/run_pass_stage2_driver.rs", "w")
51+
d.write("// AUTO-GENERATED FILE: DO NOT EDIT\n")
52+
d.write("use std;\n")
53+
d.write("use run_pass_stage2;\n")
54+
d.write("import run_pass_stage2::*;\n")
55+
d.write("fn main() {\n");
56+
d.write(" auto out = std::io::stdout();\n");
57+
i = 0
58+
for t in stage2_tests:
59+
d.write(" out.write_str(\"run-pass [stage2]: %s\\n\");\n"
60+
% os.path.join("test", "run-pass", t))
61+
if t in take_args:
62+
d.write(" t_%d::main([\"arg0\"]);\n" % i)
63+
else:
64+
d.write(" t_%d::main();\n" % i)
65+
i += 1
66+
d.write("}\n")

0 commit comments

Comments
 (0)