use stage 2 on cargo and clippy tests when possible
Signed-off-by: onur-ozkan <work@onurozkan.dev>
This commit is contained in:
parent
cf6dc742b7
commit
9ad6011494
3 changed files with 32 additions and 6 deletions
|
|
@ -293,17 +293,27 @@ impl Step for Cargo {
|
|||
}
|
||||
|
||||
fn make_run(run: RunConfig<'_>) {
|
||||
run.builder.ensure(Cargo { stage: run.builder.top_stage, host: run.target });
|
||||
// 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(Cargo { stage, host: run.target });
|
||||
}
|
||||
|
||||
/// Runs `cargo test` for `cargo` packaged with Rust.
|
||||
fn run(self, builder: &Builder<'_>) {
|
||||
if self.stage < 2 {
|
||||
eprintln!("WARNING: cargo tests on stage {} may not behave well.", self.stage);
|
||||
let stage = self.stage;
|
||||
|
||||
if stage < 2 {
|
||||
eprintln!("WARNING: cargo tests on stage {stage} may not behave well.");
|
||||
eprintln!("HELP: consider using stage 2");
|
||||
}
|
||||
|
||||
let compiler = builder.compiler(self.stage, self.host);
|
||||
let compiler = builder.compiler(stage, self.host);
|
||||
|
||||
let cargo = builder.ensure(tool::Cargo { compiler, target: self.host });
|
||||
let compiler = cargo.build_compiler;
|
||||
|
|
@ -340,7 +350,7 @@ impl Step for Cargo {
|
|||
crates: vec!["cargo".into()],
|
||||
target: self.host.triple.to_string(),
|
||||
host: self.host.triple.to_string(),
|
||||
stage: self.stage,
|
||||
stage,
|
||||
},
|
||||
builder,
|
||||
);
|
||||
|
|
@ -739,7 +749,15 @@ impl Step for Clippy {
|
|||
}
|
||||
|
||||
fn make_run(run: RunConfig<'_>) {
|
||||
run.builder.ensure(Clippy { stage: run.builder.top_stage, host: run.target });
|
||||
// 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 });
|
||||
}
|
||||
|
||||
/// Runs `cargo test` for clippy.
|
||||
|
|
|
|||
|
|
@ -2402,6 +2402,10 @@ impl Config {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn is_explicit_stage(&self) -> bool {
|
||||
self.explicit_stage_from_cli || self.explicit_stage_from_config
|
||||
}
|
||||
|
||||
/// Runs a command, printing out nice contextual information if it fails.
|
||||
/// Exits if the command failed to execute at all, otherwise returns its
|
||||
/// `status.success()`.
|
||||
|
|
|
|||
|
|
@ -471,6 +471,7 @@ fn test_explicit_stage() {
|
|||
|
||||
assert!(!config.explicit_stage_from_cli);
|
||||
assert!(config.explicit_stage_from_config);
|
||||
assert!(config.is_explicit_stage());
|
||||
|
||||
let config = Config::parse_inner(
|
||||
Flags::parse(&[
|
||||
|
|
@ -483,6 +484,7 @@ fn test_explicit_stage() {
|
|||
|
||||
assert!(config.explicit_stage_from_cli);
|
||||
assert!(!config.explicit_stage_from_config);
|
||||
assert!(config.is_explicit_stage());
|
||||
|
||||
let config = Config::parse_inner(
|
||||
Flags::parse(&[
|
||||
|
|
@ -502,6 +504,7 @@ fn test_explicit_stage() {
|
|||
|
||||
assert!(config.explicit_stage_from_cli);
|
||||
assert!(config.explicit_stage_from_config);
|
||||
assert!(config.is_explicit_stage());
|
||||
|
||||
let config = Config::parse_inner(
|
||||
Flags::parse(&["check".to_owned(), "--config=/does/not/exist".to_owned()]),
|
||||
|
|
@ -510,4 +513,5 @@ fn test_explicit_stage() {
|
|||
|
||||
assert!(!config.explicit_stage_from_cli);
|
||||
assert!(!config.explicit_stage_from_config);
|
||||
assert!(!config.is_explicit_stage());
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue