Fix test that assumed tests always were run on the stable channel

Note that this has to be set in the builder, before
`config.configure()` gets run.
This commit is contained in:
Joshua Nelson 2021-02-24 14:56:14 -05:00
parent eba5419946
commit ecfdced0d8
2 changed files with 9 additions and 10 deletions

View File

@ -47,8 +47,8 @@ impl ConfigBuilder {
}
/// Unconditionaly enable nightly features, even on stable channels.
pub fn enable_nightly_features(&mut self) -> &mut Self {
self.enable_nightly_features = true;
pub fn nightly_features_allowed(&mut self, allowed: bool) -> &mut Self {
self.enable_nightly_features = allowed;
self
}
@ -80,9 +80,7 @@ impl ConfigBuilder {
let cwd = self.cwd.clone().unwrap_or_else(|| paths::root());
let homedir = paths::home();
let mut config = Config::new(shell, cwd, homedir);
if self.enable_nightly_features || !self.unstable.is_empty() {
config.nightly_features_allowed = true;
}
config.nightly_features_allowed = self.enable_nightly_features || !self.unstable.is_empty();
config.set_env(self.env.clone());
config.set_search_stop_path(paths::root());
config.configure(
@ -1108,7 +1106,7 @@ fn unstable_table_notation() {
print-im-a-teapot = true
",
);
let config = ConfigBuilder::new().enable_nightly_features().build();
let config = ConfigBuilder::new().nightly_features_allowed(true).build();
assert_eq!(config.cli_unstable().print_im_a_teapot, true);
}
@ -1120,7 +1118,7 @@ fn unstable_dotted_notation() {
unstable.print-im-a-teapot = true
",
);
let config = ConfigBuilder::new().enable_nightly_features().build();
let config = ConfigBuilder::new().nightly_features_allowed(true).build();
assert_eq!(config.cli_unstable().print_im_a_teapot, true);
}
@ -1132,7 +1130,7 @@ fn unstable_cli_precedence() {
unstable.print-im-a-teapot = true
",
);
let config = ConfigBuilder::new().enable_nightly_features().build();
let config = ConfigBuilder::new().nightly_features_allowed(true).build();
assert_eq!(config.cli_unstable().print_im_a_teapot, true);
let config = ConfigBuilder::new()
@ -1163,7 +1161,8 @@ fn unstable_flags_ignored_on_stable() {
print-im-a-teapot = true
",
);
let config = ConfigBuilder::new().build();
// Enforce stable channel even when testing on nightly.
let config = ConfigBuilder::new().nightly_features_allowed(false).build();
assert_eq!(config.cli_unstable().print_im_a_teapot, false);
}

View File

@ -392,7 +392,7 @@ fn named_config_profile() {
"#,
)
.unwrap();
let config = ConfigBuilder::new().enable_nightly_features().build();
let config = ConfigBuilder::new().nightly_features_allowed(true).build();
let profile_name = InternedString::new("foo");
let ws = Workspace::new(&paths::root().join("Cargo.toml"), &config).unwrap();
let profiles = Profiles::new(&ws, profile_name).unwrap();