Skip to content

Commit d36ad55

Browse files
committed
Auto merge of #32755 - alexcrichton:rustbuild-start-test, r=brson
rustbuild: Add support for compiletest test suites This commit adds support in rustbuild for running all of the compiletest test suites as part of `make check`. The `compiletest` program was moved to `src/tools` (like `rustbook` and others) and is now just compiled like any other old tool. Each test suite has a pretty standard set of dependencies and just tweaks various parameters to the final compiletest executable. Note that full support is lacking in terms of: * Once a test suite has passed, that's not remembered. When a test suite is requested to be run, it's always run. * The arguments to compiletest probably don't work for every possible combination of platforms and testing environments just yet. There will likely need to be future updates to tweak various pieces here and there. * Cross compiled test suites probably don't work just yet, support for that will come in a follow-up patch.
2 parents b324fa7 + b325baf commit d36ad55

28 files changed

+432
-63
lines changed

mk/crates.mk

+1-1
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ TOOL_DEPS_rustdoc := rustdoc
133133
TOOL_DEPS_rustc := rustc_driver
134134
TOOL_DEPS_rustbook := std rustdoc
135135
TOOL_DEPS_error_index_generator := rustdoc syntax serialize
136-
TOOL_SOURCE_compiletest := $(S)src/compiletest/compiletest.rs
136+
TOOL_SOURCE_compiletest := $(S)src/tools/compiletest/src/main.rs
137137
TOOL_SOURCE_rustdoc := $(S)src/driver/driver.rs
138138
TOOL_SOURCE_rustc := $(S)src/driver/driver.rs
139139
TOOL_SOURCE_rustbook := $(S)src/tools/rustbook/main.rs

mk/dist.mk

-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ PKG_FILES := \
5050
$(addprefix $(S)src/, \
5151
bootstrap \
5252
build_helper \
53-
compiletest \
5453
doc \
5554
driver \
5655
etc \

mk/tests.mk

+1-1
Original file line numberDiff line numberDiff line change
@@ -611,7 +611,7 @@ CTEST_COMMON_ARGS$(1)-T-$(2)-H-$(3) := \
611611
--run-lib-path $$(TLIB$(1)_T_$(2)_H_$(3)) \
612612
--rustc-path $$(HBIN$(1)_H_$(3))/rustc$$(X_$(3)) \
613613
--rustdoc-path $$(HBIN$(1)_H_$(3))/rustdoc$$(X_$(3)) \
614-
--llvm-bin-path $(CFG_LLVM_INST_DIR_$(CFG_BUILD))/bin \
614+
--llvm-filecheck $(CFG_LLVM_INST_DIR_$(CFG_BUILD))/bin/FileCheck \
615615
--aux-base $$(S)src/test/auxiliary/ \
616616
--stage-id stage$(1)-$(2) \
617617
--target $(2) \

src/bootstrap/bootstrap.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -335,11 +335,11 @@ def build_triple(self):
335335

336336
# Run the bootstrap
337337
args = [os.path.join(rb.build_dir, "bootstrap/debug/bootstrap")]
338-
args.extend(sys.argv[1:])
339338
args.append('--src')
340339
args.append(rb.rust_root)
341340
args.append('--build')
342341
args.append(rb.build)
342+
args.extend(sys.argv[1:])
343343
env = os.environ.copy()
344344
env["BOOTSTRAP_PARENT_ID"] = str(os.getpid())
345345
rb.run(args, env)

src/bootstrap/build/check.rs

+53
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
// except according to those terms.
1010

1111
use std::fs;
12+
use std::path::PathBuf;
1213

1314
use build::{Build, Compiler};
1415

@@ -49,3 +50,55 @@ pub fn tidy(build: &Build, stage: u32, host: &str) {
4950
build.run(build.tool_cmd(&compiler, "tidy")
5051
.arg(build.src.join("src")));
5152
}
53+
54+
fn testdir(build: &Build, host: &str) -> PathBuf {
55+
build.out.join(host).join("test")
56+
}
57+
58+
pub fn compiletest(build: &Build,
59+
compiler: &Compiler,
60+
target: &str,
61+
mode: &str,
62+
suite: &str) {
63+
let mut cmd = build.tool_cmd(compiler, "compiletest");
64+
65+
cmd.arg("--compile-lib-path").arg(build.rustc_libdir(compiler));
66+
cmd.arg("--run-lib-path").arg(build.sysroot_libdir(compiler, target));
67+
cmd.arg("--rustc-path").arg(build.compiler_path(compiler));
68+
cmd.arg("--rustdoc-path").arg(build.rustdoc(compiler));
69+
cmd.arg("--src-base").arg(build.src.join("src/test").join(suite));
70+
cmd.arg("--aux-base").arg(build.src.join("src/test/auxiliary"));
71+
cmd.arg("--build-base").arg(testdir(build, compiler.host).join(suite));
72+
cmd.arg("--stage-id").arg(format!("stage{}-{}", compiler.stage, target));
73+
cmd.arg("--mode").arg(mode);
74+
cmd.arg("--target").arg(target);
75+
cmd.arg("--host").arg(compiler.host);
76+
cmd.arg("--llvm-filecheck").arg(build.llvm_filecheck(&build.config.build));
77+
78+
let linkflag = format!("-Lnative={}", build.test_helpers_out(target).display());
79+
cmd.arg("--host-rustcflags").arg("-Crpath");
80+
cmd.arg("--target-rustcflags").arg(format!("-Crpath {}", linkflag));
81+
82+
// FIXME: needs android support
83+
cmd.arg("--android-cross-path").arg("");
84+
// FIXME: CFG_PYTHON should probably be detected more robustly elsewhere
85+
cmd.arg("--python").arg("python");
86+
87+
if let Some(ref vers) = build.gdb_version {
88+
cmd.arg("--gdb-version").arg(vers);
89+
}
90+
if let Some(ref vers) = build.lldb_version {
91+
cmd.arg("--lldb-version").arg(vers);
92+
}
93+
if let Some(ref dir) = build.lldb_python_dir {
94+
cmd.arg("--lldb-python-dir").arg(dir);
95+
}
96+
97+
cmd.args(&build.flags.args);
98+
99+
if build.config.verbose || build.flags.verbose {
100+
cmd.arg("--verbose");
101+
}
102+
103+
build.run(&mut cmd);
104+
}

src/bootstrap/build/clean.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ pub fn clean(build: &Build) {
2525
rm_rf(build, &out.join(format!("stage{}", stage)));
2626
rm_rf(build, &out.join(format!("stage{}-std", stage)));
2727
rm_rf(build, &out.join(format!("stage{}-rustc", stage)));
28-
rm_rf(build, &out.join(format!("stage{}-test", stage)));
2928
rm_rf(build, &out.join(format!("stage{}-tools", stage)));
29+
rm_rf(build, &out.join(format!("stage{}-test", stage)));
3030
}
3131
}
3232
}

src/bootstrap/build/compile.rs

+1-8
Original file line numberDiff line numberDiff line change
@@ -191,14 +191,7 @@ pub fn rustc<'a>(build: &'a Build, target: &str, compiler: &Compiler<'a>) {
191191
if !build.unstable_features {
192192
cargo.env("CFG_DISABLE_UNSTABLE_FEATURES", "1");
193193
}
194-
let target_config = build.config.target_config.get(target);
195-
if let Some(ref s) = target_config.and_then(|c| c.llvm_config.as_ref()) {
196-
cargo.env("LLVM_CONFIG", s);
197-
} else {
198-
let llvm_config = build.llvm_out(&build.config.build).join("bin")
199-
.join(exe("llvm-config", target));
200-
cargo.env("LLVM_CONFIG", llvm_config);
201-
}
194+
cargo.env("LLVM_CONFIG", build.llvm_config(target));
202195
if build.config.llvm_static_stdcpp {
203196
cargo.env("LLVM_STATIC_STDCPP",
204197
compiler_file(build.cxx(target), "libstdc++.a"));

src/bootstrap/build/dist.rs

+30-23
Original file line numberDiff line numberDiff line change
@@ -195,29 +195,7 @@ pub fn rustc(build: &Build, stage: u32, host: &str) {
195195
cp_r(&build.src.join("man"), &image.join("share/man/man1"));
196196

197197
// Debugger scripts
198-
let cp_debugger_script = |file: &str| {
199-
let dst = image.join("lib/rustlib/etc");
200-
t!(fs::create_dir_all(&dst));
201-
install(&build.src.join("src/etc/").join(file), &dst, 0o644);
202-
};
203-
if host.contains("windows") {
204-
// no debugger scripts
205-
} else if host.contains("darwin") {
206-
// lldb debugger scripts
207-
install(&build.src.join("src/etc/rust-lldb"), &image.join("bin"),
208-
0o755);
209-
210-
cp_debugger_script("lldb_rust_formatters.py");
211-
cp_debugger_script("debugger_pretty_printers_common.py");
212-
} else {
213-
// gdb debugger scripts
214-
install(&build.src.join("src/etc/rust-gdb"), &image.join("bin"),
215-
0o755);
216-
217-
cp_debugger_script("gdb_load_rust_pretty_printers.py");
218-
cp_debugger_script("gdb_rust_pretty_printing.py");
219-
cp_debugger_script("debugger_pretty_printers_common.py");
220-
}
198+
debugger_scripts(build, &image, host);
221199

222200
// Misc license info
223201
let cp = |file: &str| {
@@ -231,6 +209,35 @@ pub fn rustc(build: &Build, stage: u32, host: &str) {
231209
}
232210
}
233211

212+
pub fn debugger_scripts(build: &Build,
213+
sysroot: &Path,
214+
host: &str) {
215+
let cp_debugger_script = |file: &str| {
216+
let dst = sysroot.join("lib/rustlib/etc");
217+
t!(fs::create_dir_all(&dst));
218+
install(&build.src.join("src/etc/").join(file), &dst, 0o644);
219+
};
220+
if host.contains("windows") {
221+
// no debugger scripts
222+
} else if host.contains("darwin") {
223+
// lldb debugger scripts
224+
install(&build.src.join("src/etc/rust-lldb"), &sysroot.join("bin"),
225+
0o755);
226+
227+
cp_debugger_script("lldb_rust_formatters.py");
228+
cp_debugger_script("debugger_pretty_printers_common.py");
229+
} else {
230+
// gdb debugger scripts
231+
install(&build.src.join("src/etc/rust-gdb"), &sysroot.join("bin"),
232+
0o755);
233+
234+
cp_debugger_script("gdb_load_rust_pretty_printers.py");
235+
cp_debugger_script("gdb_rust_pretty_printing.py");
236+
cp_debugger_script("debugger_pretty_printers_common.py");
237+
}
238+
}
239+
240+
234241
pub fn std(build: &Build, compiler: &Compiler, target: &str) {
235242
println!("Dist std stage{} ({} -> {})", compiler.stage, compiler.host,
236243
target);

src/bootstrap/build/flags.rs

-5
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,6 @@ impl Flags {
6262
usage(0);
6363
}
6464

65-
if m.free.len() > 0 {
66-
println!("free arguments are not currently accepted");
67-
usage(1);
68-
}
69-
7065
let cfg_file = m.opt_str("config").map(PathBuf::from).or_else(|| {
7166
if fs::metadata("config.toml").is_ok() {
7267
Some(PathBuf::from("config.toml"))

0 commit comments

Comments
 (0)