Skip to content

Commit 2b4c911

Browse files
committed
Auto merge of #41362 - alexcrichton:run-cargot-ests, r=aturon
Run tests for the cargo submodule in tree Previously the `cargotest` suite would run some arbitrary revision of Cargo's test suite, but now that we're bundling it in tree we should be running the Cargo submodule's test suite instead.
2 parents c7e724a + 009f45f commit 2b4c911

File tree

6 files changed

+48
-32
lines changed

6 files changed

+48
-32
lines changed

cargo

src/bootstrap/check.rs

+29-11
Original file line numberDiff line numberDiff line change
@@ -78,14 +78,6 @@ pub fn linkcheck(build: &Build, host: &str) {
7878
pub fn cargotest(build: &Build, stage: u32, host: &str) {
7979
let ref compiler = Compiler::new(stage, host);
8080

81-
// Configure PATH to find the right rustc. NB. we have to use PATH
82-
// and not RUSTC because the Cargo test suite has tests that will
83-
// fail if rustc is not spelled `rustc`.
84-
let path = build.sysroot(compiler).join("bin");
85-
let old_path = ::std::env::var("PATH").expect("");
86-
let sep = if cfg!(windows) { ";" } else {":" };
87-
let ref newpath = format!("{}{}{}", path.display(), sep, old_path);
88-
8981
// Note that this is a short, cryptic, and not scoped directory name. This
9082
// is currently to minimize the length of path on Windows where we otherwise
9183
// quickly run into path name limit constraints.
@@ -95,9 +87,35 @@ pub fn cargotest(build: &Build, stage: u32, host: &str) {
9587
let _time = util::timeit();
9688
let mut cmd = Command::new(build.tool(&Compiler::new(0, host), "cargotest"));
9789
build.prepare_tool_cmd(compiler, &mut cmd);
98-
build.run(cmd.env("PATH", newpath)
99-
.arg(&build.cargo)
100-
.arg(&out_dir));
90+
build.run(cmd.arg(&build.cargo)
91+
.arg(&out_dir)
92+
.env("RUSTC", build.compiler_path(compiler))
93+
.env("RUSTDOC", build.rustdoc(compiler)))
94+
}
95+
96+
/// Runs `cargo test` for `cargo` packaged with Rust.
97+
pub fn cargo(build: &Build, stage: u32, host: &str) {
98+
let ref compiler = Compiler::new(stage, host);
99+
100+
// Configure PATH to find the right rustc. NB. we have to use PATH
101+
// and not RUSTC because the Cargo test suite has tests that will
102+
// fail if rustc is not spelled `rustc`.
103+
let path = build.sysroot(compiler).join("bin");
104+
let old_path = ::std::env::var("PATH").expect("");
105+
let sep = if cfg!(windows) { ";" } else {":" };
106+
let ref newpath = format!("{}{}{}", path.display(), sep, old_path);
107+
108+
let mut cargo = build.cargo(compiler, Mode::Tool, host, "test");
109+
cargo.arg("--manifest-path").arg(build.src.join("cargo/Cargo.toml"));
110+
111+
// Don't build tests dynamically, just a pain to work with
112+
cargo.env("RUSTC_NO_PREFER_DYNAMIC", "1");
113+
114+
// Don't run cross-compile tests, we may not have cross-compiled libstd libs
115+
// available.
116+
cargo.env("CFG_DISABLE_CROSS_TESTS", "1");
117+
118+
build.run(cargo.env("PATH", newpath));
101119
}
102120

103121
/// Runs the `tidy` tool as compiled in `stage` by the `host` compiler.

src/bootstrap/lib.rs

+13
Original file line numberDiff line numberDiff line change
@@ -557,6 +557,19 @@ impl Build {
557557
cargo.env("RUSTC_SAVE_ANALYSIS", "api".to_string());
558558
}
559559

560+
// When being built Cargo will at some point call `nmake.exe` on Windows
561+
// MSVC. Unfortunately `nmake` will read these two environment variables
562+
// below and try to intepret them. We're likely being run, however, from
563+
// MSYS `make` which uses the same variables.
564+
//
565+
// As a result, to prevent confusion and errors, we remove these
566+
// variables from our environment to prevent passing MSYS make flags to
567+
// nmake, causing it to blow up.
568+
if cfg!(target_env = "msvc") {
569+
cargo.env_remove("MAKE");
570+
cargo.env_remove("MAKEFLAGS");
571+
}
572+
560573
// Environment variables *required* needed throughout the build
561574
//
562575
// FIXME: should update code to not require this env var

src/bootstrap/mk/Makefile.in

+1
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ check:
5555
check-aux:
5656
$(Q)$(BOOTSTRAP) test \
5757
src/tools/cargotest \
58+
cargo \
5859
src/test/pretty \
5960
src/test/run-pass/pretty \
6061
src/test/run-fail/pretty \

src/bootstrap/step.rs

+4
Original file line numberDiff line numberDiff line change
@@ -470,6 +470,10 @@ pub fn build_rules<'a>(build: &'a Build) -> Rules {
470470
.dep(|s| s.name("librustc"))
471471
.host(true)
472472
.run(move |s| check::cargotest(build, s.stage, s.target));
473+
rules.test("check-cargo", "cargo")
474+
.dep(|s| s.name("tool-cargo"))
475+
.host(true)
476+
.run(move |s| check::cargo(build, s.stage, s.target));
473477
rules.test("check-tidy", "src/tools/tidy")
474478
.dep(|s| s.name("tool-tidy").stage(0))
475479
.default(true)

src/tools/cargotest/main.rs

-20
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,6 @@ struct Test {
2222
}
2323

2424
const TEST_REPOS: &'static [Test] = &[
25-
Test {
26-
name: "cargo",
27-
repo: "https://github.com/rust-lang/cargo",
28-
sha: "0e1e34be7540bdaed4918457654fbf028cf69e56",
29-
lock: None,
30-
},
3125
Test {
3226
name: "iron",
3327
repo: "https://github.com/iron/iron",
@@ -61,20 +55,6 @@ const TEST_REPOS: &'static [Test] = &[
6155
];
6256

6357
fn main() {
64-
// One of the projects being tested here is Cargo, and when being tested
65-
// Cargo will at some point call `nmake.exe` on Windows MSVC. Unfortunately
66-
// `nmake` will read these two environment variables below and try to
67-
// intepret them. We're likely being run, however, from MSYS `make` which
68-
// uses the same variables.
69-
//
70-
// As a result, to prevent confusion and errors, we remove these variables
71-
// from our environment to prevent passing MSYS make flags to nmake, causing
72-
// it to blow up.
73-
if cfg!(target_env = "msvc") {
74-
env::remove_var("MAKE");
75-
env::remove_var("MAKEFLAGS");
76-
}
77-
7858
let args = env::args().collect::<Vec<_>>();
7959
let ref cargo = args[1];
8060
let out_dir = Path::new(&args[2]);

0 commit comments

Comments
 (0)