@@ -11,6 +11,7 @@ use std::thread;
11
11
12
12
use crate :: config:: { Color , Config , EmitMode , FileName , NewlineStyle , ReportTactic } ;
13
13
use crate :: formatting:: { ReportedErrors , SourceFile } ;
14
+ use crate :: is_nightly_channel;
14
15
use crate :: rustfmt_diff:: { make_diff, print_diff, DiffLine , Mismatch , ModifiedChunk , OutputWriter } ;
15
16
use crate :: source_file;
16
17
use crate :: { FormatReport , FormatReportFormatterBuilder , Input , Session } ;
@@ -259,9 +260,9 @@ fn assert_output(source: &Path, expected_filename: &Path) {
259
260
#[ test]
260
261
fn idempotence_tests ( ) {
261
262
run_test_with ( & TestSetting :: default ( ) , || {
262
- match option_env ! ( "CFG_RELEASE_CHANNEL" ) {
263
- None | Some ( "nightly" ) => { }
264
- _ => return , // these tests require nightly
263
+ // these tests require nightly
264
+ if ! is_nightly_channel ! ( ) {
265
+ return ;
265
266
}
266
267
// Get all files in the tests/target directory.
267
268
let files = get_test_files ( Path :: new ( "tests/target" ) , true ) ;
@@ -277,9 +278,9 @@ fn idempotence_tests() {
277
278
// no warnings are emitted.
278
279
#[ test]
279
280
fn self_tests ( ) {
280
- match option_env ! ( "CFG_RELEASE_CHANNEL" ) {
281
- None | Some ( "nightly" ) => { }
282
- _ => return , // Issue-3443: these tests require nightly
281
+ // Issue-3443: these tests require nightly
282
+ if ! is_nightly_channel ! ( ) {
283
+ return ;
283
284
}
284
285
let mut files = get_test_files ( Path :: new ( "tests" ) , false ) ;
285
286
let bin_directories = vec ! [ "cargo-fmt" , "git-rustfmt" , "bin" , "format-diff" ] ;
@@ -426,6 +427,16 @@ fn check_files(files: Vec<PathBuf>, opt_config: &Option<PathBuf>) -> (Vec<Format
426
427
let mut reports = vec ! [ ] ;
427
428
428
429
for file_name in files {
430
+ let sig_comments = read_significant_comments ( & file_name) ;
431
+ if sig_comments. contains_key ( "unstable" ) && !is_nightly_channel ! ( ) {
432
+ debug ! (
433
+ "Skipping '{}' because it requires unstable \
434
+ features which are only available on nightly...",
435
+ file_name. display( )
436
+ ) ;
437
+ continue ;
438
+ }
439
+
429
440
debug ! ( "Testing '{}'..." , file_name. display( ) ) ;
430
441
431
442
match idempotent_check ( & file_name, & opt_config) {
@@ -485,7 +496,7 @@ fn read_config(filename: &Path) -> Config {
485
496
} ;
486
497
487
498
for ( key, val) in & sig_comments {
488
- if key != "target" && key != "config" {
499
+ if key != "target" && key != "config" && key != "unstable" {
489
500
config. override_value ( key, val) ;
490
501
if config. is_default ( key) {
491
502
warn ! ( "Default value {} used explicitly for {}" , val, key) ;
0 commit comments