@@ -42,22 +42,48 @@ mod test {
4242
4343 use super :: IgnorePathSet ;
4444 use crate :: config:: { Config , FileName } ;
45+ use crate :: is_nightly_channel;
4546
4647 #[ test]
4748 fn test_ignore_path_set ( ) {
48- match option_env ! ( "CFG_RELEASE_CHANNEL" ) {
49- // this test requires nightly
50- None | Some ( "nightly" ) => {
51- let config =
52- Config :: from_toml ( r#"ignore = ["foo.rs", "bar_dir/*"]"# , Path :: new ( "" ) )
53- . unwrap ( ) ;
54- let ignore_path_set = IgnorePathSet :: from_ignore_list ( & config. ignore ( ) ) . unwrap ( ) ;
55-
56- assert ! ( ignore_path_set. is_match( & FileName :: Real ( PathBuf :: from( "src/foo.rs" ) ) ) ) ;
57- assert ! ( ignore_path_set. is_match( & FileName :: Real ( PathBuf :: from( "bar_dir/baz.rs" ) ) ) ) ;
58- assert ! ( !ignore_path_set. is_match( & FileName :: Real ( PathBuf :: from( "src/bar.rs" ) ) ) ) ;
59- }
60- _ => { }
61- } ;
49+ if !is_nightly_channel ! ( ) {
50+ // This test requires nightly
51+ return ;
52+ }
53+ let config =
54+ Config :: from_toml ( r#"ignore = ["foo.rs", "bar_dir/*"]"# , Path :: new ( "" ) ) . unwrap ( ) ;
55+ let ignore_path_set = IgnorePathSet :: from_ignore_list ( & config. ignore ( ) ) . unwrap ( ) ;
56+
57+ assert ! ( ignore_path_set. is_match( & FileName :: Real ( PathBuf :: from( "src/foo.rs" ) ) ) ) ;
58+ assert ! ( ignore_path_set. is_match( & FileName :: Real ( PathBuf :: from( "bar_dir/baz.rs" ) ) ) ) ;
59+ assert ! ( !ignore_path_set. is_match( & FileName :: Real ( PathBuf :: from( "src/bar.rs" ) ) ) ) ;
60+ }
61+ #[ test]
62+ fn test_ignore_path_set_with_dir ( ) {
63+ if !is_nightly_channel ! ( ) {
64+ // This test requires nightly
65+ return ;
66+ }
67+ let config = Config :: from_toml (
68+ r#"ignore = ["tests/**/foo/bar.rs"]"# ,
69+ Path :: new ( "tests/config/" ) ,
70+ )
71+ . unwrap ( ) ;
72+ info ! (
73+ "rustfmt_toml_path: {:?}" ,
74+ & config. ignore( ) . rustfmt_toml_path( )
75+ ) ;
76+ let ignore_path_set = IgnorePathSet :: from_ignore_list ( & config. ignore ( ) ) . unwrap ( ) ;
77+
78+ assert_eq ! (
79+ ignore_path_set. is_match( & FileName :: Real ( PathBuf :: from( "tests/source/foo/bar.rs" ) ) ) ,
80+ false
81+ ) ;
82+ assert_eq ! (
83+ ignore_path_set. is_match( & FileName :: Real ( PathBuf :: from(
84+ "tests/tests/source/foo/bar.rs"
85+ ) ) ) ,
86+ true
87+ ) ;
6288 }
6389}
0 commit comments