Initialize the execution context in parse_inner, start using dry run from the execution context, add getters and setters in the config, and update the tests and other relevant areas accordingly.
This commit is contained in:
parent
e9ced508f4
commit
51fbd145f9
6 changed files with 29 additions and 28 deletions
|
|
@ -551,7 +551,7 @@ impl Builder<'_> {
|
|||
let libdir = self.rustc_libdir(compiler);
|
||||
|
||||
let sysroot_str = sysroot.as_os_str().to_str().expect("sysroot should be UTF-8");
|
||||
if self.is_verbose() && !matches!(self.config.dry_run, DryRun::SelfCheck) {
|
||||
if self.is_verbose() && !matches!(self.config.get_dry_run(), DryRun::SelfCheck) {
|
||||
println!("using sysroot {sysroot_str}");
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -443,13 +443,15 @@ impl StepDescription {
|
|||
|
||||
fn is_excluded(&self, builder: &Builder<'_>, pathset: &PathSet) -> bool {
|
||||
if builder.config.skip.iter().any(|e| pathset.has(e, builder.kind)) {
|
||||
if !matches!(builder.config.dry_run, DryRun::SelfCheck) {
|
||||
if !matches!(builder.config.get_dry_run(), DryRun::SelfCheck) {
|
||||
println!("Skipping {pathset:?} because it is excluded");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
if !builder.config.skip.is_empty() && !matches!(builder.config.dry_run, DryRun::SelfCheck) {
|
||||
if !builder.config.skip.is_empty()
|
||||
&& !matches!(builder.config.get_dry_run(), DryRun::SelfCheck)
|
||||
{
|
||||
builder.verbose(|| {
|
||||
println!(
|
||||
"{:?} not skipped for {:?} -- not in {:?}",
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ fn configure_with_args(cmd: &[String], host: &[&str], target: &[&str]) -> Config
|
|||
let mut config = Config::parse(Flags::parse(cmd));
|
||||
// don't save toolstates
|
||||
config.save_toolstates = None;
|
||||
config.dry_run = DryRun::SelfCheck;
|
||||
config.set_dry_run(DryRun::SelfCheck);
|
||||
|
||||
// Ignore most submodules, since we don't need them for a dry run, and the
|
||||
// tests run much faster without them.
|
||||
|
|
|
|||
|
|
@ -131,7 +131,6 @@ pub struct Config {
|
|||
pub jobs: Option<u32>,
|
||||
pub cmd: Subcommand,
|
||||
pub incremental: bool,
|
||||
pub dry_run: DryRun,
|
||||
pub dump_bootstrap_shims: bool,
|
||||
/// Arguments appearing after `--` to be forwarded to tools,
|
||||
/// e.g. `--fix-broken` or test arguments.
|
||||
|
|
@ -364,16 +363,20 @@ impl Config {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn set_dry_run(&mut self, dry_run: DryRun) {
|
||||
self.exec_ctx.set_dry_run(dry_run);
|
||||
}
|
||||
|
||||
pub fn get_dry_run(&self) -> &DryRun {
|
||||
self.exec_ctx.get_dry_run()
|
||||
}
|
||||
|
||||
#[cfg_attr(
|
||||
feature = "tracing",
|
||||
instrument(target = "CONFIG_HANDLING", level = "trace", name = "Config::parse", skip_all)
|
||||
)]
|
||||
pub fn parse(flags: Flags) -> Config {
|
||||
let mut exec_ctx = ExecutionContext::new();
|
||||
exec_ctx.set_dry_run(if flags.dry_run { DryRun::UserSelected } else { DryRun::Disabled });
|
||||
exec_ctx.set_verbose(flags.verbose);
|
||||
exec_ctx.set_fail_fast(flags.cmd.fail_fast());
|
||||
Self::parse_inner(flags, Self::get_toml, exec_ctx)
|
||||
Self::parse_inner(flags, Self::get_toml)
|
||||
}
|
||||
|
||||
#[cfg_attr(
|
||||
|
|
@ -388,9 +391,12 @@ impl Config {
|
|||
pub(crate) fn parse_inner(
|
||||
mut flags: Flags,
|
||||
get_toml: impl Fn(&Path) -> Result<TomlConfig, toml::de::Error>,
|
||||
exec_ctx: ExecutionContext,
|
||||
) -> Config {
|
||||
let mut config = Config::default_opts();
|
||||
let mut exec_ctx = ExecutionContext::new();
|
||||
exec_ctx.set_verbose(flags.verbose);
|
||||
exec_ctx.set_fail_fast(flags.cmd.fail_fast());
|
||||
|
||||
config.exec_ctx = exec_ctx;
|
||||
|
||||
// Set flags.
|
||||
|
|
@ -420,7 +426,7 @@ impl Config {
|
|||
config.on_fail = flags.on_fail;
|
||||
config.cmd = flags.cmd;
|
||||
config.incremental = flags.incremental;
|
||||
config.dry_run = if flags.dry_run { DryRun::UserSelected } else { DryRun::Disabled };
|
||||
config.set_dry_run(if flags.dry_run { DryRun::UserSelected } else { DryRun::Disabled });
|
||||
config.dump_bootstrap_shims = flags.dump_bootstrap_shims;
|
||||
config.keep_stage = flags.keep_stage;
|
||||
config.keep_stage_std = flags.keep_stage_std;
|
||||
|
|
|
|||
|
|
@ -196,7 +196,6 @@ pub struct Build {
|
|||
crates: HashMap<String, Crate>,
|
||||
crate_paths: HashMap<PathBuf, String>,
|
||||
is_sudo: bool,
|
||||
delayed_failures: RefCell<Vec<String>>,
|
||||
prerelease_version: Cell<Option<u32>>,
|
||||
|
||||
#[cfg(feature = "build-metrics")]
|
||||
|
|
@ -457,7 +456,6 @@ impl Build {
|
|||
crates: HashMap::new(),
|
||||
crate_paths: HashMap::new(),
|
||||
is_sudo,
|
||||
delayed_failures: RefCell::new(Vec::new()),
|
||||
prerelease_version: Cell::new(None),
|
||||
|
||||
#[cfg(feature = "build-metrics")]
|
||||
|
|
@ -672,8 +670,7 @@ impl Build {
|
|||
#[cfg(feature = "tracing")]
|
||||
let _sanity_check_span =
|
||||
span!(tracing::Level::DEBUG, "(1) executing dry-run sanity-check").entered();
|
||||
self.config.dry_run = DryRun::SelfCheck;
|
||||
self.config.exec_ctx.set_dry_run(DryRun::SelfCheck);
|
||||
self.config.set_dry_run(DryRun::SelfCheck);
|
||||
let builder = builder::Builder::new(self);
|
||||
builder.execute_cli();
|
||||
}
|
||||
|
|
@ -683,8 +680,7 @@ impl Build {
|
|||
#[cfg(feature = "tracing")]
|
||||
let _actual_run_span =
|
||||
span!(tracing::Level::DEBUG, "(2) executing actual run").entered();
|
||||
self.config.dry_run = DryRun::Disabled;
|
||||
self.config.exec_ctx.set_dry_run(DryRun::Disabled);
|
||||
self.config.set_dry_run(DryRun::Disabled);
|
||||
let builder = builder::Builder::new(self);
|
||||
builder.execute_cli();
|
||||
}
|
||||
|
|
@ -700,14 +696,7 @@ impl Build {
|
|||
debug!("checking for postponed test failures from `test --no-fail-fast`");
|
||||
|
||||
// Check for postponed failures from `test --no-fail-fast`.
|
||||
let failures = self.delayed_failures.borrow();
|
||||
if !failures.is_empty() {
|
||||
eprintln!("\n{} command(s) did not execute successfully:\n", failures.len());
|
||||
for failure in failures.iter() {
|
||||
eprintln!(" - {failure}\n");
|
||||
}
|
||||
exit!(1);
|
||||
}
|
||||
self.config.exec_ctx().report_failures_and_exit();
|
||||
|
||||
#[cfg(feature = "build-metrics")]
|
||||
self.metrics.persist(self);
|
||||
|
|
@ -956,7 +945,7 @@ impl Build {
|
|||
}
|
||||
|
||||
fn info(&self, msg: &str) {
|
||||
match self.config.dry_run {
|
||||
match self.config.get_dry_run() {
|
||||
DryRun::SelfCheck => (),
|
||||
DryRun::Disabled | DryRun::UserSelected => {
|
||||
println!("{msg}");
|
||||
|
|
@ -1079,7 +1068,7 @@ impl Build {
|
|||
|
||||
#[track_caller]
|
||||
fn group(&self, msg: &str) -> Option<gha::Group> {
|
||||
match self.config.dry_run {
|
||||
match self.config.get_dry_run() {
|
||||
DryRun::SelfCheck => None,
|
||||
DryRun::Disabled | DryRun::UserSelected => Some(gha::group(msg)),
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,6 +28,10 @@ impl ExecutionContext {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn get_dry_run(&self) -> &DryRun {
|
||||
&self.dry_run
|
||||
}
|
||||
|
||||
pub fn verbose(&self, f: impl Fn()) {
|
||||
if self.is_verbose() {
|
||||
f()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue