Skip to content

Commit

Permalink
Auto merge of #32755 - alexcrichton:rustbuild-start-test, r=brson
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
bors committed Apr 19, 2016
2 parents b324fa7 + b325baf commit d36ad55
Show file tree
Hide file tree
Showing 28 changed files with 432 additions and 63 deletions.
2 changes: 1 addition & 1 deletion mk/crates.mk
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ TOOL_DEPS_rustdoc := rustdoc
TOOL_DEPS_rustc := rustc_driver
TOOL_DEPS_rustbook := std rustdoc
TOOL_DEPS_error_index_generator := rustdoc syntax serialize
TOOL_SOURCE_compiletest := $(S)src/compiletest/compiletest.rs
TOOL_SOURCE_compiletest := $(S)src/tools/compiletest/src/main.rs
TOOL_SOURCE_rustdoc := $(S)src/driver/driver.rs
TOOL_SOURCE_rustc := $(S)src/driver/driver.rs
TOOL_SOURCE_rustbook := $(S)src/tools/rustbook/main.rs
Expand Down
1 change: 0 additions & 1 deletion mk/dist.mk
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ PKG_FILES := \
$(addprefix $(S)src/, \
bootstrap \
build_helper \
compiletest \
doc \
driver \
etc \
Expand Down
2 changes: 1 addition & 1 deletion mk/tests.mk
Original file line number Diff line number Diff line change
Expand Up @@ -611,7 +611,7 @@ CTEST_COMMON_ARGS$(1)-T-$(2)-H-$(3) := \
--run-lib-path $$(TLIB$(1)_T_$(2)_H_$(3)) \
--rustc-path $$(HBIN$(1)_H_$(3))/rustc$$(X_$(3)) \
--rustdoc-path $$(HBIN$(1)_H_$(3))/rustdoc$$(X_$(3)) \
--llvm-bin-path $(CFG_LLVM_INST_DIR_$(CFG_BUILD))/bin \
--llvm-filecheck $(CFG_LLVM_INST_DIR_$(CFG_BUILD))/bin/FileCheck \
--aux-base $$(S)src/test/auxiliary/ \
--stage-id stage$(1)-$(2) \
--target $(2) \
Expand Down
2 changes: 1 addition & 1 deletion src/bootstrap/bootstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -335,11 +335,11 @@ def build_triple(self):

# Run the bootstrap
args = [os.path.join(rb.build_dir, "bootstrap/debug/bootstrap")]
args.extend(sys.argv[1:])
args.append('--src')
args.append(rb.rust_root)
args.append('--build')
args.append(rb.build)
args.extend(sys.argv[1:])
env = os.environ.copy()
env["BOOTSTRAP_PARENT_ID"] = str(os.getpid())
rb.run(args, env)
53 changes: 53 additions & 0 deletions src/bootstrap/build/check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
// except according to those terms.

use std::fs;
use std::path::PathBuf;

use build::{Build, Compiler};

Expand Down Expand Up @@ -49,3 +50,55 @@ pub fn tidy(build: &Build, stage: u32, host: &str) {
build.run(build.tool_cmd(&compiler, "tidy")
.arg(build.src.join("src")));
}

fn testdir(build: &Build, host: &str) -> PathBuf {
build.out.join(host).join("test")
}

pub fn compiletest(build: &Build,
compiler: &Compiler,
target: &str,
mode: &str,
suite: &str) {
let mut cmd = build.tool_cmd(compiler, "compiletest");

cmd.arg("--compile-lib-path").arg(build.rustc_libdir(compiler));
cmd.arg("--run-lib-path").arg(build.sysroot_libdir(compiler, target));
cmd.arg("--rustc-path").arg(build.compiler_path(compiler));
cmd.arg("--rustdoc-path").arg(build.rustdoc(compiler));
cmd.arg("--src-base").arg(build.src.join("src/test").join(suite));
cmd.arg("--aux-base").arg(build.src.join("src/test/auxiliary"));
cmd.arg("--build-base").arg(testdir(build, compiler.host).join(suite));
cmd.arg("--stage-id").arg(format!("stage{}-{}", compiler.stage, target));
cmd.arg("--mode").arg(mode);
cmd.arg("--target").arg(target);
cmd.arg("--host").arg(compiler.host);
cmd.arg("--llvm-filecheck").arg(build.llvm_filecheck(&build.config.build));

let linkflag = format!("-Lnative={}", build.test_helpers_out(target).display());
cmd.arg("--host-rustcflags").arg("-Crpath");
cmd.arg("--target-rustcflags").arg(format!("-Crpath {}", linkflag));

// FIXME: needs android support
cmd.arg("--android-cross-path").arg("");
// FIXME: CFG_PYTHON should probably be detected more robustly elsewhere
cmd.arg("--python").arg("python");

if let Some(ref vers) = build.gdb_version {
cmd.arg("--gdb-version").arg(vers);
}
if let Some(ref vers) = build.lldb_version {
cmd.arg("--lldb-version").arg(vers);
}
if let Some(ref dir) = build.lldb_python_dir {
cmd.arg("--lldb-python-dir").arg(dir);
}

cmd.args(&build.flags.args);

if build.config.verbose || build.flags.verbose {
cmd.arg("--verbose");
}

build.run(&mut cmd);
}
2 changes: 1 addition & 1 deletion src/bootstrap/build/clean.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ pub fn clean(build: &Build) {
rm_rf(build, &out.join(format!("stage{}", stage)));
rm_rf(build, &out.join(format!("stage{}-std", stage)));
rm_rf(build, &out.join(format!("stage{}-rustc", stage)));
rm_rf(build, &out.join(format!("stage{}-test", stage)));
rm_rf(build, &out.join(format!("stage{}-tools", stage)));
rm_rf(build, &out.join(format!("stage{}-test", stage)));
}
}
}
Expand Down
9 changes: 1 addition & 8 deletions src/bootstrap/build/compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,14 +191,7 @@ pub fn rustc<'a>(build: &'a Build, target: &str, compiler: &Compiler<'a>) {
if !build.unstable_features {
cargo.env("CFG_DISABLE_UNSTABLE_FEATURES", "1");
}
let target_config = build.config.target_config.get(target);
if let Some(ref s) = target_config.and_then(|c| c.llvm_config.as_ref()) {
cargo.env("LLVM_CONFIG", s);
} else {
let llvm_config = build.llvm_out(&build.config.build).join("bin")
.join(exe("llvm-config", target));
cargo.env("LLVM_CONFIG", llvm_config);
}
cargo.env("LLVM_CONFIG", build.llvm_config(target));
if build.config.llvm_static_stdcpp {
cargo.env("LLVM_STATIC_STDCPP",
compiler_file(build.cxx(target), "libstdc++.a"));
Expand Down
53 changes: 30 additions & 23 deletions src/bootstrap/build/dist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -195,29 +195,7 @@ pub fn rustc(build: &Build, stage: u32, host: &str) {
cp_r(&build.src.join("man"), &image.join("share/man/man1"));

// Debugger scripts
let cp_debugger_script = |file: &str| {
let dst = image.join("lib/rustlib/etc");
t!(fs::create_dir_all(&dst));
install(&build.src.join("src/etc/").join(file), &dst, 0o644);
};
if host.contains("windows") {
// no debugger scripts
} else if host.contains("darwin") {
// lldb debugger scripts
install(&build.src.join("src/etc/rust-lldb"), &image.join("bin"),
0o755);

cp_debugger_script("lldb_rust_formatters.py");
cp_debugger_script("debugger_pretty_printers_common.py");
} else {
// gdb debugger scripts
install(&build.src.join("src/etc/rust-gdb"), &image.join("bin"),
0o755);

cp_debugger_script("gdb_load_rust_pretty_printers.py");
cp_debugger_script("gdb_rust_pretty_printing.py");
cp_debugger_script("debugger_pretty_printers_common.py");
}
debugger_scripts(build, &image, host);

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

pub fn debugger_scripts(build: &Build,
sysroot: &Path,
host: &str) {
let cp_debugger_script = |file: &str| {
let dst = sysroot.join("lib/rustlib/etc");
t!(fs::create_dir_all(&dst));
install(&build.src.join("src/etc/").join(file), &dst, 0o644);
};
if host.contains("windows") {
// no debugger scripts
} else if host.contains("darwin") {
// lldb debugger scripts
install(&build.src.join("src/etc/rust-lldb"), &sysroot.join("bin"),
0o755);

cp_debugger_script("lldb_rust_formatters.py");
cp_debugger_script("debugger_pretty_printers_common.py");
} else {
// gdb debugger scripts
install(&build.src.join("src/etc/rust-gdb"), &sysroot.join("bin"),
0o755);

cp_debugger_script("gdb_load_rust_pretty_printers.py");
cp_debugger_script("gdb_rust_pretty_printing.py");
cp_debugger_script("debugger_pretty_printers_common.py");
}
}


pub fn std(build: &Build, compiler: &Compiler, target: &str) {
println!("Dist std stage{} ({} -> {})", compiler.stage, compiler.host,
target);
Expand Down
5 changes: 0 additions & 5 deletions src/bootstrap/build/flags.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,6 @@ impl Flags {
usage(0);
}

if m.free.len() > 0 {
println!("free arguments are not currently accepted");
usage(1);
}

let cfg_file = m.opt_str("config").map(PathBuf::from).or_else(|| {
if fs::metadata("config.toml").is_ok() {
Some(PathBuf::from("config.toml"))
Expand Down
Loading

0 comments on commit d36ad55

Please sign in to comment.