File tree 1 file changed +13
-12
lines changed
1 file changed +13
-12
lines changed Original file line number Diff line number Diff line change @@ -64,27 +64,28 @@ fn test_wait() {
64
64
65
65
#[ test]
66
66
fn test_mkstemp ( ) {
67
- #[ cfg( target_os = "android" ) ]
68
- let tmp = "/data/local/tmp/" ;
69
- #[ cfg( not( target_os = "android" ) ) ]
70
- let tmp = "/tmp/" ;
67
+ use std:: env;
71
68
72
- let result = mkstemp ( ( tmp. to_owned ( ) + "nix_tempfile.XXXXXX" ) . as_str ( ) ) ;
69
+ let mut path = env:: temp_dir ( ) ;
70
+ path. push ( "nix_tempfile.XXXXXX" ) ;
71
+
72
+ let result = mkstemp ( & path) ;
73
73
match result {
74
74
Ok ( ( fd, path) ) => {
75
75
close ( fd) . unwrap ( ) ;
76
76
unlink ( path. as_path ( ) ) . unwrap ( ) ;
77
77
} ,
78
78
Err ( e) => panic ! ( "mkstemp failed: {}" , e)
79
79
}
80
+ }
80
81
81
- let result = mkstemp ( tmp ) ;
82
- match result {
83
- Ok ( _ ) => {
84
- panic ! ( "mkstemp succeeded even though it should fail (provided a directory)" ) ;
85
- } ,
86
- Err ( _ ) => { }
87
- }
82
+ # [ test ]
83
+ # [ should_panic ]
84
+ fn test_mkstemp_directory ( ) {
85
+ use std :: env ;
86
+
87
+ // mkstemp should fail if a directory is given
88
+ mkstemp ( & env :: temp_dir ( ) ) . unwrap ( ) ;
88
89
}
89
90
90
91
#[ test]
You can’t perform that action at this time.
0 commit comments