Auto merge of #51138 - spastorino:add-polonius-compare-mode, r=pnkfelix
Add polonius compare mode **This is now ready to review/merge**
This commit is contained in:
commit
e1eed38fed
File diff suppressed because it is too large
Load Diff
@ -19,10 +19,10 @@ use std::process;
|
||||
|
||||
use getopts::Options;
|
||||
|
||||
use {Build, DocTests};
|
||||
use builder::Builder;
|
||||
use config::Config;
|
||||
use metadata;
|
||||
use builder::Builder;
|
||||
use {Build, DocTests};
|
||||
|
||||
use cache::{Interned, INTERNER};
|
||||
|
||||
@ -61,6 +61,7 @@ pub enum Subcommand {
|
||||
paths: Vec<PathBuf>,
|
||||
/// Whether to automatically update stderr/stdout files
|
||||
bless: bool,
|
||||
compare_mode: Option<String>,
|
||||
test_args: Vec<String>,
|
||||
rustc_args: Vec<String>,
|
||||
fail_fast: bool,
|
||||
@ -92,7 +93,8 @@ impl Default for Subcommand {
|
||||
impl Flags {
|
||||
pub fn parse(args: &[String]) -> Flags {
|
||||
let mut extra_help = String::new();
|
||||
let mut subcommand_help = format!("\
|
||||
let mut subcommand_help = format!(
|
||||
"\
|
||||
Usage: x.py <subcommand> [options] [<paths>...]
|
||||
|
||||
Subcommands:
|
||||
@ -105,7 +107,8 @@ Subcommands:
|
||||
dist Build distribution artifacts
|
||||
install Install distribution artifacts
|
||||
|
||||
To learn more about a subcommand, run `./x.py <subcommand> -h`");
|
||||
To learn more about a subcommand, run `./x.py <subcommand> -h`"
|
||||
);
|
||||
|
||||
let mut opts = Options::new();
|
||||
// Options common to all subcommands
|
||||
@ -123,33 +126,39 @@ To learn more about a subcommand, run `./x.py <subcommand> -h`");
|
||||
opts.optopt("", "src", "path to the root of the rust checkout", "DIR");
|
||||
opts.optopt("j", "jobs", "number of jobs to run in parallel", "JOBS");
|
||||
opts.optflag("h", "help", "print this help message");
|
||||
opts.optopt("", "warnings", "if value is deny, will deny warnings, otherwise use default",
|
||||
"VALUE");
|
||||
opts.optopt(
|
||||
"",
|
||||
"warnings",
|
||||
"if value is deny, will deny warnings, otherwise use default",
|
||||
"VALUE",
|
||||
);
|
||||
opts.optopt("", "error-format", "rustc error format", "FORMAT");
|
||||
|
||||
// fn usage()
|
||||
let usage = |exit_code: i32, opts: &Options, subcommand_help: &str, extra_help: &str| -> ! {
|
||||
println!("{}", opts.usage(subcommand_help));
|
||||
if !extra_help.is_empty() {
|
||||
println!("{}", extra_help);
|
||||
}
|
||||
process::exit(exit_code);
|
||||
};
|
||||
let usage =
|
||||
|exit_code: i32, opts: &Options, subcommand_help: &str, extra_help: &str| -> ! {
|
||||
println!("{}", opts.usage(subcommand_help));
|
||||
if !extra_help.is_empty() {
|
||||
println!("{}", extra_help);
|
||||
}
|
||||
process::exit(exit_code);
|
||||
};
|
||||
|
||||
// We can't use getopt to parse the options until we have completed specifying which
|
||||
// options are valid, but under the current implementation, some options are conditional on
|
||||
// the subcommand. Therefore we must manually identify the subcommand first, so that we can
|
||||
// complete the definition of the options. Then we can use the getopt::Matches object from
|
||||
// there on out.
|
||||
let subcommand = args.iter().find(|&s|
|
||||
let subcommand = args.iter().find(|&s| {
|
||||
(s == "build")
|
||||
|| (s == "check")
|
||||
|| (s == "test")
|
||||
|| (s == "bench")
|
||||
|| (s == "doc")
|
||||
|| (s == "clean")
|
||||
|| (s == "dist")
|
||||
|| (s == "install"));
|
||||
|| (s == "check")
|
||||
|| (s == "test")
|
||||
|| (s == "bench")
|
||||
|| (s == "doc")
|
||||
|| (s == "clean")
|
||||
|| (s == "dist")
|
||||
|| (s == "install")
|
||||
});
|
||||
let subcommand = match subcommand {
|
||||
Some(s) => s,
|
||||
None => {
|
||||
@ -164,7 +173,7 @@ To learn more about a subcommand, run `./x.py <subcommand> -h`");
|
||||
|
||||
// Some subcommands get extra options
|
||||
match subcommand.as_str() {
|
||||
"test" => {
|
||||
"test" => {
|
||||
opts.optflag("", "no-fail-fast", "Run all tests regardless of failure");
|
||||
opts.optmulti("", "test-args", "extra arguments", "ARGS");
|
||||
opts.optmulti(
|
||||
@ -175,11 +184,25 @@ To learn more about a subcommand, run `./x.py <subcommand> -h`");
|
||||
);
|
||||
opts.optflag("", "no-doc", "do not run doc tests");
|
||||
opts.optflag("", "doc", "only run doc tests");
|
||||
opts.optflag("", "bless", "update all stderr/stdout files of failing ui tests");
|
||||
},
|
||||
"bench" => { opts.optmulti("", "test-args", "extra arguments", "ARGS"); },
|
||||
"clean" => { opts.optflag("", "all", "clean all build artifacts"); },
|
||||
_ => { },
|
||||
opts.optflag(
|
||||
"",
|
||||
"bless",
|
||||
"update all stderr/stdout files of failing ui tests",
|
||||
);
|
||||
opts.optopt(
|
||||
"",
|
||||
"compare-mode",
|
||||
"mode describing what file the actual ui output will be compared to",
|
||||
"COMPARE MODE",
|
||||
);
|
||||
}
|
||||
"bench" => {
|
||||
opts.optmulti("", "test-args", "extra arguments", "ARGS");
|
||||
}
|
||||
"clean" => {
|
||||
opts.optflag("", "all", "clean all build artifacts");
|
||||
}
|
||||
_ => {}
|
||||
};
|
||||
|
||||
// Done specifying what options are possible, so do the getopts parsing
|
||||
@ -199,21 +222,24 @@ To learn more about a subcommand, run `./x.py <subcommand> -h`");
|
||||
if check_subcommand != subcommand {
|
||||
pass_sanity_check = false;
|
||||
}
|
||||
},
|
||||
}
|
||||
None => {
|
||||
pass_sanity_check = false;
|
||||
}
|
||||
}
|
||||
if !pass_sanity_check {
|
||||
println!("{}\n", subcommand_help);
|
||||
println!("Sorry, I couldn't figure out which subcommand you were trying to specify.\n\
|
||||
You may need to move some options to after the subcommand.\n");
|
||||
println!(
|
||||
"Sorry, I couldn't figure out which subcommand you were trying to specify.\n\
|
||||
You may need to move some options to after the subcommand.\n"
|
||||
);
|
||||
process::exit(1);
|
||||
}
|
||||
// Extra help text for some commands
|
||||
match subcommand.as_str() {
|
||||
"build" => {
|
||||
subcommand_help.push_str("\n
|
||||
subcommand_help.push_str(
|
||||
"\n
|
||||
Arguments:
|
||||
This subcommand accepts a number of paths to directories to the crates
|
||||
and/or artifacts to compile. For example:
|
||||
@ -235,10 +261,12 @@ Arguments:
|
||||
This will first build everything once (like --stage 0 without further
|
||||
arguments would), and then use the compiler built in stage 0 to build
|
||||
src/libtest and its dependencies.
|
||||
Once this is done, build/$ARCH/stage1 contains a usable compiler.");
|
||||
Once this is done, build/$ARCH/stage1 contains a usable compiler.",
|
||||
);
|
||||
}
|
||||
"check" => {
|
||||
subcommand_help.push_str("\n
|
||||
subcommand_help.push_str(
|
||||
"\n
|
||||
Arguments:
|
||||
This subcommand accepts a number of paths to directories to the crates
|
||||
and/or artifacts to compile. For example:
|
||||
@ -250,10 +278,12 @@ Arguments:
|
||||
also that since we use `cargo check`, by default this will automatically enable incremental
|
||||
compilation, so there's no need to pass it separately, though it won't hurt. We also completely
|
||||
ignore the stage passed, as there's no way to compile in non-stage 0 without actually building
|
||||
the compiler.");
|
||||
the compiler.",
|
||||
);
|
||||
}
|
||||
"test" => {
|
||||
subcommand_help.push_str("\n
|
||||
subcommand_help.push_str(
|
||||
"\n
|
||||
Arguments:
|
||||
This subcommand accepts a number of paths to directories to tests that
|
||||
should be compiled and run. For example:
|
||||
@ -262,15 +292,18 @@ Arguments:
|
||||
./x.py test src/libstd --test-args hash_map
|
||||
./x.py test src/libstd --stage 0
|
||||
./x.py test src/test/ui --bless
|
||||
./x.py test src/test/ui --compare-mode nll
|
||||
|
||||
If no arguments are passed then the complete artifacts for that stage are
|
||||
compiled and tested.
|
||||
|
||||
./x.py test
|
||||
./x.py test --stage 1");
|
||||
./x.py test --stage 1",
|
||||
);
|
||||
}
|
||||
"doc" => {
|
||||
subcommand_help.push_str("\n
|
||||
subcommand_help.push_str(
|
||||
"\n
|
||||
Arguments:
|
||||
This subcommand accepts a number of paths to directories of documentation
|
||||
to build. For example:
|
||||
@ -282,12 +315,16 @@ Arguments:
|
||||
If no arguments are passed then everything is documented:
|
||||
|
||||
./x.py doc
|
||||
./x.py doc --stage 1");
|
||||
./x.py doc --stage 1",
|
||||
);
|
||||
}
|
||||
_ => { }
|
||||
_ => {}
|
||||
};
|
||||
// Get any optional paths which occur after the subcommand
|
||||
let paths = matches.free[1..].iter().map(|p| p.into()).collect::<Vec<PathBuf>>();
|
||||
let paths = matches.free[1..]
|
||||
.iter()
|
||||
.map(|p| p.into())
|
||||
.collect::<Vec<PathBuf>>();
|
||||
|
||||
let cfg_file = matches.opt_str("config").map(PathBuf::from).or_else(|| {
|
||||
if fs::metadata("config.toml").is_ok() {
|
||||
@ -306,9 +343,12 @@ Arguments:
|
||||
let maybe_rules_help = Builder::get_help(&build, subcommand.as_str());
|
||||
extra_help.push_str(maybe_rules_help.unwrap_or_default().as_str());
|
||||
} else if subcommand.as_str() != "clean" {
|
||||
extra_help.push_str(format!(
|
||||
"Run `./x.py {} -h -v` to see a list of available paths.",
|
||||
subcommand).as_str());
|
||||
extra_help.push_str(
|
||||
format!(
|
||||
"Run `./x.py {} -h -v` to see a list of available paths.",
|
||||
subcommand
|
||||
).as_str(),
|
||||
);
|
||||
}
|
||||
|
||||
// User passed in -h/--help?
|
||||
@ -317,37 +357,28 @@ Arguments:
|
||||
}
|
||||
|
||||
let cmd = match subcommand.as_str() {
|
||||
"build" => {
|
||||
Subcommand::Build { paths: paths }
|
||||
}
|
||||
"check" => {
|
||||
Subcommand::Check { paths: paths }
|
||||
}
|
||||
"test" => {
|
||||
Subcommand::Test {
|
||||
paths,
|
||||
bless: matches.opt_present("bless"),
|
||||
test_args: matches.opt_strs("test-args"),
|
||||
rustc_args: matches.opt_strs("rustc-args"),
|
||||
fail_fast: !matches.opt_present("no-fail-fast"),
|
||||
doc_tests: if matches.opt_present("doc") {
|
||||
DocTests::Only
|
||||
} else if matches.opt_present("no-doc") {
|
||||
DocTests::No
|
||||
} else {
|
||||
DocTests::Yes
|
||||
}
|
||||
}
|
||||
}
|
||||
"bench" => {
|
||||
Subcommand::Bench {
|
||||
paths,
|
||||
test_args: matches.opt_strs("test-args"),
|
||||
}
|
||||
}
|
||||
"doc" => {
|
||||
Subcommand::Doc { paths: paths }
|
||||
}
|
||||
"build" => Subcommand::Build { paths: paths },
|
||||
"check" => Subcommand::Check { paths: paths },
|
||||
"test" => Subcommand::Test {
|
||||
paths,
|
||||
bless: matches.opt_present("bless"),
|
||||
compare_mode: matches.opt_str("compare-mode"),
|
||||
test_args: matches.opt_strs("test-args"),
|
||||
rustc_args: matches.opt_strs("rustc-args"),
|
||||
fail_fast: !matches.opt_present("no-fail-fast"),
|
||||
doc_tests: if matches.opt_present("doc") {
|
||||
DocTests::Only
|
||||
} else if matches.opt_present("no-doc") {
|
||||
DocTests::No
|
||||
} else {
|
||||
DocTests::Yes
|
||||
},
|
||||
},
|
||||
"bench" => Subcommand::Bench {
|
||||
paths,
|
||||
test_args: matches.opt_strs("test-args"),
|
||||
},
|
||||
"doc" => Subcommand::Doc { paths: paths },
|
||||
"clean" => {
|
||||
if paths.len() > 0 {
|
||||
println!("\nclean does not take a path argument\n");
|
||||
@ -358,22 +389,13 @@ Arguments:
|
||||
all: matches.opt_present("all"),
|
||||
}
|
||||
}
|
||||
"dist" => {
|
||||
Subcommand::Dist {
|
||||
paths,
|
||||
}
|
||||
}
|
||||
"install" => {
|
||||
Subcommand::Install {
|
||||
paths,
|
||||
}
|
||||
}
|
||||
"dist" => Subcommand::Dist { paths },
|
||||
"install" => Subcommand::Install { paths },
|
||||
_ => {
|
||||
usage(1, &opts, &subcommand_help, &extra_help);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Flags {
|
||||
verbose: matches.opt_count("verbose"),
|
||||
stage: matches.opt_str("stage").map(|j| j.parse().unwrap()),
|
||||
@ -382,15 +404,21 @@ Arguments:
|
||||
rustc_error_format: matches.opt_str("error-format"),
|
||||
keep_stage: matches.opt_str("keep-stage").map(|j| j.parse().unwrap()),
|
||||
host: split(matches.opt_strs("host"))
|
||||
.into_iter().map(|x| INTERNER.intern_string(x)).collect::<Vec<_>>(),
|
||||
.into_iter()
|
||||
.map(|x| INTERNER.intern_string(x))
|
||||
.collect::<Vec<_>>(),
|
||||
target: split(matches.opt_strs("target"))
|
||||
.into_iter().map(|x| INTERNER.intern_string(x)).collect::<Vec<_>>(),
|
||||
.into_iter()
|
||||
.map(|x| INTERNER.intern_string(x))
|
||||
.collect::<Vec<_>>(),
|
||||
config: cfg_file,
|
||||
jobs: matches.opt_str("jobs").map(|j| j.parse().unwrap()),
|
||||
cmd,
|
||||
incremental: matches.opt_present("incremental"),
|
||||
exclude: split(matches.opt_strs("exclude"))
|
||||
.into_iter().map(|p| p.into()).collect::<Vec<_>>(),
|
||||
.into_iter()
|
||||
.map(|p| p.into())
|
||||
.collect::<Vec<_>>(),
|
||||
warnings: matches.opt_str("warnings").map(|v| v == "deny"),
|
||||
}
|
||||
}
|
||||
@ -399,9 +427,11 @@ Arguments:
|
||||
impl Subcommand {
|
||||
pub fn test_args(&self) -> Vec<&str> {
|
||||
match *self {
|
||||
Subcommand::Test { ref test_args, .. } |
|
||||
Subcommand::Bench { ref test_args, .. } => {
|
||||
test_args.iter().flat_map(|s| s.split_whitespace()).collect()
|
||||
Subcommand::Test { ref test_args, .. } | Subcommand::Bench { ref test_args, .. } => {
|
||||
test_args
|
||||
.iter()
|
||||
.flat_map(|s| s.split_whitespace())
|
||||
.collect()
|
||||
}
|
||||
_ => Vec::new(),
|
||||
}
|
||||
@ -409,9 +439,10 @@ impl Subcommand {
|
||||
|
||||
pub fn rustc_args(&self) -> Vec<&str> {
|
||||
match *self {
|
||||
Subcommand::Test { ref rustc_args, .. } => {
|
||||
rustc_args.iter().flat_map(|s| s.split_whitespace()).collect()
|
||||
}
|
||||
Subcommand::Test { ref rustc_args, .. } => rustc_args
|
||||
.iter()
|
||||
.flat_map(|s| s.split_whitespace())
|
||||
.collect(),
|
||||
_ => Vec::new(),
|
||||
}
|
||||
}
|
||||
@ -436,8 +467,20 @@ impl Subcommand {
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn compare_mode(&self) -> Option<&str> {
|
||||
match *self {
|
||||
Subcommand::Test {
|
||||
ref compare_mode, ..
|
||||
} => compare_mode.as_ref().map(|s| &s[..]),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn split(s: Vec<String>) -> Vec<String> {
|
||||
s.iter().flat_map(|s| s.split(',')).map(|s| s.to_string()).collect()
|
||||
s.iter()
|
||||
.flat_map(|s| s.split(','))
|
||||
.map(|s| s.to_string())
|
||||
.collect()
|
||||
}
|
||||
|
@ -15,26 +15,26 @@
|
||||
|
||||
use std::env;
|
||||
use std::ffi::OsString;
|
||||
use std::iter;
|
||||
use std::fmt;
|
||||
use std::fs::{self, File};
|
||||
use std::path::{PathBuf, Path};
|
||||
use std::process::Command;
|
||||
use std::io::Read;
|
||||
use std::iter;
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::process::Command;
|
||||
|
||||
use build_helper::{self, output};
|
||||
|
||||
use builder::{Kind, RunConfig, ShouldRun, Builder, Compiler, Step};
|
||||
use Crate as CargoCrate;
|
||||
use cache::{INTERNER, Interned};
|
||||
use builder::{Builder, Compiler, Kind, RunConfig, ShouldRun, Step};
|
||||
use cache::{Interned, INTERNER};
|
||||
use compile;
|
||||
use dist;
|
||||
use flags::Subcommand;
|
||||
use native;
|
||||
use tool::{self, Tool};
|
||||
use util::{self, dylib_path, dylib_path_var};
|
||||
use {Mode, DocTests};
|
||||
use toolstate::ToolState;
|
||||
use flags::Subcommand;
|
||||
use util::{self, dylib_path, dylib_path_var};
|
||||
use Crate as CargoCrate;
|
||||
use {DocTests, Mode};
|
||||
|
||||
const ADB_TEST_DIR: &str = "/data/tmp/work";
|
||||
|
||||
@ -52,7 +52,7 @@ impl From<Kind> for TestKind {
|
||||
match kind {
|
||||
Kind::Test => TestKind::Test,
|
||||
Kind::Bench => TestKind::Bench,
|
||||
_ => panic!("unexpected kind in crate: {:?}", kind)
|
||||
_ => panic!("unexpected kind in crate: {:?}", kind),
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -124,13 +124,18 @@ impl Step for Linkcheck {
|
||||
builder.default_doc(None);
|
||||
|
||||
let _time = util::timeit(&builder);
|
||||
try_run(builder, builder.tool_cmd(Tool::Linkchecker)
|
||||
.arg(builder.out.join(host).join("doc")));
|
||||
try_run(
|
||||
builder,
|
||||
builder
|
||||
.tool_cmd(Tool::Linkchecker)
|
||||
.arg(builder.out.join(host).join("doc")),
|
||||
);
|
||||
}
|
||||
|
||||
fn should_run(run: ShouldRun) -> ShouldRun {
|
||||
let builder = run.builder;
|
||||
run.path("src/tools/linkchecker").default_condition(builder.config.docs)
|
||||
run.path("src/tools/linkchecker")
|
||||
.default_condition(builder.config.docs)
|
||||
}
|
||||
|
||||
fn make_run(run: RunConfig) {
|
||||
@ -165,7 +170,10 @@ impl Step for Cargotest {
|
||||
/// test` to ensure that we don't regress the test suites there.
|
||||
fn run(self, builder: &Builder) {
|
||||
let compiler = builder.compiler(self.stage, self.host);
|
||||
builder.ensure(compile::Rustc { compiler, target: compiler.host });
|
||||
builder.ensure(compile::Rustc {
|
||||
compiler,
|
||||
target: compiler.host,
|
||||
});
|
||||
|
||||
// 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
|
||||
@ -175,10 +183,13 @@ impl Step for Cargotest {
|
||||
|
||||
let _time = util::timeit(&builder);
|
||||
let mut cmd = builder.tool_cmd(Tool::CargoTest);
|
||||
try_run(builder, cmd.arg(&builder.initial_cargo)
|
||||
.arg(&out_dir)
|
||||
.env("RUSTC", builder.rustc(compiler))
|
||||
.env("RUSTDOC", builder.rustdoc(compiler.host)));
|
||||
try_run(
|
||||
builder,
|
||||
cmd.arg(&builder.initial_cargo)
|
||||
.arg(&out_dir)
|
||||
.env("RUSTC", builder.rustc(compiler))
|
||||
.env("RUSTDOC", builder.rustdoc(compiler.host)),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -207,9 +218,14 @@ impl Step for Cargo {
|
||||
fn run(self, builder: &Builder) {
|
||||
let compiler = builder.compiler(self.stage, self.host);
|
||||
|
||||
builder.ensure(tool::Cargo { compiler, target: self.host });
|
||||
builder.ensure(tool::Cargo {
|
||||
compiler,
|
||||
target: self.host,
|
||||
});
|
||||
let mut cargo = builder.cargo(compiler, Mode::Tool, self.host, "test");
|
||||
cargo.arg("--manifest-path").arg(builder.src.join("src/tools/cargo/Cargo.toml"));
|
||||
cargo
|
||||
.arg("--manifest-path")
|
||||
.arg(builder.src.join("src/tools/cargo/Cargo.toml"));
|
||||
if !builder.fail_fast {
|
||||
cargo.arg("--no-fail-fast");
|
||||
}
|
||||
@ -221,7 +237,10 @@ impl Step for Cargo {
|
||||
// available.
|
||||
cargo.env("CFG_DISABLE_CROSS_TESTS", "1");
|
||||
|
||||
try_run(builder, cargo.env("PATH", &path_for_cargo(builder, compiler)));
|
||||
try_run(
|
||||
builder,
|
||||
cargo.env("PATH", &path_for_cargo(builder, compiler)),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -262,11 +281,7 @@ impl Step for Rls {
|
||||
return;
|
||||
}
|
||||
|
||||
let mut cargo = tool::prepare_tool_cargo(builder,
|
||||
compiler,
|
||||
host,
|
||||
"test",
|
||||
"src/tools/rls");
|
||||
let mut cargo = tool::prepare_tool_cargo(builder, compiler, host, "test", "src/tools/rls");
|
||||
|
||||
// Don't build tests dynamically, just a pain to work with
|
||||
cargo.env("RUSTC_NO_PREFER_DYNAMIC", "1");
|
||||
@ -316,11 +331,8 @@ impl Step for Rustfmt {
|
||||
return;
|
||||
}
|
||||
|
||||
let mut cargo = tool::prepare_tool_cargo(builder,
|
||||
compiler,
|
||||
host,
|
||||
"test",
|
||||
"src/tools/rustfmt");
|
||||
let mut cargo =
|
||||
tool::prepare_tool_cargo(builder, compiler, host, "test", "src/tools/rustfmt");
|
||||
|
||||
// Don't build tests dynamically, just a pain to work with
|
||||
cargo.env("RUSTC_NO_PREFER_DYNAMIC", "1");
|
||||
@ -372,7 +384,9 @@ impl Step for Miri {
|
||||
});
|
||||
if let Some(miri) = miri {
|
||||
let mut cargo = builder.cargo(compiler, Mode::Tool, host, "test");
|
||||
cargo.arg("--manifest-path").arg(builder.src.join("src/tools/miri/Cargo.toml"));
|
||||
cargo
|
||||
.arg("--manifest-path")
|
||||
.arg(builder.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");
|
||||
@ -428,7 +442,9 @@ impl Step for Clippy {
|
||||
});
|
||||
if let Some(clippy) = clippy {
|
||||
let mut cargo = builder.cargo(compiler, Mode::Tool, host, "test");
|
||||
cargo.arg("--manifest-path").arg(builder.src.join("src/tools/clippy/Cargo.toml"));
|
||||
cargo
|
||||
.arg("--manifest-path")
|
||||
.arg(builder.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");
|
||||
@ -436,7 +452,9 @@ impl Step for Clippy {
|
||||
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());
|
||||
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);
|
||||
@ -478,23 +496,30 @@ impl Step for RustdocTheme {
|
||||
fn make_run(run: RunConfig) {
|
||||
let compiler = run.builder.compiler(run.builder.top_stage, run.host);
|
||||
|
||||
run.builder.ensure(RustdocTheme {
|
||||
compiler: compiler,
|
||||
});
|
||||
run.builder.ensure(RustdocTheme { compiler: compiler });
|
||||
}
|
||||
|
||||
fn run(self, builder: &Builder) {
|
||||
let rustdoc = builder.out.join("bootstrap/debug/rustdoc");
|
||||
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())
|
||||
.env("RUSTC_SYSROOT", builder.sysroot(self.compiler))
|
||||
.env("RUSTDOC_LIBDIR", builder.sysroot_libdir(self.compiler, self.compiler.host))
|
||||
.env("CFG_RELEASE_CHANNEL", &builder.config.channel)
|
||||
.env("RUSTDOC_REAL", builder.rustdoc(self.compiler.host))
|
||||
.env("RUSTDOC_CRATE_VERSION", builder.rust_version())
|
||||
.env("RUSTC_BOOTSTRAP", "1");
|
||||
.arg(
|
||||
builder
|
||||
.src
|
||||
.join("src/librustdoc/html/static/themes")
|
||||
.to_str()
|
||||
.unwrap(),
|
||||
)
|
||||
.env("RUSTC_STAGE", self.compiler.stage.to_string())
|
||||
.env("RUSTC_SYSROOT", builder.sysroot(self.compiler))
|
||||
.env(
|
||||
"RUSTDOC_LIBDIR",
|
||||
builder.sysroot_libdir(self.compiler, self.compiler.host),
|
||||
)
|
||||
.env("CFG_RELEASE_CHANNEL", &builder.config.channel)
|
||||
.env("RUSTDOC_REAL", builder.rustdoc(self.compiler.host))
|
||||
.env("RUSTDOC_CRATE_VERSION", builder.rust_version())
|
||||
.env("RUSTC_BOOTSTRAP", "1");
|
||||
if let Some(linker) = builder.linker(self.compiler.host) {
|
||||
cmd.env("RUSTC_TARGET_LINKER", linker);
|
||||
}
|
||||
@ -534,7 +559,9 @@ impl Step for RustdocJS {
|
||||
});
|
||||
builder.run(&mut command);
|
||||
} else {
|
||||
builder.info(&format!("No nodejs found, skipping \"src/test/rustdoc-js\" tests"));
|
||||
builder.info(&format!(
|
||||
"No nodejs found, skipping \"src/test/rustdoc-js\" tests"
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -887,7 +914,6 @@ impl Step for Compiletest {
|
||||
let target = self.target;
|
||||
let mode = self.mode;
|
||||
let suite = self.suite;
|
||||
let compare_mode = self.compare_mode;
|
||||
|
||||
// Path for test suite
|
||||
let suite_path = self.path.unwrap_or("");
|
||||
@ -919,7 +945,7 @@ impl Step for Compiletest {
|
||||
|
||||
builder.ensure(dist::DebuggerScripts {
|
||||
sysroot: builder.sysroot(compiler),
|
||||
host: target
|
||||
host: target,
|
||||
});
|
||||
}
|
||||
|
||||
@ -927,7 +953,8 @@ impl Step for Compiletest {
|
||||
// FIXME: Does pretty need librustc compiled? Note that there are
|
||||
// fulldeps test suites with mode = pretty as well.
|
||||
mode == "pretty" ||
|
||||
mode == "rustdoc" {
|
||||
mode == "rustdoc"
|
||||
{
|
||||
builder.ensure(compile::Rustc { compiler, target });
|
||||
}
|
||||
|
||||
@ -940,31 +967,41 @@ impl Step for Compiletest {
|
||||
// compiletest currently has... a lot of arguments, so let's just pass all
|
||||
// of them!
|
||||
|
||||
cmd.arg("--compile-lib-path").arg(builder.rustc_libdir(compiler));
|
||||
cmd.arg("--run-lib-path").arg(builder.sysroot_libdir(compiler, target));
|
||||
cmd.arg("--compile-lib-path")
|
||||
.arg(builder.rustc_libdir(compiler));
|
||||
cmd.arg("--run-lib-path")
|
||||
.arg(builder.sysroot_libdir(compiler, target));
|
||||
cmd.arg("--rustc-path").arg(builder.rustc(compiler));
|
||||
|
||||
let is_rustdoc_ui = suite.ends_with("rustdoc-ui");
|
||||
|
||||
// Avoid depending on rustdoc when we don't need it.
|
||||
if mode == "rustdoc" ||
|
||||
(mode == "run-make" && suite.ends_with("fulldeps")) ||
|
||||
(mode == "ui" && is_rustdoc_ui) {
|
||||
cmd.arg("--rustdoc-path").arg(builder.rustdoc(compiler.host));
|
||||
if mode == "rustdoc"
|
||||
|| (mode == "run-make" && suite.ends_with("fulldeps"))
|
||||
|| (mode == "ui" && is_rustdoc_ui)
|
||||
{
|
||||
cmd.arg("--rustdoc-path")
|
||||
.arg(builder.rustdoc(compiler.host));
|
||||
}
|
||||
|
||||
cmd.arg("--src-base").arg(builder.src.join("src/test").join(suite));
|
||||
cmd.arg("--build-base").arg(testdir(builder, compiler.host).join(suite));
|
||||
cmd.arg("--stage-id").arg(format!("stage{}-{}", compiler.stage, target));
|
||||
cmd.arg("--src-base")
|
||||
.arg(builder.src.join("src/test").join(suite));
|
||||
cmd.arg("--build-base")
|
||||
.arg(testdir(builder, compiler.host).join(suite));
|
||||
cmd.arg("--stage-id")
|
||||
.arg(format!("stage{}-{}", compiler.stage, target));
|
||||
cmd.arg("--mode").arg(mode);
|
||||
cmd.arg("--target").arg(target);
|
||||
cmd.arg("--host").arg(&*compiler.host);
|
||||
cmd.arg("--llvm-filecheck").arg(builder.llvm_filecheck(builder.config.build));
|
||||
cmd.arg("--llvm-filecheck")
|
||||
.arg(builder.llvm_filecheck(builder.config.build));
|
||||
|
||||
if builder.config.cmd.bless() {
|
||||
cmd.arg("--bless");
|
||||
}
|
||||
|
||||
let compare_mode = builder.config.cmd.compare_mode().or(self.compare_mode);
|
||||
|
||||
if let Some(ref nodejs) = builder.config.nodejs {
|
||||
cmd.arg("--nodejs").arg(nodejs);
|
||||
}
|
||||
@ -993,8 +1030,10 @@ impl Step for Compiletest {
|
||||
cmd.arg("--host-rustcflags").arg(hostflags.join(" "));
|
||||
|
||||
let mut targetflags = flags.clone();
|
||||
targetflags.push(format!("-Lnative={}",
|
||||
builder.test_helpers_out(target).display()));
|
||||
targetflags.push(format!(
|
||||
"-Lnative={}",
|
||||
builder.test_helpers_out(target).display()
|
||||
));
|
||||
cmd.arg("--target-rustcflags").arg(targetflags.join(" "));
|
||||
|
||||
cmd.arg("--docck-python").arg(builder.python());
|
||||
@ -1020,13 +1059,16 @@ impl Step for Compiletest {
|
||||
|
||||
// Get paths from cmd args
|
||||
let paths = match &builder.config.cmd {
|
||||
Subcommand::Test { ref paths, ..} => &paths[..],
|
||||
_ => &[]
|
||||
Subcommand::Test { ref paths, .. } => &paths[..],
|
||||
_ => &[],
|
||||
};
|
||||
|
||||
// Get test-args by striping suite path
|
||||
let mut test_args: Vec<&str> = paths.iter().filter(|p| p.starts_with(suite_path) &&
|
||||
p.is_file()).map(|p| p.strip_prefix(suite_path).unwrap().to_str().unwrap()).collect();
|
||||
let mut test_args: Vec<&str> = paths
|
||||
.iter()
|
||||
.filter(|p| p.starts_with(suite_path) && p.is_file())
|
||||
.map(|p| p.strip_prefix(suite_path).unwrap().to_str().unwrap())
|
||||
.collect();
|
||||
|
||||
test_args.append(&mut builder.config.cmd.test_args());
|
||||
|
||||
@ -1058,32 +1100,44 @@ impl Step for Compiletest {
|
||||
if !builder.config.dry_run && suite == "run-make-fulldeps" {
|
||||
let llvm_components = output(Command::new(&llvm_config).arg("--components"));
|
||||
let llvm_cxxflags = output(Command::new(&llvm_config).arg("--cxxflags"));
|
||||
cmd.arg("--cc").arg(builder.cc(target))
|
||||
.arg("--cxx").arg(builder.cxx(target).unwrap())
|
||||
.arg("--cflags").arg(builder.cflags(target).join(" "))
|
||||
.arg("--llvm-components").arg(llvm_components.trim())
|
||||
.arg("--llvm-cxxflags").arg(llvm_cxxflags.trim());
|
||||
cmd.arg("--cc")
|
||||
.arg(builder.cc(target))
|
||||
.arg("--cxx")
|
||||
.arg(builder.cxx(target).unwrap())
|
||||
.arg("--cflags")
|
||||
.arg(builder.cflags(target).join(" "))
|
||||
.arg("--llvm-components")
|
||||
.arg(llvm_components.trim())
|
||||
.arg("--llvm-cxxflags")
|
||||
.arg(llvm_cxxflags.trim());
|
||||
if let Some(ar) = builder.ar(target) {
|
||||
cmd.arg("--ar").arg(ar);
|
||||
}
|
||||
}
|
||||
}
|
||||
if suite == "run-make-fulldeps" && !builder.config.llvm_enabled {
|
||||
builder.info(
|
||||
&format!("Ignoring run-make test suite as they generally don't work without LLVM"));
|
||||
builder.info(&format!(
|
||||
"Ignoring run-make test suite as they generally don't work without LLVM"
|
||||
));
|
||||
return;
|
||||
}
|
||||
|
||||
if suite != "run-make-fulldeps" {
|
||||
cmd.arg("--cc").arg("")
|
||||
.arg("--cxx").arg("")
|
||||
.arg("--cflags").arg("")
|
||||
.arg("--llvm-components").arg("")
|
||||
.arg("--llvm-cxxflags").arg("");
|
||||
cmd.arg("--cc")
|
||||
.arg("")
|
||||
.arg("--cxx")
|
||||
.arg("")
|
||||
.arg("--cflags")
|
||||
.arg("")
|
||||
.arg("--llvm-components")
|
||||
.arg("")
|
||||
.arg("--llvm-cxxflags")
|
||||
.arg("");
|
||||
}
|
||||
|
||||
if builder.remote_tested(target) {
|
||||
cmd.arg("--remote-test-client").arg(builder.tool_exe(Tool::RemoteTestClient));
|
||||
cmd.arg("--remote-test-client")
|
||||
.arg(builder.tool_exe(Tool::RemoteTestClient));
|
||||
}
|
||||
|
||||
// Running a C compiler on MSVC requires a few env vars to be set, to be
|
||||
@ -1116,7 +1170,7 @@ impl Step for Compiletest {
|
||||
if target.contains("android") {
|
||||
// Assume that cc for this target comes from the android sysroot
|
||||
cmd.arg("--android-cross-path")
|
||||
.arg(builder.cc(target).parent().unwrap().parent().unwrap());
|
||||
.arg(builder.cc(target).parent().unwrap().parent().unwrap());
|
||||
} else {
|
||||
cmd.arg("--android-cross-path").arg("");
|
||||
}
|
||||
@ -1124,16 +1178,20 @@ impl Step for Compiletest {
|
||||
builder.ci_env.force_coloring_in_ci(&mut cmd);
|
||||
|
||||
let _folder = builder.fold_output(|| format!("test_{}", suite));
|
||||
builder.info(&format!("Check compiletest suite={} mode={} ({} -> {})",
|
||||
suite, mode, &compiler.host, target));
|
||||
builder.info(&format!(
|
||||
"Check compiletest suite={} mode={} ({} -> {})",
|
||||
suite, mode, &compiler.host, target
|
||||
));
|
||||
let _time = util::timeit(&builder);
|
||||
try_run(builder, &mut cmd);
|
||||
|
||||
if let Some(compare_mode) = compare_mode {
|
||||
cmd.arg("--compare-mode").arg(compare_mode);
|
||||
let _folder = builder.fold_output(|| format!("test_{}_{}", suite, compare_mode));
|
||||
builder.info(&format!("Check compiletest suite={} mode={} compare_mode={} ({} -> {})",
|
||||
suite, mode, compare_mode, &compiler.host, target));
|
||||
builder.info(&format!(
|
||||
"Check compiletest suite={} mode={} compare_mode={} ({} -> {})",
|
||||
suite, mode, compare_mode, &compiler.host, target
|
||||
));
|
||||
let _time = util::timeit(&builder);
|
||||
try_run(builder, &mut cmd);
|
||||
}
|
||||
@ -1164,7 +1222,10 @@ impl Step for DocTest {
|
||||
fn run(self, builder: &Builder) {
|
||||
let compiler = self.compiler;
|
||||
|
||||
builder.ensure(compile::Test { compiler, target: compiler.host });
|
||||
builder.ensure(compile::Test {
|
||||
compiler,
|
||||
target: compiler.host,
|
||||
});
|
||||
|
||||
// Do a breadth-first traversal of the `src/doc` directory and just run
|
||||
// tests for all files that end in `*.md`
|
||||
@ -1176,7 +1237,7 @@ impl Step for DocTest {
|
||||
while let Some(p) = stack.pop() {
|
||||
if p.is_dir() {
|
||||
stack.extend(t!(p.read_dir()).map(|p| t!(p).path()));
|
||||
continue
|
||||
continue;
|
||||
}
|
||||
|
||||
if p.extension().and_then(|s| s.to_str()) != Some("md") {
|
||||
@ -1283,7 +1344,10 @@ impl Step for ErrorIndex {
|
||||
fn run(self, builder: &Builder) {
|
||||
let compiler = self.compiler;
|
||||
|
||||
builder.ensure(compile::Std { compiler, target: compiler.host });
|
||||
builder.ensure(compile::Std {
|
||||
compiler,
|
||||
target: compiler.host,
|
||||
});
|
||||
|
||||
let dir = testdir(builder, compiler.host);
|
||||
t!(fs::create_dir_all(&dir));
|
||||
@ -1295,7 +1359,6 @@ impl Step for ErrorIndex {
|
||||
.env("CFG_BUILD", &builder.config.build)
|
||||
.env("RUSTC_ERROR_METADATA_DST", builder.extended_error_dir());
|
||||
|
||||
|
||||
let _folder = builder.fold_output(|| "test_error_index");
|
||||
builder.info(&format!("Testing error-index stage{}", compiler.stage));
|
||||
let _time = util::timeit(&builder);
|
||||
@ -1313,7 +1376,7 @@ fn markdown_test(builder: &Builder, compiler: Compiler, markdown: &Path) -> bool
|
||||
return true;
|
||||
}
|
||||
}
|
||||
Err(_) => {},
|
||||
Err(_) => {}
|
||||
}
|
||||
|
||||
builder.info(&format!("doc tests for: {}", markdown.display()));
|
||||
@ -1430,7 +1493,6 @@ impl Step for CrateNotDefault {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||
pub struct Crate {
|
||||
pub compiler: Compiler,
|
||||
@ -1448,10 +1510,11 @@ impl Step for Crate {
|
||||
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" {
|
||||
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());
|
||||
}
|
||||
}
|
||||
@ -1566,38 +1629,59 @@ impl Step for Crate {
|
||||
}
|
||||
|
||||
if target.contains("emscripten") {
|
||||
cargo.env(format!("CARGO_TARGET_{}_RUNNER", envify(&target)),
|
||||
builder.config.nodejs.as_ref().expect("nodejs not configured"));
|
||||
cargo.env(
|
||||
format!("CARGO_TARGET_{}_RUNNER", envify(&target)),
|
||||
builder
|
||||
.config
|
||||
.nodejs
|
||||
.as_ref()
|
||||
.expect("nodejs not configured"),
|
||||
);
|
||||
} else if target.starts_with("wasm32") {
|
||||
// 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 !builder.config.wasm_syscall {
|
||||
builder.info(&format!("Libstd was built without `wasm_syscall` feature enabled: \
|
||||
test output may not be visible."));
|
||||
builder.info(&format!(
|
||||
"Libstd was built without `wasm_syscall` feature enabled: \
|
||||
test output may not be visible."
|
||||
));
|
||||
}
|
||||
|
||||
// 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 = builder.config.nodejs.as_ref()
|
||||
let node = builder
|
||||
.config
|
||||
.nodejs
|
||||
.as_ref()
|
||||
.expect("nodejs not configured");
|
||||
let runner = format!("{} {}/src/etc/wasm32-shim.js",
|
||||
node.display(),
|
||||
builder.src.display());
|
||||
let runner = format!(
|
||||
"{} {}/src/etc/wasm32-shim.js",
|
||||
node.display(),
|
||||
builder.src.display()
|
||||
);
|
||||
cargo.env(format!("CARGO_TARGET_{}_RUNNER", envify(&target)), &runner);
|
||||
} else if builder.remote_tested(target) {
|
||||
cargo.env(format!("CARGO_TARGET_{}_RUNNER", envify(&target)),
|
||||
format!("{} run",
|
||||
builder.tool_exe(Tool::RemoteTestClient).display()));
|
||||
cargo.env(
|
||||
format!("CARGO_TARGET_{}_RUNNER", envify(&target)),
|
||||
format!("{} run", builder.tool_exe(Tool::RemoteTestClient).display()),
|
||||
);
|
||||
}
|
||||
|
||||
let _folder = builder.fold_output(|| {
|
||||
format!("{}_stage{}-{}", test_kind.subcommand(), compiler.stage, krate)
|
||||
format!(
|
||||
"{}_stage{}-{}",
|
||||
test_kind.subcommand(),
|
||||
compiler.stage,
|
||||
krate
|
||||
)
|
||||
});
|
||||
builder.info(&format!("{} {} stage{} ({} -> {})", test_kind, krate, compiler.stage,
|
||||
&compiler.host, target));
|
||||
builder.info(&format!(
|
||||
"{} {} stage{} ({} -> {})",
|
||||
test_kind, krate, compiler.stage, &compiler.host, target
|
||||
));
|
||||
let _time = util::timeit(&builder);
|
||||
try_run(builder, &mut cargo);
|
||||
}
|
||||
@ -1635,11 +1719,13 @@ impl Step for CrateRustdoc {
|
||||
let compiler = builder.compiler(builder.top_stage, self.host);
|
||||
let target = compiler.host;
|
||||
|
||||
let mut cargo = tool::prepare_tool_cargo(builder,
|
||||
compiler,
|
||||
target,
|
||||
test_kind.subcommand(),
|
||||
"src/tools/rustdoc");
|
||||
let mut cargo = tool::prepare_tool_cargo(
|
||||
builder,
|
||||
compiler,
|
||||
target,
|
||||
test_kind.subcommand(),
|
||||
"src/tools/rustdoc",
|
||||
);
|
||||
if test_kind.subcommand() == "test" && !builder.fail_fast {
|
||||
cargo.arg("--no-fail-fast");
|
||||
}
|
||||
@ -1653,11 +1739,12 @@ impl Step for CrateRustdoc {
|
||||
cargo.arg("--quiet");
|
||||
}
|
||||
|
||||
let _folder = builder.fold_output(|| {
|
||||
format!("{}_stage{}-rustdoc", test_kind.subcommand(), compiler.stage)
|
||||
});
|
||||
builder.info(&format!("{} rustdoc stage{} ({} -> {})", test_kind, compiler.stage,
|
||||
&compiler.host, target));
|
||||
let _folder = builder
|
||||
.fold_output(|| format!("{}_stage{}-rustdoc", test_kind.subcommand(), compiler.stage));
|
||||
builder.info(&format!(
|
||||
"{} rustdoc stage{} ({} -> {})",
|
||||
test_kind, compiler.stage, &compiler.host, target
|
||||
));
|
||||
let _time = util::timeit(&builder);
|
||||
|
||||
try_run(builder, &mut cargo);
|
||||
@ -1665,12 +1752,13 @@ impl Step for CrateRustdoc {
|
||||
}
|
||||
|
||||
fn envify(s: &str) -> String {
|
||||
s.chars().map(|c| {
|
||||
match c {
|
||||
s.chars()
|
||||
.map(|c| match c {
|
||||
'-' => '_',
|
||||
c => c,
|
||||
}
|
||||
}).flat_map(|c| c.to_uppercase()).collect()
|
||||
})
|
||||
.flat_map(|c| c.to_uppercase())
|
||||
.collect()
|
||||
}
|
||||
|
||||
/// Some test suites are run inside emulators or on remote devices, and most
|
||||
@ -1699,7 +1787,7 @@ impl Step for RemoteCopyLibs {
|
||||
let compiler = self.compiler;
|
||||
let target = self.target;
|
||||
if !builder.remote_tested(target) {
|
||||
return
|
||||
return;
|
||||
}
|
||||
|
||||
builder.ensure(compile::Test { compiler, target });
|
||||
@ -1713,9 +1801,9 @@ impl Step for RemoteCopyLibs {
|
||||
let tool = builder.tool_exe(Tool::RemoteTestClient);
|
||||
let mut cmd = Command::new(&tool);
|
||||
cmd.arg("spawn-emulator")
|
||||
.arg(target)
|
||||
.arg(&server)
|
||||
.arg(builder.out.join("tmp"));
|
||||
.arg(target)
|
||||
.arg(&server)
|
||||
.arg(builder.out.join("tmp"));
|
||||
if let Some(rootfs) = builder.qemu_rootfs(target) {
|
||||
cmd.arg(rootfs);
|
||||
}
|
||||
@ -1726,9 +1814,7 @@ impl Step for RemoteCopyLibs {
|
||||
let f = t!(f);
|
||||
let name = f.file_name().into_string().unwrap();
|
||||
if util::is_dylib(&name) {
|
||||
builder.run(Command::new(&tool)
|
||||
.arg("push")
|
||||
.arg(f.path()));
|
||||
builder.run(Command::new(&tool).arg("push").arg(f.path()));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1761,17 +1847,21 @@ impl Step for Distcheck {
|
||||
|
||||
let mut cmd = Command::new("tar");
|
||||
cmd.arg("-xzf")
|
||||
.arg(builder.ensure(dist::PlainSourceTarball))
|
||||
.arg("--strip-components=1")
|
||||
.current_dir(&dir);
|
||||
.arg(builder.ensure(dist::PlainSourceTarball))
|
||||
.arg("--strip-components=1")
|
||||
.current_dir(&dir);
|
||||
builder.run(&mut cmd);
|
||||
builder.run(Command::new("./configure")
|
||||
.args(&builder.config.configure_args)
|
||||
.arg("--enable-vendor")
|
||||
.current_dir(&dir));
|
||||
builder.run(Command::new(build_helper::make(&builder.config.build))
|
||||
.arg("check")
|
||||
.current_dir(&dir));
|
||||
builder.run(
|
||||
Command::new("./configure")
|
||||
.args(&builder.config.configure_args)
|
||||
.arg("--enable-vendor")
|
||||
.current_dir(&dir),
|
||||
);
|
||||
builder.run(
|
||||
Command::new(build_helper::make(&builder.config.build))
|
||||
.arg("check")
|
||||
.current_dir(&dir),
|
||||
);
|
||||
|
||||
// Now make sure that rust-src has all of libstd's dependencies
|
||||
builder.info(&format!("Distcheck rust-src"));
|
||||
@ -1781,17 +1871,19 @@ impl Step for Distcheck {
|
||||
|
||||
let mut cmd = Command::new("tar");
|
||||
cmd.arg("-xzf")
|
||||
.arg(builder.ensure(dist::Src))
|
||||
.arg("--strip-components=1")
|
||||
.current_dir(&dir);
|
||||
.arg(builder.ensure(dist::Src))
|
||||
.arg("--strip-components=1")
|
||||
.current_dir(&dir);
|
||||
builder.run(&mut cmd);
|
||||
|
||||
let toml = dir.join("rust-src/lib/rustlib/src/rust/src/libstd/Cargo.toml");
|
||||
builder.run(Command::new(&builder.initial_cargo)
|
||||
.arg("generate-lockfile")
|
||||
.arg("--manifest-path")
|
||||
.arg(&toml)
|
||||
.current_dir(&dir));
|
||||
builder.run(
|
||||
Command::new(&builder.initial_cargo)
|
||||
.arg("generate-lockfile")
|
||||
.arg("--manifest-path")
|
||||
.arg(&toml)
|
||||
.current_dir(&dir),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1807,11 +1899,11 @@ impl Step for Bootstrap {
|
||||
fn run(self, builder: &Builder) {
|
||||
let mut cmd = Command::new(&builder.initial_cargo);
|
||||
cmd.arg("test")
|
||||
.current_dir(builder.src.join("src/bootstrap"))
|
||||
.env("RUSTFLAGS", "-Cdebuginfo=2")
|
||||
.env("CARGO_TARGET_DIR", builder.out.join("bootstrap"))
|
||||
.env("RUSTC_BOOTSTRAP", "1")
|
||||
.env("RUSTC", &builder.initial_rustc);
|
||||
.current_dir(builder.src.join("src/bootstrap"))
|
||||
.env("RUSTFLAGS", "-Cdebuginfo=2")
|
||||
.env("CARGO_TARGET_DIR", builder.out.join("bootstrap"))
|
||||
.env("RUSTC_BOOTSTRAP", "1")
|
||||
.env("RUSTC", &builder.initial_rustc);
|
||||
if let Some(flags) = option_env!("RUSTFLAGS") {
|
||||
// Use the same rustc flags for testing as for "normal" compilation,
|
||||
// so that Cargo doesn’t recompile the entire dependency graph every time:
|
||||
|
@ -99,18 +99,21 @@ impl fmt::Display for Mode {
|
||||
#[derive(Clone, PartialEq)]
|
||||
pub enum CompareMode {
|
||||
Nll,
|
||||
Polonius,
|
||||
}
|
||||
|
||||
impl CompareMode {
|
||||
pub(crate) fn to_str(&self) -> &'static str {
|
||||
match *self {
|
||||
CompareMode::Nll => "nll",
|
||||
CompareMode::Polonius => "polonius",
|
||||
}
|
||||
}
|
||||
|
||||
pub fn parse(s: String) -> CompareMode {
|
||||
match s.as_str() {
|
||||
"nll" => CompareMode::Nll,
|
||||
"polonius" => CompareMode::Polonius,
|
||||
x => panic!("unknown --compare-mode option: {}", x),
|
||||
}
|
||||
}
|
||||
|
@ -9,7 +9,7 @@
|
||||
// except according to those terms.
|
||||
|
||||
use common::CompareMode;
|
||||
use common::{expected_output_path, UI_STDERR, UI_STDOUT, UI_FIXED};
|
||||
use common::{expected_output_path, UI_FIXED, UI_STDERR, UI_STDOUT};
|
||||
use common::{output_base_dir, output_base_name, output_testname_unique};
|
||||
use common::{Codegen, CodegenUnits, DebugInfoGdb, DebugInfoLldb, Rustdoc};
|
||||
use common::{CompileFail, ParseFail, Pretty, RunFail, RunPass, RunPassValgrind};
|
||||
@ -24,8 +24,8 @@ use regex::Regex;
|
||||
use rustfix::{apply_suggestions, get_suggestions_from_json};
|
||||
use util::{logv, PathBufExt};
|
||||
|
||||
use std::collections::{HashMap, HashSet, VecDeque};
|
||||
use std::collections::hash_map::DefaultHasher;
|
||||
use std::collections::{HashMap, HashSet, VecDeque};
|
||||
use std::env;
|
||||
use std::ffi::OsString;
|
||||
use std::fmt;
|
||||
@ -48,9 +48,7 @@ fn disable_error_reporting<F: FnOnce() -> R, R>(f: F) -> R {
|
||||
}
|
||||
|
||||
lazy_static! {
|
||||
static ref LOCK: Mutex<()> = {
|
||||
Mutex::new(())
|
||||
};
|
||||
static ref LOCK: Mutex<()> = { Mutex::new(()) };
|
||||
}
|
||||
// Error mode is a global variable, so lock it so only one thread will change it
|
||||
let _lock = LOCK.lock().unwrap();
|
||||
@ -743,7 +741,8 @@ impl<'test> TestCx<'test> {
|
||||
}
|
||||
|
||||
_ => {
|
||||
let rust_src_root = self.config
|
||||
let rust_src_root = self
|
||||
.config
|
||||
.find_rust_src_root()
|
||||
.expect("Could not find Rust source root");
|
||||
let rust_pp_module_rel_path = Path::new("./src/etc");
|
||||
@ -905,7 +904,8 @@ impl<'test> TestCx<'test> {
|
||||
script_str.push_str("version\n");
|
||||
|
||||
// Switch LLDB into "Rust mode"
|
||||
let rust_src_root = self.config
|
||||
let rust_src_root = self
|
||||
.config
|
||||
.find_rust_src_root()
|
||||
.expect("Could not find Rust source root");
|
||||
let rust_pp_module_rel_path = Path::new("./src/etc/lldb_rust_formatters.py");
|
||||
@ -1052,7 +1052,8 @@ impl<'test> TestCx<'test> {
|
||||
|
||||
// Remove options that are either unwanted (-O) or may lead to duplicates due to RUSTFLAGS.
|
||||
let options_to_remove = ["-O".to_owned(), "-g".to_owned(), "--debuginfo".to_owned()];
|
||||
let new_options = self.split_maybe_args(options)
|
||||
let new_options = self
|
||||
.split_maybe_args(options)
|
||||
.into_iter()
|
||||
.filter(|x| !options_to_remove.contains(x))
|
||||
.collect::<Vec<String>>();
|
||||
@ -1351,7 +1352,8 @@ impl<'test> TestCx<'test> {
|
||||
|
||||
let aux_dir = self.aux_output_dir_name();
|
||||
|
||||
let rustdoc_path = self.config
|
||||
let rustdoc_path = self
|
||||
.config
|
||||
.rustdoc_path
|
||||
.as_ref()
|
||||
.expect("--rustdoc-path passed");
|
||||
@ -1449,7 +1451,8 @@ impl<'test> TestCx<'test> {
|
||||
/// For each `aux-build: foo/bar` annotation, we check to find the
|
||||
/// file in a `auxiliary` directory relative to the test itself.
|
||||
fn compute_aux_test_paths(&self, rel_ab: &str) -> TestPaths {
|
||||
let test_ab = self.testpaths
|
||||
let test_ab = self
|
||||
.testpaths
|
||||
.file
|
||||
.parent()
|
||||
.expect("test file path has no parent")
|
||||
@ -1464,7 +1467,8 @@ impl<'test> TestCx<'test> {
|
||||
|
||||
TestPaths {
|
||||
file: test_ab,
|
||||
relative_dir: self.testpaths
|
||||
relative_dir: self
|
||||
.testpaths
|
||||
.relative_dir
|
||||
.join(self.output_testname_unique())
|
||||
.join("auxiliary")
|
||||
@ -1617,16 +1621,20 @@ impl<'test> TestCx<'test> {
|
||||
let mut rustc = if !is_rustdoc {
|
||||
Command::new(&self.config.rustc_path)
|
||||
} else {
|
||||
Command::new(&self.config
|
||||
.rustdoc_path
|
||||
.clone()
|
||||
.expect("no rustdoc built yet"))
|
||||
Command::new(
|
||||
&self
|
||||
.config
|
||||
.rustdoc_path
|
||||
.clone()
|
||||
.expect("no rustdoc built yet"),
|
||||
)
|
||||
};
|
||||
// FIXME Why is -L here?
|
||||
rustc.arg(input_file);//.arg("-L").arg(&self.config.build_base);
|
||||
rustc.arg(input_file); //.arg("-L").arg(&self.config.build_base);
|
||||
|
||||
// Optionally prevent default --target if specified in test compile-flags.
|
||||
let custom_target = self.props
|
||||
let custom_target = self
|
||||
.props
|
||||
.compile_flags
|
||||
.iter()
|
||||
.any(|x| x.starts_with("--target"));
|
||||
@ -1670,7 +1678,8 @@ impl<'test> TestCx<'test> {
|
||||
}
|
||||
}
|
||||
Ui => {
|
||||
if !self.props
|
||||
if !self
|
||||
.props
|
||||
.compile_flags
|
||||
.iter()
|
||||
.any(|s| s.starts_with("--error-format"))
|
||||
@ -1704,7 +1713,13 @@ impl<'test> TestCx<'test> {
|
||||
}
|
||||
|
||||
if self.props.skip_codegen {
|
||||
assert!(!self.props.compile_flags.iter().any(|s| s.starts_with("--emit")));
|
||||
assert!(
|
||||
!self
|
||||
.props
|
||||
.compile_flags
|
||||
.iter()
|
||||
.any(|s| s.starts_with("--emit"))
|
||||
);
|
||||
rustc.args(&["--emit", "metadata"]);
|
||||
}
|
||||
|
||||
@ -1729,6 +1744,9 @@ impl<'test> TestCx<'test> {
|
||||
Some(CompareMode::Nll) => {
|
||||
rustc.args(&["-Zborrowck=mir", "-Ztwo-phase-borrows"]);
|
||||
}
|
||||
Some(CompareMode::Polonius) => {
|
||||
rustc.args(&["-Zpolonius", "-Zborrowck=mir", "-Ztwo-phase-borrows"]);
|
||||
}
|
||||
None => {}
|
||||
}
|
||||
|
||||
@ -1809,7 +1827,8 @@ impl<'test> TestCx<'test> {
|
||||
|
||||
fn split_maybe_args(&self, argstr: &Option<String>) -> Vec<String> {
|
||||
match *argstr {
|
||||
Some(ref s) => s.split(' ')
|
||||
Some(ref s) => s
|
||||
.split(' ')
|
||||
.filter_map(|s| {
|
||||
if s.chars().all(|c| c.is_whitespace()) {
|
||||
None
|
||||
@ -2122,7 +2141,8 @@ impl<'test> TestCx<'test> {
|
||||
}
|
||||
|
||||
let mut tested = 0;
|
||||
for _ in res.stdout
|
||||
for _ in res
|
||||
.stdout
|
||||
.split('\n')
|
||||
.filter(|s| s.starts_with("test "))
|
||||
.inspect(|s| {
|
||||
@ -2133,7 +2153,8 @@ impl<'test> TestCx<'test> {
|
||||
tested += 1;
|
||||
let mut iter = tmp[1].split("(line ");
|
||||
iter.next();
|
||||
let line = iter.next()
|
||||
let line = iter
|
||||
.next()
|
||||
.unwrap_or(")")
|
||||
.split(')')
|
||||
.next()
|
||||
@ -2287,7 +2308,8 @@ impl<'test> TestCx<'test> {
|
||||
|
||||
let full_string = format!("{}{}", PREFIX, s.trim().to_owned());
|
||||
|
||||
let parts: Vec<&str> = s.split(CGU_MARKER)
|
||||
let parts: Vec<&str> = s
|
||||
.split(CGU_MARKER)
|
||||
.map(str::trim)
|
||||
.filter(|s| !s.is_empty())
|
||||
.collect();
|
||||
@ -2372,7 +2394,8 @@ impl<'test> TestCx<'test> {
|
||||
// FIXME -- use non-incremental mode as an oracle? That doesn't apply
|
||||
// to #[rustc_dirty] and clean tests I guess
|
||||
|
||||
let revision = self.revision
|
||||
let revision = self
|
||||
.revision
|
||||
.expect("incremental tests require a list of revisions");
|
||||
|
||||
// Incremental workproduct directory should have already been created.
|
||||
@ -2418,7 +2441,8 @@ impl<'test> TestCx<'test> {
|
||||
|
||||
fn run_rmake_test(&self) {
|
||||
let cwd = env::current_dir().unwrap();
|
||||
let src_root = self.config
|
||||
let src_root = self
|
||||
.config
|
||||
.src_base
|
||||
.parent()
|
||||
.unwrap()
|
||||
@ -2435,8 +2459,10 @@ impl<'test> TestCx<'test> {
|
||||
create_dir_all(&tmpdir).unwrap();
|
||||
|
||||
let host = &self.config.host;
|
||||
let make = if host.contains("bitrig") || host.contains("dragonfly")
|
||||
|| host.contains("freebsd") || host.contains("netbsd")
|
||||
let make = if host.contains("bitrig")
|
||||
|| host.contains("dragonfly")
|
||||
|| host.contains("freebsd")
|
||||
|| host.contains("netbsd")
|
||||
|| host.contains("openbsd")
|
||||
{
|
||||
"gmake"
|
||||
@ -2491,7 +2517,8 @@ impl<'test> TestCx<'test> {
|
||||
// MSYS doesn't like passing flags of the form `/foo` as it thinks it's
|
||||
// a path and instead passes `C:\msys64\foo`, so convert all
|
||||
// `/`-arguments to MSVC here to `-` arguments.
|
||||
let cflags = self.config
|
||||
let cflags = self
|
||||
.config
|
||||
.cflags
|
||||
.split(' ')
|
||||
.map(|s| s.replace("/", "-"))
|
||||
@ -2513,7 +2540,8 @@ impl<'test> TestCx<'test> {
|
||||
}
|
||||
}
|
||||
|
||||
let output = cmd.spawn()
|
||||
let output = cmd
|
||||
.spawn()
|
||||
.and_then(read2_abbreviated)
|
||||
.expect("failed to spawn `make`");
|
||||
if !output.status.success() {
|
||||
@ -2554,7 +2582,8 @@ impl<'test> TestCx<'test> {
|
||||
// if the user specified a format in the ui test
|
||||
// print the output to the stderr file, otherwise extract
|
||||
// the rendered error messages from json and print them
|
||||
let explicit = self.props
|
||||
let explicit = self
|
||||
.props
|
||||
.compile_flags
|
||||
.iter()
|
||||
.any(|s| s.contains("--error-format"));
|
||||
@ -2584,22 +2613,27 @@ impl<'test> TestCx<'test> {
|
||||
// don't test rustfix with nll right now
|
||||
} else if self.props.run_rustfix {
|
||||
// Apply suggestions from rustc to the code itself
|
||||
let unfixed_code = self.load_expected_output_from_path(&self.testpaths.file)
|
||||
let unfixed_code = self
|
||||
.load_expected_output_from_path(&self.testpaths.file)
|
||||
.unwrap();
|
||||
let suggestions = get_suggestions_from_json(&proc_res.stderr, &HashSet::new()).unwrap();
|
||||
let fixed_code = apply_suggestions(&unfixed_code, &suggestions).expect(
|
||||
&format!("failed to apply suggestions for {:?} with rustfix", self.testpaths.file)
|
||||
);
|
||||
let fixed_code = apply_suggestions(&unfixed_code, &suggestions).expect(&format!(
|
||||
"failed to apply suggestions for {:?} with rustfix",
|
||||
self.testpaths.file
|
||||
));
|
||||
|
||||
errors += self.compare_output("fixed", &fixed_code, &expected_fixed);
|
||||
} else if !expected_fixed.is_empty() {
|
||||
panic!("the `// run-rustfix` directive wasn't found but a `*.fixed` \
|
||||
file was found");
|
||||
panic!(
|
||||
"the `// run-rustfix` directive wasn't found but a `*.fixed` \
|
||||
file was found"
|
||||
);
|
||||
}
|
||||
|
||||
if errors > 0 {
|
||||
println!("To update references, rerun the tests and pass the `--bless` flag");
|
||||
let relative_path_to_file = self.testpaths
|
||||
let relative_path_to_file = self
|
||||
.testpaths
|
||||
.relative_dir
|
||||
.join(self.testpaths.file.file_name().unwrap());
|
||||
println!(
|
||||
@ -2781,11 +2815,7 @@ impl<'test> TestCx<'test> {
|
||||
Test Name: {}\n\
|
||||
Expected:\n{}\n\
|
||||
Actual:\n{}",
|
||||
extra_msg,
|
||||
expected_line,
|
||||
test_name,
|
||||
expected_content,
|
||||
normalize_all
|
||||
extra_msg, expected_line, test_name, expected_content, normalize_all
|
||||
);
|
||||
};
|
||||
|
||||
@ -2898,8 +2928,19 @@ impl<'test> TestCx<'test> {
|
||||
&self.config.compare_mode,
|
||||
kind,
|
||||
);
|
||||
if !path.exists() && self.config.compare_mode.is_some() {
|
||||
// fallback!
|
||||
|
||||
if !path.exists() {
|
||||
if let Some(CompareMode::Polonius) = self.config.compare_mode {
|
||||
path = expected_output_path(
|
||||
&self.testpaths,
|
||||
self.revision,
|
||||
&Some(CompareMode::Nll),
|
||||
kind,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if !path.exists() {
|
||||
path = expected_output_path(&self.testpaths, self.revision, &None, kind);
|
||||
}
|
||||
|
||||
@ -2964,7 +3005,8 @@ impl<'test> TestCx<'test> {
|
||||
}
|
||||
|
||||
let mode = self.config.compare_mode.as_ref().map_or("", |m| m.to_str());
|
||||
let output_file = self.output_base_name()
|
||||
let output_file = self
|
||||
.output_base_name()
|
||||
.with_extra_extension(self.revision.unwrap_or(""))
|
||||
.with_extra_extension(mode)
|
||||
.with_extra_extension(kind);
|
||||
@ -3014,7 +3056,8 @@ impl<'test> TestCx<'test> {
|
||||
|
||||
fn create_stamp(&self) {
|
||||
let mut f = File::create(::stamp(&self.config, self.testpaths, self.revision)).unwrap();
|
||||
f.write_all(compute_stamp_hash(&self.config).as_bytes()).unwrap();
|
||||
f.write_all(compute_stamp_hash(&self.config).as_bytes())
|
||||
.unwrap();
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user