Skip to content

Commit 788eb5a

Browse files
tests: fix tests that use unstable config opts
1 parent d38f145 commit 788eb5a

File tree

4 files changed

+33
-3
lines changed

4 files changed

+33
-3
lines changed

src/config.rs

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -698,13 +698,31 @@ ignore = []
698698
}
699699

700700
#[test]
701-
fn test_from_toml_not_nightly() {
701+
fn test_from_toml_not_nightly_unstable_set() {
702702
if is_nightly_channel!() {
703703
// This test requires non-nightly
704704
return;
705705
}
706-
let config = Config::from_toml("unstable_features = true", Path::new("")).unwrap();
707-
assert_eq!(config.was_set().unstable_features(), false);
706+
let toml = r#"
707+
unstable_features = true
708+
merge_imports = true
709+
"#;
710+
let config = Config::from_toml(toml, Path::new("")).unwrap();
711+
assert_eq!(config.was_set().unstable_features(), true);
712+
assert_eq!(config.was_set().merge_imports(), true);
713+
assert_eq!(config.unstable_features(), true);
714+
assert_eq!(config.merge_imports(), true);
715+
}
716+
717+
#[test]
718+
fn test_from_toml_not_nightly_unstable_not_set() {
719+
if is_nightly_channel!() {
720+
// This test requires non-nightly
721+
return;
722+
}
723+
let config = Config::from_toml("merge_imports = true", Path::new("")).unwrap();
724+
assert_eq!(config.was_set().merge_imports(), false);
725+
assert_eq!(config.merge_imports(), false);
708726
}
709727

710728
#[test]
@@ -749,8 +767,12 @@ ignore = []
749767
}
750768
let mut config = Config::default();
751769
assert_eq!(config.unstable_features(), false);
770+
config.override_value("merge_imports", "true");
771+
assert_eq!(config.merge_imports(), false);
752772
config.override_value("unstable_features", "true");
753773
assert_eq!(config.unstable_features(), true);
774+
config.override_value("merge_imports", "true");
775+
assert_eq!(config.merge_imports(), true);
754776
}
755777

756778
#[test]

src/test/configuration_snippet.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,9 @@ impl ConfigCodeBlock {
9696

9797
fn get_block_config(&self) -> Config {
9898
let mut config = Config::default();
99+
if !crate::is_nightly_channel!() {
100+
config.override_value("unstable_features", "true");
101+
}
99102
if self.config_name.is_some() && self.config_value.is_some() {
100103
config.override_value(
101104
self.config_name.as_ref().unwrap(),

src/test/mod.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -629,6 +629,10 @@ fn read_config(filename: &Path) -> (Config, OperationSetting, EmitterConfig) {
629629
get_config(filename.with_extension("toml").file_name().map(Path::new))
630630
};
631631

632+
if !config.was_set().unstable_features() && !is_nightly_channel!() {
633+
config.override_value("unstable_features", "true");
634+
}
635+
632636
let mut operation_setting = OperationSetting::default();
633637
let mut emitter_config = EmitterConfig::default();
634638
for (key, val) in &sig_comments {

tests/config/small_tabs.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
unstable_features = true
12
max_width = 100
23
comment_width = 80
34
tab_spaces = 2

0 commit comments

Comments
 (0)