Skip to content

Commit

Permalink
Add a flag for pretending to be a stable compiler when bisecting.
Browse files Browse the repository at this point in the history
  • Loading branch information
oli-obk committed Apr 25, 2024
1 parent 4facc9a commit bf10cc2
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 1 deletion.
7 changes: 7 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,13 @@ struct Opts {
)]
command_args: Vec<OsString>,

#[arg(
long,
help = "Pretend to be a stable compiler (disable features, \
report a version that looks like a stable version)"
)]
pretend_to_be_stable: bool,

#[arg(
long,
help = "Left bound for search (*without* regression). You can use \
Expand Down
19 changes: 18 additions & 1 deletion src/toolchains.rs
Original file line number Diff line number Diff line change
Expand Up @@ -313,12 +313,29 @@ impl Toolchain {
}

fn set_cargo_args_and_envs(&self, cmd: &mut Command, cfg: &Config) {
cmd.arg(&format!("+{}", self.rustup_name()));
let rustup_name = format!("+{}", self.rustup_name());
cmd.arg(&rustup_name);
if cfg.args.command_args.is_empty() {
cmd.arg("build");
} else {
cmd.args(&cfg.args.command_args);
}
if cfg.args.pretend_to_be_stable && self.is_current_nightly() {
// Forbid using features
cmd.env(
"RUSTFLAGS",
format!(
"{} -Zenable-features=",
std::env::var("RUSTFLAGS").unwrap_or_default()
),
);
// Make rustc report a stable version string derived from the current nightly's version string.
let version = rustc_version::version_meta().unwrap().semver;
cmd.env(
"RUSTC_FORCE_RUSTC_VERSION",
format!("{}.{}.{}", version.major, version.minor, version.patch),
);
}
}

pub(crate) fn test(&self, cfg: &Config) -> TestOutcome {
Expand Down
2 changes: 2 additions & 0 deletions tests/cmd/h.stdout
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ Options:
--install <INSTALL> Install the given artifact
--preserve Preserve the downloaded artifacts
--preserve-target Preserve the target directory used for builds
--pretend-to-be-stable Pretend to be a stable compiler (disable features, report a version
that looks like a stable version)
--prompt Manually evaluate for regression with prompts
--regress <REGRESS> Custom regression definition [default: error] [possible values:
error, success, ice, non-ice, non-error]
Expand Down
4 changes: 4 additions & 0 deletions tests/cmd/help.stdout
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ Options:
--preserve-target
Preserve the target directory used for builds

--pretend-to-be-stable
Pretend to be a stable compiler (disable features, report a version that looks like a
stable version)

--prompt
Manually evaluate for regression with prompts

Expand Down

0 comments on commit bf10cc2

Please sign in to comment.