2016-03-07 23:15:55 -08:00
|
|
|
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
|
|
|
|
// file at the top-level directory of this distribution and at
|
|
|
|
// http://rust-lang.org/COPYRIGHT.
|
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
|
|
|
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
|
|
|
// option. This file may not be copied, modified, or distributed
|
|
|
|
// except according to those terms.
|
|
|
|
|
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;
|
2017-06-26 10:23:50 -06:00
|
|
|
use std::iter;
|
2016-11-25 22:13:59 +01:00
|
|
|
use std::fmt;
|
2017-06-04 17:55:50 -06:00
|
|
|
use std::fs::{self, File};
|
2016-04-14 18:00:35 -07:00
|
|
|
use std::path::{PathBuf, Path};
|
|
|
|
use std::process::Command;
|
2017-06-04 17:55:50 -06:00
|
|
|
use std::io::Read;
|
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
|
|
|
|
2017-07-17 09:32:08 -07:00
|
|
|
use builder::{Kind, RunConfig, ShouldRun, Builder, Compiler, Step};
|
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
|
|
|
use Crate as CargoCrate;
|
2017-07-17 09:32:08 -07:00
|
|
|
use cache::{INTERNER, Interned};
|
2017-07-04 19:41:43 -06:00
|
|
|
use compile;
|
2017-07-17 09:32:08 -07:00
|
|
|
use dist;
|
2017-07-04 19:41:43 -06:00
|
|
|
use native;
|
2017-07-12 10:12:47 -06:00
|
|
|
use tool::{self, Tool};
|
2017-07-17 09:32:08 -07:00
|
|
|
use util::{self, dylib_path, dylib_path_var};
|
|
|
|
use {Build, Mode};
|
2017-08-30 18:59:26 +02:00
|
|
|
use toolstate::ToolState;
|
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.
|
2017-07-13 18:48:44 -06:00
|
|
|
#[derive(Debug, PartialEq, Eq, Hash, Copy, Clone)]
|
2016-11-25 22:13:59 +01:00
|
|
|
pub enum TestKind {
|
|
|
|
/// Run `cargo test`
|
|
|
|
Test,
|
|
|
|
/// Run `cargo bench`
|
|
|
|
Bench,
|
|
|
|
}
|
|
|
|
|
|
|
|
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",
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-12-07 05:06:48 +08:00
|
|
|
fn try_run(build: &Build, cmd: &mut Command) -> bool {
|
2017-06-27 13:37:24 -06:00
|
|
|
if !build.fail_fast {
|
2017-12-07 05:06:48 +08:00
|
|
|
if !build.try_run(cmd) {
|
2017-09-18 21:21:24 +02:00
|
|
|
let mut failures = build.delayed_failures.borrow_mut();
|
|
|
|
failures.push(format!("{:?}", cmd));
|
2017-12-06 09:25:29 +01:00
|
|
|
return false;
|
2017-06-02 09:27:44 -07:00
|
|
|
}
|
|
|
|
} else {
|
2017-12-07 05:06:48 +08:00
|
|
|
build.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-02-22 03:25:23 +08:00
|
|
|
fn try_run_quiet(build: &Build, cmd: &mut Command) -> bool {
|
2017-06-27 13:37:24 -06:00
|
|
|
if !build.fail_fast {
|
2017-06-02 09:27:44 -07:00
|
|
|
if !build.try_run_quiet(cmd) {
|
2017-09-18 21:21:24 +02:00
|
|
|
let mut failures = build.delayed_failures.borrow_mut();
|
|
|
|
failures.push(format!("{:?}", cmd));
|
2018-02-22 03:25:23 +08:00
|
|
|
return false;
|
2017-06-02 09:27:44 -07:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
build.run_quiet(cmd);
|
|
|
|
}
|
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 build = builder.build;
|
|
|
|
let host = self.host;
|
|
|
|
|
|
|
|
println!("Linkcheck ({})", host);
|
2017-07-05 06:41:27 -06:00
|
|
|
|
|
|
|
builder.default_doc(None);
|
2017-07-04 19:41:43 -06:00
|
|
|
|
|
|
|
let _time = util::timeit();
|
2017-07-05 06:41:27 -06:00
|
|
|
try_run(build, builder.tool_cmd(Tool::Linkchecker)
|
2018-02-05 23:43:53 +01:00
|
|
|
.arg(build.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;
|
|
|
|
run.path("src/tools/linkchecker").default_condition(builder.build.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) {
|
|
|
|
let build = builder.build;
|
2017-07-05 10:46:41 -06:00
|
|
|
let compiler = builder.compiler(self.stage, self.host);
|
2017-07-05 06:41:27 -06: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.
|
|
|
|
let out_dir = build.out.join("ct");
|
|
|
|
t!(fs::create_dir_all(&out_dir));
|
|
|
|
|
|
|
|
let _time = util::timeit();
|
2017-07-05 06:41:27 -06:00
|
|
|
let mut cmd = builder.tool_cmd(Tool::CargoTest);
|
2017-07-04 19:41:43 -06:00
|
|
|
try_run(build, cmd.arg(&build.initial_cargo)
|
|
|
|
.arg(&out_dir)
|
2017-07-05 11:21:33 -06:00
|
|
|
.env("RUSTC", builder.rustc(compiler))
|
2017-08-04 16:13:01 -06:00
|
|
|
.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) {
|
|
|
|
let build = builder.build;
|
2017-07-05 06:41:27 -06:00
|
|
|
let compiler = builder.compiler(self.stage, self.host);
|
2017-07-04 19:41:43 -06:00
|
|
|
|
2017-07-22 19:29:08 -06:00
|
|
|
builder.ensure(tool::Cargo { compiler, target: self.host });
|
2017-07-05 11:21:33 -06:00
|
|
|
let mut cargo = builder.cargo(compiler, Mode::Tool, self.host, "test");
|
2017-07-04 19:41:43 -06:00
|
|
|
cargo.arg("--manifest-path").arg(build.src.join("src/tools/cargo/Cargo.toml"));
|
|
|
|
if !build.fail_fast {
|
|
|
|
cargo.arg("--no-fail-fast");
|
|
|
|
}
|
2017-04-17 17:24:05 -07:00
|
|
|
|
2017-07-04 19:41:43 -06:00
|
|
|
// Don't build tests dynamically, just a pain to work with
|
|
|
|
cargo.env("RUSTC_NO_PREFER_DYNAMIC", "1");
|
|
|
|
|
|
|
|
// Don't run cross-compile tests, we may not have cross-compiled libstd libs
|
|
|
|
// available.
|
|
|
|
cargo.env("CFG_DISABLE_CROSS_TESTS", "1");
|
2017-04-17 17:24:05 -07:00
|
|
|
|
2017-07-17 09:52:05 -06:00
|
|
|
try_run(build, 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 build = builder.build;
|
|
|
|
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
|
|
|
|
2017-07-22 19:29:08 -06:00
|
|
|
builder.ensure(tool::Rls { compiler, target: self.host });
|
2017-12-06 09:25:29 +01:00
|
|
|
let mut cargo = tool::prepare_tool_cargo(builder,
|
|
|
|
compiler,
|
|
|
|
host,
|
|
|
|
"test",
|
|
|
|
"src/tools/rls");
|
2017-07-01 06:58:54 +12:00
|
|
|
|
2017-07-04 19:41:43 -06:00
|
|
|
// Don't build tests dynamically, just a pain to work with
|
|
|
|
cargo.env("RUSTC_NO_PREFER_DYNAMIC", "1");
|
|
|
|
|
2017-07-17 09:52:05 -06:00
|
|
|
builder.add_rustc_lib_path(compiler, &mut cargo);
|
2017-07-04 19:41:43 -06:00
|
|
|
|
2017-12-07 05:06:48 +08:00
|
|
|
if try_run(build, &mut cargo) {
|
2017-12-22 01:16:21 +08:00
|
|
|
build.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 build = builder.build;
|
|
|
|
let stage = self.stage;
|
|
|
|
let host = self.host;
|
|
|
|
let compiler = builder.compiler(stage, host);
|
|
|
|
|
|
|
|
builder.ensure(tool::Rustfmt { compiler, target: self.host });
|
2017-12-06 09:25:29 +01:00
|
|
|
let mut cargo = tool::prepare_tool_cargo(builder,
|
|
|
|
compiler,
|
|
|
|
host,
|
|
|
|
"test",
|
|
|
|
"src/tools/rustfmt");
|
2017-09-01 18:43:00 +12:00
|
|
|
|
|
|
|
// Don't build tests dynamically, just a pain to work with
|
|
|
|
cargo.env("RUSTC_NO_PREFER_DYNAMIC", "1");
|
|
|
|
|
|
|
|
builder.add_rustc_lib_path(compiler, &mut cargo);
|
|
|
|
|
2017-12-07 05:06:48 +08:00
|
|
|
if try_run(build, &mut cargo) {
|
2017-12-22 01:16:21 +08:00
|
|
|
build.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 {
|
|
|
|
let test_miri = run.builder.build.config.test_miri;
|
|
|
|
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) {
|
|
|
|
let build = builder.build;
|
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
|
|
|
|
2017-12-06 09:25:29 +01:00
|
|
|
if let Some(miri) = builder.ensure(tool::Miri { compiler, target: self.host }) {
|
|
|
|
let mut cargo = builder.cargo(compiler, Mode::Tool, host, "test");
|
|
|
|
cargo.arg("--manifest-path").arg(build.src.join("src/tools/miri/Cargo.toml"));
|
|
|
|
|
|
|
|
// Don't build tests dynamically, just a pain to work with
|
|
|
|
cargo.env("RUSTC_NO_PREFER_DYNAMIC", "1");
|
|
|
|
// 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);
|
|
|
|
|
2017-12-07 05:06:48 +08:00
|
|
|
if try_run(build, &mut cargo) {
|
2017-12-22 01:16:21 +08:00
|
|
|
build.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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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) {
|
|
|
|
let build = builder.build;
|
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
|
|
|
|
2017-12-06 09:25:29 +01:00
|
|
|
if let Some(clippy) = builder.ensure(tool::Clippy { compiler, target: self.host }) {
|
|
|
|
let mut cargo = builder.cargo(compiler, Mode::Tool, host, "test");
|
|
|
|
cargo.arg("--manifest-path").arg(build.src.join("src/tools/clippy/Cargo.toml"));
|
|
|
|
|
|
|
|
// Don't build tests dynamically, just a pain to work with
|
|
|
|
cargo.env("RUSTC_NO_PREFER_DYNAMIC", "1");
|
|
|
|
// 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));
|
|
|
|
let host_libs = builder.stage_out(compiler, Mode::Tool).join(builder.cargo_dir());
|
|
|
|
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);
|
|
|
|
|
2017-12-07 05:06:48 +08:00
|
|
|
if try_run(build, &mut cargo) {
|
2017-12-22 01:16:21 +08:00
|
|
|
build.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);
|
|
|
|
|
|
|
|
run.builder.ensure(RustdocTheme {
|
|
|
|
compiler: compiler,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
fn run(self, builder: &Builder) {
|
|
|
|
let rustdoc = builder.rustdoc(self.compiler.host);
|
2018-02-05 23:43:53 +01:00
|
|
|
let mut cmd = builder.tool_cmd(Tool::RustdocTheme);
|
|
|
|
cmd.arg(rustdoc.to_str().unwrap())
|
|
|
|
.arg(builder.src.join("src/librustdoc/html/static/themes").to_str().unwrap())
|
|
|
|
.env("RUSTC_STAGE", self.compiler.stage.to_string())
|
2018-01-26 00:44:52 +01:00
|
|
|
.env("RUSTC_SYSROOT", builder.sysroot(self.compiler))
|
|
|
|
.env("RUSTDOC_LIBDIR", builder.sysroot_libdir(self.compiler, self.compiler.host))
|
|
|
|
.env("CFG_RELEASE_CHANNEL", &builder.build.config.channel)
|
2018-02-05 23:43:53 +01:00
|
|
|
.env("RUSTDOC_REAL", builder.rustdoc(self.compiler.host))
|
2018-01-26 00:44:52 +01:00
|
|
|
.env("RUSTDOC_CRATE_VERSION", builder.build.rust_version())
|
|
|
|
.env("RUSTC_BOOTSTRAP", "1");
|
2018-02-05 23:43:53 +01:00
|
|
|
if let Some(linker) = builder.build.linker(self.compiler.host) {
|
2018-01-26 00:44:52 +01:00
|
|
|
cmd.env("RUSTC_TARGET_LINKER", linker);
|
|
|
|
}
|
2018-02-05 23:43:53 +01:00
|
|
|
try_run(builder.build, &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]);
|
|
|
|
builder.ensure(::doc::Std {
|
|
|
|
target: self.target,
|
|
|
|
stage: builder.top_stage,
|
|
|
|
});
|
|
|
|
builder.run(&mut command);
|
|
|
|
} else {
|
|
|
|
println!("No nodejs found, skipping \"src/test/rustdoc-js\" tests");
|
|
|
|
}
|
2017-12-12 23:53:24 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-07-13 18:48:44 -06:00
|
|
|
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
|
|
|
|
pub struct Tidy {
|
|
|
|
host: Interned<String>,
|
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;
|
|
|
|
const ONLY_BUILD: bool = true;
|
2017-07-04 19:41:43 -06:00
|
|
|
|
|
|
|
/// Runs the `tidy` tool as compiled in `stage` by the `host` compiler.
|
|
|
|
///
|
|
|
|
/// 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) {
|
|
|
|
let build = builder.build;
|
|
|
|
let host = self.host;
|
|
|
|
|
|
|
|
let _folder = build.fold_output(|| "tidy");
|
|
|
|
println!("tidy check ({})", host);
|
2017-07-05 10:46:41 -06:00
|
|
|
let mut cmd = builder.tool_cmd(Tool::Tidy);
|
2017-07-04 19:41:43 -06:00
|
|
|
cmd.arg(build.src.join("src"));
|
|
|
|
if !build.config.vendor {
|
|
|
|
cmd.arg("--no-vendor");
|
|
|
|
}
|
|
|
|
if build.config.quiet_tests {
|
|
|
|
cmd.arg("--quiet");
|
|
|
|
}
|
|
|
|
try_run(build, &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) {
|
|
|
|
run.builder.ensure(Tidy {
|
|
|
|
host: run.builder.build.build,
|
2017-07-05 06:41:27 -06:00
|
|
|
});
|
|
|
|
}
|
2016-03-29 13:14:52 -07:00
|
|
|
}
|
2016-04-05 11:34:23 -07:00
|
|
|
|
2017-07-13 18:48:44 -06:00
|
|
|
fn testdir(build: &Build, host: Interned<String>) -> PathBuf {
|
2016-04-05 11:34:23 -07:00
|
|
|
build.out.join(host).join("test")
|
|
|
|
}
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
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 {
|
|
|
|
($name:ident {
|
|
|
|
path: $path:expr,
|
|
|
|
mode: $mode:expr,
|
|
|
|
suite: $suite:expr,
|
|
|
|
default: $default:expr,
|
|
|
|
host: $host:expr
|
|
|
|
}) => {
|
|
|
|
#[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 {
|
|
|
|
run.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,
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
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
|
|
|
default_test!(Ui {
|
|
|
|
path: "src/test/ui",
|
|
|
|
mode: "ui",
|
|
|
|
suite: "ui"
|
|
|
|
});
|
|
|
|
|
|
|
|
default_test!(RunPass {
|
|
|
|
path: "src/test/run-pass",
|
|
|
|
mode: "run-pass",
|
|
|
|
suite: "run-pass"
|
|
|
|
});
|
|
|
|
|
|
|
|
default_test!(CompileFail {
|
|
|
|
path: "src/test/compile-fail",
|
|
|
|
mode: "compile-fail",
|
|
|
|
suite: "compile-fail"
|
|
|
|
});
|
|
|
|
|
|
|
|
default_test!(ParseFail {
|
|
|
|
path: "src/test/parse-fail",
|
|
|
|
mode: "parse-fail",
|
|
|
|
suite: "parse-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",
|
|
|
|
// What this runs varies depending on the native platform being apple
|
|
|
|
mode: "debuginfo-XXX",
|
|
|
|
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!(CompileFailFullDeps {
|
|
|
|
path: "src/test/compile-fail-fulldeps",
|
|
|
|
mode: "compile-fail",
|
|
|
|
suite: "compile-fail-fulldeps"
|
|
|
|
});
|
|
|
|
|
|
|
|
host_test!(IncrementalFullDeps {
|
|
|
|
path: "src/test/incremental-fulldeps",
|
|
|
|
mode: "incremental",
|
|
|
|
suite: "incremental-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
|
|
|
|
});
|
|
|
|
|
|
|
|
host_test!(RunMake {
|
|
|
|
path: "src/test/run-make",
|
|
|
|
mode: "run-make",
|
|
|
|
suite: "run-make"
|
|
|
|
});
|
|
|
|
|
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,
|
|
|
|
}
|
|
|
|
|
|
|
|
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 build = builder.build;
|
|
|
|
let compiler = self.compiler;
|
|
|
|
let target = self.target;
|
|
|
|
let mode = self.mode;
|
|
|
|
let suite = self.suite;
|
2017-07-05 06:41:27 -06:00
|
|
|
|
|
|
|
// Skip codegen tests if they aren't enabled in configuration.
|
|
|
|
if !build.config.codegen_tests && suite == "codegen" {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if suite == "debuginfo" {
|
2017-07-20 11:23:29 -06:00
|
|
|
// Skip debuginfo tests on MSVC
|
|
|
|
if build.build.contains("msvc") {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-07-05 06:41:27 -06:00
|
|
|
if mode == "debuginfo-XXX" {
|
|
|
|
return if build.build.contains("apple") {
|
|
|
|
builder.ensure(Compiletest {
|
|
|
|
mode: "debuginfo-lldb",
|
|
|
|
..self
|
2017-07-13 18:48:44 -06:00
|
|
|
});
|
2017-07-05 06:41:27 -06:00
|
|
|
} else {
|
|
|
|
builder.ensure(Compiletest {
|
|
|
|
mode: "debuginfo-gdb",
|
|
|
|
..self
|
2017-07-13 18:48:44 -06:00
|
|
|
});
|
2017-07-05 06:41:27 -06:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
builder.ensure(dist::DebuggerScripts {
|
2017-07-13 18:48:44 -06:00
|
|
|
sysroot: builder.sysroot(compiler),
|
2017-07-23 10:03:40 -06: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.
|
|
|
|
mode == "pretty" ||
|
|
|
|
mode == "rustdoc" ||
|
|
|
|
mode == "run-make" {
|
|
|
|
builder.ensure(compile::Rustc { compiler, target });
|
|
|
|
}
|
|
|
|
|
|
|
|
builder.ensure(compile::Test { compiler, target });
|
|
|
|
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
|
|
|
|
2017-07-04 19:41:43 -06:00
|
|
|
let _folder = build.fold_output(|| format!("test_{}", suite));
|
|
|
|
println!("Check compiletest suite={} mode={} ({} -> {})",
|
2017-07-13 18:48:44 -06:00
|
|
|
suite, mode, &compiler.host, 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!
|
|
|
|
|
2017-07-05 11:21:33 -06:00
|
|
|
cmd.arg("--compile-lib-path").arg(builder.rustc_libdir(compiler));
|
2017-07-05 10:46:41 -06:00
|
|
|
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
|
|
|
|
|
|
|
// Avoid depending on rustdoc when we don't need it.
|
|
|
|
if mode == "rustdoc" || mode == "run-make" {
|
2017-08-04 16:13:01 -06:00
|
|
|
cmd.arg("--rustdoc-path").arg(builder.rustdoc(compiler.host));
|
2017-07-25 16:54:33 -06:00
|
|
|
}
|
|
|
|
|
2017-07-04 19:41:43 -06:00
|
|
|
cmd.arg("--src-base").arg(build.src.join("src/test").join(suite));
|
|
|
|
cmd.arg("--build-base").arg(testdir(build, compiler.host).join(suite));
|
|
|
|
cmd.arg("--stage-id").arg(format!("stage{}-{}", compiler.stage, target));
|
|
|
|
cmd.arg("--mode").arg(mode);
|
|
|
|
cmd.arg("--target").arg(target);
|
2017-07-13 18:48:44 -06:00
|
|
|
cmd.arg("--host").arg(&*compiler.host);
|
|
|
|
cmd.arg("--llvm-filecheck").arg(build.llvm_filecheck(build.build));
|
2017-07-04 19:41:43 -06:00
|
|
|
|
|
|
|
if let Some(ref nodejs) = build.config.nodejs {
|
|
|
|
cmd.arg("--nodejs").arg(nodejs);
|
|
|
|
}
|
2016-04-19 09:44:19 -07:00
|
|
|
|
2017-07-04 19:41:43 -06:00
|
|
|
let mut flags = vec!["-Crpath".to_string()];
|
|
|
|
if build.config.rust_optimize_tests {
|
|
|
|
flags.push("-O".to_string());
|
|
|
|
}
|
|
|
|
if build.config.rust_debuginfo_tests {
|
|
|
|
flags.push("-g".to_string());
|
|
|
|
}
|
2017-12-11 22:27:32 +01:00
|
|
|
flags.push("-Zmiri -Zunstable-options".to_string());
|
2018-01-18 19:44:41 -03:00
|
|
|
flags.push(build.config.cmd.rustc_args().join(" "));
|
2016-04-19 09:44:19 -07:00
|
|
|
|
2017-12-06 09:25:29 +01:00
|
|
|
if let Some(linker) = build.linker(target) {
|
|
|
|
cmd.arg("--linker").arg(linker);
|
|
|
|
}
|
|
|
|
|
|
|
|
let hostflags = flags.clone();
|
2017-07-04 19:41:43 -06:00
|
|
|
cmd.arg("--host-rustcflags").arg(hostflags.join(" "));
|
|
|
|
|
2017-12-06 09:25:29 +01:00
|
|
|
let mut targetflags = flags.clone();
|
2017-07-04 19:41:43 -06:00
|
|
|
targetflags.push(format!("-Lnative={}",
|
|
|
|
build.test_helpers_out(target).display()));
|
|
|
|
cmd.arg("--target-rustcflags").arg(targetflags.join(" "));
|
|
|
|
|
|
|
|
cmd.arg("--docck-python").arg(build.python());
|
|
|
|
|
|
|
|
if build.build.ends_with("apple-darwin") {
|
|
|
|
// 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 {
|
|
|
|
cmd.arg("--lldb-python").arg(build.python());
|
|
|
|
}
|
2016-04-05 11:34:23 -07:00
|
|
|
|
2017-07-04 19:41:43 -06:00
|
|
|
if let Some(ref gdb) = build.config.gdb {
|
|
|
|
cmd.arg("--gdb").arg(gdb);
|
|
|
|
}
|
|
|
|
if let Some(ref vers) = build.lldb_version {
|
|
|
|
cmd.arg("--lldb-version").arg(vers);
|
|
|
|
}
|
|
|
|
if let Some(ref dir) = build.lldb_python_dir {
|
|
|
|
cmd.arg("--lldb-python-dir").arg(dir);
|
|
|
|
}
|
2016-04-05 11:34:23 -07:00
|
|
|
|
2017-07-29 22:12:53 -06:00
|
|
|
cmd.args(&build.config.cmd.test_args());
|
2016-04-05 11:34:23 -07:00
|
|
|
|
2017-07-04 19:41:43 -06:00
|
|
|
if build.is_verbose() {
|
|
|
|
cmd.arg("--verbose");
|
|
|
|
}
|
2016-04-05 11:34:23 -07:00
|
|
|
|
2017-07-04 19:41:43 -06:00
|
|
|
if build.config.quiet_tests {
|
|
|
|
cmd.arg("--quiet");
|
|
|
|
}
|
2016-10-29 21:58:52 -04:00
|
|
|
|
2017-08-13 12:30:54 +02:00
|
|
|
if build.config.llvm_enabled {
|
rust: Import LLD for linking wasm objects
This commit imports the LLD project from LLVM to serve as the default linker for
the `wasm32-unknown-unknown` target. The `binaryen` submoule is consequently
removed along with "binaryen linker" support in rustc.
Moving to LLD brings with it a number of benefits for wasm code:
* LLD is itself an actual linker, so there's no need to compile all wasm code
with LTO any more. As a result builds should be *much* speedier as LTO is no
longer forcibly enabled for all builds of the wasm target.
* LLD is quickly becoming an "official solution" for linking wasm code together.
This, I believe at least, is intended to be the main supported linker for
native code and wasm moving forward. Picking up support early on should help
ensure that we can help LLD identify bugs and otherwise prove that it works
great for all our use cases!
* Improvements to the wasm toolchain are currently primarily focused around LLVM
and LLD (from what I can tell at least), so it's in general much better to be
on this bandwagon for bugfixes and new features.
* Historical "hacks" like `wasm-gc` will soon no longer be necessary, LLD
will [natively implement][gc] `--gc-sections` (better than `wasm-gc`!) which
means a postprocessor is no longer needed to show off Rust's "small wasm
binary size".
LLD is added in a pretty standard way to rustc right now. A new rustbuild target
was defined for building LLD, and this is executed when a compiler's sysroot is
being assembled. LLD is compiled against the LLVM that we've got in tree, which
means we're currently on the `release_60` branch, but this may get upgraded in
the near future!
LLD is placed into rustc's sysroot in a `bin` directory. This is similar to
where `gcc.exe` can be found on Windows. This directory is automatically added
to `PATH` whenever rustc executes the linker, allowing us to define a `WasmLd`
linker which implements the interface that `wasm-ld`, LLD's frontend, expects.
Like Emscripten the LLD target is currently only enabled for Tier 1 platforms,
notably OSX/Windows/Linux, and will need to be installed manually for compiling
to wasm on other platforms. LLD is by default turned off in rustbuild, and
requires a `config.toml` option to be enabled to turn it on.
Finally the unstable `#![wasm_import_memory]` attribute was also removed as LLD
has a native option for controlling this.
[gc]: https://reviews.llvm.org/D42511
2017-08-26 18:30:12 -07:00
|
|
|
let llvm_config = build.llvm_config(build.config.build);
|
2017-08-13 12:30:54 +02:00
|
|
|
let llvm_version = output(Command::new(&llvm_config).arg("--version"));
|
|
|
|
cmd.arg("--llvm-version").arg(llvm_version);
|
|
|
|
if !build.is_rust_llvm(target) {
|
|
|
|
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.
|
|
|
|
if suite == "run-make" {
|
|
|
|
let llvm_components = output(Command::new(&llvm_config).arg("--components"));
|
|
|
|
let llvm_cxxflags = output(Command::new(&llvm_config).arg("--cxxflags"));
|
|
|
|
cmd.arg("--cc").arg(build.cc(target))
|
|
|
|
.arg("--cxx").arg(build.cxx(target).unwrap())
|
|
|
|
.arg("--cflags").arg(build.cflags(target).join(" "))
|
|
|
|
.arg("--llvm-components").arg(llvm_components.trim())
|
|
|
|
.arg("--llvm-cxxflags").arg(llvm_cxxflags.trim());
|
2017-12-06 09:25:29 +01:00
|
|
|
if let Some(ar) = build.ar(target) {
|
|
|
|
cmd.arg("--ar").arg(ar);
|
|
|
|
}
|
2017-08-13 12:30:54 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if suite == "run-make" && !build.config.llvm_enabled {
|
2018-02-16 15:56:50 +01:00
|
|
|
println!("Ignoring run-make test suite as they generally don't work without LLVM");
|
2017-08-13 12:30:54 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if suite != "run-make" {
|
2017-07-04 19:41:43 -06:00
|
|
|
cmd.arg("--cc").arg("")
|
|
|
|
.arg("--cxx").arg("")
|
|
|
|
.arg("--cflags").arg("")
|
|
|
|
.arg("--llvm-components").arg("")
|
|
|
|
.arg("--llvm-cxxflags").arg("");
|
|
|
|
}
|
2016-04-14 15:51:03 -07:00
|
|
|
|
2017-07-04 19:41:43 -06:00
|
|
|
if build.remote_tested(target) {
|
2017-07-05 06:41:27 -06: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") {
|
2017-12-06 09:25:29 +01:00
|
|
|
for &(ref k, ref v) in build.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");
|
|
|
|
build.add_rust_test_threads(&mut cmd);
|
2016-04-14 15:51:03 -07:00
|
|
|
|
2017-07-04 19:41:43 -06:00
|
|
|
if build.config.sanitizers {
|
|
|
|
cmd.env("SANITIZER_SUPPORT", "1");
|
|
|
|
}
|
2017-02-03 18:58:47 -05:00
|
|
|
|
2017-07-04 19:41:43 -06:00
|
|
|
if build.config.profiler {
|
|
|
|
cmd.env("PROFILER_SUPPORT", "1");
|
|
|
|
}
|
2017-02-13 09:57:50 +00:00
|
|
|
|
2018-01-22 07:29:24 -08:00
|
|
|
cmd.env("RUST_TEST_TMPDIR", build.out.join("tmp"));
|
|
|
|
|
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")
|
|
|
|
.arg(build.cc(target).parent().unwrap().parent().unwrap());
|
|
|
|
} else {
|
|
|
|
cmd.arg("--android-cross-path").arg("");
|
|
|
|
}
|
2016-06-28 13:31:30 -07:00
|
|
|
|
2017-07-04 19:41:43 -06:00
|
|
|
build.ci_env.force_coloring_in_ci(&mut cmd);
|
2017-05-18 00:33:20 +08:00
|
|
|
|
2017-07-04 19:41:43 -06:00
|
|
|
let _time = util::timeit();
|
|
|
|
try_run(build, &mut cmd);
|
|
|
|
}
|
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`.
|
|
|
|
///
|
|
|
|
/// This will run all tests in our markdown documentation (e.g. the book)
|
|
|
|
/// located in `src/doc`. The `rustdoc` that's run is the one that sits next to
|
|
|
|
/// `compiler`.
|
|
|
|
fn run(self, builder: &Builder) {
|
|
|
|
let build = builder.build;
|
|
|
|
let compiler = self.compiler;
|
2017-07-12 10:12:47 -06:00
|
|
|
|
|
|
|
builder.ensure(compile::Test { compiler, target: compiler.host });
|
|
|
|
|
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-02-22 03:13:34 +08:00
|
|
|
let mut stack = vec![build.src.join(self.path)];
|
2017-07-12 09:15:00 -06:00
|
|
|
let _time = util::timeit();
|
2018-02-22 03:13:34 +08:00
|
|
|
let _folder = build.fold_output(|| format!("test_{}", self.name));
|
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()));
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
|
// guaranteed to build. We don't care if it doesn't build, so skip it.
|
|
|
|
if p.to_str().map_or(false, |p| p.contains("nostarch")) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2018-02-22 03:25:23 +08:00
|
|
|
let test_result = markdown_test(builder, compiler, &p);
|
|
|
|
if self.is_ext_doc {
|
|
|
|
let toolstate = if test_result {
|
|
|
|
ToolState::TestPass
|
|
|
|
} else {
|
|
|
|
ToolState::TestFail
|
|
|
|
};
|
|
|
|
build.save_toolstate(self.name, toolstate);
|
|
|
|
}
|
2017-07-12 09:15:00 -06:00
|
|
|
}
|
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;
|
|
|
|
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 build = builder.build;
|
|
|
|
let compiler = self.compiler;
|
|
|
|
|
2017-07-05 06:41:27 -06:00
|
|
|
builder.ensure(compile::Std { compiler, target: compiler.host });
|
|
|
|
|
2017-07-04 19:41:43 -06:00
|
|
|
let _folder = build.fold_output(|| "test_error_index");
|
|
|
|
println!("Testing error-index stage{}", compiler.stage);
|
|
|
|
|
|
|
|
let dir = testdir(build, compiler.host);
|
|
|
|
t!(fs::create_dir_all(&dir));
|
|
|
|
let output = dir.join("error-index.md");
|
|
|
|
|
|
|
|
let _time = util::timeit();
|
2017-07-05 10:46:41 -06:00
|
|
|
build.run(builder.tool_cmd(Tool::ErrorIndex)
|
2017-07-04 19:41:43 -06:00
|
|
|
.arg("markdown")
|
|
|
|
.arg(&output)
|
2018-01-02 16:21:35 -08:00
|
|
|
.env("CFG_BUILD", &build.build)
|
|
|
|
.env("RUSTC_ERROR_METADATA_DST", build.extended_error_dir()));
|
2017-07-04 19:41:43 -06:00
|
|
|
|
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 {
|
2017-07-05 11:21:33 -06:00
|
|
|
let build = builder.build;
|
2017-06-04 17:55:50 -06:00
|
|
|
let mut file = t!(File::open(markdown));
|
|
|
|
let mut contents = String::new();
|
|
|
|
t!(file.read_to_string(&mut contents));
|
|
|
|
if !contents.contains("```") {
|
2018-02-22 03:25:23 +08:00
|
|
|
return true;
|
2017-06-04 17:55:50 -06:00
|
|
|
}
|
|
|
|
|
2017-06-06 12:00:22 -06:00
|
|
|
println!("doc tests for: {}", markdown.display());
|
2017-08-04 16:13:01 -06:00
|
|
|
let mut cmd = builder.rustdoc_cmd(compiler.host);
|
2016-11-16 12:31:19 -08:00
|
|
|
build.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
|
|
|
|
2017-07-29 22:12:53 -06:00
|
|
|
let test_args = build.config.cmd.test_args().join(" ");
|
2016-10-29 21:58:52 -04:00
|
|
|
cmd.arg("--test-args").arg(test_args);
|
|
|
|
|
2017-05-22 04:27:47 +08:00
|
|
|
if build.config.quiet_tests {
|
2018-02-22 03:25:23 +08:00
|
|
|
try_run_quiet(build, &mut cmd)
|
2017-05-22 04:27:47 +08:00
|
|
|
} else {
|
2018-02-22 03:25:23 +08:00
|
|
|
try_run(build, &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) {
|
|
|
|
let test_kind = if builder.kind == Kind::Test {
|
|
|
|
TestKind::Test
|
|
|
|
} else if builder.kind == Kind::Bench {
|
|
|
|
TestKind::Bench
|
|
|
|
} else {
|
|
|
|
panic!("unexpected builder.kind in crate: {:?}", builder.kind);
|
|
|
|
};
|
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,
|
|
|
|
mode: Mode::Librustc,
|
|
|
|
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 {
|
|
|
|
run.path("src/liballoc_jemalloc")
|
|
|
|
.path("src/librustc_asan")
|
|
|
|
.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);
|
|
|
|
|
|
|
|
let test_kind = if builder.kind == Kind::Test {
|
|
|
|
TestKind::Test
|
|
|
|
} else if builder.kind == Kind::Bench {
|
|
|
|
TestKind::Bench
|
|
|
|
} else {
|
|
|
|
panic!("unexpected builder.kind in crate: {:?}", builder.kind);
|
|
|
|
};
|
|
|
|
|
|
|
|
builder.ensure(CrateNotDefault {
|
|
|
|
compiler,
|
|
|
|
target: run.target,
|
|
|
|
test_kind,
|
|
|
|
krate: match run.path {
|
|
|
|
_ if run.path.ends_with("src/liballoc_jemalloc") => "alloc_jemalloc",
|
|
|
|
_ 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,
|
|
|
|
mode: Mode::Libstd,
|
|
|
|
test_kind: self.test_kind,
|
|
|
|
krate: INTERNER.intern_str(self.krate),
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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 Crate {
|
2017-07-13 18:48:44 -06:00
|
|
|
compiler: Compiler,
|
|
|
|
target: Interned<String>,
|
2017-07-04 19:41:43 -06:00
|
|
|
mode: Mode,
|
|
|
|
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-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") {
|
|
|
|
if krate.is_local(&run.builder) &&
|
|
|
|
!krate.name.contains("jemalloc") &&
|
|
|
|
!(krate.name.starts_with("rustc_") && krate.name.ends_with("san")) &&
|
|
|
|
krate.name != "dlmalloc" {
|
|
|
|
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| {
|
2017-07-05 06:41:27 -06:00
|
|
|
let test_kind = if builder.kind == Kind::Test {
|
|
|
|
TestKind::Test
|
|
|
|
} else if builder.kind == Kind::Bench {
|
|
|
|
TestKind::Bench
|
|
|
|
} else {
|
2017-07-18 15:28:53 -06:00
|
|
|
panic!("unexpected builder.kind in crate: {:?}", builder.kind);
|
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)) {
|
|
|
|
make(Mode::Libstd, 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)) {
|
|
|
|
make(Mode::Libtest, 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 build = builder.build;
|
|
|
|
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.
|
|
|
|
let compiler = if build.force_use_stage1(compiler, target) {
|
|
|
|
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 {
|
2017-07-04 19:41:43 -06:00
|
|
|
Mode::Libstd => {
|
2017-07-17 09:32:08 -07:00
|
|
|
compile::std_cargo(build, &compiler, target, &mut cargo);
|
2017-07-04 19:41:43 -06:00
|
|
|
}
|
|
|
|
Mode::Libtest => {
|
2017-07-17 09:32:08 -07:00
|
|
|
compile::test_cargo(build, &compiler, target, &mut cargo);
|
2017-07-04 19:41:43 -06:00
|
|
|
}
|
|
|
|
Mode::Librustc => {
|
2017-07-12 10:12:47 -06:00
|
|
|
builder.ensure(compile::Rustc { compiler, target });
|
2018-01-22 07:29:24 -08:00
|
|
|
compile::rustc_cargo(build, &mut cargo);
|
2017-07-04 19:41:43 -06:00
|
|
|
}
|
|
|
|
_ => panic!("can only test libraries"),
|
|
|
|
};
|
|
|
|
let _folder = build.fold_output(|| {
|
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
|
|
|
format!("{}_stage{}-{}", test_kind.subcommand(), compiler.stage, krate)
|
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
|
|
|
println!("{} {} stage{} ({} -> {})", test_kind, krate, compiler.stage,
|
2017-07-13 18:48:44 -06:00
|
|
|
&compiler.host, target);
|
2017-07-04 19:41:43 -06:00
|
|
|
|
|
|
|
// 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.
|
|
|
|
if test_kind.subcommand() == "test" && !build.fail_fast {
|
|
|
|
cargo.arg("--no-fail-fast");
|
|
|
|
}
|
2018-02-17 15:45:39 +01:00
|
|
|
if build.doc_tests {
|
|
|
|
cargo.arg("--doc");
|
|
|
|
}
|
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("--");
|
2017-07-29 22:12:53 -06:00
|
|
|
cargo.args(&build.config.cmd.test_args());
|
2016-10-29 21:58:52 -04:00
|
|
|
|
2017-07-04 19:41:43 -06:00
|
|
|
if build.config.quiet_tests {
|
|
|
|
cargo.arg("--quiet");
|
|
|
|
}
|
2016-11-16 12:31:19 -08:00
|
|
|
|
2017-07-04 19:41:43 -06:00
|
|
|
let _time = util::timeit();
|
|
|
|
|
|
|
|
if target.contains("emscripten") {
|
2017-07-28 17:52:44 -07:00
|
|
|
cargo.env(format!("CARGO_TARGET_{}_RUNNER", envify(&target)),
|
|
|
|
build.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.
|
|
|
|
if !build.config.wasm_syscall {
|
|
|
|
println!("Libstd was built without `wasm_syscall` feature enabled: \
|
|
|
|
test output may not be visible.");
|
|
|
|
}
|
|
|
|
|
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");
|
|
|
|
|
|
|
|
let node = build.config.nodejs.as_ref()
|
|
|
|
.expect("nodejs not configured");
|
|
|
|
let runner = format!("{} {}/src/etc/wasm32-shim.js",
|
|
|
|
node.display(),
|
|
|
|
build.src.display());
|
|
|
|
cargo.env(format!("CARGO_TARGET_{}_RUNNER", envify(&target)), &runner);
|
2017-07-04 19:41:43 -06:00
|
|
|
} else if build.remote_tested(target) {
|
2017-07-28 17:52:44 -07: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
|
|
|
}
|
2017-07-28 17:52:44 -07:00
|
|
|
try_run(build, &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;
|
|
|
|
|
|
|
|
let test_kind = if builder.kind == Kind::Test {
|
|
|
|
TestKind::Test
|
|
|
|
} else if builder.kind == Kind::Bench {
|
|
|
|
TestKind::Bench
|
|
|
|
} else {
|
|
|
|
panic!("unexpected builder.kind in crate: {:?}", builder.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
|
|
|
builder.ensure(CrateRustdoc {
|
2017-09-02 08:02:32 -06:00
|
|
|
host: run.host,
|
|
|
|
test_kind,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
fn run(self, builder: &Builder) {
|
|
|
|
let build = builder.build;
|
|
|
|
let test_kind = self.test_kind;
|
|
|
|
|
|
|
|
let compiler = builder.compiler(builder.top_stage, self.host);
|
|
|
|
let target = compiler.host;
|
|
|
|
|
2017-09-15 15:28:59 -07:00
|
|
|
let mut cargo = tool::prepare_tool_cargo(builder,
|
|
|
|
compiler,
|
|
|
|
target,
|
|
|
|
test_kind.subcommand(),
|
|
|
|
"src/tools/rustdoc");
|
2017-09-02 08:02:32 -06:00
|
|
|
let _folder = build.fold_output(|| {
|
|
|
|
format!("{}_stage{}-rustdoc", test_kind.subcommand(), compiler.stage)
|
|
|
|
});
|
|
|
|
println!("{} rustdoc stage{} ({} -> {})", test_kind, compiler.stage,
|
|
|
|
&compiler.host, target);
|
|
|
|
|
|
|
|
if test_kind.subcommand() == "test" && !build.fail_fast {
|
|
|
|
cargo.arg("--no-fail-fast");
|
|
|
|
}
|
|
|
|
|
|
|
|
cargo.arg("-p").arg("rustdoc:0.0.0");
|
|
|
|
|
|
|
|
cargo.arg("--");
|
|
|
|
cargo.args(&build.config.cmd.test_args());
|
|
|
|
|
|
|
|
if build.config.quiet_tests {
|
|
|
|
cargo.arg("--quiet");
|
|
|
|
}
|
|
|
|
|
|
|
|
let _time = util::timeit();
|
|
|
|
|
|
|
|
try_run(build, &mut cargo);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-07-28 17:52:44 -07:00
|
|
|
fn envify(s: &str) -> String {
|
|
|
|
s.chars().map(|c| {
|
|
|
|
match c {
|
|
|
|
'-' => '_',
|
|
|
|
c => c,
|
2016-06-28 13:31:30 -07:00
|
|
|
}
|
2017-07-28 17:52:44 -07: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 build = builder.build;
|
|
|
|
let compiler = self.compiler;
|
|
|
|
let target = self.target;
|
|
|
|
if !build.remote_tested(target) {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2017-07-05 06:41:27 -06:00
|
|
|
builder.ensure(compile::Test { compiler, target });
|
|
|
|
|
2017-07-04 19:41:43 -06:00
|
|
|
println!("REMOTE copy libs to emulator ({})", target);
|
|
|
|
t!(fs::create_dir_all(build.out.join("tmp")));
|
2017-01-28 13:38:06 -08:00
|
|
|
|
2017-07-22 19:29:08 -06:00
|
|
|
let server = builder.ensure(tool::RemoteTestServer { compiler, 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")
|
|
|
|
.arg(target)
|
|
|
|
.arg(&server)
|
|
|
|
.arg(build.out.join("tmp"));
|
|
|
|
if let Some(rootfs) = build.qemu_rootfs(target) {
|
|
|
|
cmd.arg(rootfs);
|
|
|
|
}
|
|
|
|
build.run(&mut cmd);
|
|
|
|
|
|
|
|
// 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) {
|
|
|
|
build.run(Command::new(&tool)
|
|
|
|
.arg("push")
|
|
|
|
.arg(f.path()));
|
|
|
|
}
|
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-29 22:12:53 -06:00
|
|
|
const ONLY_BUILD: 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("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) {
|
|
|
|
let build = builder.build;
|
|
|
|
|
|
|
|
println!("Distcheck");
|
|
|
|
let dir = build.out.join("tmp").join("distcheck");
|
|
|
|
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")
|
2017-07-12 18:52:31 -06:00
|
|
|
.arg(builder.ensure(dist::PlainSourceTarball))
|
2017-07-04 19:41:43 -06:00
|
|
|
.arg("--strip-components=1")
|
|
|
|
.current_dir(&dir);
|
|
|
|
build.run(&mut cmd);
|
|
|
|
build.run(Command::new("./configure")
|
|
|
|
.args(&build.config.configure_args)
|
|
|
|
.arg("--enable-vendor")
|
|
|
|
.current_dir(&dir));
|
|
|
|
build.run(Command::new(build_helper::make(&build.build))
|
|
|
|
.arg("check")
|
|
|
|
.current_dir(&dir));
|
|
|
|
|
|
|
|
// Now make sure that rust-src has all of libstd's dependencies
|
|
|
|
println!("Distcheck rust-src");
|
|
|
|
let dir = build.out.join("tmp").join("distcheck-src");
|
|
|
|
let _ = fs::remove_dir_all(&dir);
|
|
|
|
t!(fs::create_dir_all(&dir));
|
|
|
|
|
|
|
|
let mut cmd = Command::new("tar");
|
|
|
|
cmd.arg("-xzf")
|
2017-07-12 18:52:31 -06:00
|
|
|
.arg(builder.ensure(dist::Src))
|
2017-07-04 19:41:43 -06:00
|
|
|
.arg("--strip-components=1")
|
|
|
|
.current_dir(&dir);
|
|
|
|
build.run(&mut cmd);
|
|
|
|
|
|
|
|
let toml = dir.join("rust-src/lib/rustlib/src/rust/src/libstd/Cargo.toml");
|
|
|
|
build.run(Command::new(&build.initial_cargo)
|
|
|
|
.arg("generate-lockfile")
|
|
|
|
.arg("--manifest-path")
|
|
|
|
.arg(&toml)
|
|
|
|
.current_dir(&dir));
|
|
|
|
}
|
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;
|
|
|
|
const ONLY_BUILD: bool = true;
|
2017-07-04 19:41:43 -06:00
|
|
|
|
|
|
|
/// Test the build system itself
|
|
|
|
fn run(self, builder: &Builder) {
|
|
|
|
let build = builder.build;
|
|
|
|
let mut cmd = Command::new(&build.initial_cargo);
|
|
|
|
cmd.arg("test")
|
|
|
|
.current_dir(build.src.join("src/bootstrap"))
|
|
|
|
.env("CARGO_TARGET_DIR", build.out.join("bootstrap"))
|
|
|
|
.env("RUSTC_BOOTSTRAP", "1")
|
|
|
|
.env("RUSTC", &build.initial_rustc);
|
|
|
|
if !build.fail_fast {
|
|
|
|
cmd.arg("--no-fail-fast");
|
|
|
|
}
|
2017-07-29 22:12:53 -06:00
|
|
|
cmd.arg("--").args(&build.config.cmd.test_args());
|
2017-07-04 19:41:43 -06:00
|
|
|
try_run(build, &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
|
|
|
}
|