2016-11-16 12:31:19 -08:00
|
|
|
|
//! Implementation of the test-related targets of the build system.
|
2016-05-02 15:16:15 -07:00
|
|
|
|
//!
|
|
|
|
|
//! This file implements the various regression test suites that we execute on
|
|
|
|
|
//! our CI.
|
|
|
|
|
|
2016-04-29 14:23:15 -07:00
|
|
|
|
use std::env;
|
2017-07-01 06:58:54 +12:00
|
|
|
|
use std::ffi::OsString;
|
2016-11-25 22:13:59 +01:00
|
|
|
|
use std::fmt;
|
2018-11-16 16:22:06 -05:00
|
|
|
|
use std::fs;
|
2018-05-30 14:33:43 -03:00
|
|
|
|
use std::iter;
|
|
|
|
|
use std::path::{Path, PathBuf};
|
|
|
|
|
use std::process::Command;
|
2016-04-14 14:27:51 -07:00
|
|
|
|
|
2017-12-07 05:06:48 +08:00
|
|
|
|
use build_helper::{self, output};
|
2016-04-14 15:51:03 -07:00
|
|
|
|
|
2018-12-07 13:21:05 +01:00
|
|
|
|
use crate::builder::{Builder, Compiler, Kind, RunConfig, ShouldRun, Step};
|
|
|
|
|
use crate::cache::{Interned, INTERNER};
|
|
|
|
|
use crate::compile;
|
|
|
|
|
use crate::dist;
|
|
|
|
|
use crate::flags::Subcommand;
|
|
|
|
|
use crate::native;
|
|
|
|
|
use crate::tool::{self, Tool, SourceType};
|
|
|
|
|
use crate::toolstate::ToolState;
|
|
|
|
|
use crate::util::{self, dylib_path, dylib_path_var};
|
|
|
|
|
use crate::Crate as CargoCrate;
|
|
|
|
|
use crate::{DocTests, Mode, GitRepo};
|
2016-06-28 13:31:30 -07:00
|
|
|
|
|
2017-06-26 10:23:50 -06:00
|
|
|
|
const ADB_TEST_DIR: &str = "/data/tmp/work";
|
2016-03-07 23:15:55 -08:00
|
|
|
|
|
2016-11-25 22:13:59 +01:00
|
|
|
|
/// The two modes of the test runner; tests or benchmarks.
|
2018-05-06 02:33:01 +08:00
|
|
|
|
#[derive(Debug, PartialEq, Eq, Hash, Copy, Clone, PartialOrd, Ord)]
|
2016-11-25 22:13:59 +01:00
|
|
|
|
pub enum TestKind {
|
|
|
|
|
/// Run `cargo test`
|
|
|
|
|
Test,
|
|
|
|
|
/// Run `cargo bench`
|
|
|
|
|
Bench,
|
|
|
|
|
}
|
|
|
|
|
|
2018-05-16 17:18:19 +02:00
|
|
|
|
impl From<Kind> for TestKind {
|
|
|
|
|
fn from(kind: Kind) -> Self {
|
|
|
|
|
match kind {
|
|
|
|
|
Kind::Test => TestKind::Test,
|
|
|
|
|
Kind::Bench => TestKind::Bench,
|
2018-05-30 14:33:43 -03:00
|
|
|
|
_ => panic!("unexpected kind in crate: {:?}", kind),
|
2018-05-16 17:18:19 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-11-25 22:13:59 +01:00
|
|
|
|
impl TestKind {
|
|
|
|
|
// Return the cargo subcommand for this test kind
|
|
|
|
|
fn subcommand(self) -> &'static str {
|
|
|
|
|
match self {
|
|
|
|
|
TestKind::Test => "test",
|
|
|
|
|
TestKind::Bench => "bench",
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl fmt::Display for TestKind {
|
|
|
|
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
|
|
|
|
f.write_str(match *self {
|
|
|
|
|
TestKind::Test => "Testing",
|
|
|
|
|
TestKind::Bench => "Benchmarking",
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-04-14 17:27:57 -06:00
|
|
|
|
fn try_run(builder: &Builder, cmd: &mut Command) -> bool {
|
|
|
|
|
if !builder.fail_fast {
|
|
|
|
|
if !builder.try_run(cmd) {
|
|
|
|
|
let mut failures = builder.delayed_failures.borrow_mut();
|
2017-09-18 21:21:24 +02:00
|
|
|
|
failures.push(format!("{:?}", cmd));
|
2017-12-06 09:25:29 +01:00
|
|
|
|
return false;
|
2017-06-02 09:27:44 -07:00
|
|
|
|
}
|
|
|
|
|
} else {
|
2018-04-14 17:27:57 -06:00
|
|
|
|
builder.run(cmd);
|
2017-06-02 09:27:44 -07:00
|
|
|
|
}
|
2017-12-06 09:25:29 +01:00
|
|
|
|
true
|
2017-06-02 09:27:44 -07:00
|
|
|
|
}
|
|
|
|
|
|
2018-04-14 17:27:57 -06:00
|
|
|
|
fn try_run_quiet(builder: &Builder, cmd: &mut Command) -> bool {
|
|
|
|
|
if !builder.fail_fast {
|
|
|
|
|
if !builder.try_run_quiet(cmd) {
|
|
|
|
|
let mut failures = builder.delayed_failures.borrow_mut();
|
2017-09-18 21:21:24 +02:00
|
|
|
|
failures.push(format!("{:?}", cmd));
|
2018-02-22 03:25:23 +08:00
|
|
|
|
return false;
|
2017-06-02 09:27:44 -07:00
|
|
|
|
}
|
|
|
|
|
} else {
|
2018-04-14 17:27:57 -06:00
|
|
|
|
builder.run_quiet(cmd);
|
2017-06-02 09:27:44 -07:00
|
|
|
|
}
|
2018-02-22 03:25:23 +08:00
|
|
|
|
true
|
2017-06-02 09:27:44 -07:00
|
|
|
|
}
|
|
|
|
|
|
2017-07-13 18:48:44 -06:00
|
|
|
|
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
|
|
|
|
|
pub struct Linkcheck {
|
|
|
|
|
host: Interned<String>,
|
2017-07-04 19:41:43 -06:00
|
|
|
|
}
|
|
|
|
|
|
2017-07-13 18:48:44 -06:00
|
|
|
|
impl Step for Linkcheck {
|
2017-07-04 19:41:43 -06:00
|
|
|
|
type Output = ();
|
2017-07-05 06:41:27 -06:00
|
|
|
|
const ONLY_HOSTS: bool = true;
|
|
|
|
|
const DEFAULT: bool = true;
|
2017-07-04 19:41:43 -06:00
|
|
|
|
|
|
|
|
|
/// Runs the `linkchecker` tool as compiled in `stage` by the `host` compiler.
|
|
|
|
|
///
|
|
|
|
|
/// This tool in `src/tools` will verify the validity of all our links in the
|
|
|
|
|
/// documentation to ensure we don't have a bunch of dead ones.
|
|
|
|
|
fn run(self, builder: &Builder) {
|
|
|
|
|
let host = self.host;
|
|
|
|
|
|
2018-04-14 17:27:57 -06:00
|
|
|
|
builder.info(&format!("Linkcheck ({})", host));
|
2017-07-05 06:41:27 -06:00
|
|
|
|
|
|
|
|
|
builder.default_doc(None);
|
2017-07-04 19:41:43 -06:00
|
|
|
|
|
2018-04-14 17:27:57 -06:00
|
|
|
|
let _time = util::timeit(&builder);
|
2018-05-30 14:33:43 -03:00
|
|
|
|
try_run(
|
|
|
|
|
builder,
|
|
|
|
|
builder
|
|
|
|
|
.tool_cmd(Tool::Linkchecker)
|
|
|
|
|
.arg(builder.out.join(host).join("doc")),
|
|
|
|
|
);
|
2017-07-04 19:41:43 -06:00
|
|
|
|
}
|
2017-07-05 06:41:27 -06:00
|
|
|
|
|
2017-07-18 18:03:38 -06:00
|
|
|
|
fn should_run(run: ShouldRun) -> ShouldRun {
|
2017-07-20 17:24:11 -06:00
|
|
|
|
let builder = run.builder;
|
2018-05-30 14:33:43 -03:00
|
|
|
|
run.path("src/tools/linkchecker")
|
|
|
|
|
.default_condition(builder.config.docs)
|
2017-07-05 06:41:27 -06:00
|
|
|
|
}
|
|
|
|
|
|
2017-07-20 17:51:07 -06:00
|
|
|
|
fn make_run(run: RunConfig) {
|
2017-07-27 06:50:43 -06:00
|
|
|
|
run.builder.ensure(Linkcheck { host: run.target });
|
2017-07-05 06:41:27 -06:00
|
|
|
|
}
|
2016-03-07 23:15:55 -08:00
|
|
|
|
}
|
2016-03-18 20:54:31 +00:00
|
|
|
|
|
2017-07-13 18:48:44 -06:00
|
|
|
|
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
|
|
|
|
|
pub struct Cargotest {
|
2017-07-04 19:41:43 -06:00
|
|
|
|
stage: u32,
|
2017-07-13 18:48:44 -06:00
|
|
|
|
host: Interned<String>,
|
2017-07-04 19:41:43 -06:00
|
|
|
|
}
|
2016-04-14 14:27:51 -07:00
|
|
|
|
|
2017-07-13 18:48:44 -06:00
|
|
|
|
impl Step for Cargotest {
|
2017-07-04 19:41:43 -06:00
|
|
|
|
type Output = ();
|
2017-07-05 06:41:27 -06:00
|
|
|
|
const ONLY_HOSTS: bool = true;
|
2017-07-04 19:41:43 -06:00
|
|
|
|
|
2017-07-18 18:03:38 -06:00
|
|
|
|
fn should_run(run: ShouldRun) -> ShouldRun {
|
|
|
|
|
run.path("src/tools/cargotest")
|
2017-07-12 10:12:47 -06:00
|
|
|
|
}
|
|
|
|
|
|
2017-07-20 17:51:07 -06:00
|
|
|
|
fn make_run(run: RunConfig) {
|
|
|
|
|
run.builder.ensure(Cargotest {
|
|
|
|
|
stage: run.builder.top_stage,
|
2017-07-27 06:50:43 -06:00
|
|
|
|
host: run.target,
|
2017-07-12 10:12:47 -06:00
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2017-07-04 19:41:43 -06:00
|
|
|
|
/// Runs the `cargotest` tool as compiled in `stage` by the `host` compiler.
|
|
|
|
|
///
|
|
|
|
|
/// This tool in `src/tools` will check out a few Rust projects and run `cargo
|
|
|
|
|
/// test` to ensure that we don't regress the test suites there.
|
|
|
|
|
fn run(self, builder: &Builder) {
|
2017-07-05 10:46:41 -06:00
|
|
|
|
let compiler = builder.compiler(self.stage, self.host);
|
2018-05-30 14:33:43 -03:00
|
|
|
|
builder.ensure(compile::Rustc {
|
|
|
|
|
compiler,
|
|
|
|
|
target: compiler.host,
|
|
|
|
|
});
|
2017-07-04 19:41:43 -06:00
|
|
|
|
|
|
|
|
|
// Note that this is a short, cryptic, and not scoped directory name. This
|
|
|
|
|
// is currently to minimize the length of path on Windows where we otherwise
|
|
|
|
|
// quickly run into path name limit constraints.
|
2018-04-14 17:27:57 -06:00
|
|
|
|
let out_dir = builder.out.join("ct");
|
2017-07-04 19:41:43 -06:00
|
|
|
|
t!(fs::create_dir_all(&out_dir));
|
|
|
|
|
|
2018-04-14 17:27:57 -06:00
|
|
|
|
let _time = util::timeit(&builder);
|
2017-07-05 06:41:27 -06:00
|
|
|
|
let mut cmd = builder.tool_cmd(Tool::CargoTest);
|
2018-05-30 14:33:43 -03:00
|
|
|
|
try_run(
|
|
|
|
|
builder,
|
|
|
|
|
cmd.arg(&builder.initial_cargo)
|
|
|
|
|
.arg(&out_dir)
|
|
|
|
|
.env("RUSTC", builder.rustc(compiler))
|
|
|
|
|
.env("RUSTDOC", builder.rustdoc(compiler.host)),
|
|
|
|
|
);
|
2017-07-04 19:41:43 -06:00
|
|
|
|
}
|
2017-04-17 17:24:05 -07:00
|
|
|
|
}
|
|
|
|
|
|
2017-07-13 18:48:44 -06:00
|
|
|
|
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
|
|
|
|
|
pub struct Cargo {
|
2017-07-04 19:41:43 -06:00
|
|
|
|
stage: u32,
|
2017-07-13 18:48:44 -06:00
|
|
|
|
host: Interned<String>,
|
2017-07-04 19:41:43 -06:00
|
|
|
|
}
|
|
|
|
|
|
2017-07-13 18:48:44 -06:00
|
|
|
|
impl Step for Cargo {
|
2017-07-04 19:41:43 -06:00
|
|
|
|
type Output = ();
|
2017-07-05 06:41:27 -06:00
|
|
|
|
const ONLY_HOSTS: bool = true;
|
|
|
|
|
|
2017-07-18 18:03:38 -06:00
|
|
|
|
fn should_run(run: ShouldRun) -> ShouldRun {
|
|
|
|
|
run.path("src/tools/cargo")
|
2017-07-05 06:41:27 -06:00
|
|
|
|
}
|
|
|
|
|
|
2017-07-20 17:51:07 -06:00
|
|
|
|
fn make_run(run: RunConfig) {
|
|
|
|
|
run.builder.ensure(Cargo {
|
|
|
|
|
stage: run.builder.top_stage,
|
|
|
|
|
host: run.target,
|
2017-07-05 06:41:27 -06:00
|
|
|
|
});
|
|
|
|
|
}
|
2017-07-04 19:41:43 -06:00
|
|
|
|
|
|
|
|
|
/// Runs `cargo test` for `cargo` packaged with Rust.
|
|
|
|
|
fn run(self, builder: &Builder) {
|
2017-07-05 06:41:27 -06:00
|
|
|
|
let compiler = builder.compiler(self.stage, self.host);
|
2017-07-04 19:41:43 -06:00
|
|
|
|
|
2018-05-30 14:33:43 -03:00
|
|
|
|
builder.ensure(tool::Cargo {
|
|
|
|
|
compiler,
|
|
|
|
|
target: self.host,
|
|
|
|
|
});
|
2018-07-25 14:46:47 +09:00
|
|
|
|
let mut cargo = tool::prepare_tool_cargo(builder,
|
|
|
|
|
compiler,
|
|
|
|
|
Mode::ToolRustc,
|
|
|
|
|
self.host,
|
|
|
|
|
"test",
|
|
|
|
|
"src/tools/cargo",
|
2018-10-08 10:39:09 -07:00
|
|
|
|
SourceType::Submodule,
|
|
|
|
|
&[]);
|
2018-07-25 14:46:47 +09:00
|
|
|
|
|
2018-04-14 17:27:57 -06:00
|
|
|
|
if !builder.fail_fast {
|
2017-07-04 19:41:43 -06:00
|
|
|
|
cargo.arg("--no-fail-fast");
|
|
|
|
|
}
|
2017-04-17 17:24:05 -07:00
|
|
|
|
|
2017-07-04 19:41:43 -06:00
|
|
|
|
// Don't run cross-compile tests, we may not have cross-compiled libstd libs
|
|
|
|
|
// available.
|
|
|
|
|
cargo.env("CFG_DISABLE_CROSS_TESTS", "1");
|
2018-09-09 03:08:47 +02:00
|
|
|
|
// Disable a test that has issues with mingw.
|
|
|
|
|
cargo.env("CARGO_TEST_DISABLE_GIT_CLI", "1");
|
2017-04-17 17:24:05 -07:00
|
|
|
|
|
2018-05-30 14:33:43 -03:00
|
|
|
|
try_run(
|
|
|
|
|
builder,
|
|
|
|
|
cargo.env("PATH", &path_for_cargo(builder, compiler)),
|
|
|
|
|
);
|
2017-07-04 19:41:43 -06:00
|
|
|
|
}
|
2017-07-01 06:58:54 +12:00
|
|
|
|
}
|
|
|
|
|
|
2017-07-17 09:52:05 -06:00
|
|
|
|
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
|
|
|
|
|
pub struct Rls {
|
2017-07-04 19:41:43 -06:00
|
|
|
|
stage: u32,
|
2017-07-17 09:52:05 -06:00
|
|
|
|
host: Interned<String>,
|
2017-07-04 19:41:43 -06:00
|
|
|
|
}
|
2017-07-01 06:58:54 +12:00
|
|
|
|
|
2017-07-17 09:52:05 -06:00
|
|
|
|
impl Step for Rls {
|
2017-07-04 19:41:43 -06:00
|
|
|
|
type Output = ();
|
2017-07-17 09:52:05 -06:00
|
|
|
|
const ONLY_HOSTS: bool = true;
|
|
|
|
|
|
2017-07-18 18:03:38 -06:00
|
|
|
|
fn should_run(run: ShouldRun) -> ShouldRun {
|
|
|
|
|
run.path("src/tools/rls")
|
2017-07-17 09:52:05 -06:00
|
|
|
|
}
|
|
|
|
|
|
2017-07-20 17:51:07 -06:00
|
|
|
|
fn make_run(run: RunConfig) {
|
|
|
|
|
run.builder.ensure(Rls {
|
|
|
|
|
stage: run.builder.top_stage,
|
|
|
|
|
host: run.target,
|
2017-07-17 09:52:05 -06:00
|
|
|
|
});
|
|
|
|
|
}
|
2017-07-01 06:58:54 +12:00
|
|
|
|
|
2017-07-04 19:41:43 -06:00
|
|
|
|
/// Runs `cargo test` for the rls.
|
|
|
|
|
fn run(self, builder: &Builder) {
|
|
|
|
|
let stage = self.stage;
|
|
|
|
|
let host = self.host;
|
2017-07-17 09:52:05 -06:00
|
|
|
|
let compiler = builder.compiler(stage, host);
|
2017-07-01 06:58:54 +12:00
|
|
|
|
|
2018-04-21 00:53:36 +08:00
|
|
|
|
let build_result = builder.ensure(tool::Rls {
|
|
|
|
|
compiler,
|
|
|
|
|
target: self.host,
|
|
|
|
|
extra_features: Vec::new(),
|
|
|
|
|
});
|
|
|
|
|
if build_result.is_none() {
|
|
|
|
|
eprintln!("failed to test rls: could not build");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2018-05-28 01:09:43 +03:00
|
|
|
|
let mut cargo = tool::prepare_tool_cargo(builder,
|
|
|
|
|
compiler,
|
2018-05-28 02:02:58 +03:00
|
|
|
|
Mode::ToolRustc,
|
2018-05-28 01:09:43 +03:00
|
|
|
|
host,
|
|
|
|
|
"test",
|
2018-07-13 14:12:58 +09:00
|
|
|
|
"src/tools/rls",
|
2018-10-08 10:39:09 -07:00
|
|
|
|
SourceType::Submodule,
|
|
|
|
|
&[]);
|
2017-07-01 06:58:54 +12:00
|
|
|
|
|
2018-07-29 03:36:18 +08:00
|
|
|
|
// Copy `src/tools/rls/test_data` to a writable drive.
|
|
|
|
|
let test_workspace_path = builder.out.join("rls-test-data");
|
|
|
|
|
let test_data_path = test_workspace_path.join("test_data");
|
|
|
|
|
builder.create_dir(&test_data_path);
|
|
|
|
|
builder.cp_r(&builder.src.join("src/tools/rls/test_data"), &test_data_path);
|
|
|
|
|
cargo.env("RLS_TEST_WORKSPACE_DIR", test_workspace_path);
|
|
|
|
|
|
2017-07-17 09:52:05 -06:00
|
|
|
|
builder.add_rustc_lib_path(compiler, &mut cargo);
|
2018-07-31 14:16:55 -07:00
|
|
|
|
cargo.arg("--")
|
|
|
|
|
.args(builder.config.cmd.test_args());
|
2017-07-04 19:41:43 -06:00
|
|
|
|
|
2018-04-14 17:27:57 -06:00
|
|
|
|
if try_run(builder, &mut cargo) {
|
|
|
|
|
builder.save_toolstate("rls", ToolState::TestPass);
|
2017-12-06 09:25:29 +01:00
|
|
|
|
}
|
2017-07-04 19:41:43 -06:00
|
|
|
|
}
|
2017-07-01 06:58:54 +12:00
|
|
|
|
}
|
|
|
|
|
|
2017-09-01 18:43:00 +12:00
|
|
|
|
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
|
|
|
|
|
pub struct Rustfmt {
|
|
|
|
|
stage: u32,
|
|
|
|
|
host: Interned<String>,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl Step for Rustfmt {
|
|
|
|
|
type Output = ();
|
|
|
|
|
const ONLY_HOSTS: bool = true;
|
|
|
|
|
|
|
|
|
|
fn should_run(run: ShouldRun) -> ShouldRun {
|
|
|
|
|
run.path("src/tools/rustfmt")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn make_run(run: RunConfig) {
|
|
|
|
|
run.builder.ensure(Rustfmt {
|
|
|
|
|
stage: run.builder.top_stage,
|
|
|
|
|
host: run.target,
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// Runs `cargo test` for rustfmt.
|
|
|
|
|
fn run(self, builder: &Builder) {
|
|
|
|
|
let stage = self.stage;
|
|
|
|
|
let host = self.host;
|
|
|
|
|
let compiler = builder.compiler(stage, host);
|
|
|
|
|
|
2018-04-21 00:53:36 +08:00
|
|
|
|
let build_result = builder.ensure(tool::Rustfmt {
|
|
|
|
|
compiler,
|
|
|
|
|
target: self.host,
|
|
|
|
|
extra_features: Vec::new(),
|
|
|
|
|
});
|
|
|
|
|
if build_result.is_none() {
|
|
|
|
|
eprintln!("failed to test rustfmt: could not build");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2018-05-28 01:09:43 +03:00
|
|
|
|
let mut cargo = tool::prepare_tool_cargo(builder,
|
|
|
|
|
compiler,
|
2018-05-28 02:02:58 +03:00
|
|
|
|
Mode::ToolRustc,
|
2018-05-28 01:09:43 +03:00
|
|
|
|
host,
|
|
|
|
|
"test",
|
2018-07-13 14:12:58 +09:00
|
|
|
|
"src/tools/rustfmt",
|
2018-10-08 10:39:09 -07:00
|
|
|
|
SourceType::Submodule,
|
|
|
|
|
&[]);
|
2017-09-01 18:43:00 +12:00
|
|
|
|
|
2018-05-06 08:27:48 +12:00
|
|
|
|
let dir = testdir(builder, compiler.host);
|
|
|
|
|
t!(fs::create_dir_all(&dir));
|
|
|
|
|
cargo.env("RUSTFMT_TEST_DIR", dir);
|
2017-09-01 18:43:00 +12:00
|
|
|
|
|
|
|
|
|
builder.add_rustc_lib_path(compiler, &mut cargo);
|
|
|
|
|
|
2018-04-14 17:27:57 -06:00
|
|
|
|
if try_run(builder, &mut cargo) {
|
|
|
|
|
builder.save_toolstate("rustfmt", ToolState::TestPass);
|
2017-12-06 09:25:29 +01:00
|
|
|
|
}
|
2017-09-01 18:43:00 +12:00
|
|
|
|
}
|
|
|
|
|
}
|
2017-09-17 21:45:54 +02:00
|
|
|
|
|
|
|
|
|
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
|
2017-08-28 16:54:50 +02:00
|
|
|
|
pub struct Miri {
|
2017-12-06 09:25:29 +01:00
|
|
|
|
stage: u32,
|
2017-08-28 16:54:50 +02:00
|
|
|
|
host: Interned<String>,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl Step for Miri {
|
|
|
|
|
type Output = ();
|
|
|
|
|
const ONLY_HOSTS: bool = true;
|
|
|
|
|
const DEFAULT: bool = true;
|
|
|
|
|
|
|
|
|
|
fn should_run(run: ShouldRun) -> ShouldRun {
|
2018-04-14 17:27:57 -06:00
|
|
|
|
let test_miri = run.builder.config.test_miri;
|
2017-08-28 16:54:50 +02:00
|
|
|
|
run.path("src/tools/miri").default_condition(test_miri)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn make_run(run: RunConfig) {
|
|
|
|
|
run.builder.ensure(Miri {
|
2017-12-06 09:25:29 +01:00
|
|
|
|
stage: run.builder.top_stage,
|
2017-08-28 16:54:50 +02:00
|
|
|
|
host: run.target,
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// Runs `cargo test` for miri.
|
|
|
|
|
fn run(self, builder: &Builder) {
|
2017-12-06 09:25:29 +01:00
|
|
|
|
let stage = self.stage;
|
2017-08-28 16:54:50 +02:00
|
|
|
|
let host = self.host;
|
2017-12-06 09:25:29 +01:00
|
|
|
|
let compiler = builder.compiler(stage, host);
|
2017-08-28 16:54:50 +02:00
|
|
|
|
|
2018-02-09 18:53:41 +01:00
|
|
|
|
let miri = builder.ensure(tool::Miri {
|
|
|
|
|
compiler,
|
|
|
|
|
target: self.host,
|
|
|
|
|
extra_features: Vec::new(),
|
|
|
|
|
});
|
|
|
|
|
if let Some(miri) = miri {
|
2018-07-25 14:46:47 +09:00
|
|
|
|
let mut cargo = tool::prepare_tool_cargo(builder,
|
|
|
|
|
compiler,
|
|
|
|
|
Mode::ToolRustc,
|
|
|
|
|
host,
|
|
|
|
|
"test",
|
|
|
|
|
"src/tools/miri",
|
2018-10-08 10:39:09 -07:00
|
|
|
|
SourceType::Submodule,
|
|
|
|
|
&[]);
|
2017-12-06 09:25:29 +01:00
|
|
|
|
|
|
|
|
|
// miri tests need to know about the stage sysroot
|
|
|
|
|
cargo.env("MIRI_SYSROOT", builder.sysroot(compiler));
|
|
|
|
|
cargo.env("RUSTC_TEST_SUITE", builder.rustc(compiler));
|
|
|
|
|
cargo.env("RUSTC_LIB_PATH", builder.rustc_libdir(compiler));
|
|
|
|
|
cargo.env("MIRI_PATH", miri);
|
|
|
|
|
|
|
|
|
|
builder.add_rustc_lib_path(compiler, &mut cargo);
|
|
|
|
|
|
2018-04-14 17:27:57 -06:00
|
|
|
|
if try_run(builder, &mut cargo) {
|
|
|
|
|
builder.save_toolstate("miri", ToolState::TestPass);
|
2017-12-06 09:25:29 +01:00
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
eprintln!("failed to test miri: could not build");
|
|
|
|
|
}
|
2017-08-28 16:54:50 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-12-13 21:57:23 +01:00
|
|
|
|
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
|
|
|
|
|
pub struct CompiletestTest {
|
|
|
|
|
stage: u32,
|
|
|
|
|
host: Interned<String>,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl Step for CompiletestTest {
|
|
|
|
|
type Output = ();
|
|
|
|
|
|
|
|
|
|
fn should_run(run: ShouldRun) -> ShouldRun {
|
|
|
|
|
run.path("src/tools/compiletest")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn make_run(run: RunConfig) {
|
|
|
|
|
run.builder.ensure(CompiletestTest {
|
|
|
|
|
stage: run.builder.top_stage,
|
|
|
|
|
host: run.target,
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// Runs `cargo test` for compiletest.
|
|
|
|
|
fn run(self, builder: &Builder) {
|
|
|
|
|
let stage = self.stage;
|
|
|
|
|
let host = self.host;
|
|
|
|
|
let compiler = builder.compiler(stage, host);
|
|
|
|
|
|
|
|
|
|
let mut cargo = tool::prepare_tool_cargo(builder,
|
|
|
|
|
compiler,
|
|
|
|
|
Mode::ToolBootstrap,
|
|
|
|
|
host,
|
|
|
|
|
"test",
|
|
|
|
|
"src/tools/compiletest",
|
|
|
|
|
SourceType::InTree,
|
|
|
|
|
&[]);
|
|
|
|
|
|
|
|
|
|
try_run(builder, &mut cargo);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-09-18 13:13:57 +02:00
|
|
|
|
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
|
|
|
|
|
pub struct Clippy {
|
2017-12-06 09:25:29 +01:00
|
|
|
|
stage: u32,
|
2017-09-18 13:13:57 +02:00
|
|
|
|
host: Interned<String>,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl Step for Clippy {
|
|
|
|
|
type Output = ();
|
|
|
|
|
const ONLY_HOSTS: bool = true;
|
|
|
|
|
const DEFAULT: bool = false;
|
|
|
|
|
|
|
|
|
|
fn should_run(run: ShouldRun) -> ShouldRun {
|
|
|
|
|
run.path("src/tools/clippy")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn make_run(run: RunConfig) {
|
|
|
|
|
run.builder.ensure(Clippy {
|
2017-12-06 09:25:29 +01:00
|
|
|
|
stage: run.builder.top_stage,
|
2017-09-18 13:13:57 +02:00
|
|
|
|
host: run.target,
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// Runs `cargo test` for clippy.
|
|
|
|
|
fn run(self, builder: &Builder) {
|
2017-12-06 09:25:29 +01:00
|
|
|
|
let stage = self.stage;
|
2017-09-18 13:13:57 +02:00
|
|
|
|
let host = self.host;
|
2017-12-06 09:25:29 +01:00
|
|
|
|
let compiler = builder.compiler(stage, host);
|
2017-09-18 13:13:57 +02:00
|
|
|
|
|
2018-02-09 18:53:41 +01:00
|
|
|
|
let clippy = builder.ensure(tool::Clippy {
|
|
|
|
|
compiler,
|
|
|
|
|
target: self.host,
|
|
|
|
|
extra_features: Vec::new(),
|
|
|
|
|
});
|
|
|
|
|
if let Some(clippy) = clippy {
|
2018-07-25 14:46:47 +09:00
|
|
|
|
let mut cargo = tool::prepare_tool_cargo(builder,
|
|
|
|
|
compiler,
|
|
|
|
|
Mode::ToolRustc,
|
|
|
|
|
host,
|
|
|
|
|
"test",
|
|
|
|
|
"src/tools/clippy",
|
2018-10-08 10:39:09 -07:00
|
|
|
|
SourceType::Submodule,
|
|
|
|
|
&[]);
|
2017-12-06 09:25:29 +01:00
|
|
|
|
|
|
|
|
|
// clippy tests need to know about the stage sysroot
|
|
|
|
|
cargo.env("SYSROOT", builder.sysroot(compiler));
|
|
|
|
|
cargo.env("RUSTC_TEST_SUITE", builder.rustc(compiler));
|
|
|
|
|
cargo.env("RUSTC_LIB_PATH", builder.rustc_libdir(compiler));
|
2018-05-30 14:33:43 -03:00
|
|
|
|
let host_libs = builder
|
2018-05-19 23:04:41 +03:00
|
|
|
|
.stage_out(compiler, Mode::ToolRustc)
|
2018-05-30 14:33:43 -03:00
|
|
|
|
.join(builder.cargo_dir());
|
2017-12-06 09:25:29 +01:00
|
|
|
|
cargo.env("HOST_LIBS", host_libs);
|
|
|
|
|
// clippy tests need to find the driver
|
|
|
|
|
cargo.env("CLIPPY_DRIVER_PATH", clippy);
|
|
|
|
|
|
|
|
|
|
builder.add_rustc_lib_path(compiler, &mut cargo);
|
|
|
|
|
|
2018-04-14 17:27:57 -06:00
|
|
|
|
if try_run(builder, &mut cargo) {
|
|
|
|
|
builder.save_toolstate("clippy-driver", ToolState::TestPass);
|
2017-12-06 09:25:29 +01:00
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
eprintln!("failed to test clippy: could not build");
|
|
|
|
|
}
|
2017-09-18 13:13:57 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
2017-09-01 18:43:00 +12:00
|
|
|
|
|
2017-07-17 09:52:05 -06:00
|
|
|
|
fn path_for_cargo(builder: &Builder, compiler: Compiler) -> OsString {
|
2017-07-01 06:58:54 +12:00
|
|
|
|
// Configure PATH to find the right rustc. NB. we have to use PATH
|
|
|
|
|
// and not RUSTC because the Cargo test suite has tests that will
|
|
|
|
|
// fail if rustc is not spelled `rustc`.
|
2017-07-17 09:52:05 -06:00
|
|
|
|
let path = builder.sysroot(compiler).join("bin");
|
2017-07-01 06:58:54 +12:00
|
|
|
|
let old_path = env::var_os("PATH").unwrap_or_default();
|
|
|
|
|
env::join_paths(iter::once(path).chain(env::split_paths(&old_path))).expect("")
|
2016-03-18 20:54:31 +00:00
|
|
|
|
}
|
2016-03-29 13:14:52 -07:00
|
|
|
|
|
2018-01-26 00:44:52 +01:00
|
|
|
|
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
|
|
|
|
|
pub struct RustdocTheme {
|
|
|
|
|
pub compiler: Compiler,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl Step for RustdocTheme {
|
|
|
|
|
type Output = ();
|
|
|
|
|
const DEFAULT: bool = true;
|
|
|
|
|
const ONLY_HOSTS: bool = true;
|
|
|
|
|
|
|
|
|
|
fn should_run(run: ShouldRun) -> ShouldRun {
|
|
|
|
|
run.path("src/tools/rustdoc-themes")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn make_run(run: RunConfig) {
|
|
|
|
|
let compiler = run.builder.compiler(run.builder.top_stage, run.host);
|
|
|
|
|
|
2018-10-26 16:23:02 +02:00
|
|
|
|
run.builder.ensure(RustdocTheme { compiler });
|
2018-01-26 00:44:52 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn run(self, builder: &Builder) {
|
2018-04-12 15:01:49 +01:00
|
|
|
|
let rustdoc = builder.out.join("bootstrap/debug/rustdoc");
|
2018-02-05 23:43:53 +01:00
|
|
|
|
let mut cmd = builder.tool_cmd(Tool::RustdocTheme);
|
|
|
|
|
cmd.arg(rustdoc.to_str().unwrap())
|
2018-05-30 14:33:43 -03:00
|
|
|
|
.arg(
|
|
|
|
|
builder
|
|
|
|
|
.src
|
|
|
|
|
.join("src/librustdoc/html/static/themes")
|
|
|
|
|
.to_str()
|
|
|
|
|
.unwrap(),
|
|
|
|
|
)
|
|
|
|
|
.env("RUSTC_STAGE", self.compiler.stage.to_string())
|
|
|
|
|
.env("RUSTC_SYSROOT", builder.sysroot(self.compiler))
|
|
|
|
|
.env(
|
|
|
|
|
"RUSTDOC_LIBDIR",
|
|
|
|
|
builder.sysroot_libdir(self.compiler, self.compiler.host),
|
|
|
|
|
)
|
|
|
|
|
.env("CFG_RELEASE_CHANNEL", &builder.config.channel)
|
|
|
|
|
.env("RUSTDOC_REAL", builder.rustdoc(self.compiler.host))
|
|
|
|
|
.env("RUSTDOC_CRATE_VERSION", builder.rust_version())
|
|
|
|
|
.env("RUSTC_BOOTSTRAP", "1");
|
2018-04-14 17:27:57 -06:00
|
|
|
|
if let Some(linker) = builder.linker(self.compiler.host) {
|
2018-01-26 00:44:52 +01:00
|
|
|
|
cmd.env("RUSTC_TARGET_LINKER", linker);
|
|
|
|
|
}
|
2018-04-14 17:27:57 -06:00
|
|
|
|
try_run(builder, &mut cmd);
|
2018-01-26 00:44:52 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-12-12 23:53:24 +01:00
|
|
|
|
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
|
|
|
|
|
pub struct RustdocJS {
|
|
|
|
|
pub host: Interned<String>,
|
2018-01-12 23:40:00 +01:00
|
|
|
|
pub target: Interned<String>,
|
2017-12-12 23:53:24 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl Step for RustdocJS {
|
2018-01-08 23:43:20 +01:00
|
|
|
|
type Output = ();
|
2017-12-12 23:53:24 +01:00
|
|
|
|
const DEFAULT: bool = true;
|
|
|
|
|
const ONLY_HOSTS: bool = true;
|
|
|
|
|
|
|
|
|
|
fn should_run(run: ShouldRun) -> ShouldRun {
|
2018-01-12 23:40:00 +01:00
|
|
|
|
run.path("src/test/rustdoc-js")
|
2017-12-12 23:53:24 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn make_run(run: RunConfig) {
|
|
|
|
|
run.builder.ensure(RustdocJS {
|
|
|
|
|
host: run.host,
|
2018-01-12 23:40:00 +01:00
|
|
|
|
target: run.target,
|
2017-12-12 23:53:24 +01:00
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2018-01-08 23:43:20 +01:00
|
|
|
|
fn run(self, builder: &Builder) {
|
2018-01-13 22:35:41 +01:00
|
|
|
|
if let Some(ref nodejs) = builder.config.nodejs {
|
|
|
|
|
let mut command = Command::new(nodejs);
|
|
|
|
|
command.args(&["src/tools/rustdoc-js/tester.js", &*self.host]);
|
2018-12-07 13:21:05 +01:00
|
|
|
|
builder.ensure(crate::doc::Std {
|
2018-01-13 22:35:41 +01:00
|
|
|
|
target: self.target,
|
|
|
|
|
stage: builder.top_stage,
|
|
|
|
|
});
|
|
|
|
|
builder.run(&mut command);
|
|
|
|
|
} else {
|
2018-10-26 16:23:02 +02:00
|
|
|
|
builder.info(
|
2018-05-30 14:33:43 -03:00
|
|
|
|
"No nodejs found, skipping \"src/test/rustdoc-js\" tests"
|
2018-10-26 16:23:02 +02:00
|
|
|
|
);
|
2018-01-13 22:35:41 +01:00
|
|
|
|
}
|
2017-12-12 23:53:24 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-03-31 14:49:56 +02:00
|
|
|
|
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
|
|
|
|
|
pub struct RustdocUi {
|
|
|
|
|
pub host: Interned<String>,
|
|
|
|
|
pub target: Interned<String>,
|
|
|
|
|
pub compiler: Compiler,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl Step for RustdocUi {
|
|
|
|
|
type Output = ();
|
|
|
|
|
const DEFAULT: bool = true;
|
|
|
|
|
const ONLY_HOSTS: bool = true;
|
|
|
|
|
|
|
|
|
|
fn should_run(run: ShouldRun) -> ShouldRun {
|
|
|
|
|
run.path("src/test/rustdoc-ui")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn make_run(run: RunConfig) {
|
|
|
|
|
let compiler = run.builder.compiler(run.builder.top_stage, run.host);
|
|
|
|
|
run.builder.ensure(RustdocUi {
|
|
|
|
|
host: run.host,
|
|
|
|
|
target: run.target,
|
|
|
|
|
compiler,
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn run(self, builder: &Builder) {
|
|
|
|
|
builder.ensure(Compiletest {
|
|
|
|
|
compiler: self.compiler,
|
|
|
|
|
target: self.target,
|
|
|
|
|
mode: "ui",
|
|
|
|
|
suite: "rustdoc-ui",
|
2018-04-12 14:49:31 +03:00
|
|
|
|
path: None,
|
2018-04-11 17:15:59 +02:00
|
|
|
|
compare_mode: None,
|
2018-03-31 14:49:56 +02:00
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-07-13 18:48:44 -06:00
|
|
|
|
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
|
2018-02-11 15:41:06 -07:00
|
|
|
|
pub struct Tidy;
|
2017-07-04 19:41:43 -06:00
|
|
|
|
|
2017-07-13 18:48:44 -06:00
|
|
|
|
impl Step for Tidy {
|
2017-07-04 19:41:43 -06:00
|
|
|
|
type Output = ();
|
2017-07-05 06:41:27 -06:00
|
|
|
|
const DEFAULT: bool = true;
|
|
|
|
|
const ONLY_HOSTS: bool = true;
|
2017-07-04 19:41:43 -06:00
|
|
|
|
|
2018-02-11 15:41:06 -07:00
|
|
|
|
/// Runs the `tidy` tool.
|
2017-07-04 19:41:43 -06:00
|
|
|
|
///
|
|
|
|
|
/// This tool in `src/tools` checks up on various bits and pieces of style and
|
|
|
|
|
/// otherwise just implements a few lint-like checks that are specific to the
|
|
|
|
|
/// compiler itself.
|
|
|
|
|
fn run(self, builder: &Builder) {
|
2017-07-05 10:46:41 -06:00
|
|
|
|
let mut cmd = builder.tool_cmd(Tool::Tidy);
|
2018-04-14 17:27:57 -06:00
|
|
|
|
cmd.arg(builder.src.join("src"));
|
|
|
|
|
cmd.arg(&builder.initial_cargo);
|
|
|
|
|
if !builder.config.vendor {
|
2017-07-04 19:41:43 -06:00
|
|
|
|
cmd.arg("--no-vendor");
|
|
|
|
|
}
|
2018-06-07 14:40:36 +02:00
|
|
|
|
if !builder.config.verbose_tests {
|
2017-07-04 19:41:43 -06:00
|
|
|
|
cmd.arg("--quiet");
|
|
|
|
|
}
|
2018-03-16 08:35:03 -07:00
|
|
|
|
|
2018-04-14 17:27:57 -06:00
|
|
|
|
let _folder = builder.fold_output(|| "tidy");
|
2018-10-26 16:23:02 +02:00
|
|
|
|
builder.info("tidy check");
|
2018-04-14 17:27:57 -06:00
|
|
|
|
try_run(builder, &mut cmd);
|
2017-05-22 04:27:47 +08:00
|
|
|
|
}
|
2017-07-05 06:41:27 -06:00
|
|
|
|
|
2017-07-18 18:03:38 -06:00
|
|
|
|
fn should_run(run: ShouldRun) -> ShouldRun {
|
|
|
|
|
run.path("src/tools/tidy")
|
2017-07-05 06:41:27 -06:00
|
|
|
|
}
|
|
|
|
|
|
2017-07-20 17:51:07 -06:00
|
|
|
|
fn make_run(run: RunConfig) {
|
2018-02-11 15:41:06 -07:00
|
|
|
|
run.builder.ensure(Tidy);
|
2017-07-05 06:41:27 -06:00
|
|
|
|
}
|
2016-03-29 13:14:52 -07:00
|
|
|
|
}
|
2016-04-05 11:34:23 -07:00
|
|
|
|
|
2018-04-14 17:27:57 -06:00
|
|
|
|
fn testdir(builder: &Builder, host: Interned<String>) -> PathBuf {
|
|
|
|
|
builder.out.join(host).join("test")
|
2016-04-05 11:34:23 -07:00
|
|
|
|
}
|
|
|
|
|
|
Change Step to be invoked with a path when in default mode.
Previously, a Step would be able to tell on its own when it was invoked
"by-default" (that is, `./x.py test` was called instead of `./x.py test
some/path`). This commit replaces that functionality, invoking each Step
with each of the paths it has specified as "should be invoked by."
For example, if a step calls `path("src/tools/cargo")` and
`path("src/doc/cargo")` then it's make_run will be called twice, with
"src/tools/cargo" and "src/doc/cargo." This makes it so that default
handling logic is in builder, instead of spread across various Steps.
However, this meant that some Step specifications needed to be updated,
since for example `rustdoc` can be built by `./x.py build
src/librustdoc` or `./x.py build src/tools/rustdoc`. A `PathSet`
abstraction is added that handles this: now, each Step can not only list
`path(...)` but also `paths(&[a, b, ...])` which will make it so that we
don't invoke it with each of the individual paths, instead invoking it
with the first path in the list (though this shouldn't be depended on).
Future work likely consists of implementing a better/easier way for a
given Step to work with "any" crate in-tree, especially those that want
to run tests, build, or check crates in the std, test, or rustc crate
trees. Currently this is rather painful to do as most of the logic is
duplicated across should_run and make_run. It seems likely this can be
abstracted away into builder somehow.
2018-02-11 09:51:58 -07:00
|
|
|
|
macro_rules! default_test {
|
|
|
|
|
($name:ident { path: $path:expr, mode: $mode:expr, suite: $suite:expr }) => {
|
|
|
|
|
test!($name { path: $path, mode: $mode, suite: $suite, default: true, host: false });
|
|
|
|
|
}
|
2017-07-07 11:51:57 -06:00
|
|
|
|
}
|
|
|
|
|
|
2018-04-11 17:15:59 +02:00
|
|
|
|
macro_rules! default_test_with_compare_mode {
|
|
|
|
|
($name:ident { path: $path:expr, mode: $mode:expr, suite: $suite:expr,
|
|
|
|
|
compare_mode: $compare_mode:expr }) => {
|
|
|
|
|
test_with_compare_mode!($name { path: $path, mode: $mode, suite: $suite, default: true,
|
|
|
|
|
host: false, compare_mode: $compare_mode });
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
Change Step to be invoked with a path when in default mode.
Previously, a Step would be able to tell on its own when it was invoked
"by-default" (that is, `./x.py test` was called instead of `./x.py test
some/path`). This commit replaces that functionality, invoking each Step
with each of the paths it has specified as "should be invoked by."
For example, if a step calls `path("src/tools/cargo")` and
`path("src/doc/cargo")` then it's make_run will be called twice, with
"src/tools/cargo" and "src/doc/cargo." This makes it so that default
handling logic is in builder, instead of spread across various Steps.
However, this meant that some Step specifications needed to be updated,
since for example `rustdoc` can be built by `./x.py build
src/librustdoc` or `./x.py build src/tools/rustdoc`. A `PathSet`
abstraction is added that handles this: now, each Step can not only list
`path(...)` but also `paths(&[a, b, ...])` which will make it so that we
don't invoke it with each of the individual paths, instead invoking it
with the first path in the list (though this shouldn't be depended on).
Future work likely consists of implementing a better/easier way for a
given Step to work with "any" crate in-tree, especially those that want
to run tests, build, or check crates in the std, test, or rustc crate
trees. Currently this is rather painful to do as most of the logic is
duplicated across should_run and make_run. It seems likely this can be
abstracted away into builder somehow.
2018-02-11 09:51:58 -07:00
|
|
|
|
macro_rules! host_test {
|
|
|
|
|
($name:ident { path: $path:expr, mode: $mode:expr, suite: $suite:expr }) => {
|
|
|
|
|
test!($name { path: $path, mode: $mode, suite: $suite, default: true, host: true });
|
|
|
|
|
}
|
2017-07-20 09:42:18 -06:00
|
|
|
|
}
|
|
|
|
|
|
Change Step to be invoked with a path when in default mode.
Previously, a Step would be able to tell on its own when it was invoked
"by-default" (that is, `./x.py test` was called instead of `./x.py test
some/path`). This commit replaces that functionality, invoking each Step
with each of the paths it has specified as "should be invoked by."
For example, if a step calls `path("src/tools/cargo")` and
`path("src/doc/cargo")` then it's make_run will be called twice, with
"src/tools/cargo" and "src/doc/cargo." This makes it so that default
handling logic is in builder, instead of spread across various Steps.
However, this meant that some Step specifications needed to be updated,
since for example `rustdoc` can be built by `./x.py build
src/librustdoc` or `./x.py build src/tools/rustdoc`. A `PathSet`
abstraction is added that handles this: now, each Step can not only list
`path(...)` but also `paths(&[a, b, ...])` which will make it so that we
don't invoke it with each of the individual paths, instead invoking it
with the first path in the list (though this shouldn't be depended on).
Future work likely consists of implementing a better/easier way for a
given Step to work with "any" crate in-tree, especially those that want
to run tests, build, or check crates in the std, test, or rustc crate
trees. Currently this is rather painful to do as most of the logic is
duplicated across should_run and make_run. It seems likely this can be
abstracted away into builder somehow.
2018-02-11 09:51:58 -07:00
|
|
|
|
macro_rules! test {
|
2018-04-11 17:15:59 +02:00
|
|
|
|
($name:ident { path: $path:expr, mode: $mode:expr, suite: $suite:expr, default: $default:expr,
|
|
|
|
|
host: $host:expr }) => {
|
|
|
|
|
test_definitions!($name { path: $path, mode: $mode, suite: $suite, default: $default,
|
|
|
|
|
host: $host, compare_mode: None });
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
macro_rules! test_with_compare_mode {
|
|
|
|
|
($name:ident { path: $path:expr, mode: $mode:expr, suite: $suite:expr, default: $default:expr,
|
|
|
|
|
host: $host:expr, compare_mode: $compare_mode:expr }) => {
|
|
|
|
|
test_definitions!($name { path: $path, mode: $mode, suite: $suite, default: $default,
|
|
|
|
|
host: $host, compare_mode: Some($compare_mode) });
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
macro_rules! test_definitions {
|
Change Step to be invoked with a path when in default mode.
Previously, a Step would be able to tell on its own when it was invoked
"by-default" (that is, `./x.py test` was called instead of `./x.py test
some/path`). This commit replaces that functionality, invoking each Step
with each of the paths it has specified as "should be invoked by."
For example, if a step calls `path("src/tools/cargo")` and
`path("src/doc/cargo")` then it's make_run will be called twice, with
"src/tools/cargo" and "src/doc/cargo." This makes it so that default
handling logic is in builder, instead of spread across various Steps.
However, this meant that some Step specifications needed to be updated,
since for example `rustdoc` can be built by `./x.py build
src/librustdoc` or `./x.py build src/tools/rustdoc`. A `PathSet`
abstraction is added that handles this: now, each Step can not only list
`path(...)` but also `paths(&[a, b, ...])` which will make it so that we
don't invoke it with each of the individual paths, instead invoking it
with the first path in the list (though this shouldn't be depended on).
Future work likely consists of implementing a better/easier way for a
given Step to work with "any" crate in-tree, especially those that want
to run tests, build, or check crates in the std, test, or rustc crate
trees. Currently this is rather painful to do as most of the logic is
duplicated across should_run and make_run. It seems likely this can be
abstracted away into builder somehow.
2018-02-11 09:51:58 -07:00
|
|
|
|
($name:ident {
|
|
|
|
|
path: $path:expr,
|
|
|
|
|
mode: $mode:expr,
|
|
|
|
|
suite: $suite:expr,
|
|
|
|
|
default: $default:expr,
|
2018-04-11 17:15:59 +02:00
|
|
|
|
host: $host:expr,
|
|
|
|
|
compare_mode: $compare_mode:expr
|
Change Step to be invoked with a path when in default mode.
Previously, a Step would be able to tell on its own when it was invoked
"by-default" (that is, `./x.py test` was called instead of `./x.py test
some/path`). This commit replaces that functionality, invoking each Step
with each of the paths it has specified as "should be invoked by."
For example, if a step calls `path("src/tools/cargo")` and
`path("src/doc/cargo")` then it's make_run will be called twice, with
"src/tools/cargo" and "src/doc/cargo." This makes it so that default
handling logic is in builder, instead of spread across various Steps.
However, this meant that some Step specifications needed to be updated,
since for example `rustdoc` can be built by `./x.py build
src/librustdoc` or `./x.py build src/tools/rustdoc`. A `PathSet`
abstraction is added that handles this: now, each Step can not only list
`path(...)` but also `paths(&[a, b, ...])` which will make it so that we
don't invoke it with each of the individual paths, instead invoking it
with the first path in the list (though this shouldn't be depended on).
Future work likely consists of implementing a better/easier way for a
given Step to work with "any" crate in-tree, especially those that want
to run tests, build, or check crates in the std, test, or rustc crate
trees. Currently this is rather painful to do as most of the logic is
duplicated across should_run and make_run. It seems likely this can be
abstracted away into builder somehow.
2018-02-11 09:51:58 -07:00
|
|
|
|
}) => {
|
|
|
|
|
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
|
|
|
|
|
pub struct $name {
|
|
|
|
|
pub compiler: Compiler,
|
|
|
|
|
pub target: Interned<String>,
|
2017-07-20 09:42:18 -06:00
|
|
|
|
}
|
|
|
|
|
|
Change Step to be invoked with a path when in default mode.
Previously, a Step would be able to tell on its own when it was invoked
"by-default" (that is, `./x.py test` was called instead of `./x.py test
some/path`). This commit replaces that functionality, invoking each Step
with each of the paths it has specified as "should be invoked by."
For example, if a step calls `path("src/tools/cargo")` and
`path("src/doc/cargo")` then it's make_run will be called twice, with
"src/tools/cargo" and "src/doc/cargo." This makes it so that default
handling logic is in builder, instead of spread across various Steps.
However, this meant that some Step specifications needed to be updated,
since for example `rustdoc` can be built by `./x.py build
src/librustdoc` or `./x.py build src/tools/rustdoc`. A `PathSet`
abstraction is added that handles this: now, each Step can not only list
`path(...)` but also `paths(&[a, b, ...])` which will make it so that we
don't invoke it with each of the individual paths, instead invoking it
with the first path in the list (though this shouldn't be depended on).
Future work likely consists of implementing a better/easier way for a
given Step to work with "any" crate in-tree, especially those that want
to run tests, build, or check crates in the std, test, or rustc crate
trees. Currently this is rather painful to do as most of the logic is
duplicated across should_run and make_run. It seems likely this can be
abstracted away into builder somehow.
2018-02-11 09:51:58 -07:00
|
|
|
|
impl Step for $name {
|
|
|
|
|
type Output = ();
|
|
|
|
|
const DEFAULT: bool = $default;
|
|
|
|
|
const ONLY_HOSTS: bool = $host;
|
2017-07-20 09:42:18 -06:00
|
|
|
|
|
Change Step to be invoked with a path when in default mode.
Previously, a Step would be able to tell on its own when it was invoked
"by-default" (that is, `./x.py test` was called instead of `./x.py test
some/path`). This commit replaces that functionality, invoking each Step
with each of the paths it has specified as "should be invoked by."
For example, if a step calls `path("src/tools/cargo")` and
`path("src/doc/cargo")` then it's make_run will be called twice, with
"src/tools/cargo" and "src/doc/cargo." This makes it so that default
handling logic is in builder, instead of spread across various Steps.
However, this meant that some Step specifications needed to be updated,
since for example `rustdoc` can be built by `./x.py build
src/librustdoc` or `./x.py build src/tools/rustdoc`. A `PathSet`
abstraction is added that handles this: now, each Step can not only list
`path(...)` but also `paths(&[a, b, ...])` which will make it so that we
don't invoke it with each of the individual paths, instead invoking it
with the first path in the list (though this shouldn't be depended on).
Future work likely consists of implementing a better/easier way for a
given Step to work with "any" crate in-tree, especially those that want
to run tests, build, or check crates in the std, test, or rustc crate
trees. Currently this is rather painful to do as most of the logic is
duplicated across should_run and make_run. It seems likely this can be
abstracted away into builder somehow.
2018-02-11 09:51:58 -07:00
|
|
|
|
fn should_run(run: ShouldRun) -> ShouldRun {
|
2018-04-12 14:49:31 +03:00
|
|
|
|
run.suite_path($path)
|
2017-07-20 09:42:18 -06:00
|
|
|
|
}
|
2017-07-05 06:41:27 -06:00
|
|
|
|
|
Change Step to be invoked with a path when in default mode.
Previously, a Step would be able to tell on its own when it was invoked
"by-default" (that is, `./x.py test` was called instead of `./x.py test
some/path`). This commit replaces that functionality, invoking each Step
with each of the paths it has specified as "should be invoked by."
For example, if a step calls `path("src/tools/cargo")` and
`path("src/doc/cargo")` then it's make_run will be called twice, with
"src/tools/cargo" and "src/doc/cargo." This makes it so that default
handling logic is in builder, instead of spread across various Steps.
However, this meant that some Step specifications needed to be updated,
since for example `rustdoc` can be built by `./x.py build
src/librustdoc` or `./x.py build src/tools/rustdoc`. A `PathSet`
abstraction is added that handles this: now, each Step can not only list
`path(...)` but also `paths(&[a, b, ...])` which will make it so that we
don't invoke it with each of the individual paths, instead invoking it
with the first path in the list (though this shouldn't be depended on).
Future work likely consists of implementing a better/easier way for a
given Step to work with "any" crate in-tree, especially those that want
to run tests, build, or check crates in the std, test, or rustc crate
trees. Currently this is rather painful to do as most of the logic is
duplicated across should_run and make_run. It seems likely this can be
abstracted away into builder somehow.
2018-02-11 09:51:58 -07:00
|
|
|
|
fn make_run(run: RunConfig) {
|
|
|
|
|
let compiler = run.builder.compiler(run.builder.top_stage, run.host);
|
2017-07-05 06:41:27 -06:00
|
|
|
|
|
Change Step to be invoked with a path when in default mode.
Previously, a Step would be able to tell on its own when it was invoked
"by-default" (that is, `./x.py test` was called instead of `./x.py test
some/path`). This commit replaces that functionality, invoking each Step
with each of the paths it has specified as "should be invoked by."
For example, if a step calls `path("src/tools/cargo")` and
`path("src/doc/cargo")` then it's make_run will be called twice, with
"src/tools/cargo" and "src/doc/cargo." This makes it so that default
handling logic is in builder, instead of spread across various Steps.
However, this meant that some Step specifications needed to be updated,
since for example `rustdoc` can be built by `./x.py build
src/librustdoc` or `./x.py build src/tools/rustdoc`. A `PathSet`
abstraction is added that handles this: now, each Step can not only list
`path(...)` but also `paths(&[a, b, ...])` which will make it so that we
don't invoke it with each of the individual paths, instead invoking it
with the first path in the list (though this shouldn't be depended on).
Future work likely consists of implementing a better/easier way for a
given Step to work with "any" crate in-tree, especially those that want
to run tests, build, or check crates in the std, test, or rustc crate
trees. Currently this is rather painful to do as most of the logic is
duplicated across should_run and make_run. It seems likely this can be
abstracted away into builder somehow.
2018-02-11 09:51:58 -07:00
|
|
|
|
run.builder.ensure($name {
|
2017-07-07 12:31:29 -06:00
|
|
|
|
compiler,
|
2017-07-20 17:51:07 -06:00
|
|
|
|
target: run.target,
|
2017-07-07 12:31:29 -06:00
|
|
|
|
});
|
|
|
|
|
}
|
2017-07-04 19:41:43 -06:00
|
|
|
|
|
Change Step to be invoked with a path when in default mode.
Previously, a Step would be able to tell on its own when it was invoked
"by-default" (that is, `./x.py test` was called instead of `./x.py test
some/path`). This commit replaces that functionality, invoking each Step
with each of the paths it has specified as "should be invoked by."
For example, if a step calls `path("src/tools/cargo")` and
`path("src/doc/cargo")` then it's make_run will be called twice, with
"src/tools/cargo" and "src/doc/cargo." This makes it so that default
handling logic is in builder, instead of spread across various Steps.
However, this meant that some Step specifications needed to be updated,
since for example `rustdoc` can be built by `./x.py build
src/librustdoc` or `./x.py build src/tools/rustdoc`. A `PathSet`
abstraction is added that handles this: now, each Step can not only list
`path(...)` but also `paths(&[a, b, ...])` which will make it so that we
don't invoke it with each of the individual paths, instead invoking it
with the first path in the list (though this shouldn't be depended on).
Future work likely consists of implementing a better/easier way for a
given Step to work with "any" crate in-tree, especially those that want
to run tests, build, or check crates in the std, test, or rustc crate
trees. Currently this is rather painful to do as most of the logic is
duplicated across should_run and make_run. It seems likely this can be
abstracted away into builder somehow.
2018-02-11 09:51:58 -07:00
|
|
|
|
fn run(self, builder: &Builder) {
|
|
|
|
|
builder.ensure(Compiletest {
|
|
|
|
|
compiler: self.compiler,
|
|
|
|
|
target: self.target,
|
|
|
|
|
mode: $mode,
|
|
|
|
|
suite: $suite,
|
2018-04-12 14:49:31 +03:00
|
|
|
|
path: Some($path),
|
2018-04-11 17:15:59 +02:00
|
|
|
|
compare_mode: $compare_mode,
|
Change Step to be invoked with a path when in default mode.
Previously, a Step would be able to tell on its own when it was invoked
"by-default" (that is, `./x.py test` was called instead of `./x.py test
some/path`). This commit replaces that functionality, invoking each Step
with each of the paths it has specified as "should be invoked by."
For example, if a step calls `path("src/tools/cargo")` and
`path("src/doc/cargo")` then it's make_run will be called twice, with
"src/tools/cargo" and "src/doc/cargo." This makes it so that default
handling logic is in builder, instead of spread across various Steps.
However, this meant that some Step specifications needed to be updated,
since for example `rustdoc` can be built by `./x.py build
src/librustdoc` or `./x.py build src/tools/rustdoc`. A `PathSet`
abstraction is added that handles this: now, each Step can not only list
`path(...)` but also `paths(&[a, b, ...])` which will make it so that we
don't invoke it with each of the individual paths, instead invoking it
with the first path in the list (though this shouldn't be depended on).
Future work likely consists of implementing a better/easier way for a
given Step to work with "any" crate in-tree, especially those that want
to run tests, build, or check crates in the std, test, or rustc crate
trees. Currently this is rather painful to do as most of the logic is
duplicated across should_run and make_run. It seems likely this can be
abstracted away into builder somehow.
2018-02-11 09:51:58 -07:00
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}
|
2017-07-20 09:42:18 -06:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-04-11 17:15:59 +02:00
|
|
|
|
default_test_with_compare_mode!(Ui {
|
Change Step to be invoked with a path when in default mode.
Previously, a Step would be able to tell on its own when it was invoked
"by-default" (that is, `./x.py test` was called instead of `./x.py test
some/path`). This commit replaces that functionality, invoking each Step
with each of the paths it has specified as "should be invoked by."
For example, if a step calls `path("src/tools/cargo")` and
`path("src/doc/cargo")` then it's make_run will be called twice, with
"src/tools/cargo" and "src/doc/cargo." This makes it so that default
handling logic is in builder, instead of spread across various Steps.
However, this meant that some Step specifications needed to be updated,
since for example `rustdoc` can be built by `./x.py build
src/librustdoc` or `./x.py build src/tools/rustdoc`. A `PathSet`
abstraction is added that handles this: now, each Step can not only list
`path(...)` but also `paths(&[a, b, ...])` which will make it so that we
don't invoke it with each of the individual paths, instead invoking it
with the first path in the list (though this shouldn't be depended on).
Future work likely consists of implementing a better/easier way for a
given Step to work with "any" crate in-tree, especially those that want
to run tests, build, or check crates in the std, test, or rustc crate
trees. Currently this is rather painful to do as most of the logic is
duplicated across should_run and make_run. It seems likely this can be
abstracted away into builder somehow.
2018-02-11 09:51:58 -07:00
|
|
|
|
path: "src/test/ui",
|
|
|
|
|
mode: "ui",
|
2018-04-11 17:15:59 +02:00
|
|
|
|
suite: "ui",
|
|
|
|
|
compare_mode: "nll"
|
Change Step to be invoked with a path when in default mode.
Previously, a Step would be able to tell on its own when it was invoked
"by-default" (that is, `./x.py test` was called instead of `./x.py test
some/path`). This commit replaces that functionality, invoking each Step
with each of the paths it has specified as "should be invoked by."
For example, if a step calls `path("src/tools/cargo")` and
`path("src/doc/cargo")` then it's make_run will be called twice, with
"src/tools/cargo" and "src/doc/cargo." This makes it so that default
handling logic is in builder, instead of spread across various Steps.
However, this meant that some Step specifications needed to be updated,
since for example `rustdoc` can be built by `./x.py build
src/librustdoc` or `./x.py build src/tools/rustdoc`. A `PathSet`
abstraction is added that handles this: now, each Step can not only list
`path(...)` but also `paths(&[a, b, ...])` which will make it so that we
don't invoke it with each of the individual paths, instead invoking it
with the first path in the list (though this shouldn't be depended on).
Future work likely consists of implementing a better/easier way for a
given Step to work with "any" crate in-tree, especially those that want
to run tests, build, or check crates in the std, test, or rustc crate
trees. Currently this is rather painful to do as most of the logic is
duplicated across should_run and make_run. It seems likely this can be
abstracted away into builder somehow.
2018-02-11 09:51:58 -07:00
|
|
|
|
});
|
|
|
|
|
|
2018-09-14 13:18:02 +02:00
|
|
|
|
default_test_with_compare_mode!(RunPass {
|
Change Step to be invoked with a path when in default mode.
Previously, a Step would be able to tell on its own when it was invoked
"by-default" (that is, `./x.py test` was called instead of `./x.py test
some/path`). This commit replaces that functionality, invoking each Step
with each of the paths it has specified as "should be invoked by."
For example, if a step calls `path("src/tools/cargo")` and
`path("src/doc/cargo")` then it's make_run will be called twice, with
"src/tools/cargo" and "src/doc/cargo." This makes it so that default
handling logic is in builder, instead of spread across various Steps.
However, this meant that some Step specifications needed to be updated,
since for example `rustdoc` can be built by `./x.py build
src/librustdoc` or `./x.py build src/tools/rustdoc`. A `PathSet`
abstraction is added that handles this: now, each Step can not only list
`path(...)` but also `paths(&[a, b, ...])` which will make it so that we
don't invoke it with each of the individual paths, instead invoking it
with the first path in the list (though this shouldn't be depended on).
Future work likely consists of implementing a better/easier way for a
given Step to work with "any" crate in-tree, especially those that want
to run tests, build, or check crates in the std, test, or rustc crate
trees. Currently this is rather painful to do as most of the logic is
duplicated across should_run and make_run. It seems likely this can be
abstracted away into builder somehow.
2018-02-11 09:51:58 -07:00
|
|
|
|
path: "src/test/run-pass",
|
|
|
|
|
mode: "run-pass",
|
2018-09-14 13:18:02 +02:00
|
|
|
|
suite: "run-pass",
|
|
|
|
|
compare_mode: "nll"
|
Change Step to be invoked with a path when in default mode.
Previously, a Step would be able to tell on its own when it was invoked
"by-default" (that is, `./x.py test` was called instead of `./x.py test
some/path`). This commit replaces that functionality, invoking each Step
with each of the paths it has specified as "should be invoked by."
For example, if a step calls `path("src/tools/cargo")` and
`path("src/doc/cargo")` then it's make_run will be called twice, with
"src/tools/cargo" and "src/doc/cargo." This makes it so that default
handling logic is in builder, instead of spread across various Steps.
However, this meant that some Step specifications needed to be updated,
since for example `rustdoc` can be built by `./x.py build
src/librustdoc` or `./x.py build src/tools/rustdoc`. A `PathSet`
abstraction is added that handles this: now, each Step can not only list
`path(...)` but also `paths(&[a, b, ...])` which will make it so that we
don't invoke it with each of the individual paths, instead invoking it
with the first path in the list (though this shouldn't be depended on).
Future work likely consists of implementing a better/easier way for a
given Step to work with "any" crate in-tree, especially those that want
to run tests, build, or check crates in the std, test, or rustc crate
trees. Currently this is rather painful to do as most of the logic is
duplicated across should_run and make_run. It seems likely this can be
abstracted away into builder somehow.
2018-02-11 09:51:58 -07:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
default_test!(CompileFail {
|
|
|
|
|
path: "src/test/compile-fail",
|
|
|
|
|
mode: "compile-fail",
|
|
|
|
|
suite: "compile-fail"
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
default_test!(RunFail {
|
|
|
|
|
path: "src/test/run-fail",
|
|
|
|
|
mode: "run-fail",
|
|
|
|
|
suite: "run-fail"
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
default_test!(RunPassValgrind {
|
|
|
|
|
path: "src/test/run-pass-valgrind",
|
|
|
|
|
mode: "run-pass-valgrind",
|
|
|
|
|
suite: "run-pass-valgrind"
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
default_test!(MirOpt {
|
|
|
|
|
path: "src/test/mir-opt",
|
|
|
|
|
mode: "mir-opt",
|
|
|
|
|
suite: "mir-opt"
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
default_test!(Codegen {
|
|
|
|
|
path: "src/test/codegen",
|
|
|
|
|
mode: "codegen",
|
|
|
|
|
suite: "codegen"
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
default_test!(CodegenUnits {
|
|
|
|
|
path: "src/test/codegen-units",
|
|
|
|
|
mode: "codegen-units",
|
|
|
|
|
suite: "codegen-units"
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
default_test!(Incremental {
|
|
|
|
|
path: "src/test/incremental",
|
|
|
|
|
mode: "incremental",
|
|
|
|
|
suite: "incremental"
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
default_test!(Debuginfo {
|
|
|
|
|
path: "src/test/debuginfo",
|
2018-10-03 10:01:56 -06:00
|
|
|
|
mode: "debuginfo",
|
Change Step to be invoked with a path when in default mode.
Previously, a Step would be able to tell on its own when it was invoked
"by-default" (that is, `./x.py test` was called instead of `./x.py test
some/path`). This commit replaces that functionality, invoking each Step
with each of the paths it has specified as "should be invoked by."
For example, if a step calls `path("src/tools/cargo")` and
`path("src/doc/cargo")` then it's make_run will be called twice, with
"src/tools/cargo" and "src/doc/cargo." This makes it so that default
handling logic is in builder, instead of spread across various Steps.
However, this meant that some Step specifications needed to be updated,
since for example `rustdoc` can be built by `./x.py build
src/librustdoc` or `./x.py build src/tools/rustdoc`. A `PathSet`
abstraction is added that handles this: now, each Step can not only list
`path(...)` but also `paths(&[a, b, ...])` which will make it so that we
don't invoke it with each of the individual paths, instead invoking it
with the first path in the list (though this shouldn't be depended on).
Future work likely consists of implementing a better/easier way for a
given Step to work with "any" crate in-tree, especially those that want
to run tests, build, or check crates in the std, test, or rustc crate
trees. Currently this is rather painful to do as most of the logic is
duplicated across should_run and make_run. It seems likely this can be
abstracted away into builder somehow.
2018-02-11 09:51:58 -07:00
|
|
|
|
suite: "debuginfo"
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
host_test!(UiFullDeps {
|
|
|
|
|
path: "src/test/ui-fulldeps",
|
|
|
|
|
mode: "ui",
|
|
|
|
|
suite: "ui-fulldeps"
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
host_test!(RunPassFullDeps {
|
|
|
|
|
path: "src/test/run-pass-fulldeps",
|
|
|
|
|
mode: "run-pass",
|
|
|
|
|
suite: "run-pass-fulldeps"
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
host_test!(RunFailFullDeps {
|
|
|
|
|
path: "src/test/run-fail-fulldeps",
|
|
|
|
|
mode: "run-fail",
|
|
|
|
|
suite: "run-fail-fulldeps"
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
host_test!(Rustdoc {
|
|
|
|
|
path: "src/test/rustdoc",
|
|
|
|
|
mode: "rustdoc",
|
|
|
|
|
suite: "rustdoc"
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test!(Pretty {
|
|
|
|
|
path: "src/test/pretty",
|
|
|
|
|
mode: "pretty",
|
|
|
|
|
suite: "pretty",
|
|
|
|
|
default: false,
|
|
|
|
|
host: true
|
|
|
|
|
});
|
|
|
|
|
test!(RunPassPretty {
|
|
|
|
|
path: "src/test/run-pass/pretty",
|
|
|
|
|
mode: "pretty",
|
|
|
|
|
suite: "run-pass",
|
|
|
|
|
default: false,
|
|
|
|
|
host: true
|
|
|
|
|
});
|
|
|
|
|
test!(RunFailPretty {
|
|
|
|
|
path: "src/test/run-fail/pretty",
|
|
|
|
|
mode: "pretty",
|
|
|
|
|
suite: "run-fail",
|
|
|
|
|
default: false,
|
|
|
|
|
host: true
|
|
|
|
|
});
|
|
|
|
|
test!(RunPassValgrindPretty {
|
|
|
|
|
path: "src/test/run-pass-valgrind/pretty",
|
|
|
|
|
mode: "pretty",
|
|
|
|
|
suite: "run-pass-valgrind",
|
|
|
|
|
default: false,
|
|
|
|
|
host: true
|
|
|
|
|
});
|
|
|
|
|
test!(RunPassFullDepsPretty {
|
|
|
|
|
path: "src/test/run-pass-fulldeps/pretty",
|
|
|
|
|
mode: "pretty",
|
|
|
|
|
suite: "run-pass-fulldeps",
|
|
|
|
|
default: false,
|
|
|
|
|
host: true
|
|
|
|
|
});
|
|
|
|
|
test!(RunFailFullDepsPretty {
|
|
|
|
|
path: "src/test/run-fail-fulldeps/pretty",
|
|
|
|
|
mode: "pretty",
|
|
|
|
|
suite: "run-fail-fulldeps",
|
|
|
|
|
default: false,
|
|
|
|
|
host: true
|
|
|
|
|
});
|
|
|
|
|
|
2018-05-15 16:39:21 -07:00
|
|
|
|
default_test!(RunMake {
|
Change Step to be invoked with a path when in default mode.
Previously, a Step would be able to tell on its own when it was invoked
"by-default" (that is, `./x.py test` was called instead of `./x.py test
some/path`). This commit replaces that functionality, invoking each Step
with each of the paths it has specified as "should be invoked by."
For example, if a step calls `path("src/tools/cargo")` and
`path("src/doc/cargo")` then it's make_run will be called twice, with
"src/tools/cargo" and "src/doc/cargo." This makes it so that default
handling logic is in builder, instead of spread across various Steps.
However, this meant that some Step specifications needed to be updated,
since for example `rustdoc` can be built by `./x.py build
src/librustdoc` or `./x.py build src/tools/rustdoc`. A `PathSet`
abstraction is added that handles this: now, each Step can not only list
`path(...)` but also `paths(&[a, b, ...])` which will make it so that we
don't invoke it with each of the individual paths, instead invoking it
with the first path in the list (though this shouldn't be depended on).
Future work likely consists of implementing a better/easier way for a
given Step to work with "any" crate in-tree, especially those that want
to run tests, build, or check crates in the std, test, or rustc crate
trees. Currently this is rather painful to do as most of the logic is
duplicated across should_run and make_run. It seems likely this can be
abstracted away into builder somehow.
2018-02-11 09:51:58 -07:00
|
|
|
|
path: "src/test/run-make",
|
|
|
|
|
mode: "run-make",
|
|
|
|
|
suite: "run-make"
|
|
|
|
|
});
|
|
|
|
|
|
2018-03-09 09:26:15 -08:00
|
|
|
|
host_test!(RunMakeFullDeps {
|
|
|
|
|
path: "src/test/run-make-fulldeps",
|
|
|
|
|
mode: "run-make",
|
|
|
|
|
suite: "run-make-fulldeps"
|
|
|
|
|
});
|
|
|
|
|
|
2017-07-20 09:42:18 -06:00
|
|
|
|
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
|
|
|
|
|
struct Compiletest {
|
|
|
|
|
compiler: Compiler,
|
|
|
|
|
target: Interned<String>,
|
|
|
|
|
mode: &'static str,
|
|
|
|
|
suite: &'static str,
|
2018-04-12 14:49:31 +03:00
|
|
|
|
path: Option<&'static str>,
|
2018-04-11 17:15:59 +02:00
|
|
|
|
compare_mode: Option<&'static str>,
|
2017-07-20 09:42:18 -06:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl Step for Compiletest {
|
|
|
|
|
type Output = ();
|
|
|
|
|
|
|
|
|
|
fn should_run(run: ShouldRun) -> ShouldRun {
|
|
|
|
|
run.never()
|
|
|
|
|
}
|
|
|
|
|
|
2017-07-04 19:41:43 -06:00
|
|
|
|
/// Executes the `compiletest` tool to run a suite of tests.
|
|
|
|
|
///
|
|
|
|
|
/// Compiles all tests with `compiler` for `target` with the specified
|
|
|
|
|
/// compiletest `mode` and `suite` arguments. For example `mode` can be
|
|
|
|
|
/// "run-pass" or `suite` can be something like `debuginfo`.
|
|
|
|
|
fn run(self, builder: &Builder) {
|
|
|
|
|
let compiler = self.compiler;
|
|
|
|
|
let target = self.target;
|
|
|
|
|
let mode = self.mode;
|
|
|
|
|
let suite = self.suite;
|
2017-07-05 06:41:27 -06:00
|
|
|
|
|
2018-04-12 14:49:31 +03:00
|
|
|
|
// Path for test suite
|
|
|
|
|
let suite_path = self.path.unwrap_or("");
|
|
|
|
|
|
2017-07-05 06:41:27 -06:00
|
|
|
|
// Skip codegen tests if they aren't enabled in configuration.
|
2018-04-14 17:27:57 -06:00
|
|
|
|
if !builder.config.codegen_tests && suite == "codegen" {
|
2017-07-05 06:41:27 -06:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if suite == "debuginfo" {
|
2017-07-20 11:23:29 -06:00
|
|
|
|
// Skip debuginfo tests on MSVC
|
2018-04-14 17:27:57 -06:00
|
|
|
|
if builder.config.build.contains("msvc") {
|
2017-07-20 11:23:29 -06:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2018-10-03 10:01:56 -06:00
|
|
|
|
if mode == "debuginfo" {
|
|
|
|
|
return builder.ensure(Compiletest {
|
|
|
|
|
mode: "debuginfo-both",
|
|
|
|
|
..self
|
|
|
|
|
});
|
2017-07-05 06:41:27 -06:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
builder.ensure(dist::DebuggerScripts {
|
2017-07-13 18:48:44 -06:00
|
|
|
|
sysroot: builder.sysroot(compiler),
|
2018-05-30 14:33:43 -03:00
|
|
|
|
host: target,
|
2017-07-05 06:41:27 -06:00
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if suite.ends_with("fulldeps") ||
|
|
|
|
|
// FIXME: Does pretty need librustc compiled? Note that there are
|
|
|
|
|
// fulldeps test suites with mode = pretty as well.
|
2018-06-02 07:50:35 -06:00
|
|
|
|
mode == "pretty"
|
2018-05-30 14:33:43 -03:00
|
|
|
|
{
|
2017-07-05 06:41:27 -06:00
|
|
|
|
builder.ensure(compile::Rustc { compiler, target });
|
|
|
|
|
}
|
|
|
|
|
|
2018-08-08 18:29:17 +09:00
|
|
|
|
if builder.no_std(target) == Some(true) {
|
|
|
|
|
// the `test` doesn't compile for no-std targets
|
|
|
|
|
builder.ensure(compile::Std { compiler, target });
|
|
|
|
|
} else {
|
2018-07-18 00:40:55 +09:00
|
|
|
|
builder.ensure(compile::Test { compiler, target });
|
|
|
|
|
}
|
2018-08-08 18:29:17 +09:00
|
|
|
|
|
|
|
|
|
if builder.no_std(target) == Some(true) {
|
2018-11-27 02:59:49 +00:00
|
|
|
|
// for no_std run-make (e.g., thumb*),
|
2018-08-08 18:29:17 +09:00
|
|
|
|
// we need a host compiler which is called by cargo.
|
|
|
|
|
builder.ensure(compile::Std { compiler, target: compiler.host });
|
|
|
|
|
}
|
|
|
|
|
|
2018-05-16 15:38:32 +03:00
|
|
|
|
// HACK(eddyb) ensure that `libproc_macro` is available on the host.
|
|
|
|
|
builder.ensure(compile::Test { compiler, target: compiler.host });
|
2018-11-27 15:40:40 +02:00
|
|
|
|
// Also provide `rust_test_helpers` for the host.
|
|
|
|
|
builder.ensure(native::TestHelpers { target: compiler.host });
|
2018-05-16 15:38:32 +03:00
|
|
|
|
|
2017-07-05 06:41:27 -06:00
|
|
|
|
builder.ensure(native::TestHelpers { target });
|
2017-07-07 12:31:29 -06:00
|
|
|
|
builder.ensure(RemoteCopyLibs { compiler, target });
|
2017-07-05 06:41:27 -06:00
|
|
|
|
|
|
|
|
|
let mut cmd = builder.tool_cmd(Tool::Compiletest);
|
2017-07-04 19:41:43 -06:00
|
|
|
|
|
|
|
|
|
// compiletest currently has... a lot of arguments, so let's just pass all
|
|
|
|
|
// of them!
|
|
|
|
|
|
2018-05-30 14:33:43 -03:00
|
|
|
|
cmd.arg("--compile-lib-path")
|
|
|
|
|
.arg(builder.rustc_libdir(compiler));
|
|
|
|
|
cmd.arg("--run-lib-path")
|
|
|
|
|
.arg(builder.sysroot_libdir(compiler, target));
|
2017-07-05 11:21:33 -06:00
|
|
|
|
cmd.arg("--rustc-path").arg(builder.rustc(compiler));
|
2017-07-25 16:54:33 -06:00
|
|
|
|
|
2018-04-01 21:06:35 +02:00
|
|
|
|
let is_rustdoc_ui = suite.ends_with("rustdoc-ui");
|
|
|
|
|
|
2017-07-25 16:54:33 -06:00
|
|
|
|
// Avoid depending on rustdoc when we don't need it.
|
2018-05-30 14:33:43 -03:00
|
|
|
|
if mode == "rustdoc"
|
|
|
|
|
|| (mode == "run-make" && suite.ends_with("fulldeps"))
|
|
|
|
|
|| (mode == "ui" && is_rustdoc_ui)
|
|
|
|
|
{
|
|
|
|
|
cmd.arg("--rustdoc-path")
|
|
|
|
|
.arg(builder.rustdoc(compiler.host));
|
2017-07-25 16:54:33 -06:00
|
|
|
|
}
|
|
|
|
|
|
2018-05-30 14:33:43 -03:00
|
|
|
|
cmd.arg("--src-base")
|
|
|
|
|
.arg(builder.src.join("src/test").join(suite));
|
|
|
|
|
cmd.arg("--build-base")
|
|
|
|
|
.arg(testdir(builder, compiler.host).join(suite));
|
|
|
|
|
cmd.arg("--stage-id")
|
|
|
|
|
.arg(format!("stage{}-{}", compiler.stage, target));
|
2017-07-04 19:41:43 -06:00
|
|
|
|
cmd.arg("--mode").arg(mode);
|
|
|
|
|
cmd.arg("--target").arg(target);
|
2017-07-13 18:48:44 -06:00
|
|
|
|
cmd.arg("--host").arg(&*compiler.host);
|
2018-05-30 14:33:43 -03:00
|
|
|
|
cmd.arg("--llvm-filecheck")
|
|
|
|
|
.arg(builder.llvm_filecheck(builder.config.build));
|
2017-07-04 19:41:43 -06:00
|
|
|
|
|
2018-05-16 18:17:29 +02:00
|
|
|
|
if builder.config.cmd.bless() {
|
2018-05-16 17:18:19 +02:00
|
|
|
|
cmd.arg("--bless");
|
|
|
|
|
}
|
|
|
|
|
|
2018-11-30 14:31:04 -08:00
|
|
|
|
let compare_mode = builder.config.cmd.compare_mode().or_else(|| {
|
|
|
|
|
if builder.config.test_compare_mode {
|
|
|
|
|
self.compare_mode
|
|
|
|
|
} else {
|
|
|
|
|
None
|
|
|
|
|
}
|
|
|
|
|
});
|
2018-05-28 19:44:33 -03:00
|
|
|
|
|
2018-04-14 17:27:57 -06:00
|
|
|
|
if let Some(ref nodejs) = builder.config.nodejs {
|
2017-07-04 19:41:43 -06:00
|
|
|
|
cmd.arg("--nodejs").arg(nodejs);
|
|
|
|
|
}
|
2016-04-19 09:44:19 -07:00
|
|
|
|
|
2018-04-01 21:06:35 +02:00
|
|
|
|
let mut flags = if is_rustdoc_ui {
|
|
|
|
|
Vec::new()
|
|
|
|
|
} else {
|
|
|
|
|
vec!["-Crpath".to_string()]
|
|
|
|
|
};
|
|
|
|
|
if !is_rustdoc_ui {
|
2018-04-14 17:27:57 -06:00
|
|
|
|
if builder.config.rust_optimize_tests {
|
2018-04-01 21:06:35 +02:00
|
|
|
|
flags.push("-O".to_string());
|
|
|
|
|
}
|
2018-04-14 17:27:57 -06:00
|
|
|
|
if builder.config.rust_debuginfo_tests {
|
2018-04-01 21:06:35 +02:00
|
|
|
|
flags.push("-g".to_string());
|
|
|
|
|
}
|
2017-07-04 19:41:43 -06:00
|
|
|
|
}
|
2018-04-15 13:05:14 +02:00
|
|
|
|
flags.push("-Zunstable-options".to_string());
|
2018-04-14 17:27:57 -06:00
|
|
|
|
flags.push(builder.config.cmd.rustc_args().join(" "));
|
2016-04-19 09:44:19 -07:00
|
|
|
|
|
2018-04-14 17:27:57 -06:00
|
|
|
|
if let Some(linker) = builder.linker(target) {
|
2017-12-06 09:25:29 +01:00
|
|
|
|
cmd.arg("--linker").arg(linker);
|
|
|
|
|
}
|
|
|
|
|
|
2018-11-27 15:40:40 +02:00
|
|
|
|
let mut hostflags = flags.clone();
|
|
|
|
|
hostflags.push(format!(
|
|
|
|
|
"-Lnative={}",
|
|
|
|
|
builder.test_helpers_out(compiler.host).display()
|
|
|
|
|
));
|
2017-07-04 19:41:43 -06:00
|
|
|
|
cmd.arg("--host-rustcflags").arg(hostflags.join(" "));
|
|
|
|
|
|
2018-10-26 03:11:11 +09:00
|
|
|
|
let mut targetflags = flags;
|
2018-05-30 14:33:43 -03:00
|
|
|
|
targetflags.push(format!(
|
|
|
|
|
"-Lnative={}",
|
|
|
|
|
builder.test_helpers_out(target).display()
|
|
|
|
|
));
|
2017-07-04 19:41:43 -06:00
|
|
|
|
cmd.arg("--target-rustcflags").arg(targetflags.join(" "));
|
|
|
|
|
|
2018-04-14 17:27:57 -06:00
|
|
|
|
cmd.arg("--docck-python").arg(builder.python());
|
2017-07-04 19:41:43 -06:00
|
|
|
|
|
2018-04-14 17:27:57 -06:00
|
|
|
|
if builder.config.build.ends_with("apple-darwin") {
|
2017-07-04 19:41:43 -06:00
|
|
|
|
// Force /usr/bin/python on macOS for LLDB tests because we're loading the
|
|
|
|
|
// LLDB plugin's compiled module which only works with the system python
|
|
|
|
|
// (namely not Homebrew-installed python)
|
|
|
|
|
cmd.arg("--lldb-python").arg("/usr/bin/python");
|
|
|
|
|
} else {
|
2018-04-14 17:27:57 -06:00
|
|
|
|
cmd.arg("--lldb-python").arg(builder.python());
|
2017-07-04 19:41:43 -06:00
|
|
|
|
}
|
2016-04-05 11:34:23 -07:00
|
|
|
|
|
2018-04-14 17:27:57 -06:00
|
|
|
|
if let Some(ref gdb) = builder.config.gdb {
|
2017-07-04 19:41:43 -06:00
|
|
|
|
cmd.arg("--gdb").arg(gdb);
|
|
|
|
|
}
|
2018-10-02 10:13:30 -06:00
|
|
|
|
|
|
|
|
|
let run = |cmd: &mut Command| {
|
|
|
|
|
cmd.output().map(|output| {
|
|
|
|
|
String::from_utf8_lossy(&output.stdout)
|
|
|
|
|
.lines().next().unwrap_or_else(|| {
|
|
|
|
|
panic!("{:?} failed {:?}", cmd, output)
|
|
|
|
|
}).to_string()
|
|
|
|
|
})
|
|
|
|
|
};
|
|
|
|
|
let lldb_exe = if builder.config.lldb_enabled && !target.contains("emscripten") {
|
|
|
|
|
// Test against the lldb that was just built.
|
|
|
|
|
builder.llvm_out(target)
|
|
|
|
|
.join("bin")
|
|
|
|
|
.join("lldb")
|
|
|
|
|
} else {
|
|
|
|
|
PathBuf::from("lldb")
|
|
|
|
|
};
|
|
|
|
|
let lldb_version = Command::new(&lldb_exe)
|
|
|
|
|
.arg("--version")
|
|
|
|
|
.output()
|
|
|
|
|
.map(|output| { String::from_utf8_lossy(&output.stdout).to_string() })
|
|
|
|
|
.ok();
|
|
|
|
|
if let Some(ref vers) = lldb_version {
|
2017-07-04 19:41:43 -06:00
|
|
|
|
cmd.arg("--lldb-version").arg(vers);
|
2018-10-02 10:13:30 -06:00
|
|
|
|
let lldb_python_dir = run(Command::new(&lldb_exe).arg("-P")).ok();
|
|
|
|
|
if let Some(ref dir) = lldb_python_dir {
|
|
|
|
|
cmd.arg("--lldb-python-dir").arg(dir);
|
|
|
|
|
}
|
2017-07-04 19:41:43 -06:00
|
|
|
|
}
|
2016-04-05 11:34:23 -07:00
|
|
|
|
|
2018-04-12 14:49:31 +03:00
|
|
|
|
// Get paths from cmd args
|
|
|
|
|
let paths = match &builder.config.cmd {
|
2018-05-30 14:33:43 -03:00
|
|
|
|
Subcommand::Test { ref paths, .. } => &paths[..],
|
|
|
|
|
_ => &[],
|
2018-04-12 14:49:31 +03:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// Get test-args by striping suite path
|
2018-05-30 14:33:43 -03:00
|
|
|
|
let mut test_args: Vec<&str> = paths
|
|
|
|
|
.iter()
|
2018-06-21 23:57:06 -05:00
|
|
|
|
.map(|p| {
|
|
|
|
|
match p.strip_prefix(".") {
|
|
|
|
|
Ok(path) => path,
|
|
|
|
|
Err(_) => p,
|
|
|
|
|
}
|
|
|
|
|
})
|
2018-05-30 14:33:43 -03:00
|
|
|
|
.filter(|p| p.starts_with(suite_path) && p.is_file())
|
|
|
|
|
.map(|p| p.strip_prefix(suite_path).unwrap().to_str().unwrap())
|
|
|
|
|
.collect();
|
2018-04-12 14:49:31 +03:00
|
|
|
|
|
|
|
|
|
test_args.append(&mut builder.config.cmd.test_args());
|
|
|
|
|
|
|
|
|
|
cmd.args(&test_args);
|
2016-04-05 11:34:23 -07:00
|
|
|
|
|
2018-04-14 17:27:57 -06:00
|
|
|
|
if builder.is_verbose() {
|
2017-07-04 19:41:43 -06:00
|
|
|
|
cmd.arg("--verbose");
|
|
|
|
|
}
|
2016-04-05 11:34:23 -07:00
|
|
|
|
|
2018-06-07 14:40:36 +02:00
|
|
|
|
if !builder.config.verbose_tests {
|
2017-07-04 19:41:43 -06:00
|
|
|
|
cmd.arg("--quiet");
|
|
|
|
|
}
|
2016-10-29 21:58:52 -04:00
|
|
|
|
|
2018-04-14 17:27:57 -06:00
|
|
|
|
if builder.config.llvm_enabled {
|
2018-03-05 09:47:54 -08:00
|
|
|
|
let llvm_config = builder.ensure(native::Llvm {
|
2018-04-14 17:27:57 -06:00
|
|
|
|
target: builder.config.build,
|
2018-03-05 09:47:54 -08:00
|
|
|
|
emscripten: false,
|
|
|
|
|
});
|
2018-04-14 17:27:57 -06:00
|
|
|
|
if !builder.config.dry_run {
|
2018-03-31 19:21:14 -06:00
|
|
|
|
let llvm_version = output(Command::new(&llvm_config).arg("--version"));
|
|
|
|
|
cmd.arg("--llvm-version").arg(llvm_version);
|
|
|
|
|
}
|
2018-04-14 17:27:57 -06:00
|
|
|
|
if !builder.is_rust_llvm(target) {
|
2017-08-13 12:30:54 +02:00
|
|
|
|
cmd.arg("--system-llvm");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Only pass correct values for these flags for the `run-make` suite as it
|
|
|
|
|
// requires that a C++ compiler was configured which isn't always the case.
|
2018-05-15 16:39:21 -07:00
|
|
|
|
if !builder.config.dry_run && suite == "run-make-fulldeps" {
|
2017-08-13 12:30:54 +02:00
|
|
|
|
let llvm_components = output(Command::new(&llvm_config).arg("--components"));
|
|
|
|
|
let llvm_cxxflags = output(Command::new(&llvm_config).arg("--cxxflags"));
|
2018-05-30 14:33:43 -03:00
|
|
|
|
cmd.arg("--cc")
|
|
|
|
|
.arg(builder.cc(target))
|
|
|
|
|
.arg("--cxx")
|
|
|
|
|
.arg(builder.cxx(target).unwrap())
|
|
|
|
|
.arg("--cflags")
|
2018-08-30 10:25:07 -07:00
|
|
|
|
.arg(builder.cflags(target, GitRepo::Rustc).join(" "))
|
2018-05-30 14:33:43 -03:00
|
|
|
|
.arg("--llvm-components")
|
|
|
|
|
.arg(llvm_components.trim())
|
|
|
|
|
.arg("--llvm-cxxflags")
|
|
|
|
|
.arg(llvm_cxxflags.trim());
|
2018-04-14 17:27:57 -06:00
|
|
|
|
if let Some(ar) = builder.ar(target) {
|
2017-12-06 09:25:29 +01:00
|
|
|
|
cmd.arg("--ar").arg(ar);
|
|
|
|
|
}
|
2017-08-13 12:30:54 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
2018-05-15 16:39:21 -07:00
|
|
|
|
if suite == "run-make-fulldeps" && !builder.config.llvm_enabled {
|
2018-10-26 16:23:02 +02:00
|
|
|
|
builder.info(
|
2018-05-30 14:33:43 -03:00
|
|
|
|
"Ignoring run-make test suite as they generally don't work without LLVM"
|
2018-10-26 16:23:02 +02:00
|
|
|
|
);
|
2017-08-13 12:30:54 +02:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2018-05-15 16:39:21 -07:00
|
|
|
|
if suite != "run-make-fulldeps" {
|
2018-05-30 14:33:43 -03:00
|
|
|
|
cmd.arg("--cc")
|
|
|
|
|
.arg("")
|
|
|
|
|
.arg("--cxx")
|
|
|
|
|
.arg("")
|
|
|
|
|
.arg("--cflags")
|
|
|
|
|
.arg("")
|
|
|
|
|
.arg("--llvm-components")
|
|
|
|
|
.arg("")
|
|
|
|
|
.arg("--llvm-cxxflags")
|
|
|
|
|
.arg("");
|
2017-07-04 19:41:43 -06:00
|
|
|
|
}
|
2016-04-14 15:51:03 -07:00
|
|
|
|
|
2018-04-14 17:27:57 -06:00
|
|
|
|
if builder.remote_tested(target) {
|
2018-05-30 14:33:43 -03:00
|
|
|
|
cmd.arg("--remote-test-client")
|
|
|
|
|
.arg(builder.tool_exe(Tool::RemoteTestClient));
|
2017-07-04 19:41:43 -06:00
|
|
|
|
}
|
2017-01-28 13:38:06 -08:00
|
|
|
|
|
2017-07-04 19:41:43 -06:00
|
|
|
|
// Running a C compiler on MSVC requires a few env vars to be set, to be
|
|
|
|
|
// sure to set them here.
|
|
|
|
|
//
|
|
|
|
|
// Note that if we encounter `PATH` we make sure to append to our own `PATH`
|
|
|
|
|
// rather than stomp over it.
|
|
|
|
|
if target.contains("msvc") {
|
2018-04-14 17:27:57 -06:00
|
|
|
|
for &(ref k, ref v) in builder.cc[&target].env() {
|
2017-07-04 19:41:43 -06:00
|
|
|
|
if k != "PATH" {
|
|
|
|
|
cmd.env(k, v);
|
|
|
|
|
}
|
2016-04-14 15:51:03 -07:00
|
|
|
|
}
|
|
|
|
|
}
|
2017-07-04 19:41:43 -06:00
|
|
|
|
cmd.env("RUSTC_BOOTSTRAP", "1");
|
2018-04-14 17:27:57 -06:00
|
|
|
|
builder.add_rust_test_threads(&mut cmd);
|
2016-04-14 15:51:03 -07:00
|
|
|
|
|
2018-04-14 17:27:57 -06:00
|
|
|
|
if builder.config.sanitizers {
|
2017-07-04 19:41:43 -06:00
|
|
|
|
cmd.env("SANITIZER_SUPPORT", "1");
|
|
|
|
|
}
|
2017-02-03 18:58:47 -05:00
|
|
|
|
|
2018-04-14 17:27:57 -06:00
|
|
|
|
if builder.config.profiler {
|
2017-07-04 19:41:43 -06:00
|
|
|
|
cmd.env("PROFILER_SUPPORT", "1");
|
|
|
|
|
}
|
2017-02-13 09:57:50 +00:00
|
|
|
|
|
2018-04-14 17:27:57 -06:00
|
|
|
|
cmd.env("RUST_TEST_TMPDIR", builder.out.join("tmp"));
|
2018-01-22 07:29:24 -08:00
|
|
|
|
|
2017-07-04 19:41:43 -06:00
|
|
|
|
cmd.arg("--adb-path").arg("adb");
|
|
|
|
|
cmd.arg("--adb-test-dir").arg(ADB_TEST_DIR);
|
|
|
|
|
if target.contains("android") {
|
|
|
|
|
// Assume that cc for this target comes from the android sysroot
|
|
|
|
|
cmd.arg("--android-cross-path")
|
2018-05-30 14:33:43 -03:00
|
|
|
|
.arg(builder.cc(target).parent().unwrap().parent().unwrap());
|
2017-07-04 19:41:43 -06:00
|
|
|
|
} else {
|
|
|
|
|
cmd.arg("--android-cross-path").arg("");
|
|
|
|
|
}
|
2016-06-28 13:31:30 -07:00
|
|
|
|
|
2018-04-14 17:27:57 -06:00
|
|
|
|
builder.ci_env.force_coloring_in_ci(&mut cmd);
|
2017-05-18 00:33:20 +08:00
|
|
|
|
|
2018-04-14 17:27:57 -06:00
|
|
|
|
let _folder = builder.fold_output(|| format!("test_{}", suite));
|
2018-05-30 14:33:43 -03:00
|
|
|
|
builder.info(&format!(
|
|
|
|
|
"Check compiletest suite={} mode={} ({} -> {})",
|
|
|
|
|
suite, mode, &compiler.host, target
|
|
|
|
|
));
|
2018-04-14 17:27:57 -06:00
|
|
|
|
let _time = util::timeit(&builder);
|
|
|
|
|
try_run(builder, &mut cmd);
|
2018-04-11 17:15:59 +02:00
|
|
|
|
|
|
|
|
|
if let Some(compare_mode) = compare_mode {
|
|
|
|
|
cmd.arg("--compare-mode").arg(compare_mode);
|
|
|
|
|
let _folder = builder.fold_output(|| format!("test_{}_{}", suite, compare_mode));
|
2018-05-30 14:33:43 -03:00
|
|
|
|
builder.info(&format!(
|
|
|
|
|
"Check compiletest suite={} mode={} compare_mode={} ({} -> {})",
|
|
|
|
|
suite, mode, compare_mode, &compiler.host, target
|
|
|
|
|
));
|
2018-04-11 17:15:59 +02:00
|
|
|
|
let _time = util::timeit(&builder);
|
|
|
|
|
try_run(builder, &mut cmd);
|
|
|
|
|
}
|
2017-07-04 19:41:43 -06:00
|
|
|
|
}
|
2016-04-05 11:34:23 -07:00
|
|
|
|
}
|
2016-04-14 18:00:35 -07:00
|
|
|
|
|
2017-07-13 18:48:44 -06:00
|
|
|
|
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
|
2018-02-22 03:13:34 +08:00
|
|
|
|
struct DocTest {
|
2017-07-13 18:48:44 -06:00
|
|
|
|
compiler: Compiler,
|
2018-02-22 03:13:34 +08:00
|
|
|
|
path: &'static str,
|
|
|
|
|
name: &'static str,
|
|
|
|
|
is_ext_doc: bool,
|
2017-07-12 09:15:00 -06:00
|
|
|
|
}
|
|
|
|
|
|
2018-02-22 03:13:34 +08:00
|
|
|
|
impl Step for DocTest {
|
2017-07-12 09:15:00 -06:00
|
|
|
|
type Output = ();
|
|
|
|
|
const ONLY_HOSTS: bool = true;
|
2016-04-14 18:00:35 -07:00
|
|
|
|
|
2017-07-18 18:03:38 -06:00
|
|
|
|
fn should_run(run: ShouldRun) -> ShouldRun {
|
2018-02-22 03:13:34 +08:00
|
|
|
|
run.never()
|
2017-07-12 09:15:00 -06:00
|
|
|
|
}
|
2017-07-10 11:43:02 -06:00
|
|
|
|
|
2017-07-12 09:15:00 -06:00
|
|
|
|
/// Run `rustdoc --test` for all documentation in `src/doc`.
|
|
|
|
|
///
|
2018-11-27 02:59:49 +00:00
|
|
|
|
/// This will run all tests in our markdown documentation (e.g., the book)
|
2017-07-12 09:15:00 -06:00
|
|
|
|
/// located in `src/doc`. The `rustdoc` that's run is the one that sits next to
|
|
|
|
|
/// `compiler`.
|
|
|
|
|
fn run(self, builder: &Builder) {
|
|
|
|
|
let compiler = self.compiler;
|
2017-07-12 10:12:47 -06:00
|
|
|
|
|
2018-05-30 14:33:43 -03:00
|
|
|
|
builder.ensure(compile::Test {
|
|
|
|
|
compiler,
|
|
|
|
|
target: compiler.host,
|
|
|
|
|
});
|
2017-07-12 10:12:47 -06:00
|
|
|
|
|
2017-07-12 09:15:00 -06:00
|
|
|
|
// Do a breadth-first traversal of the `src/doc` directory and just run
|
|
|
|
|
// tests for all files that end in `*.md`
|
2018-04-14 17:27:57 -06:00
|
|
|
|
let mut stack = vec![builder.src.join(self.path)];
|
|
|
|
|
let _time = util::timeit(&builder);
|
|
|
|
|
let _folder = builder.fold_output(|| format!("test_{}", self.name));
|
2017-07-12 09:15:00 -06:00
|
|
|
|
|
2018-03-27 16:06:47 +02:00
|
|
|
|
let mut files = Vec::new();
|
2017-07-12 09:15:00 -06:00
|
|
|
|
while let Some(p) = stack.pop() {
|
|
|
|
|
if p.is_dir() {
|
|
|
|
|
stack.extend(t!(p.read_dir()).map(|p| t!(p).path()));
|
2018-05-30 14:33:43 -03:00
|
|
|
|
continue;
|
2017-07-12 09:15:00 -06:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if p.extension().and_then(|s| s.to_str()) != Some("md") {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// The nostarch directory in the book is for no starch, and so isn't
|
2018-04-14 17:27:57 -06:00
|
|
|
|
// guaranteed to builder. We don't care if it doesn't build, so skip it.
|
2017-07-12 09:15:00 -06:00
|
|
|
|
if p.to_str().map_or(false, |p| p.contains("nostarch")) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
2018-03-27 16:06:47 +02:00
|
|
|
|
files.push(p);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
files.sort();
|
|
|
|
|
|
2018-07-03 05:53:18 +08:00
|
|
|
|
let mut toolstate = ToolState::TestPass;
|
2018-03-27 16:06:47 +02:00
|
|
|
|
for file in files {
|
2018-07-03 05:53:18 +08:00
|
|
|
|
if !markdown_test(builder, compiler, &file) {
|
|
|
|
|
toolstate = ToolState::TestFail;
|
2018-02-22 03:25:23 +08:00
|
|
|
|
}
|
2017-07-12 09:15:00 -06:00
|
|
|
|
}
|
2018-07-03 05:53:18 +08:00
|
|
|
|
if self.is_ext_doc {
|
|
|
|
|
builder.save_toolstate(self.name, toolstate);
|
|
|
|
|
}
|
2016-04-14 18:00:35 -07:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-02-22 03:13:34 +08:00
|
|
|
|
macro_rules! test_book {
|
|
|
|
|
($($name:ident, $path:expr, $book_name:expr, default=$default:expr;)+) => {
|
|
|
|
|
$(
|
|
|
|
|
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
|
|
|
|
|
pub struct $name {
|
|
|
|
|
compiler: Compiler,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl Step for $name {
|
|
|
|
|
type Output = ();
|
|
|
|
|
const DEFAULT: bool = $default;
|
|
|
|
|
const ONLY_HOSTS: bool = true;
|
|
|
|
|
|
|
|
|
|
fn should_run(run: ShouldRun) -> ShouldRun {
|
|
|
|
|
run.path($path)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn make_run(run: RunConfig) {
|
|
|
|
|
run.builder.ensure($name {
|
|
|
|
|
compiler: run.builder.compiler(run.builder.top_stage, run.host),
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn run(self, builder: &Builder) {
|
|
|
|
|
builder.ensure(DocTest {
|
|
|
|
|
compiler: self.compiler,
|
|
|
|
|
path: $path,
|
|
|
|
|
name: $book_name,
|
|
|
|
|
is_ext_doc: !$default,
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
)+
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test_book!(
|
|
|
|
|
Nomicon, "src/doc/nomicon", "nomicon", default=false;
|
|
|
|
|
Reference, "src/doc/reference", "reference", default=false;
|
|
|
|
|
RustdocBook, "src/doc/rustdoc", "rustdoc", default=true;
|
2018-04-05 14:41:48 -04:00
|
|
|
|
RustcBook, "src/doc/rustc", "rustc", default=true;
|
2018-02-22 03:13:34 +08:00
|
|
|
|
RustByExample, "src/doc/rust-by-example", "rust-by-example", default=false;
|
|
|
|
|
TheBook, "src/doc/book", "book", default=false;
|
|
|
|
|
UnstableBook, "src/doc/unstable-book", "unstable-book", default=true;
|
|
|
|
|
);
|
|
|
|
|
|
2017-07-13 18:48:44 -06:00
|
|
|
|
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
|
|
|
|
|
pub struct ErrorIndex {
|
|
|
|
|
compiler: Compiler,
|
2017-07-04 19:41:43 -06:00
|
|
|
|
}
|
2016-04-14 18:00:35 -07:00
|
|
|
|
|
2017-07-13 18:48:44 -06:00
|
|
|
|
impl Step for ErrorIndex {
|
2017-07-04 19:41:43 -06:00
|
|
|
|
type Output = ();
|
2017-07-05 06:41:27 -06:00
|
|
|
|
const DEFAULT: bool = true;
|
|
|
|
|
const ONLY_HOSTS: bool = true;
|
|
|
|
|
|
2017-07-18 18:03:38 -06:00
|
|
|
|
fn should_run(run: ShouldRun) -> ShouldRun {
|
|
|
|
|
run.path("src/tools/error_index_generator")
|
2017-07-05 06:41:27 -06:00
|
|
|
|
}
|
|
|
|
|
|
2017-07-20 17:51:07 -06:00
|
|
|
|
fn make_run(run: RunConfig) {
|
|
|
|
|
run.builder.ensure(ErrorIndex {
|
|
|
|
|
compiler: run.builder.compiler(run.builder.top_stage, run.host),
|
2017-07-05 06:41:27 -06:00
|
|
|
|
});
|
|
|
|
|
}
|
2017-07-04 19:41:43 -06:00
|
|
|
|
|
|
|
|
|
/// Run the error index generator tool to execute the tests located in the error
|
|
|
|
|
/// index.
|
|
|
|
|
///
|
|
|
|
|
/// The `error_index_generator` tool lives in `src/tools` and is used to
|
|
|
|
|
/// generate a markdown file from the error indexes of the code base which is
|
|
|
|
|
/// then passed to `rustdoc --test`.
|
|
|
|
|
fn run(self, builder: &Builder) {
|
|
|
|
|
let compiler = self.compiler;
|
|
|
|
|
|
2018-05-30 14:33:43 -03:00
|
|
|
|
builder.ensure(compile::Std {
|
|
|
|
|
compiler,
|
|
|
|
|
target: compiler.host,
|
|
|
|
|
});
|
2017-07-05 06:41:27 -06:00
|
|
|
|
|
2018-04-14 17:27:57 -06:00
|
|
|
|
let dir = testdir(builder, compiler.host);
|
2017-07-04 19:41:43 -06:00
|
|
|
|
t!(fs::create_dir_all(&dir));
|
|
|
|
|
let output = dir.join("error-index.md");
|
|
|
|
|
|
2018-03-16 08:35:03 -07:00
|
|
|
|
let mut tool = builder.tool_cmd(Tool::ErrorIndex);
|
|
|
|
|
tool.arg("markdown")
|
|
|
|
|
.arg(&output)
|
2018-04-14 17:27:57 -06:00
|
|
|
|
.env("CFG_BUILD", &builder.config.build)
|
|
|
|
|
.env("RUSTC_ERROR_METADATA_DST", builder.extended_error_dir());
|
2018-03-16 08:35:03 -07:00
|
|
|
|
|
2018-04-14 17:27:57 -06:00
|
|
|
|
let _folder = builder.fold_output(|| "test_error_index");
|
|
|
|
|
builder.info(&format!("Testing error-index stage{}", compiler.stage));
|
|
|
|
|
let _time = util::timeit(&builder);
|
|
|
|
|
builder.run(&mut tool);
|
2017-07-05 11:21:33 -06:00
|
|
|
|
markdown_test(builder, compiler, &output);
|
2017-07-04 19:41:43 -06:00
|
|
|
|
}
|
2016-04-14 18:00:35 -07:00
|
|
|
|
}
|
|
|
|
|
|
2018-02-22 03:25:23 +08:00
|
|
|
|
fn markdown_test(builder: &Builder, compiler: Compiler, markdown: &Path) -> bool {
|
2018-11-16 16:22:06 -05:00
|
|
|
|
match fs::read_to_string(markdown) {
|
|
|
|
|
Ok(contents) => {
|
2018-03-31 19:21:14 -06:00
|
|
|
|
if !contents.contains("```") {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
2018-05-30 14:33:43 -03:00
|
|
|
|
Err(_) => {}
|
2017-06-04 17:55:50 -06:00
|
|
|
|
}
|
|
|
|
|
|
2018-04-14 17:27:57 -06:00
|
|
|
|
builder.info(&format!("doc tests for: {}", markdown.display()));
|
2017-08-04 16:13:01 -06:00
|
|
|
|
let mut cmd = builder.rustdoc_cmd(compiler.host);
|
2018-04-14 17:27:57 -06:00
|
|
|
|
builder.add_rust_test_threads(&mut cmd);
|
2016-04-14 18:00:35 -07:00
|
|
|
|
cmd.arg("--test");
|
|
|
|
|
cmd.arg(markdown);
|
2016-12-12 09:03:35 -08:00
|
|
|
|
cmd.env("RUSTC_BOOTSTRAP", "1");
|
2016-10-29 21:58:52 -04:00
|
|
|
|
|
2018-04-14 17:27:57 -06:00
|
|
|
|
let test_args = builder.config.cmd.test_args().join(" ");
|
2016-10-29 21:58:52 -04:00
|
|
|
|
cmd.arg("--test-args").arg(test_args);
|
|
|
|
|
|
2018-06-07 14:40:36 +02:00
|
|
|
|
if builder.config.verbose_tests {
|
2018-04-14 17:27:57 -06:00
|
|
|
|
try_run(builder, &mut cmd)
|
2018-06-07 14:40:36 +02:00
|
|
|
|
} else {
|
|
|
|
|
try_run_quiet(builder, &mut cmd)
|
2017-05-22 04:27:47 +08:00
|
|
|
|
}
|
2016-04-14 18:00:35 -07:00
|
|
|
|
}
|
2016-04-29 14:23:15 -07:00
|
|
|
|
|
2017-07-13 18:48:44 -06:00
|
|
|
|
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
|
2017-07-18 15:28:53 -06:00
|
|
|
|
pub struct CrateLibrustc {
|
2017-07-13 18:48:44 -06:00
|
|
|
|
compiler: Compiler,
|
|
|
|
|
target: Interned<String>,
|
2017-07-05 06:41:27 -06:00
|
|
|
|
test_kind: TestKind,
|
Change Step to be invoked with a path when in default mode.
Previously, a Step would be able to tell on its own when it was invoked
"by-default" (that is, `./x.py test` was called instead of `./x.py test
some/path`). This commit replaces that functionality, invoking each Step
with each of the paths it has specified as "should be invoked by."
For example, if a step calls `path("src/tools/cargo")` and
`path("src/doc/cargo")` then it's make_run will be called twice, with
"src/tools/cargo" and "src/doc/cargo." This makes it so that default
handling logic is in builder, instead of spread across various Steps.
However, this meant that some Step specifications needed to be updated,
since for example `rustdoc` can be built by `./x.py build
src/librustdoc` or `./x.py build src/tools/rustdoc`. A `PathSet`
abstraction is added that handles this: now, each Step can not only list
`path(...)` but also `paths(&[a, b, ...])` which will make it so that we
don't invoke it with each of the individual paths, instead invoking it
with the first path in the list (though this shouldn't be depended on).
Future work likely consists of implementing a better/easier way for a
given Step to work with "any" crate in-tree, especially those that want
to run tests, build, or check crates in the std, test, or rustc crate
trees. Currently this is rather painful to do as most of the logic is
duplicated across should_run and make_run. It seems likely this can be
abstracted away into builder somehow.
2018-02-11 09:51:58 -07:00
|
|
|
|
krate: Interned<String>,
|
2017-07-05 06:41:27 -06:00
|
|
|
|
}
|
|
|
|
|
|
2017-07-18 15:28:53 -06:00
|
|
|
|
impl Step for CrateLibrustc {
|
2017-07-05 06:41:27 -06:00
|
|
|
|
type Output = ();
|
|
|
|
|
const DEFAULT: bool = true;
|
|
|
|
|
const ONLY_HOSTS: bool = true;
|
|
|
|
|
|
2017-07-18 18:03:38 -06:00
|
|
|
|
fn should_run(run: ShouldRun) -> ShouldRun {
|
|
|
|
|
run.krate("rustc-main")
|
2017-07-05 06:41:27 -06:00
|
|
|
|
}
|
|
|
|
|
|
2017-07-20 17:51:07 -06:00
|
|
|
|
fn make_run(run: RunConfig) {
|
|
|
|
|
let builder = run.builder;
|
|
|
|
|
let compiler = builder.compiler(builder.top_stage, run.host);
|
2017-07-05 06:41:27 -06:00
|
|
|
|
|
Change Step to be invoked with a path when in default mode.
Previously, a Step would be able to tell on its own when it was invoked
"by-default" (that is, `./x.py test` was called instead of `./x.py test
some/path`). This commit replaces that functionality, invoking each Step
with each of the paths it has specified as "should be invoked by."
For example, if a step calls `path("src/tools/cargo")` and
`path("src/doc/cargo")` then it's make_run will be called twice, with
"src/tools/cargo" and "src/doc/cargo." This makes it so that default
handling logic is in builder, instead of spread across various Steps.
However, this meant that some Step specifications needed to be updated,
since for example `rustdoc` can be built by `./x.py build
src/librustdoc` or `./x.py build src/tools/rustdoc`. A `PathSet`
abstraction is added that handles this: now, each Step can not only list
`path(...)` but also `paths(&[a, b, ...])` which will make it so that we
don't invoke it with each of the individual paths, instead invoking it
with the first path in the list (though this shouldn't be depended on).
Future work likely consists of implementing a better/easier way for a
given Step to work with "any" crate in-tree, especially those that want
to run tests, build, or check crates in the std, test, or rustc crate
trees. Currently this is rather painful to do as most of the logic is
duplicated across should_run and make_run. It seems likely this can be
abstracted away into builder somehow.
2018-02-11 09:51:58 -07:00
|
|
|
|
for krate in builder.in_tree_crates("rustc-main") {
|
|
|
|
|
if run.path.ends_with(&krate.path) {
|
2018-05-16 17:18:19 +02:00
|
|
|
|
let test_kind = builder.kind.into();
|
2017-07-05 06:41:27 -06:00
|
|
|
|
|
Change Step to be invoked with a path when in default mode.
Previously, a Step would be able to tell on its own when it was invoked
"by-default" (that is, `./x.py test` was called instead of `./x.py test
some/path`). This commit replaces that functionality, invoking each Step
with each of the paths it has specified as "should be invoked by."
For example, if a step calls `path("src/tools/cargo")` and
`path("src/doc/cargo")` then it's make_run will be called twice, with
"src/tools/cargo" and "src/doc/cargo." This makes it so that default
handling logic is in builder, instead of spread across various Steps.
However, this meant that some Step specifications needed to be updated,
since for example `rustdoc` can be built by `./x.py build
src/librustdoc` or `./x.py build src/tools/rustdoc`. A `PathSet`
abstraction is added that handles this: now, each Step can not only list
`path(...)` but also `paths(&[a, b, ...])` which will make it so that we
don't invoke it with each of the individual paths, instead invoking it
with the first path in the list (though this shouldn't be depended on).
Future work likely consists of implementing a better/easier way for a
given Step to work with "any" crate in-tree, especially those that want
to run tests, build, or check crates in the std, test, or rustc crate
trees. Currently this is rather painful to do as most of the logic is
duplicated across should_run and make_run. It seems likely this can be
abstracted away into builder somehow.
2018-02-11 09:51:58 -07:00
|
|
|
|
builder.ensure(CrateLibrustc {
|
|
|
|
|
compiler,
|
|
|
|
|
target: run.target,
|
|
|
|
|
test_kind,
|
|
|
|
|
krate: krate.name,
|
|
|
|
|
});
|
2017-07-05 06:41:27 -06:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn run(self, builder: &Builder) {
|
2017-07-18 15:28:53 -06:00
|
|
|
|
builder.ensure(Crate {
|
2017-07-05 06:41:27 -06:00
|
|
|
|
compiler: self.compiler,
|
|
|
|
|
target: self.target,
|
2018-05-19 23:04:41 +03:00
|
|
|
|
mode: Mode::Rustc,
|
2017-07-05 06:41:27 -06:00
|
|
|
|
test_kind: self.test_kind,
|
|
|
|
|
krate: self.krate,
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
Change Step to be invoked with a path when in default mode.
Previously, a Step would be able to tell on its own when it was invoked
"by-default" (that is, `./x.py test` was called instead of `./x.py test
some/path`). This commit replaces that functionality, invoking each Step
with each of the paths it has specified as "should be invoked by."
For example, if a step calls `path("src/tools/cargo")` and
`path("src/doc/cargo")` then it's make_run will be called twice, with
"src/tools/cargo" and "src/doc/cargo." This makes it so that default
handling logic is in builder, instead of spread across various Steps.
However, this meant that some Step specifications needed to be updated,
since for example `rustdoc` can be built by `./x.py build
src/librustdoc` or `./x.py build src/tools/rustdoc`. A `PathSet`
abstraction is added that handles this: now, each Step can not only list
`path(...)` but also `paths(&[a, b, ...])` which will make it so that we
don't invoke it with each of the individual paths, instead invoking it
with the first path in the list (though this shouldn't be depended on).
Future work likely consists of implementing a better/easier way for a
given Step to work with "any" crate in-tree, especially those that want
to run tests, build, or check crates in the std, test, or rustc crate
trees. Currently this is rather painful to do as most of the logic is
duplicated across should_run and make_run. It seems likely this can be
abstracted away into builder somehow.
2018-02-11 09:51:58 -07:00
|
|
|
|
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
|
|
|
|
|
pub struct CrateNotDefault {
|
|
|
|
|
compiler: Compiler,
|
|
|
|
|
target: Interned<String>,
|
|
|
|
|
test_kind: TestKind,
|
|
|
|
|
krate: &'static str,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl Step for CrateNotDefault {
|
|
|
|
|
type Output = ();
|
|
|
|
|
|
|
|
|
|
fn should_run(run: ShouldRun) -> ShouldRun {
|
2018-10-20 19:04:42 -07:00
|
|
|
|
run.path("src/librustc_asan")
|
Change Step to be invoked with a path when in default mode.
Previously, a Step would be able to tell on its own when it was invoked
"by-default" (that is, `./x.py test` was called instead of `./x.py test
some/path`). This commit replaces that functionality, invoking each Step
with each of the paths it has specified as "should be invoked by."
For example, if a step calls `path("src/tools/cargo")` and
`path("src/doc/cargo")` then it's make_run will be called twice, with
"src/tools/cargo" and "src/doc/cargo." This makes it so that default
handling logic is in builder, instead of spread across various Steps.
However, this meant that some Step specifications needed to be updated,
since for example `rustdoc` can be built by `./x.py build
src/librustdoc` or `./x.py build src/tools/rustdoc`. A `PathSet`
abstraction is added that handles this: now, each Step can not only list
`path(...)` but also `paths(&[a, b, ...])` which will make it so that we
don't invoke it with each of the individual paths, instead invoking it
with the first path in the list (though this shouldn't be depended on).
Future work likely consists of implementing a better/easier way for a
given Step to work with "any" crate in-tree, especially those that want
to run tests, build, or check crates in the std, test, or rustc crate
trees. Currently this is rather painful to do as most of the logic is
duplicated across should_run and make_run. It seems likely this can be
abstracted away into builder somehow.
2018-02-11 09:51:58 -07:00
|
|
|
|
.path("src/librustc_lsan")
|
|
|
|
|
.path("src/librustc_msan")
|
|
|
|
|
.path("src/librustc_tsan")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn make_run(run: RunConfig) {
|
|
|
|
|
let builder = run.builder;
|
|
|
|
|
let compiler = builder.compiler(builder.top_stage, run.host);
|
|
|
|
|
|
2018-05-16 17:18:19 +02:00
|
|
|
|
let test_kind = builder.kind.into();
|
Change Step to be invoked with a path when in default mode.
Previously, a Step would be able to tell on its own when it was invoked
"by-default" (that is, `./x.py test` was called instead of `./x.py test
some/path`). This commit replaces that functionality, invoking each Step
with each of the paths it has specified as "should be invoked by."
For example, if a step calls `path("src/tools/cargo")` and
`path("src/doc/cargo")` then it's make_run will be called twice, with
"src/tools/cargo" and "src/doc/cargo." This makes it so that default
handling logic is in builder, instead of spread across various Steps.
However, this meant that some Step specifications needed to be updated,
since for example `rustdoc` can be built by `./x.py build
src/librustdoc` or `./x.py build src/tools/rustdoc`. A `PathSet`
abstraction is added that handles this: now, each Step can not only list
`path(...)` but also `paths(&[a, b, ...])` which will make it so that we
don't invoke it with each of the individual paths, instead invoking it
with the first path in the list (though this shouldn't be depended on).
Future work likely consists of implementing a better/easier way for a
given Step to work with "any" crate in-tree, especially those that want
to run tests, build, or check crates in the std, test, or rustc crate
trees. Currently this is rather painful to do as most of the logic is
duplicated across should_run and make_run. It seems likely this can be
abstracted away into builder somehow.
2018-02-11 09:51:58 -07:00
|
|
|
|
|
|
|
|
|
builder.ensure(CrateNotDefault {
|
|
|
|
|
compiler,
|
|
|
|
|
target: run.target,
|
|
|
|
|
test_kind,
|
|
|
|
|
krate: match run.path {
|
|
|
|
|
_ if run.path.ends_with("src/librustc_asan") => "rustc_asan",
|
|
|
|
|
_ if run.path.ends_with("src/librustc_lsan") => "rustc_lsan",
|
|
|
|
|
_ if run.path.ends_with("src/librustc_msan") => "rustc_msan",
|
|
|
|
|
_ if run.path.ends_with("src/librustc_tsan") => "rustc_tsan",
|
|
|
|
|
_ => panic!("unexpected path {:?}", run.path),
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn run(self, builder: &Builder) {
|
|
|
|
|
builder.ensure(Crate {
|
|
|
|
|
compiler: self.compiler,
|
|
|
|
|
target: self.target,
|
2018-05-19 23:04:41 +03:00
|
|
|
|
mode: Mode::Std,
|
Change Step to be invoked with a path when in default mode.
Previously, a Step would be able to tell on its own when it was invoked
"by-default" (that is, `./x.py test` was called instead of `./x.py test
some/path`). This commit replaces that functionality, invoking each Step
with each of the paths it has specified as "should be invoked by."
For example, if a step calls `path("src/tools/cargo")` and
`path("src/doc/cargo")` then it's make_run will be called twice, with
"src/tools/cargo" and "src/doc/cargo." This makes it so that default
handling logic is in builder, instead of spread across various Steps.
However, this meant that some Step specifications needed to be updated,
since for example `rustdoc` can be built by `./x.py build
src/librustdoc` or `./x.py build src/tools/rustdoc`. A `PathSet`
abstraction is added that handles this: now, each Step can not only list
`path(...)` but also `paths(&[a, b, ...])` which will make it so that we
don't invoke it with each of the individual paths, instead invoking it
with the first path in the list (though this shouldn't be depended on).
Future work likely consists of implementing a better/easier way for a
given Step to work with "any" crate in-tree, especially those that want
to run tests, build, or check crates in the std, test, or rustc crate
trees. Currently this is rather painful to do as most of the logic is
duplicated across should_run and make_run. It seems likely this can be
abstracted away into builder somehow.
2018-02-11 09:51:58 -07:00
|
|
|
|
test_kind: self.test_kind,
|
|
|
|
|
krate: INTERNER.intern_str(self.krate),
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-05-06 02:33:01 +08:00
|
|
|
|
#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
2017-07-18 15:28:53 -06:00
|
|
|
|
pub struct Crate {
|
2018-05-06 02:33:01 +08:00
|
|
|
|
pub compiler: Compiler,
|
|
|
|
|
pub target: Interned<String>,
|
|
|
|
|
pub mode: Mode,
|
|
|
|
|
pub test_kind: TestKind,
|
|
|
|
|
pub krate: Interned<String>,
|
2017-07-04 19:41:43 -06:00
|
|
|
|
}
|
2016-04-29 14:23:15 -07:00
|
|
|
|
|
2017-07-18 15:28:53 -06:00
|
|
|
|
impl Step for Crate {
|
2017-07-04 19:41:43 -06:00
|
|
|
|
type Output = ();
|
2017-07-05 06:41:27 -06:00
|
|
|
|
const DEFAULT: bool = true;
|
|
|
|
|
|
Change Step to be invoked with a path when in default mode.
Previously, a Step would be able to tell on its own when it was invoked
"by-default" (that is, `./x.py test` was called instead of `./x.py test
some/path`). This commit replaces that functionality, invoking each Step
with each of the paths it has specified as "should be invoked by."
For example, if a step calls `path("src/tools/cargo")` and
`path("src/doc/cargo")` then it's make_run will be called twice, with
"src/tools/cargo" and "src/doc/cargo." This makes it so that default
handling logic is in builder, instead of spread across various Steps.
However, this meant that some Step specifications needed to be updated,
since for example `rustdoc` can be built by `./x.py build
src/librustdoc` or `./x.py build src/tools/rustdoc`. A `PathSet`
abstraction is added that handles this: now, each Step can not only list
`path(...)` but also `paths(&[a, b, ...])` which will make it so that we
don't invoke it with each of the individual paths, instead invoking it
with the first path in the list (though this shouldn't be depended on).
Future work likely consists of implementing a better/easier way for a
given Step to work with "any" crate in-tree, especially those that want
to run tests, build, or check crates in the std, test, or rustc crate
trees. Currently this is rather painful to do as most of the logic is
duplicated across should_run and make_run. It seems likely this can be
abstracted away into builder somehow.
2018-02-11 09:51:58 -07:00
|
|
|
|
fn should_run(mut run: ShouldRun) -> ShouldRun {
|
|
|
|
|
let builder = run.builder;
|
|
|
|
|
run = run.krate("test");
|
|
|
|
|
for krate in run.builder.in_tree_crates("std") {
|
std: Depend directly on crates.io crates
Ever since we added a Cargo-based build system for the compiler the
standard library has always been a little special, it's never been able
to depend on crates.io crates for runtime dependencies. This has been a
result of various limitations, namely that Cargo doesn't understand that
crates from crates.io depend on libcore, so Cargo tries to build crates
before libcore is finished.
I had an idea this afternoon, however, which lifts the strategy
from #52919 to directly depend on crates.io crates from the standard
library. After all is said and done this removes a whopping three
submodules that we need to manage!
The basic idea here is that for any crate `std` depends on it adds an
*optional* dependency on an empty crate on crates.io, in this case named
`rustc-std-workspace-core`. This crate is overridden via `[patch]` in
this repository to point to a local crate we write, and *that* has a
`path` dependency on libcore.
Note that all `no_std` crates also depend on `compiler_builtins`, but if
we're not using submodules we can publish `compiler_builtins` to
crates.io and all crates can depend on it anyway! The basic strategy
then looks like:
* The standard library (or some transitive dep) decides to depend on a
crate `foo`.
* The standard library adds
```toml
[dependencies]
foo = { version = "0.1", features = ['rustc-dep-of-std'] }
```
* The crate `foo` has an optional dependency on `rustc-std-workspace-core`
* The crate `foo` has an optional dependency on `compiler_builtins`
* The crate `foo` has a feature `rustc-dep-of-std` which activates these
crates and any other necessary infrastructure in the crate.
A sample commit for `dlmalloc` [turns out to be quite simple][commit].
After that all `no_std` crates should largely build "as is" and still be
publishable on crates.io! Notably they should be able to continue to use
stable Rust if necessary, since the `rename-dependency` feature of Cargo
is soon stabilizing.
As a proof of concept, this commit removes the `dlmalloc`,
`libcompiler_builtins`, and `libc` submodules from this repository. Long
thorns in our side these are now gone for good and we can directly
depend on crates.io! It's hoped that in the long term we can bring in
other crates as necessary, but for now this is largely intended to
simply make it easier to manage these crates and remove submodules.
This should be a transparent non-breaking change for all users, but one
possible stickler is that this almost for sure breaks out-of-tree
`std`-building tools like `xargo` and `cargo-xbuild`. I think it should
be relatively easy to get them working, however, as all that's needed is
an entry in the `[patch]` section used to build the standard library.
Hopefully we can work with these tools to solve this problem!
[commit]: https://github.com/alexcrichton/dlmalloc-rs/commit/28ee12db813a3b650a7c25d1c36d2c17dcb88ae3
2018-11-19 21:52:50 -08:00
|
|
|
|
if !(krate.name.starts_with("rustc_") && krate.name.ends_with("san")) {
|
Change Step to be invoked with a path when in default mode.
Previously, a Step would be able to tell on its own when it was invoked
"by-default" (that is, `./x.py test` was called instead of `./x.py test
some/path`). This commit replaces that functionality, invoking each Step
with each of the paths it has specified as "should be invoked by."
For example, if a step calls `path("src/tools/cargo")` and
`path("src/doc/cargo")` then it's make_run will be called twice, with
"src/tools/cargo" and "src/doc/cargo." This makes it so that default
handling logic is in builder, instead of spread across various Steps.
However, this meant that some Step specifications needed to be updated,
since for example `rustdoc` can be built by `./x.py build
src/librustdoc` or `./x.py build src/tools/rustdoc`. A `PathSet`
abstraction is added that handles this: now, each Step can not only list
`path(...)` but also `paths(&[a, b, ...])` which will make it so that we
don't invoke it with each of the individual paths, instead invoking it
with the first path in the list (though this shouldn't be depended on).
Future work likely consists of implementing a better/easier way for a
given Step to work with "any" crate in-tree, especially those that want
to run tests, build, or check crates in the std, test, or rustc crate
trees. Currently this is rather painful to do as most of the logic is
duplicated across should_run and make_run. It seems likely this can be
abstracted away into builder somehow.
2018-02-11 09:51:58 -07:00
|
|
|
|
run = run.path(krate.local_path(&builder).to_str().unwrap());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
run
|
2017-07-05 06:41:27 -06:00
|
|
|
|
}
|
|
|
|
|
|
2017-07-20 17:51:07 -06:00
|
|
|
|
fn make_run(run: RunConfig) {
|
|
|
|
|
let builder = run.builder;
|
|
|
|
|
let compiler = builder.compiler(builder.top_stage, run.host);
|
2017-07-05 06:41:27 -06:00
|
|
|
|
|
Change Step to be invoked with a path when in default mode.
Previously, a Step would be able to tell on its own when it was invoked
"by-default" (that is, `./x.py test` was called instead of `./x.py test
some/path`). This commit replaces that functionality, invoking each Step
with each of the paths it has specified as "should be invoked by."
For example, if a step calls `path("src/tools/cargo")` and
`path("src/doc/cargo")` then it's make_run will be called twice, with
"src/tools/cargo" and "src/doc/cargo." This makes it so that default
handling logic is in builder, instead of spread across various Steps.
However, this meant that some Step specifications needed to be updated,
since for example `rustdoc` can be built by `./x.py build
src/librustdoc` or `./x.py build src/tools/rustdoc`. A `PathSet`
abstraction is added that handles this: now, each Step can not only list
`path(...)` but also `paths(&[a, b, ...])` which will make it so that we
don't invoke it with each of the individual paths, instead invoking it
with the first path in the list (though this shouldn't be depended on).
Future work likely consists of implementing a better/easier way for a
given Step to work with "any" crate in-tree, especially those that want
to run tests, build, or check crates in the std, test, or rustc crate
trees. Currently this is rather painful to do as most of the logic is
duplicated across should_run and make_run. It seems likely this can be
abstracted away into builder somehow.
2018-02-11 09:51:58 -07:00
|
|
|
|
let make = |mode: Mode, krate: &CargoCrate| {
|
2018-05-16 17:18:19 +02:00
|
|
|
|
let test_kind = builder.kind.into();
|
2017-07-05 06:41:27 -06:00
|
|
|
|
|
2017-07-18 15:28:53 -06:00
|
|
|
|
builder.ensure(Crate {
|
2017-07-20 17:51:07 -06:00
|
|
|
|
compiler,
|
|
|
|
|
target: run.target,
|
2017-08-06 22:54:09 -07:00
|
|
|
|
mode,
|
|
|
|
|
test_kind,
|
Change Step to be invoked with a path when in default mode.
Previously, a Step would be able to tell on its own when it was invoked
"by-default" (that is, `./x.py test` was called instead of `./x.py test
some/path`). This commit replaces that functionality, invoking each Step
with each of the paths it has specified as "should be invoked by."
For example, if a step calls `path("src/tools/cargo")` and
`path("src/doc/cargo")` then it's make_run will be called twice, with
"src/tools/cargo" and "src/doc/cargo." This makes it so that default
handling logic is in builder, instead of spread across various Steps.
However, this meant that some Step specifications needed to be updated,
since for example `rustdoc` can be built by `./x.py build
src/librustdoc` or `./x.py build src/tools/rustdoc`. A `PathSet`
abstraction is added that handles this: now, each Step can not only list
`path(...)` but also `paths(&[a, b, ...])` which will make it so that we
don't invoke it with each of the individual paths, instead invoking it
with the first path in the list (though this shouldn't be depended on).
Future work likely consists of implementing a better/easier way for a
given Step to work with "any" crate in-tree, especially those that want
to run tests, build, or check crates in the std, test, or rustc crate
trees. Currently this is rather painful to do as most of the logic is
duplicated across should_run and make_run. It seems likely this can be
abstracted away into builder somehow.
2018-02-11 09:51:58 -07:00
|
|
|
|
krate: krate.name,
|
2017-07-05 06:41:27 -06:00
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
Change Step to be invoked with a path when in default mode.
Previously, a Step would be able to tell on its own when it was invoked
"by-default" (that is, `./x.py test` was called instead of `./x.py test
some/path`). This commit replaces that functionality, invoking each Step
with each of the paths it has specified as "should be invoked by."
For example, if a step calls `path("src/tools/cargo")` and
`path("src/doc/cargo")` then it's make_run will be called twice, with
"src/tools/cargo" and "src/doc/cargo." This makes it so that default
handling logic is in builder, instead of spread across various Steps.
However, this meant that some Step specifications needed to be updated,
since for example `rustdoc` can be built by `./x.py build
src/librustdoc` or `./x.py build src/tools/rustdoc`. A `PathSet`
abstraction is added that handles this: now, each Step can not only list
`path(...)` but also `paths(&[a, b, ...])` which will make it so that we
don't invoke it with each of the individual paths, instead invoking it
with the first path in the list (though this shouldn't be depended on).
Future work likely consists of implementing a better/easier way for a
given Step to work with "any" crate in-tree, especially those that want
to run tests, build, or check crates in the std, test, or rustc crate
trees. Currently this is rather painful to do as most of the logic is
duplicated across should_run and make_run. It seems likely this can be
abstracted away into builder somehow.
2018-02-11 09:51:58 -07:00
|
|
|
|
for krate in builder.in_tree_crates("std") {
|
|
|
|
|
if run.path.ends_with(&krate.local_path(&builder)) {
|
2018-05-19 23:04:41 +03:00
|
|
|
|
make(Mode::Std, krate);
|
2017-07-05 06:41:27 -06:00
|
|
|
|
}
|
Change Step to be invoked with a path when in default mode.
Previously, a Step would be able to tell on its own when it was invoked
"by-default" (that is, `./x.py test` was called instead of `./x.py test
some/path`). This commit replaces that functionality, invoking each Step
with each of the paths it has specified as "should be invoked by."
For example, if a step calls `path("src/tools/cargo")` and
`path("src/doc/cargo")` then it's make_run will be called twice, with
"src/tools/cargo" and "src/doc/cargo." This makes it so that default
handling logic is in builder, instead of spread across various Steps.
However, this meant that some Step specifications needed to be updated,
since for example `rustdoc` can be built by `./x.py build
src/librustdoc` or `./x.py build src/tools/rustdoc`. A `PathSet`
abstraction is added that handles this: now, each Step can not only list
`path(...)` but also `paths(&[a, b, ...])` which will make it so that we
don't invoke it with each of the individual paths, instead invoking it
with the first path in the list (though this shouldn't be depended on).
Future work likely consists of implementing a better/easier way for a
given Step to work with "any" crate in-tree, especially those that want
to run tests, build, or check crates in the std, test, or rustc crate
trees. Currently this is rather painful to do as most of the logic is
duplicated across should_run and make_run. It seems likely this can be
abstracted away into builder somehow.
2018-02-11 09:51:58 -07:00
|
|
|
|
}
|
|
|
|
|
for krate in builder.in_tree_crates("test") {
|
|
|
|
|
if run.path.ends_with(&krate.local_path(&builder)) {
|
2018-05-19 23:04:41 +03:00
|
|
|
|
make(Mode::Test, krate);
|
2017-07-05 06:41:27 -06:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2017-07-04 19:41:43 -06:00
|
|
|
|
|
Change Step to be invoked with a path when in default mode.
Previously, a Step would be able to tell on its own when it was invoked
"by-default" (that is, `./x.py test` was called instead of `./x.py test
some/path`). This commit replaces that functionality, invoking each Step
with each of the paths it has specified as "should be invoked by."
For example, if a step calls `path("src/tools/cargo")` and
`path("src/doc/cargo")` then it's make_run will be called twice, with
"src/tools/cargo" and "src/doc/cargo." This makes it so that default
handling logic is in builder, instead of spread across various Steps.
However, this meant that some Step specifications needed to be updated,
since for example `rustdoc` can be built by `./x.py build
src/librustdoc` or `./x.py build src/tools/rustdoc`. A `PathSet`
abstraction is added that handles this: now, each Step can not only list
`path(...)` but also `paths(&[a, b, ...])` which will make it so that we
don't invoke it with each of the individual paths, instead invoking it
with the first path in the list (though this shouldn't be depended on).
Future work likely consists of implementing a better/easier way for a
given Step to work with "any" crate in-tree, especially those that want
to run tests, build, or check crates in the std, test, or rustc crate
trees. Currently this is rather painful to do as most of the logic is
duplicated across should_run and make_run. It seems likely this can be
abstracted away into builder somehow.
2018-02-11 09:51:58 -07:00
|
|
|
|
/// Run all unit tests plus documentation tests for a given crate defined
|
|
|
|
|
/// by a `Cargo.toml` (single manifest)
|
2017-07-04 19:41:43 -06:00
|
|
|
|
///
|
|
|
|
|
/// This is what runs tests for crates like the standard library, compiler, etc.
|
|
|
|
|
/// It essentially is the driver for running `cargo test`.
|
|
|
|
|
///
|
|
|
|
|
/// Currently this runs all tests for a DAG by passing a bunch of `-p foo`
|
|
|
|
|
/// arguments, and those arguments are discovered from `cargo metadata`.
|
|
|
|
|
fn run(self, builder: &Builder) {
|
|
|
|
|
let compiler = self.compiler;
|
|
|
|
|
let target = self.target;
|
|
|
|
|
let mode = self.mode;
|
|
|
|
|
let test_kind = self.test_kind;
|
|
|
|
|
let krate = self.krate;
|
|
|
|
|
|
2017-07-05 06:41:27 -06:00
|
|
|
|
builder.ensure(compile::Test { compiler, target });
|
|
|
|
|
builder.ensure(RemoteCopyLibs { compiler, target });
|
2017-07-17 09:32:08 -07:00
|
|
|
|
|
|
|
|
|
// If we're not doing a full bootstrap but we're testing a stage2 version of
|
|
|
|
|
// libstd, then what we're actually testing is the libstd produced in
|
|
|
|
|
// stage1. Reflect that here by updating the compiler that we're working
|
|
|
|
|
// with automatically.
|
2018-04-14 17:27:57 -06:00
|
|
|
|
let compiler = if builder.force_use_stage1(compiler, target) {
|
2017-07-17 09:32:08 -07:00
|
|
|
|
builder.compiler(1, compiler.host)
|
|
|
|
|
} else {
|
|
|
|
|
compiler.clone()
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
let mut cargo = builder.cargo(compiler, mode, target, test_kind.subcommand());
|
Change Step to be invoked with a path when in default mode.
Previously, a Step would be able to tell on its own when it was invoked
"by-default" (that is, `./x.py test` was called instead of `./x.py test
some/path`). This commit replaces that functionality, invoking each Step
with each of the paths it has specified as "should be invoked by."
For example, if a step calls `path("src/tools/cargo")` and
`path("src/doc/cargo")` then it's make_run will be called twice, with
"src/tools/cargo" and "src/doc/cargo." This makes it so that default
handling logic is in builder, instead of spread across various Steps.
However, this meant that some Step specifications needed to be updated,
since for example `rustdoc` can be built by `./x.py build
src/librustdoc` or `./x.py build src/tools/rustdoc`. A `PathSet`
abstraction is added that handles this: now, each Step can not only list
`path(...)` but also `paths(&[a, b, ...])` which will make it so that we
don't invoke it with each of the individual paths, instead invoking it
with the first path in the list (though this shouldn't be depended on).
Future work likely consists of implementing a better/easier way for a
given Step to work with "any" crate in-tree, especially those that want
to run tests, build, or check crates in the std, test, or rustc crate
trees. Currently this is rather painful to do as most of the logic is
duplicated across should_run and make_run. It seems likely this can be
abstracted away into builder somehow.
2018-02-11 09:51:58 -07:00
|
|
|
|
match mode {
|
2018-05-19 23:04:41 +03:00
|
|
|
|
Mode::Std => {
|
2018-03-05 09:47:54 -08:00
|
|
|
|
compile::std_cargo(builder, &compiler, target, &mut cargo);
|
2017-07-04 19:41:43 -06:00
|
|
|
|
}
|
2018-05-19 23:04:41 +03:00
|
|
|
|
Mode::Test => {
|
2018-04-14 17:27:57 -06:00
|
|
|
|
compile::test_cargo(builder, &compiler, target, &mut cargo);
|
2017-07-04 19:41:43 -06:00
|
|
|
|
}
|
2018-05-19 23:04:41 +03:00
|
|
|
|
Mode::Rustc => {
|
2017-07-12 10:12:47 -06:00
|
|
|
|
builder.ensure(compile::Rustc { compiler, target });
|
2018-04-14 17:27:57 -06:00
|
|
|
|
compile::rustc_cargo(builder, &mut cargo);
|
2017-07-04 19:41:43 -06:00
|
|
|
|
}
|
|
|
|
|
_ => panic!("can only test libraries"),
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// Build up the base `cargo test` command.
|
|
|
|
|
//
|
|
|
|
|
// Pass in some standard flags then iterate over the graph we've discovered
|
|
|
|
|
// in `cargo metadata` with the maps above and figure out what `-p`
|
|
|
|
|
// arguments need to get passed.
|
2018-04-14 17:27:57 -06:00
|
|
|
|
if test_kind.subcommand() == "test" && !builder.fail_fast {
|
2017-07-04 19:41:43 -06:00
|
|
|
|
cargo.arg("--no-fail-fast");
|
|
|
|
|
}
|
2018-05-06 00:04:06 +08:00
|
|
|
|
match builder.doc_tests {
|
2018-05-06 03:30:42 +08:00
|
|
|
|
DocTests::Only => {
|
2018-05-06 00:04:06 +08:00
|
|
|
|
cargo.arg("--doc");
|
|
|
|
|
}
|
2018-05-06 03:30:42 +08:00
|
|
|
|
DocTests::No => {
|
2018-05-06 00:04:06 +08:00
|
|
|
|
cargo.args(&["--lib", "--bins", "--examples", "--tests", "--benches"]);
|
|
|
|
|
}
|
2018-05-06 03:30:42 +08:00
|
|
|
|
DocTests::Yes => {}
|
2018-02-17 15:45:39 +01:00
|
|
|
|
}
|
2017-07-04 19:41:43 -06:00
|
|
|
|
|
Change Step to be invoked with a path when in default mode.
Previously, a Step would be able to tell on its own when it was invoked
"by-default" (that is, `./x.py test` was called instead of `./x.py test
some/path`). This commit replaces that functionality, invoking each Step
with each of the paths it has specified as "should be invoked by."
For example, if a step calls `path("src/tools/cargo")` and
`path("src/doc/cargo")` then it's make_run will be called twice, with
"src/tools/cargo" and "src/doc/cargo." This makes it so that default
handling logic is in builder, instead of spread across various Steps.
However, this meant that some Step specifications needed to be updated,
since for example `rustdoc` can be built by `./x.py build
src/librustdoc` or `./x.py build src/tools/rustdoc`. A `PathSet`
abstraction is added that handles this: now, each Step can not only list
`path(...)` but also `paths(&[a, b, ...])` which will make it so that we
don't invoke it with each of the individual paths, instead invoking it
with the first path in the list (though this shouldn't be depended on).
Future work likely consists of implementing a better/easier way for a
given Step to work with "any" crate in-tree, especially those that want
to run tests, build, or check crates in the std, test, or rustc crate
trees. Currently this is rather painful to do as most of the logic is
duplicated across should_run and make_run. It seems likely this can be
abstracted away into builder somehow.
2018-02-11 09:51:58 -07:00
|
|
|
|
cargo.arg("-p").arg(krate);
|
2016-11-16 12:31:19 -08:00
|
|
|
|
|
2017-07-04 19:41:43 -06:00
|
|
|
|
// The tests are going to run with the *target* libraries, so we need to
|
|
|
|
|
// ensure that those libraries show up in the LD_LIBRARY_PATH equivalent.
|
|
|
|
|
//
|
|
|
|
|
// Note that to run the compiler we need to run with the *host* libraries,
|
|
|
|
|
// but our wrapper scripts arrange for that to be the case anyway.
|
|
|
|
|
let mut dylib_path = dylib_path();
|
2017-07-13 18:48:44 -06:00
|
|
|
|
dylib_path.insert(0, PathBuf::from(&*builder.sysroot_libdir(compiler, target)));
|
2017-07-04 19:41:43 -06:00
|
|
|
|
cargo.env(dylib_path_var(), env::join_paths(&dylib_path).unwrap());
|
|
|
|
|
|
|
|
|
|
cargo.arg("--");
|
2018-04-14 17:27:57 -06:00
|
|
|
|
cargo.args(&builder.config.cmd.test_args());
|
2016-10-29 21:58:52 -04:00
|
|
|
|
|
2018-06-07 14:40:36 +02:00
|
|
|
|
if !builder.config.verbose_tests {
|
2017-07-04 19:41:43 -06:00
|
|
|
|
cargo.arg("--quiet");
|
|
|
|
|
}
|
2016-11-16 12:31:19 -08:00
|
|
|
|
|
2017-07-04 19:41:43 -06:00
|
|
|
|
if target.contains("emscripten") {
|
2018-05-30 14:33:43 -03:00
|
|
|
|
cargo.env(
|
|
|
|
|
format!("CARGO_TARGET_{}_RUNNER", envify(&target)),
|
|
|
|
|
builder
|
|
|
|
|
.config
|
|
|
|
|
.nodejs
|
|
|
|
|
.as_ref()
|
|
|
|
|
.expect("nodejs not configured"),
|
|
|
|
|
);
|
2017-12-06 09:25:29 +01:00
|
|
|
|
} else if target.starts_with("wasm32") {
|
2018-01-11 17:51:49 +00:00
|
|
|
|
// Warn about running tests without the `wasm_syscall` feature enabled.
|
|
|
|
|
// The javascript shim implements the syscall interface so that test
|
|
|
|
|
// output can be correctly reported.
|
2018-04-14 17:27:57 -06:00
|
|
|
|
if !builder.config.wasm_syscall {
|
2018-10-26 16:23:02 +02:00
|
|
|
|
builder.info(
|
2018-05-30 14:33:43 -03:00
|
|
|
|
"Libstd was built without `wasm_syscall` feature enabled: \
|
|
|
|
|
test output may not be visible."
|
2018-10-26 16:23:02 +02:00
|
|
|
|
);
|
2018-01-11 17:51:49 +00:00
|
|
|
|
}
|
|
|
|
|
|
2017-12-06 09:25:29 +01:00
|
|
|
|
// On the wasm32-unknown-unknown target we're using LTO which is
|
|
|
|
|
// incompatible with `-C prefer-dynamic`, so disable that here
|
|
|
|
|
cargo.env("RUSTC_NO_PREFER_DYNAMIC", "1");
|
|
|
|
|
|
2018-05-30 14:33:43 -03:00
|
|
|
|
let node = builder
|
|
|
|
|
.config
|
|
|
|
|
.nodejs
|
|
|
|
|
.as_ref()
|
2017-12-06 09:25:29 +01:00
|
|
|
|
.expect("nodejs not configured");
|
2018-05-30 14:33:43 -03:00
|
|
|
|
let runner = format!(
|
|
|
|
|
"{} {}/src/etc/wasm32-shim.js",
|
|
|
|
|
node.display(),
|
|
|
|
|
builder.src.display()
|
|
|
|
|
);
|
2017-12-06 09:25:29 +01:00
|
|
|
|
cargo.env(format!("CARGO_TARGET_{}_RUNNER", envify(&target)), &runner);
|
2018-04-14 17:27:57 -06:00
|
|
|
|
} else if builder.remote_tested(target) {
|
2018-05-30 14:33:43 -03:00
|
|
|
|
cargo.env(
|
|
|
|
|
format!("CARGO_TARGET_{}_RUNNER", envify(&target)),
|
|
|
|
|
format!("{} run", builder.tool_exe(Tool::RemoteTestClient).display()),
|
|
|
|
|
);
|
2017-01-28 13:38:06 -08:00
|
|
|
|
}
|
2018-03-16 08:35:03 -07:00
|
|
|
|
|
2018-04-14 17:27:57 -06:00
|
|
|
|
let _folder = builder.fold_output(|| {
|
2018-05-30 14:33:43 -03:00
|
|
|
|
format!(
|
|
|
|
|
"{}_stage{}-{}",
|
|
|
|
|
test_kind.subcommand(),
|
|
|
|
|
compiler.stage,
|
|
|
|
|
krate
|
|
|
|
|
)
|
2018-03-16 08:35:03 -07:00
|
|
|
|
});
|
2018-05-30 14:33:43 -03:00
|
|
|
|
builder.info(&format!(
|
|
|
|
|
"{} {} stage{} ({} -> {})",
|
|
|
|
|
test_kind, krate, compiler.stage, &compiler.host, target
|
|
|
|
|
));
|
2018-04-14 17:27:57 -06:00
|
|
|
|
let _time = util::timeit(&builder);
|
|
|
|
|
try_run(builder, &mut cargo);
|
2017-01-28 13:38:06 -08:00
|
|
|
|
}
|
|
|
|
|
}
|
2016-09-05 19:56:48 -04:00
|
|
|
|
|
2017-09-02 08:02:32 -06:00
|
|
|
|
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
|
Change Step to be invoked with a path when in default mode.
Previously, a Step would be able to tell on its own when it was invoked
"by-default" (that is, `./x.py test` was called instead of `./x.py test
some/path`). This commit replaces that functionality, invoking each Step
with each of the paths it has specified as "should be invoked by."
For example, if a step calls `path("src/tools/cargo")` and
`path("src/doc/cargo")` then it's make_run will be called twice, with
"src/tools/cargo" and "src/doc/cargo." This makes it so that default
handling logic is in builder, instead of spread across various Steps.
However, this meant that some Step specifications needed to be updated,
since for example `rustdoc` can be built by `./x.py build
src/librustdoc` or `./x.py build src/tools/rustdoc`. A `PathSet`
abstraction is added that handles this: now, each Step can not only list
`path(...)` but also `paths(&[a, b, ...])` which will make it so that we
don't invoke it with each of the individual paths, instead invoking it
with the first path in the list (though this shouldn't be depended on).
Future work likely consists of implementing a better/easier way for a
given Step to work with "any" crate in-tree, especially those that want
to run tests, build, or check crates in the std, test, or rustc crate
trees. Currently this is rather painful to do as most of the logic is
duplicated across should_run and make_run. It seems likely this can be
abstracted away into builder somehow.
2018-02-11 09:51:58 -07:00
|
|
|
|
pub struct CrateRustdoc {
|
2017-09-02 08:02:32 -06:00
|
|
|
|
host: Interned<String>,
|
|
|
|
|
test_kind: TestKind,
|
|
|
|
|
}
|
|
|
|
|
|
Change Step to be invoked with a path when in default mode.
Previously, a Step would be able to tell on its own when it was invoked
"by-default" (that is, `./x.py test` was called instead of `./x.py test
some/path`). This commit replaces that functionality, invoking each Step
with each of the paths it has specified as "should be invoked by."
For example, if a step calls `path("src/tools/cargo")` and
`path("src/doc/cargo")` then it's make_run will be called twice, with
"src/tools/cargo" and "src/doc/cargo." This makes it so that default
handling logic is in builder, instead of spread across various Steps.
However, this meant that some Step specifications needed to be updated,
since for example `rustdoc` can be built by `./x.py build
src/librustdoc` or `./x.py build src/tools/rustdoc`. A `PathSet`
abstraction is added that handles this: now, each Step can not only list
`path(...)` but also `paths(&[a, b, ...])` which will make it so that we
don't invoke it with each of the individual paths, instead invoking it
with the first path in the list (though this shouldn't be depended on).
Future work likely consists of implementing a better/easier way for a
given Step to work with "any" crate in-tree, especially those that want
to run tests, build, or check crates in the std, test, or rustc crate
trees. Currently this is rather painful to do as most of the logic is
duplicated across should_run and make_run. It seems likely this can be
abstracted away into builder somehow.
2018-02-11 09:51:58 -07:00
|
|
|
|
impl Step for CrateRustdoc {
|
2017-09-02 08:02:32 -06:00
|
|
|
|
type Output = ();
|
|
|
|
|
const DEFAULT: bool = true;
|
|
|
|
|
const ONLY_HOSTS: bool = true;
|
|
|
|
|
|
|
|
|
|
fn should_run(run: ShouldRun) -> ShouldRun {
|
Change Step to be invoked with a path when in default mode.
Previously, a Step would be able to tell on its own when it was invoked
"by-default" (that is, `./x.py test` was called instead of `./x.py test
some/path`). This commit replaces that functionality, invoking each Step
with each of the paths it has specified as "should be invoked by."
For example, if a step calls `path("src/tools/cargo")` and
`path("src/doc/cargo")` then it's make_run will be called twice, with
"src/tools/cargo" and "src/doc/cargo." This makes it so that default
handling logic is in builder, instead of spread across various Steps.
However, this meant that some Step specifications needed to be updated,
since for example `rustdoc` can be built by `./x.py build
src/librustdoc` or `./x.py build src/tools/rustdoc`. A `PathSet`
abstraction is added that handles this: now, each Step can not only list
`path(...)` but also `paths(&[a, b, ...])` which will make it so that we
don't invoke it with each of the individual paths, instead invoking it
with the first path in the list (though this shouldn't be depended on).
Future work likely consists of implementing a better/easier way for a
given Step to work with "any" crate in-tree, especially those that want
to run tests, build, or check crates in the std, test, or rustc crate
trees. Currently this is rather painful to do as most of the logic is
duplicated across should_run and make_run. It seems likely this can be
abstracted away into builder somehow.
2018-02-11 09:51:58 -07:00
|
|
|
|
run.paths(&["src/librustdoc", "src/tools/rustdoc"])
|
2017-09-02 08:02:32 -06:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn make_run(run: RunConfig) {
|
|
|
|
|
let builder = run.builder;
|
|
|
|
|
|
2018-05-16 17:18:19 +02:00
|
|
|
|
let test_kind = builder.kind.into();
|
2017-09-02 08:02:32 -06:00
|
|
|
|
|
Change Step to be invoked with a path when in default mode.
Previously, a Step would be able to tell on its own when it was invoked
"by-default" (that is, `./x.py test` was called instead of `./x.py test
some/path`). This commit replaces that functionality, invoking each Step
with each of the paths it has specified as "should be invoked by."
For example, if a step calls `path("src/tools/cargo")` and
`path("src/doc/cargo")` then it's make_run will be called twice, with
"src/tools/cargo" and "src/doc/cargo." This makes it so that default
handling logic is in builder, instead of spread across various Steps.
However, this meant that some Step specifications needed to be updated,
since for example `rustdoc` can be built by `./x.py build
src/librustdoc` or `./x.py build src/tools/rustdoc`. A `PathSet`
abstraction is added that handles this: now, each Step can not only list
`path(...)` but also `paths(&[a, b, ...])` which will make it so that we
don't invoke it with each of the individual paths, instead invoking it
with the first path in the list (though this shouldn't be depended on).
Future work likely consists of implementing a better/easier way for a
given Step to work with "any" crate in-tree, especially those that want
to run tests, build, or check crates in the std, test, or rustc crate
trees. Currently this is rather painful to do as most of the logic is
duplicated across should_run and make_run. It seems likely this can be
abstracted away into builder somehow.
2018-02-11 09:51:58 -07:00
|
|
|
|
builder.ensure(CrateRustdoc {
|
2017-09-02 08:02:32 -06:00
|
|
|
|
host: run.host,
|
|
|
|
|
test_kind,
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn run(self, builder: &Builder) {
|
|
|
|
|
let test_kind = self.test_kind;
|
|
|
|
|
|
|
|
|
|
let compiler = builder.compiler(builder.top_stage, self.host);
|
|
|
|
|
let target = compiler.host;
|
2018-07-21 15:54:54 -06:00
|
|
|
|
builder.ensure(compile::Rustc { compiler, target });
|
2017-09-02 08:02:32 -06:00
|
|
|
|
|
2018-05-28 01:09:43 +03:00
|
|
|
|
let mut cargo = tool::prepare_tool_cargo(builder,
|
|
|
|
|
compiler,
|
2018-05-28 02:56:33 +03:00
|
|
|
|
Mode::ToolRustc,
|
2018-05-28 01:09:43 +03:00
|
|
|
|
target,
|
|
|
|
|
test_kind.subcommand(),
|
2018-07-13 14:12:58 +09:00
|
|
|
|
"src/tools/rustdoc",
|
2018-10-08 10:39:09 -07:00
|
|
|
|
SourceType::InTree,
|
|
|
|
|
&[]);
|
2018-04-14 17:27:57 -06:00
|
|
|
|
if test_kind.subcommand() == "test" && !builder.fail_fast {
|
2017-09-02 08:02:32 -06:00
|
|
|
|
cargo.arg("--no-fail-fast");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
cargo.arg("-p").arg("rustdoc:0.0.0");
|
|
|
|
|
|
|
|
|
|
cargo.arg("--");
|
2018-04-14 17:27:57 -06:00
|
|
|
|
cargo.args(&builder.config.cmd.test_args());
|
2017-09-02 08:02:32 -06:00
|
|
|
|
|
2018-06-07 14:40:36 +02:00
|
|
|
|
if !builder.config.verbose_tests {
|
2017-09-02 08:02:32 -06:00
|
|
|
|
cargo.arg("--quiet");
|
|
|
|
|
}
|
|
|
|
|
|
2018-05-30 14:33:43 -03:00
|
|
|
|
let _folder = builder
|
|
|
|
|
.fold_output(|| format!("{}_stage{}-rustdoc", test_kind.subcommand(), compiler.stage));
|
|
|
|
|
builder.info(&format!(
|
|
|
|
|
"{} rustdoc stage{} ({} -> {})",
|
|
|
|
|
test_kind, compiler.stage, &compiler.host, target
|
|
|
|
|
));
|
2018-04-14 17:27:57 -06:00
|
|
|
|
let _time = util::timeit(&builder);
|
2017-09-02 08:02:32 -06:00
|
|
|
|
|
2018-04-14 17:27:57 -06:00
|
|
|
|
try_run(builder, &mut cargo);
|
2017-09-02 08:02:32 -06:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-07-28 17:52:44 -07:00
|
|
|
|
fn envify(s: &str) -> String {
|
2018-05-30 14:33:43 -03:00
|
|
|
|
s.chars()
|
|
|
|
|
.map(|c| match c {
|
2017-07-28 17:52:44 -07:00
|
|
|
|
'-' => '_',
|
|
|
|
|
c => c,
|
2018-05-30 14:33:43 -03:00
|
|
|
|
})
|
|
|
|
|
.flat_map(|c| c.to_uppercase())
|
|
|
|
|
.collect()
|
2016-06-28 13:31:30 -07:00
|
|
|
|
}
|
|
|
|
|
|
2017-07-12 10:12:47 -06:00
|
|
|
|
/// Some test suites are run inside emulators or on remote devices, and most
|
|
|
|
|
/// of our test binaries are linked dynamically which means we need to ship
|
|
|
|
|
/// the standard library and such to the emulator ahead of time. This step
|
|
|
|
|
/// represents this and is a dependency of all test suites.
|
|
|
|
|
///
|
|
|
|
|
/// Most of the time this is a noop. For some steps such as shipping data to
|
|
|
|
|
/// QEMU we have to build our own tools so we've got conditional dependencies
|
|
|
|
|
/// on those programs as well. Note that the remote test client is built for
|
|
|
|
|
/// the build target (us) and the server is built for the target.
|
2017-07-13 18:48:44 -06:00
|
|
|
|
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
|
|
|
|
|
pub struct RemoteCopyLibs {
|
|
|
|
|
compiler: Compiler,
|
|
|
|
|
target: Interned<String>,
|
2017-07-04 19:41:43 -06:00
|
|
|
|
}
|
2017-01-28 13:38:06 -08:00
|
|
|
|
|
2017-07-13 18:48:44 -06:00
|
|
|
|
impl Step for RemoteCopyLibs {
|
2017-07-04 19:41:43 -06:00
|
|
|
|
type Output = ();
|
2017-01-28 13:38:06 -08:00
|
|
|
|
|
2017-07-18 18:03:38 -06:00
|
|
|
|
fn should_run(run: ShouldRun) -> ShouldRun {
|
|
|
|
|
run.never()
|
2017-07-14 06:30:16 -06:00
|
|
|
|
}
|
|
|
|
|
|
2017-07-04 19:41:43 -06:00
|
|
|
|
fn run(self, builder: &Builder) {
|
|
|
|
|
let compiler = self.compiler;
|
|
|
|
|
let target = self.target;
|
2018-04-14 17:27:57 -06:00
|
|
|
|
if !builder.remote_tested(target) {
|
2018-05-30 14:33:43 -03:00
|
|
|
|
return;
|
2017-07-04 19:41:43 -06:00
|
|
|
|
}
|
|
|
|
|
|
2017-07-05 06:41:27 -06:00
|
|
|
|
builder.ensure(compile::Test { compiler, target });
|
|
|
|
|
|
2018-04-14 17:27:57 -06:00
|
|
|
|
builder.info(&format!("REMOTE copy libs to emulator ({})", target));
|
|
|
|
|
t!(fs::create_dir_all(builder.out.join("tmp")));
|
2017-01-28 13:38:06 -08:00
|
|
|
|
|
2018-06-29 14:35:10 -07:00
|
|
|
|
let server = builder.ensure(tool::RemoteTestServer {
|
|
|
|
|
compiler: compiler.with_stage(0),
|
|
|
|
|
target,
|
|
|
|
|
});
|
2017-07-04 19:41:43 -06:00
|
|
|
|
|
|
|
|
|
// Spawn the emulator and wait for it to come online
|
2017-07-05 06:41:27 -06:00
|
|
|
|
let tool = builder.tool_exe(Tool::RemoteTestClient);
|
2017-07-04 19:41:43 -06:00
|
|
|
|
let mut cmd = Command::new(&tool);
|
|
|
|
|
cmd.arg("spawn-emulator")
|
2018-05-30 14:33:43 -03:00
|
|
|
|
.arg(target)
|
|
|
|
|
.arg(&server)
|
|
|
|
|
.arg(builder.out.join("tmp"));
|
2018-04-14 17:27:57 -06:00
|
|
|
|
if let Some(rootfs) = builder.qemu_rootfs(target) {
|
2017-07-04 19:41:43 -06:00
|
|
|
|
cmd.arg(rootfs);
|
|
|
|
|
}
|
2018-04-14 17:27:57 -06:00
|
|
|
|
builder.run(&mut cmd);
|
2017-07-04 19:41:43 -06:00
|
|
|
|
|
|
|
|
|
// Push all our dylibs to the emulator
|
2017-07-05 10:46:41 -06:00
|
|
|
|
for f in t!(builder.sysroot_libdir(compiler, target).read_dir()) {
|
2017-07-04 19:41:43 -06:00
|
|
|
|
let f = t!(f);
|
|
|
|
|
let name = f.file_name().into_string().unwrap();
|
|
|
|
|
if util::is_dylib(&name) {
|
2018-05-30 14:33:43 -03:00
|
|
|
|
builder.run(Command::new(&tool).arg("push").arg(f.path()));
|
2017-07-04 19:41:43 -06:00
|
|
|
|
}
|
2017-01-28 13:38:06 -08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-07-13 18:48:44 -06:00
|
|
|
|
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
|
2017-07-04 19:41:43 -06:00
|
|
|
|
pub struct Distcheck;
|
2016-12-08 17:13:55 -08:00
|
|
|
|
|
2017-07-13 18:48:44 -06:00
|
|
|
|
impl Step for Distcheck {
|
2017-07-04 19:41:43 -06:00
|
|
|
|
type Output = ();
|
|
|
|
|
|
2017-07-18 18:03:38 -06:00
|
|
|
|
fn should_run(run: ShouldRun) -> ShouldRun {
|
|
|
|
|
run.path("distcheck")
|
2017-07-14 06:30:16 -06:00
|
|
|
|
}
|
|
|
|
|
|
2017-07-22 07:35:42 -06:00
|
|
|
|
fn make_run(run: RunConfig) {
|
|
|
|
|
run.builder.ensure(Distcheck);
|
|
|
|
|
}
|
|
|
|
|
|
2017-07-04 19:41:43 -06:00
|
|
|
|
/// Run "distcheck", a 'make check' from a tarball
|
|
|
|
|
fn run(self, builder: &Builder) {
|
2018-10-26 16:23:02 +02:00
|
|
|
|
builder.info("Distcheck");
|
2018-04-14 17:27:57 -06:00
|
|
|
|
let dir = builder.out.join("tmp").join("distcheck");
|
2017-07-04 19:41:43 -06:00
|
|
|
|
let _ = fs::remove_dir_all(&dir);
|
|
|
|
|
t!(fs::create_dir_all(&dir));
|
|
|
|
|
|
2017-07-22 10:48:29 -06:00
|
|
|
|
// Guarantee that these are built before we begin running.
|
|
|
|
|
builder.ensure(dist::PlainSourceTarball);
|
|
|
|
|
builder.ensure(dist::Src);
|
|
|
|
|
|
2017-07-04 19:41:43 -06:00
|
|
|
|
let mut cmd = Command::new("tar");
|
|
|
|
|
cmd.arg("-xzf")
|
2018-05-30 14:33:43 -03:00
|
|
|
|
.arg(builder.ensure(dist::PlainSourceTarball))
|
|
|
|
|
.arg("--strip-components=1")
|
|
|
|
|
.current_dir(&dir);
|
2018-04-14 17:27:57 -06:00
|
|
|
|
builder.run(&mut cmd);
|
2018-05-30 14:33:43 -03:00
|
|
|
|
builder.run(
|
|
|
|
|
Command::new("./configure")
|
|
|
|
|
.args(&builder.config.configure_args)
|
|
|
|
|
.arg("--enable-vendor")
|
|
|
|
|
.current_dir(&dir),
|
|
|
|
|
);
|
|
|
|
|
builder.run(
|
|
|
|
|
Command::new(build_helper::make(&builder.config.build))
|
|
|
|
|
.arg("check")
|
|
|
|
|
.current_dir(&dir),
|
|
|
|
|
);
|
2017-07-04 19:41:43 -06:00
|
|
|
|
|
|
|
|
|
// Now make sure that rust-src has all of libstd's dependencies
|
2018-10-26 16:23:02 +02:00
|
|
|
|
builder.info("Distcheck rust-src");
|
2018-04-14 17:27:57 -06:00
|
|
|
|
let dir = builder.out.join("tmp").join("distcheck-src");
|
2017-07-04 19:41:43 -06:00
|
|
|
|
let _ = fs::remove_dir_all(&dir);
|
|
|
|
|
t!(fs::create_dir_all(&dir));
|
|
|
|
|
|
|
|
|
|
let mut cmd = Command::new("tar");
|
|
|
|
|
cmd.arg("-xzf")
|
2018-05-30 14:33:43 -03:00
|
|
|
|
.arg(builder.ensure(dist::Src))
|
|
|
|
|
.arg("--strip-components=1")
|
|
|
|
|
.current_dir(&dir);
|
2018-04-14 17:27:57 -06:00
|
|
|
|
builder.run(&mut cmd);
|
2017-07-04 19:41:43 -06:00
|
|
|
|
|
|
|
|
|
let toml = dir.join("rust-src/lib/rustlib/src/rust/src/libstd/Cargo.toml");
|
2018-05-30 14:33:43 -03:00
|
|
|
|
builder.run(
|
|
|
|
|
Command::new(&builder.initial_cargo)
|
|
|
|
|
.arg("generate-lockfile")
|
|
|
|
|
.arg("--manifest-path")
|
|
|
|
|
.arg(&toml)
|
|
|
|
|
.current_dir(&dir),
|
|
|
|
|
);
|
2017-07-04 19:41:43 -06:00
|
|
|
|
}
|
2016-12-08 17:13:55 -08:00
|
|
|
|
}
|
2016-12-30 19:50:57 -08:00
|
|
|
|
|
2017-07-13 18:48:44 -06:00
|
|
|
|
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
|
2017-07-04 19:41:43 -06:00
|
|
|
|
pub struct Bootstrap;
|
|
|
|
|
|
2017-07-13 18:48:44 -06:00
|
|
|
|
impl Step for Bootstrap {
|
2017-07-04 19:41:43 -06:00
|
|
|
|
type Output = ();
|
2017-07-05 06:41:27 -06:00
|
|
|
|
const DEFAULT: bool = true;
|
|
|
|
|
const ONLY_HOSTS: bool = true;
|
2017-07-04 19:41:43 -06:00
|
|
|
|
|
|
|
|
|
/// Test the build system itself
|
|
|
|
|
fn run(self, builder: &Builder) {
|
2018-04-14 17:27:57 -06:00
|
|
|
|
let mut cmd = Command::new(&builder.initial_cargo);
|
2017-07-04 19:41:43 -06:00
|
|
|
|
cmd.arg("test")
|
2018-05-30 14:33:43 -03:00
|
|
|
|
.current_dir(builder.src.join("src/bootstrap"))
|
|
|
|
|
.env("RUSTFLAGS", "-Cdebuginfo=2")
|
|
|
|
|
.env("CARGO_TARGET_DIR", builder.out.join("bootstrap"))
|
|
|
|
|
.env("RUSTC_BOOTSTRAP", "1")
|
|
|
|
|
.env("RUSTC", &builder.initial_rustc);
|
2018-03-23 19:55:41 +01:00
|
|
|
|
if let Some(flags) = option_env!("RUSTFLAGS") {
|
|
|
|
|
// Use the same rustc flags for testing as for "normal" compilation,
|
|
|
|
|
// so that Cargo doesn’t recompile the entire dependency graph every time:
|
|
|
|
|
// https://github.com/rust-lang/rust/issues/49215
|
|
|
|
|
cmd.env("RUSTFLAGS", flags);
|
|
|
|
|
}
|
2018-04-14 17:27:57 -06:00
|
|
|
|
if !builder.fail_fast {
|
2017-07-04 19:41:43 -06:00
|
|
|
|
cmd.arg("--no-fail-fast");
|
|
|
|
|
}
|
2018-04-14 17:27:57 -06:00
|
|
|
|
cmd.arg("--").args(&builder.config.cmd.test_args());
|
2018-06-16 11:12:15 -06:00
|
|
|
|
// rustbuild tests are racy on directory creation so just run them one at a time.
|
|
|
|
|
// Since there's not many this shouldn't be a problem.
|
|
|
|
|
cmd.arg("--test-threads=1");
|
2018-04-14 17:27:57 -06:00
|
|
|
|
try_run(builder, &mut cmd);
|
2017-06-02 09:27:44 -07:00
|
|
|
|
}
|
2017-07-05 06:41:27 -06:00
|
|
|
|
|
2017-07-18 18:03:38 -06:00
|
|
|
|
fn should_run(run: ShouldRun) -> ShouldRun {
|
|
|
|
|
run.path("src/bootstrap")
|
2017-07-05 06:41:27 -06:00
|
|
|
|
}
|
|
|
|
|
|
2017-07-20 17:51:07 -06:00
|
|
|
|
fn make_run(run: RunConfig) {
|
|
|
|
|
run.builder.ensure(Bootstrap);
|
2017-07-05 06:41:27 -06:00
|
|
|
|
}
|
2016-12-30 19:50:57 -08:00
|
|
|
|
}
|