Rollup merge of #77473 - Mark-Simulacrum:check-limited, r=ecstatic-morse

Make --all-targets in x.py check opt-in

In particular due to #76822, making this the default is currently suboptimal.

r? @ecstatic-morse
This commit is contained in:
Yuki Okushi 2020-10-04 11:45:10 +09:00 committed by GitHub
commit 69f2cf5ad9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 51 additions and 34 deletions

View File

@ -6,7 +6,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
## [Non-breaking changes since the last major version]
None.
- `x.py check` needs opt-in to check tests (--all-targets) [#77473](https://github.com/rust-lang/rust/pull/77473)
## [Version 2] - 2020-09-25

View File

@ -532,7 +532,7 @@ impl<'a> Builder<'a> {
pub fn new(build: &Build) -> Builder<'_> {
let (kind, paths) = match build.config.cmd {
Subcommand::Build { ref paths } => (Kind::Build, &paths[..]),
Subcommand::Check { ref paths } => (Kind::Check, &paths[..]),
Subcommand::Check { ref paths, all_targets: _ } => (Kind::Check, &paths[..]),
Subcommand::Clippy { ref paths } => (Kind::Clippy, &paths[..]),
Subcommand::Fix { ref paths } => (Kind::Fix, &paths[..]),
Subcommand::Doc { ref paths, .. } => (Kind::Doc, &paths[..]),

View File

@ -1,9 +1,12 @@
//! Implementation of compiling the compiler and standard library, in "check"-based modes.
use crate::builder::{Builder, Kind, RunConfig, ShouldRun, Step};
use crate::compile::{add_to_sysroot, run_cargo, rustc_cargo, std_cargo};
use crate::config::TargetSelection;
use crate::tool::{prepare_tool_cargo, SourceType};
use crate::{
builder::{Builder, Kind, RunConfig, ShouldRun, Step},
Subcommand,
};
use crate::{Compiler, Mode};
use std::path::PathBuf;
@ -74,35 +77,37 @@ impl Step for Std {
//
// Currently only the "libtest" tree of crates does this.
let mut cargo = builder.cargo(
compiler,
Mode::Std,
SourceType::InTree,
target,
cargo_subcommand(builder.kind),
);
std_cargo(builder, target, compiler.stage, &mut cargo);
cargo.arg("--all-targets");
if let Subcommand::Check { all_targets: true, .. } = builder.config.cmd {
let mut cargo = builder.cargo(
compiler,
Mode::Std,
SourceType::InTree,
target,
cargo_subcommand(builder.kind),
);
std_cargo(builder, target, compiler.stage, &mut cargo);
cargo.arg("--all-targets");
// Explicitly pass -p for all dependencies krates -- this will force cargo
// to also check the tests/benches/examples for these crates, rather
// than just the leaf crate.
for krate in builder.in_tree_crates("test") {
cargo.arg("-p").arg(krate.name);
// Explicitly pass -p for all dependencies krates -- this will force cargo
// to also check the tests/benches/examples for these crates, rather
// than just the leaf crate.
for krate in builder.in_tree_crates("test") {
cargo.arg("-p").arg(krate.name);
}
builder.info(&format!(
"Checking std test/bench/example targets ({} -> {})",
&compiler.host, target
));
run_cargo(
builder,
cargo,
args(builder.kind),
&libstd_test_stamp(builder, compiler, target),
vec![],
true,
);
}
builder.info(&format!(
"Checking std test/bench/example targets ({} -> {})",
&compiler.host, target
));
run_cargo(
builder,
cargo,
args(builder.kind),
&libstd_test_stamp(builder, compiler, target),
vec![],
true,
);
}
}
@ -143,7 +148,9 @@ impl Step for Rustc {
cargo_subcommand(builder.kind),
);
rustc_cargo(builder, &mut cargo, target);
cargo.arg("--all-targets");
if let Subcommand::Check { all_targets: true, .. } = builder.config.cmd {
cargo.arg("--all-targets");
}
// Explicitly pass -p for all compiler krates -- this will force cargo
// to also check the tests/benches/examples for these crates, rather
@ -205,7 +212,9 @@ macro_rules! tool_check_step {
&[],
);
cargo.arg("--all-targets");
if let Subcommand::Check { all_targets: true, .. } = builder.config.cmd {
cargo.arg("--all-targets");
}
builder.info(&format!(
"Checking {} artifacts ({} -> {})",

View File

@ -47,6 +47,9 @@ pub enum Subcommand {
paths: Vec<PathBuf>,
},
Check {
// Whether to run checking over all targets (e.g., unit / integration
// tests).
all_targets: bool,
paths: Vec<PathBuf>,
},
Clippy {
@ -250,6 +253,9 @@ To learn more about a subcommand, run `./x.py <subcommand> -h`",
`/<build_base>/rustfix_missing_coverage.txt`",
);
}
"check" => {
opts.optflag("", "all-targets", "Check all targets");
}
"bench" => {
opts.optmulti("", "test-args", "extra arguments", "ARGS");
}
@ -484,7 +490,9 @@ Arguments:
let cmd = match subcommand.as_str() {
"build" | "b" => Subcommand::Build { paths },
"check" | "c" => Subcommand::Check { paths },
"check" | "c" => {
Subcommand::Check { paths, all_targets: matches.opt_present("all-targets") }
}
"clippy" => Subcommand::Clippy { paths },
"fix" => Subcommand::Fix { paths },
"test" | "t" => Subcommand::Test {

View File

@ -24,7 +24,7 @@ COPY host-x86_64/mingw-check/validate-toolstate.sh /scripts/
ENV RUN_CHECK_WITH_PARALLEL_QUERIES 1
ENV SCRIPT python3 ../x.py --stage 2 test src/tools/expand-yaml-anchors && \
python3 ../x.py check --target=i686-pc-windows-gnu --host=i686-pc-windows-gnu && \
python3 ../x.py check --target=i686-pc-windows-gnu --host=i686-pc-windows-gnu --all-targets && \
python3 ../x.py build --stage 0 src/tools/build-manifest && \
python3 ../x.py test --stage 0 src/tools/compiletest && \
python3 ../x.py test --stage 2 src/tools/tidy && \