@@ -405,6 +405,8 @@ mod test {
405
405
use super :: * ;
406
406
use std:: str;
407
407
408
+ use rustfmt_config_proc_macro:: { nightly_only_test, stable_only_test} ;
409
+
408
410
#[ allow( dead_code) ]
409
411
mod mock {
410
412
use super :: super :: * ;
@@ -525,21 +527,17 @@ mod test {
525
527
assert ! ( config. license_template. is_none( ) ) ;
526
528
}
527
529
530
+ #[ nightly_only_test]
528
531
#[ test]
529
532
fn test_valid_license_template_path ( ) {
530
- if !crate :: is_nightly_channel!( ) {
531
- return ;
532
- }
533
533
let toml = r#"license_template_path = "tests/license-template/lt.txt""# ;
534
534
let config = Config :: from_toml ( toml, Path :: new ( "" ) ) . unwrap ( ) ;
535
535
assert ! ( config. license_template. is_some( ) ) ;
536
536
}
537
537
538
+ #[ nightly_only_test]
538
539
#[ test]
539
540
fn test_override_existing_license_with_no_license ( ) {
540
- if !crate :: is_nightly_channel!( ) {
541
- return ;
542
- }
543
541
let toml = r#"license_template_path = "tests/license-template/lt.txt""# ;
544
542
let mut config = Config :: from_toml ( toml, Path :: new ( "" ) ) . unwrap ( ) ;
545
543
assert ! ( config. license_template. is_some( ) ) ;
@@ -634,48 +632,42 @@ make_backup = false
634
632
assert_eq ! ( & toml, & default_config) ;
635
633
}
636
634
637
- // FIXME(#2183): these tests cannot be run in parallel because they use env vars.
638
- // #[test]
639
- // fn test_as_not_nightly_channel() {
640
- // let mut config = Config::default();
641
- // assert_eq!(config.was_set().unstable_features(), false);
642
- // config.set().unstable_features(true);
643
- // assert_eq!(config.was_set().unstable_features(), false);
644
- // }
645
-
646
- // #[test]
647
- // fn test_as_nightly_channel() {
648
- // let v = ::std::env::var("CFG_RELEASE_CHANNEL").unwrap_or(String::from(""));
649
- // ::std::env::set_var("CFG_RELEASE_CHANNEL", "nightly");
650
- // let mut config = Config::default();
651
- // config.set().unstable_features(true);
652
- // assert_eq!(config.was_set().unstable_features(), false);
653
- // config.set().unstable_features(true);
654
- // assert_eq!(config.unstable_features(), true);
655
- // ::std::env::set_var("CFG_RELEASE_CHANNEL", v);
656
- // }
657
-
658
- // #[test]
659
- // fn test_unstable_from_toml() {
660
- // let mut config = Config::from_toml("unstable_features = true").unwrap();
661
- // assert_eq!(config.was_set().unstable_features(), false);
662
- // let v = ::std::env::var("CFG_RELEASE_CHANNEL").unwrap_or(String::from(""));
663
- // ::std::env::set_var("CFG_RELEASE_CHANNEL", "nightly");
664
- // config = Config::from_toml("unstable_features = true").unwrap();
665
- // assert_eq!(config.was_set().unstable_features(), true);
666
- // assert_eq!(config.unstable_features(), true);
667
- // ::std::env::set_var("CFG_RELEASE_CHANNEL", v);
668
- // }
635
+ #[ stable_only_test]
636
+ #[ test]
637
+ fn test_as_not_nightly_channel ( ) {
638
+ let mut config = Config :: default ( ) ;
639
+ assert_eq ! ( config. was_set( ) . unstable_features( ) , false ) ;
640
+ config. set ( ) . unstable_features ( true ) ;
641
+ assert_eq ! ( config. was_set( ) . unstable_features( ) , false ) ;
642
+ }
643
+
644
+ #[ nightly_only_test]
645
+ #[ test]
646
+ fn test_as_nightly_channel ( ) {
647
+ let mut config = Config :: default ( ) ;
648
+ config. set ( ) . unstable_features ( true ) ;
649
+ // When we don't set the config from toml or command line options it
650
+ // doesn't get marked as set by the user.
651
+ assert_eq ! ( config. was_set( ) . unstable_features( ) , false ) ;
652
+ config. set ( ) . unstable_features ( true ) ;
653
+ assert_eq ! ( config. unstable_features( ) , true ) ;
654
+ }
655
+
656
+ #[ nightly_only_test]
657
+ #[ test]
658
+ fn test_unstable_from_toml ( ) {
659
+ let config = Config :: from_toml ( "unstable_features = true" , Path :: new ( "" ) ) . unwrap ( ) ;
660
+ assert_eq ! ( config. was_set( ) . unstable_features( ) , true ) ;
661
+ assert_eq ! ( config. unstable_features( ) , true ) ;
662
+ }
669
663
670
664
#[ cfg( test) ]
671
665
mod deprecated_option_merge_imports {
672
666
use super :: * ;
673
667
668
+ #[ nightly_only_test]
674
669
#[ test]
675
670
fn test_old_option_set ( ) {
676
- if !crate :: is_nightly_channel!( ) {
677
- return ;
678
- }
679
671
let toml = r#"
680
672
unstable_features = true
681
673
merge_imports = true
@@ -684,11 +676,9 @@ make_backup = false
684
676
assert_eq ! ( config. imports_granularity( ) , ImportGranularity :: Crate ) ;
685
677
}
686
678
679
+ #[ nightly_only_test]
687
680
#[ test]
688
681
fn test_both_set ( ) {
689
- if !crate :: is_nightly_channel!( ) {
690
- return ;
691
- }
692
682
let toml = r#"
693
683
unstable_features = true
694
684
merge_imports = true
@@ -698,11 +688,9 @@ make_backup = false
698
688
assert_eq ! ( config. imports_granularity( ) , ImportGranularity :: Preserve ) ;
699
689
}
700
690
691
+ #[ nightly_only_test]
701
692
#[ test]
702
693
fn test_new_overridden ( ) {
703
- if !crate :: is_nightly_channel!( ) {
704
- return ;
705
- }
706
694
let toml = r#"
707
695
unstable_features = true
708
696
merge_imports = true
@@ -712,11 +700,9 @@ make_backup = false
712
700
assert_eq ! ( config. imports_granularity( ) , ImportGranularity :: Preserve ) ;
713
701
}
714
702
703
+ #[ nightly_only_test]
715
704
#[ test]
716
705
fn test_old_overridden ( ) {
717
- if !crate :: is_nightly_channel!( ) {
718
- return ;
719
- }
720
706
let toml = r#"
721
707
unstable_features = true
722
708
imports_granularity = "Module"
0 commit comments