2011-06-29 17:12:02 -05:00
|
|
|
#!/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).
|
|
|
|
|
2011-06-30 11:26:17 -05:00
|
|
|
import sys, os, re, codecs
|
2011-06-29 17:12:02 -05:00
|
|
|
|
|
|
|
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")
|
2011-06-29 19:54:05 -05:00
|
|
|
run_pass = os.path.abspath(run_pass)
|
2011-06-29 17:12:02 -05:00
|
|
|
stage2_tests = []
|
|
|
|
take_args = {}
|
|
|
|
|
|
|
|
for t in os.listdir(run_pass):
|
2011-07-28 16:24:20 -05:00
|
|
|
if t.endswith(".rs") and not (
|
|
|
|
t.startswith(".") or t.startswith("#") or t.startswith("~")):
|
2011-06-30 11:26:17 -05:00
|
|
|
f = codecs.open(os.path.join(run_pass, t), "r", "utf8")
|
2011-06-29 17:12:02 -05:00
|
|
|
s = f.read()
|
2011-08-31 06:22:58 -05:00
|
|
|
if not ("xfail-test" in s or
|
2011-09-09 15:52:49 -05:00
|
|
|
"xfail-fast" in s or
|
|
|
|
"xfail-win32" in s):
|
2011-06-29 17:12:02 -05:00
|
|
|
stage2_tests.append(t)
|
2011-08-14 00:34:16 -05:00
|
|
|
if "main(args: [str])" in s:
|
2011-06-29 17:12:02 -05:00
|
|
|
take_args[t] = True
|
2012-06-30 15:59:54 -05:00
|
|
|
if "main(args: ~[str])" in s:
|
|
|
|
take_args[t] = True
|
2011-06-29 17:12:02 -05:00
|
|
|
f.close()
|
|
|
|
|
|
|
|
stage2_tests.sort()
|
|
|
|
|
2011-11-29 09:07:25 -06:00
|
|
|
c = open("tmp/run_pass_stage2.rc", "w")
|
2011-06-29 17:12:02 -05:00
|
|
|
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:
|
2011-06-30 11:26:17 -05:00
|
|
|
p = os.path.join(run_pass, t)
|
|
|
|
p = p.replace("\\", "\\\\")
|
2011-11-24 17:45:40 -06:00
|
|
|
c.write("#[path = \"%s\"]" % p);
|
|
|
|
c.write("mod t_%d;\n" % i)
|
2011-06-29 17:12:02 -05:00
|
|
|
i += 1
|
|
|
|
c.close()
|
|
|
|
|
|
|
|
|
2011-11-29 09:07:25 -06:00
|
|
|
d = open("tmp/run_pass_stage2_driver.rs", "w")
|
2011-06-29 17:12:02 -05:00
|
|
|
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")
|
2012-03-12 22:04:27 -05:00
|
|
|
d.write("import io::writer_util;\n");
|
2011-06-29 17:12:02 -05:00
|
|
|
d.write("fn main() {\n");
|
2012-03-12 22:04:27 -05:00
|
|
|
d.write(" let out = io::stdout();\n");
|
2011-06-29 17:12:02 -05:00
|
|
|
i = 0
|
|
|
|
for t in stage2_tests:
|
2011-06-30 11:26:17 -05:00
|
|
|
p = os.path.join("test", "run-pass", t)
|
|
|
|
p = p.replace("\\", "\\\\")
|
2011-09-02 18:45:53 -05:00
|
|
|
d.write(" out.write_str(\"run-pass [stage2]: %s\\n\");\n" % p)
|
2011-06-29 17:12:02 -05:00
|
|
|
if t in take_args:
|
2012-07-10 18:29:00 -05:00
|
|
|
d.write(" t_%d::main(~[\"arg0\"]);\n" % i)
|
2011-06-29 17:12:02 -05:00
|
|
|
else:
|
|
|
|
d.write(" t_%d::main();\n" % i)
|
|
|
|
i += 1
|
|
|
|
d.write("}\n")
|