Skip to content

Commit 0574945

Browse files
authored
Rollup merge of rust-lang#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 94493bc + 2c9d756 commit 0574945

File tree

5 files changed

+46
-31
lines changed

5 files changed

+46
-31
lines changed

src/bootstrap/check.rs

+40-10
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,11 +87,49 @@ 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)
90+
build.run(cmd.arg(&build.cargo)
10091
.arg(&out_dir));
10192
}
10293

94+
/// Runs `cargo test` for `cargo` packaged with Rust.
95+
pub fn cargo(build: &Build, stage: u32, host: &str) {
96+
let ref compiler = Compiler::new(stage, host);
97+
98+
// Configure PATH to find the right rustc. NB. we have to use PATH
99+
// and not RUSTC because the Cargo test suite has tests that will
100+
// fail if rustc is not spelled `rustc`.
101+
let path = build.sysroot(compiler).join("bin");
102+
let old_path = ::std::env::var("PATH").expect("");
103+
let sep = if cfg!(windows) { ";" } else {":" };
104+
let ref newpath = format!("{}{}{}", path.display(), sep, old_path);
105+
106+
let mut cargo = build.cargo(compiler, Mode::Tool, host, "test");
107+
cargo.arg("--manifest-path").arg(build.src.join("cargo/Cargo.toml"));
108+
109+
// Don't build tests dynamically, just a pain to work with
110+
cargo.env("RUSTC_NO_PREFER_DYNAMIC", "1");
111+
112+
// Don't run cross-compile tests, we may not have cross-compiled libstd libs
113+
// available.
114+
cargo.env("CFG_DISABLE_CROSS_TESTS", "1");
115+
116+
// When being tested Cargo will at some point call `nmake.exe` on Windows
117+
// MSVC. Unfortunately `nmake` will read these two environment variables
118+
// below and try to intepret them. We're likely being run, however, from
119+
// MSYS `make` which uses the same variables.
120+
//
121+
// As a result, to prevent confusion and errors, we remove these variables
122+
// from our environment to prevent passing MSYS make flags to nmake, causing
123+
// it to blow up.
124+
if cfg!(target_env = "msvc") {
125+
cargo.env_remove("MAKE");
126+
cargo.env_remove("MAKEFLAGS");
127+
}
128+
129+
130+
build.run(cargo.env("PATH", newpath));
131+
}
132+
103133
/// Runs the `tidy` tool as compiled in `stage` by the `host` compiler.
104134
///
105135
/// This tool in `src/tools` checks up on various bits and pieces of style and

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)