Fix a typo in the unstable options handling and address fallout

This commit is contained in:
Nick Cameron 2017-11-24 15:37:01 +13:00
parent e5bcb2259a
commit 96886cd67f
4 changed files with 37 additions and 33 deletions

View File

@ -289,7 +289,7 @@ macro_rules! create_config {
fn fill_from_parsed_config(mut self, parsed: PartialConfig) -> Config {
$(
if let Some(val) = parsed.$i {
if !self.$i.3 {
if self.$i.3 {
self.$i.1 = true;
self.$i.2 = val;
} else {
@ -669,36 +669,36 @@ mod test {
assert_eq!(config.was_set().verbose(), false);
}
#[test]
fn test_as_not_nightly_channel() {
let mut config = Config::default();
assert_eq!(config.was_set().unstable_features(), false);
config.set().unstable_features(true);
assert_eq!(config.was_set().unstable_features(), false);
}
// FIXME(#2183) these tests cannot be run in parallel because they use env vars
// #[test]
// fn test_as_not_nightly_channel() {
// let mut config = Config::default();
// assert_eq!(config.was_set().unstable_features(), false);
// config.set().unstable_features(true);
// assert_eq!(config.was_set().unstable_features(), false);
// }
#[test]
fn test_as_nightly_channel() {
let v = ::std::env::var("CFG_RELEASE_CHANNEL").unwrap_or(String::from(""));
::std::env::set_var("CFG_RELEASE_CHANNEL", "nightly");
let mut config = Config::default();
config.set().unstable_features(true);
assert_eq!(config.was_set().unstable_features(), false);
config.set().unstable_features(true);
assert_eq!(config.unstable_features(), true);
::std::env::set_var("CFG_RELEASE_CHANNEL", v);
}
#[test]
fn test_unstable_from_toml() {
let mut config = Config::from_toml("unstable_features = true").unwrap();
assert_eq!(config.was_set().unstable_features(), false);
let v = ::std::env::var("CFG_RELEASE_CHANNEL").unwrap_or(String::from(""));
::std::env::set_var("CFG_RELEASE_CHANNEL", "nightly");
config = Config::from_toml("unstable_features = true").unwrap();
assert_eq!(config.was_set().unstable_features(), true);
assert_eq!(config.unstable_features(), true);
::std::env::set_var("CFG_RELEASE_CHANNEL", v);
}
// #[test]
// fn test_as_nightly_channel() {
// let v = ::std::env::var("CFG_RELEASE_CHANNEL").unwrap_or(String::from(""));
// ::std::env::set_var("CFG_RELEASE_CHANNEL", "nightly");
// let mut config = Config::default();
// config.set().unstable_features(true);
// assert_eq!(config.was_set().unstable_features(), false);
// config.set().unstable_features(true);
// assert_eq!(config.unstable_features(), true);
// ::std::env::set_var("CFG_RELEASE_CHANNEL", v);
// }
// #[test]
// fn test_unstable_from_toml() {
// let mut config = Config::from_toml("unstable_features = true").unwrap();
// assert_eq!(config.was_set().unstable_features(), false);
// let v = ::std::env::var("CFG_RELEASE_CHANNEL").unwrap_or(String::from(""));
// ::std::env::set_var("CFG_RELEASE_CHANNEL", "nightly");
// config = Config::from_toml("unstable_features = true").unwrap();
// assert_eq!(config.was_set().unstable_features(), true);
// assert_eq!(config.unstable_features(), true);
// ::std::env::set_var("CFG_RELEASE_CHANNEL", v);
// }
}

View File

@ -1,2 +0,0 @@
reorder_imports = true
normalize_comments = true

View File

@ -1,3 +1,6 @@
// rustfmt-reorder_imports: true
// rustfmt-normalize_comments: true
use d; use c; use b; use a;
// The previous line has a space after the `use a;`

View File

@ -1,3 +1,6 @@
// rustfmt-reorder_imports: true
// rustfmt-normalize_comments: true
use a;
use b;
use c;