clippy: make tests work in stage 1
This commit is contained in:
parent
e27f16a499
commit
192efbbd20
14 changed files with 84 additions and 63 deletions
|
|
@ -739,7 +739,6 @@ impl Step for CompiletestTest {
|
|||
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
||||
pub struct Clippy {
|
||||
stage: u32,
|
||||
host: TargetSelection,
|
||||
}
|
||||
|
||||
|
|
@ -753,33 +752,23 @@ impl Step for Clippy {
|
|||
}
|
||||
|
||||
fn make_run(run: RunConfig<'_>) {
|
||||
// If stage is explicitly set or not lower than 2, keep it. Otherwise, make sure it's at least 2
|
||||
// as tests for this step don't work with a lower stage.
|
||||
let stage = if run.builder.config.is_explicit_stage() || run.builder.top_stage >= 2 {
|
||||
run.builder.top_stage
|
||||
} else {
|
||||
2
|
||||
};
|
||||
|
||||
run.builder.ensure(Clippy { stage, host: run.target });
|
||||
run.builder.ensure(Clippy { host: run.target });
|
||||
}
|
||||
|
||||
/// Runs `cargo test` for clippy.
|
||||
fn run(self, builder: &Builder<'_>) {
|
||||
let stage = self.stage;
|
||||
let stage = builder.top_stage;
|
||||
let host = self.host;
|
||||
let compiler = builder.compiler(stage, host);
|
||||
// We need to carefully distinguish the compiler that builds clippy, and the compiler
|
||||
// that is linked into the clippy being tested. `target_compiler` is the latter,
|
||||
// and it must also be used by clippy's test runner to build tests and their dependencies.
|
||||
let target_compiler = builder.compiler(stage, host);
|
||||
|
||||
if stage < 2 {
|
||||
eprintln!("WARNING: clippy tests on stage {stage} may not behave well.");
|
||||
eprintln!("HELP: consider using stage 2");
|
||||
}
|
||||
|
||||
let tool_result = builder.ensure(tool::Clippy { compiler, target: self.host });
|
||||
let compiler = tool_result.build_compiler;
|
||||
let tool_result = builder.ensure(tool::Clippy { compiler: target_compiler, target: host });
|
||||
let tool_compiler = tool_result.build_compiler;
|
||||
let mut cargo = tool::prepare_tool_cargo(
|
||||
builder,
|
||||
compiler,
|
||||
tool_compiler,
|
||||
Mode::ToolRustc,
|
||||
host,
|
||||
Kind::Test,
|
||||
|
|
@ -788,11 +777,17 @@ impl Step for Clippy {
|
|||
&[],
|
||||
);
|
||||
|
||||
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::ToolRustc).join(builder.cargo_dir());
|
||||
cargo.env("RUSTC_TEST_SUITE", builder.rustc(tool_compiler));
|
||||
cargo.env("RUSTC_LIB_PATH", builder.rustc_libdir(tool_compiler));
|
||||
let host_libs = builder.stage_out(tool_compiler, Mode::ToolRustc).join(builder.cargo_dir());
|
||||
cargo.env("HOST_LIBS", host_libs);
|
||||
|
||||
// Build the standard library that the tests can use.
|
||||
builder.std(target_compiler, host);
|
||||
cargo.env("TEST_SYSROOT", builder.sysroot(target_compiler));
|
||||
cargo.env("TEST_RUSTC", builder.rustc(target_compiler));
|
||||
cargo.env("TEST_RUSTC_LIB", builder.rustc_libdir(target_compiler));
|
||||
|
||||
// Collect paths of tests to run
|
||||
'partially_test: {
|
||||
let paths = &builder.config.paths[..];
|
||||
|
|
@ -813,7 +808,8 @@ impl Step for Clippy {
|
|||
cargo.add_rustc_lib_path(builder);
|
||||
let cargo = prepare_cargo_test(cargo, &[], &[], host, builder);
|
||||
|
||||
let _guard = builder.msg_sysroot_tool(Kind::Test, compiler.stage, "clippy", host, host);
|
||||
let _guard =
|
||||
builder.msg_sysroot_tool(Kind::Test, tool_compiler.stage, "clippy", host, host);
|
||||
|
||||
// Clippy reports errors if it blessed the outputs
|
||||
if cargo.allow_failure().run(builder) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue