@@ -461,6 +461,61 @@ mod test {
461
461
partially_unstable_option: PartiallyUnstableOption , PartiallyUnstableOption :: V1 , true ,
462
462
"A partially unstable option" ;
463
463
}
464
+
465
+ #[ cfg( test) ]
466
+ mod partially_unstable_option {
467
+ use super :: { Config , PartialConfig , PartiallyUnstableOption } ;
468
+ use rustfmt_config_proc_macro:: { nightly_only_test, stable_only_test} ;
469
+ use std:: path:: Path ;
470
+
471
+ /// From the config file, we can fill with a stable variant
472
+ #[ test]
473
+ fn test_from_toml_stable_value ( ) {
474
+ let toml = r#"
475
+ partially_unstable_option = "V2"
476
+ "# ;
477
+ let partial_config: PartialConfig = toml:: from_str ( toml) . unwrap ( ) ;
478
+ let config = Config :: default ( ) ;
479
+ let config = config. fill_from_parsed_config ( partial_config, Path :: new ( "" ) ) ;
480
+ assert_eq ! (
481
+ config. partially_unstable_option( ) ,
482
+ PartiallyUnstableOption :: V2
483
+ ) ;
484
+ }
485
+
486
+ /// From the config file, we cannot fill with an unstable variant (stable only)
487
+ #[ stable_only_test]
488
+ #[ test]
489
+ fn test_from_toml_unstable_value_on_stable ( ) {
490
+ let toml = r#"
491
+ partially_unstable_option = "V3"
492
+ "# ;
493
+ let partial_config: PartialConfig = toml:: from_str ( toml) . unwrap ( ) ;
494
+ let config = Config :: default ( ) ;
495
+ let config = config. fill_from_parsed_config ( partial_config, Path :: new ( "" ) ) ;
496
+ assert_eq ! (
497
+ config. partially_unstable_option( ) ,
498
+ // default value from config, i.e. fill failed
499
+ PartiallyUnstableOption :: V1
500
+ ) ;
501
+ }
502
+
503
+ /// From the config file, we can fill with an unstable variant (nightly only)
504
+ #[ nightly_only_test]
505
+ #[ test]
506
+ fn test_from_toml_unstable_value_on_nightly ( ) {
507
+ let toml = r#"
508
+ partially_unstable_option = "V3"
509
+ "# ;
510
+ let partial_config: PartialConfig = toml:: from_str ( toml) . unwrap ( ) ;
511
+ let config = Config :: default ( ) ;
512
+ let config = config. fill_from_parsed_config ( partial_config, Path :: new ( "" ) ) ;
513
+ assert_eq ! (
514
+ config. partially_unstable_option( ) ,
515
+ PartiallyUnstableOption :: V3
516
+ ) ;
517
+ }
518
+ }
464
519
}
465
520
466
521
#[ test]
@@ -939,6 +994,7 @@ make_backup = false
939
994
use super :: mock:: { Config , PartiallyUnstableOption } ;
940
995
use super :: * ;
941
996
997
+ /// From the command line, we can override with a stable variant.
942
998
#[ test]
943
999
fn test_override_stable_value ( ) {
944
1000
let mut config = Config :: default ( ) ;
@@ -949,20 +1005,9 @@ make_backup = false
949
1005
) ;
950
1006
}
951
1007
952
- #[ stable_only_test]
953
- #[ test]
954
- fn test_override_unstable_value_on_stable ( ) {
955
- let mut config = Config :: default ( ) ;
956
- config. override_value ( "partially_unstable_option" , "V3" ) ;
957
- assert_eq ! (
958
- config. partially_unstable_option( ) ,
959
- PartiallyUnstableOption :: V1
960
- ) ;
961
- }
962
-
963
- #[ nightly_only_test]
1008
+ /// From the command line, we can override with an unstable variant.
964
1009
#[ test]
965
- fn test_override_unstable_value_on_nightly ( ) {
1010
+ fn test_override_unstable_value ( ) {
966
1011
let mut config = Config :: default ( ) ;
967
1012
config. override_value ( "partially_unstable_option" , "V3" ) ;
968
1013
assert_eq ! (
0 commit comments