1
Fork 0

Make bless a flag instead of a subcommand

This commit is contained in:
Oliver Schneider 2018-05-16 18:17:29 +02:00
parent 37dee69dac
commit ceed8eb89c
3 changed files with 11 additions and 22 deletions

View file

@ -311,8 +311,6 @@ impl<'a> ShouldRun<'a> {
pub enum Kind { pub enum Kind {
Build, Build,
Check, Check,
/// Run tests and replace any failing tests' output files (stderr/stout) with the correct ones
Bless,
Test, Test,
Bench, Bench,
Dist, Dist,
@ -336,7 +334,6 @@ impl<'a> Builder<'a> {
native::Llvm, tool::Rustfmt, tool::Miri, native::Lld), native::Llvm, tool::Rustfmt, tool::Miri, native::Lld),
Kind::Check => describe!(check::Std, check::Test, check::Rustc, check::CodegenBackend, Kind::Check => describe!(check::Std, check::Test, check::Rustc, check::CodegenBackend,
check::Rustdoc), check::Rustdoc),
Kind::Bless |
Kind::Test => describe!(test::Tidy, test::Bootstrap, test::Ui, test::RunPass, Kind::Test => describe!(test::Tidy, test::Bootstrap, test::Ui, test::RunPass,
test::CompileFail, test::ParseFail, test::RunFail, test::RunPassValgrind, test::CompileFail, test::ParseFail, test::RunFail, test::RunPassValgrind,
test::MirOpt, test::Codegen, test::CodegenUnits, test::Incremental, test::Debuginfo, test::MirOpt, test::Codegen, test::CodegenUnits, test::Incremental, test::Debuginfo,
@ -370,7 +367,6 @@ impl<'a> Builder<'a> {
let kind = match subcommand { let kind = match subcommand {
"build" => Kind::Build, "build" => Kind::Build,
"doc" => Kind::Doc, "doc" => Kind::Doc,
"bless" => Kind::Bless,
"test" => Kind::Test, "test" => Kind::Test,
"bench" => Kind::Bench, "bench" => Kind::Bench,
"dist" => Kind::Dist, "dist" => Kind::Dist,
@ -412,7 +408,6 @@ impl<'a> Builder<'a> {
Subcommand::Build { ref paths } => (Kind::Build, &paths[..]), Subcommand::Build { ref paths } => (Kind::Build, &paths[..]),
Subcommand::Check { ref paths } => (Kind::Check, &paths[..]), Subcommand::Check { ref paths } => (Kind::Check, &paths[..]),
Subcommand::Doc { ref paths } => (Kind::Doc, &paths[..]), Subcommand::Doc { ref paths } => (Kind::Doc, &paths[..]),
Subcommand::Test { ref paths, bless: true, .. } => (Kind::Bless, &paths[..]),
Subcommand::Test { ref paths, .. } => (Kind::Test, &paths[..]), Subcommand::Test { ref paths, .. } => (Kind::Test, &paths[..]),
Subcommand::Bench { ref paths, .. } => (Kind::Bench, &paths[..]), Subcommand::Bench { ref paths, .. } => (Kind::Bench, &paths[..]),
Subcommand::Dist { ref paths } => (Kind::Dist, &paths[..]), Subcommand::Dist { ref paths } => (Kind::Dist, &paths[..]),

View file

@ -144,7 +144,6 @@ To learn more about a subcommand, run `./x.py <subcommand> -h`");
let subcommand = args.iter().find(|&s| let subcommand = args.iter().find(|&s|
(s == "build") (s == "build")
|| (s == "check") || (s == "check")
|| (s == "bless")
|| (s == "test") || (s == "test")
|| (s == "bench") || (s == "bench")
|| (s == "doc") || (s == "doc")
@ -165,7 +164,6 @@ To learn more about a subcommand, run `./x.py <subcommand> -h`");
// Some subcommands get extra options // Some subcommands get extra options
match subcommand.as_str() { match subcommand.as_str() {
"bless" |
"test" => { "test" => {
opts.optflag("", "no-fail-fast", "Run all tests regardless of failure"); opts.optflag("", "no-fail-fast", "Run all tests regardless of failure");
opts.optmulti("", "test-args", "extra arguments", "ARGS"); opts.optmulti("", "test-args", "extra arguments", "ARGS");
@ -177,6 +175,7 @@ To learn more about a subcommand, run `./x.py <subcommand> -h`");
); );
opts.optflag("", "no-doc", "do not run doc tests"); opts.optflag("", "no-doc", "do not run doc tests");
opts.optflag("", "doc", "only 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"); }, "bench" => { opts.optmulti("", "test-args", "extra arguments", "ARGS"); },
"clean" => { opts.optflag("", "all", "clean all build artifacts"); }, "clean" => { opts.optflag("", "all", "clean all build artifacts"); },
@ -252,12 +251,6 @@ Arguments:
compilation, so there's no need to pass it separately, though it won't hurt. We also completely 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 ignore the stage passed, as there's no way to compile in non-stage 0 without actually building
the compiler."); the compiler.");
}
"bless" => {
subcommand_help.push_str("\n
Arguments:
This subcommand works exactly like the `test` subcommand, but also updates stderr/stdout files
before they cause a test failure");
} }
"test" => { "test" => {
subcommand_help.push_str("\n subcommand_help.push_str("\n
@ -268,6 +261,7 @@ Arguments:
./x.py test src/test/run-pass ./x.py test src/test/run-pass
./x.py test src/libstd --test-args hash_map ./x.py test src/libstd --test-args hash_map
./x.py test src/libstd --stage 0 ./x.py test src/libstd --stage 0
./x.py test src/test/ui --bless
If no arguments are passed then the complete artifacts for that stage are If no arguments are passed then the complete artifacts for that stage are
compiled and tested. compiled and tested.
@ -329,11 +323,10 @@ Arguments:
"check" => { "check" => {
Subcommand::Check { paths: paths } Subcommand::Check { paths: paths }
} }
"bless" |
"test" => { "test" => {
Subcommand::Test { Subcommand::Test {
paths, paths,
bless: subcommand.as_str() == "bless", bless: matches.opt_present("bless"),
test_args: matches.opt_strs("test-args"), test_args: matches.opt_strs("test-args"),
rustc_args: matches.opt_strs("rustc-args"), rustc_args: matches.opt_strs("rustc-args"),
fail_fast: !matches.opt_present("no-fail-fast"), fail_fast: !matches.opt_present("no-fail-fast"),
@ -436,6 +429,13 @@ impl Subcommand {
_ => DocTests::Yes, _ => DocTests::Yes,
} }
} }
pub fn bless(&self) -> bool {
match *self {
Subcommand::Test { bless, .. } => bless,
_ => false,
}
}
} }
fn split(s: Vec<String>) -> Vec<String> { fn split(s: Vec<String>) -> Vec<String> {

View file

@ -41,8 +41,6 @@ const ADB_TEST_DIR: &str = "/data/tmp/work";
/// The two modes of the test runner; tests or benchmarks. /// The two modes of the test runner; tests or benchmarks.
#[derive(Debug, PartialEq, Eq, Hash, Copy, Clone, PartialOrd, Ord)] #[derive(Debug, PartialEq, Eq, Hash, Copy, Clone, PartialOrd, Ord)]
pub enum TestKind { pub enum TestKind {
/// Run `cargo bless`
Bless,
/// Run `cargo test` /// Run `cargo test`
Test, Test,
/// Run `cargo bench` /// Run `cargo bench`
@ -53,7 +51,6 @@ impl From<Kind> for TestKind {
fn from(kind: Kind) -> Self { fn from(kind: Kind) -> Self {
match kind { match kind {
Kind::Test => TestKind::Test, Kind::Test => TestKind::Test,
Kind::Bless => TestKind::Bless,
Kind::Bench => TestKind::Bench, Kind::Bench => TestKind::Bench,
_ => panic!("unexpected kind in crate: {:?}", kind) _ => panic!("unexpected kind in crate: {:?}", kind)
} }
@ -64,8 +61,6 @@ impl TestKind {
// Return the cargo subcommand for this test kind // Return the cargo subcommand for this test kind
fn subcommand(self) -> &'static str { fn subcommand(self) -> &'static str {
match self { match self {
// bless and test are both `test` for folder names and cargo subcommands
TestKind::Bless |
TestKind::Test => "test", TestKind::Test => "test",
TestKind::Bench => "bench", TestKind::Bench => "bench",
} }
@ -75,7 +70,6 @@ impl TestKind {
impl fmt::Display for TestKind { impl fmt::Display for TestKind {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.write_str(match *self { f.write_str(match *self {
TestKind::Bless => "Testing (bless)",
TestKind::Test => "Testing", TestKind::Test => "Testing",
TestKind::Bench => "Benchmarking", TestKind::Bench => "Benchmarking",
}) })
@ -967,7 +961,7 @@ impl Step for Compiletest {
cmd.arg("--host").arg(&*compiler.host); 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.kind == Kind::Bless { if builder.config.cmd.bless() {
cmd.arg("--bless"); cmd.arg("--bless");
} }