@@ -171,38 +171,41 @@ fn file_in_subdirectory() {
171171 . success ( ) ;
172172}
173173
174- // disable test on macos, since it does not allow non-unicode filenames
175- #[ cfg( not( target_os = "macos" ) ) ]
176174#[ test]
177175fn non_unicode_path_error ( ) {
178176 use std:: path:: PathBuf ;
179177
178+ // macos does not allow non-unicode filenames
179+ if cfg ! ( target_os = "macos" ) {
180+ return ;
181+ }
182+
180183 let dir = TempDir :: new ( ) . unwrap ( ) ;
181184
182- let path : PathBuf ;
185+ let invalid : PathBuf ;
183186
184187 #[ cfg( unix) ]
185188 {
186189 use std:: { ffi:: OsStr , os:: unix:: ffi:: OsStrExt } ;
187190
188- path = OsStr :: from_bytes ( & [ 0x80 ] ) . into ( ) ;
191+ invalid = OsStr :: from_bytes ( & [ 0x80 ] ) . into ( ) ;
189192 } ;
190193
191194 #[ cfg( windows) ]
192195 {
193196 use std:: { ffi:: OsString , os:: windows:: ffi:: OsStringExt } ;
194197
195- path = OsString :: from_wide ( & [ 0xd800 ] ) . into ( ) ;
198+ invalid = OsString :: from_wide ( & [ 0xd800 ] ) . into ( ) ;
196199 } ;
197200
198- dir. child ( path ) . touch ( ) . unwrap ( ) ;
201+ dir. child ( invalid ) . touch ( ) . unwrap ( ) ;
199202
200203 Command :: cargo_bin ( "filepack" )
201204 . unwrap ( )
202205 . args ( [ "create" , "." ] )
203206 . current_dir ( & dir)
204207 . assert ( )
205- . stderr ( format ! ( "error: path not valid unicode: `.{SEPARATOR} �`\n " ) )
208+ . stderr ( path ( "error: path not valid unicode: `./ �`\n " ) )
206209 . failure ( ) ;
207210}
208211
@@ -268,13 +271,16 @@ fn only_leaf_empty_directory_is_reported() {
268271 . args ( [ "create" , "." ] )
269272 . current_dir ( & dir)
270273 . assert ( )
271- . stderr ( format ! ( "error: empty directory `foo{SEPARATOR} bar`\n " ) )
274+ . stderr ( path ( "error: empty directory `foo/ bar`\n " ) )
272275 . failure ( ) ;
273276}
274277
275- #[ cfg( not( windows) ) ]
276278#[ test]
277279fn backslash_error ( ) {
280+ if cfg ! ( windows) {
281+ return ;
282+ }
283+
278284 let dir = TempDir :: new ( ) . unwrap ( ) ;
279285
280286 dir. child ( "\\ " ) . touch ( ) . unwrap ( ) ;
@@ -293,9 +299,12 @@ error: invalid path `\\`
293299 . failure ( ) ;
294300}
295301
296- #[ cfg( all( not( windows) , not( target_os = "macos" ) ) ) ]
297302#[ test]
298303fn deny_case_insensitive_filesystem_path_conflict ( ) {
304+ if cfg ! ( windows) || cfg ! ( target_os = "macos" ) {
305+ return ;
306+ }
307+
299308 let dir = TempDir :: new ( ) . unwrap ( ) ;
300309
301310 dir. child ( "foo" ) . touch ( ) . unwrap ( ) ;
@@ -317,9 +326,12 @@ error: 1 lint error
317326 . failure ( ) ;
318327}
319328
320- #[ cfg( not( windows) ) ]
321329#[ test]
322330fn deny_lint ( ) {
331+ if cfg ! ( windows) {
332+ return ;
333+ }
334+
323335 let dir = TempDir :: new ( ) . unwrap ( ) ;
324336
325337 dir. child ( "aux" ) . touch ( ) . unwrap ( ) ;
@@ -339,9 +351,12 @@ error: 1 lint error
339351 . failure ( ) ;
340352}
341353
342- #[ cfg( not( windows) ) ]
343354#[ test]
344355fn allow_lint ( ) {
356+ if cfg ! ( windows) {
357+ return ;
358+ }
359+
345360 let dir = TempDir :: new ( ) . unwrap ( ) ;
346361
347362 dir. child ( "aux" ) . touch ( ) . unwrap ( ) ;
@@ -617,9 +632,7 @@ fn metadata_already_exists() {
617632 . args ( [ "create" , "foo" , "--metadata" , "metadata.yaml" ] )
618633 . current_dir ( & dir)
619634 . assert ( )
620- . stderr ( format ! (
621- "error: metadata `foo{SEPARATOR}metadata.json` already exists\n "
622- ) )
635+ . stderr ( path ( "error: metadata `foo/metadata.json` already exists\n " ) )
623636 . failure ( ) ;
624637
625638 Command :: cargo_bin ( "filepack" )
0 commit comments