@@ -259,9 +259,9 @@ fn assert_output(source: &Path, expected_filename: &Path) {
259
259
#[ test]
260
260
fn idempotence_tests ( ) {
261
261
run_test_with ( & TestSetting :: default ( ) , || {
262
- match option_env ! ( "CFG_RELEASE_CHANNEL" ) {
263
- None | Some ( "nightly" ) => { }
264
- _ => return , // these tests require nightly
262
+ // these tests require nightly
263
+ if ! is_nightly ( ) {
264
+ return ;
265
265
}
266
266
// Get all files in the tests/target directory.
267
267
let files = get_test_files ( Path :: new ( "tests/target" ) , true ) ;
@@ -277,9 +277,9 @@ fn idempotence_tests() {
277
277
// no warnings are emitted.
278
278
#[ test]
279
279
fn self_tests ( ) {
280
- match option_env ! ( "CFG_RELEASE_CHANNEL" ) {
281
- None | Some ( "nightly" ) => { }
282
- _ => return , // Issue-3443: these tests require nightly
280
+ // Issue-3443: these tests require nightly
281
+ if ! is_nightly ( ) {
282
+ return ;
283
283
}
284
284
let mut files = get_test_files ( Path :: new ( "tests" ) , false ) ;
285
285
let bin_directories = vec ! [ "cargo-fmt" , "git-rustfmt" , "bin" , "format-diff" ] ;
@@ -313,6 +313,11 @@ fn self_tests() {
313
313
) ;
314
314
}
315
315
316
+ fn is_nightly ( ) -> bool {
317
+ let release_channel = option_env ! ( "CFG_RELEASE_CHANNEL" ) ;
318
+ release_channel. is_none ( ) || release_channel == Some ( "nightly" )
319
+ }
320
+
316
321
#[ test]
317
322
fn stdin_formatting_smoke_test ( ) {
318
323
let input = Input :: Text ( "fn main () {}" . to_owned ( ) ) ;
@@ -426,6 +431,16 @@ fn check_files(files: Vec<PathBuf>, opt_config: &Option<PathBuf>) -> (Vec<Format
426
431
let mut reports = vec ! [ ] ;
427
432
428
433
for file_name in files {
434
+ let sig_comments = read_significant_comments ( & file_name) ;
435
+ if sig_comments. contains_key ( "unstable" ) && !is_nightly ( ) {
436
+ debug ! (
437
+ "Skipping '{}' because it requires unstable \
438
+ features which are only available on nightly...",
439
+ file_name. display( )
440
+ ) ;
441
+ continue ;
442
+ }
443
+
429
444
debug ! ( "Testing '{}'..." , file_name. display( ) ) ;
430
445
431
446
match idempotent_check ( & file_name, & opt_config) {
@@ -485,7 +500,7 @@ fn read_config(filename: &Path) -> Config {
485
500
} ;
486
501
487
502
for ( key, val) in & sig_comments {
488
- if key != "target" && key != "config" {
503
+ if key != "target" && key != "config" && key != "unstable" {
489
504
config. override_value ( key, val) ;
490
505
if config. is_default ( key) {
491
506
warn ! ( "Default value {} used explicitly for {}" , val, key) ;
0 commit comments