@@ -42,13 +42,18 @@ mod tests {
42
42
use core:: libc:: consts:: os:: posix88:: { S_IRUSR, S_IWUSR, S_IXUSR} ;
43
43
use core:: os;
44
44
45
- let root = mkdtemp( & os:: tmpdir( ) , "temp" ) . expect( "recursive_mkdir_rel" ) ;
46
- os:: change_dir( & root) ;
47
- let path = Path ( "frob" ) ;
48
- assert ! ( os:: mkdir_recursive( & path, ( S_IRUSR | S_IWUSR | S_IXUSR ) as i32 ) ) ;
49
- assert ! ( os:: path_is_dir( & path) ) ;
50
- assert ! ( os:: mkdir_recursive( & path, ( S_IRUSR | S_IWUSR | S_IXUSR ) as i32 ) ) ;
51
- assert ! ( os:: path_is_dir( & path) ) ;
45
+ let root = mkdtemp( & os:: tmpdir( ) , "recursive_mkdir_rel" ) .
46
+ expect( "recursive_mkdir_rel" ) ;
47
+ assert ! ( do os:: change_dir_locked( & root) {
48
+ let path = Path ( "frob" ) ;
49
+ debug!( "recursive_mkdir_rel: Making: %s in cwd %s [%?]" , path. to_str( ) ,
50
+ os:: getcwd( ) . to_str( ) ,
51
+ os:: path_exists( & path) ) ;
52
+ assert!( os:: mkdir_recursive( & path, ( S_IRUSR | S_IWUSR | S_IXUSR ) as i32 ) ) ;
53
+ assert!( os:: path_is_dir( & path) ) ;
54
+ assert!( os:: mkdir_recursive( & path, ( S_IRUSR | S_IWUSR | S_IXUSR ) as i32 ) ) ;
55
+ assert!( os:: path_is_dir( & path) ) ;
56
+ } ) ;
52
57
}
53
58
54
59
#[ test]
@@ -67,18 +72,21 @@ mod tests {
67
72
use core:: libc:: consts:: os:: posix88:: { S_IRUSR, S_IWUSR, S_IXUSR} ;
68
73
use core:: os;
69
74
70
- let root = mkdtemp( & os:: tmpdir( ) , "temp" ) . expect( "recursive_mkdir_rel_2" ) ;
71
- os:: change_dir( & root) ;
72
- let path = Path ( "./frob/baz" ) ;
73
- debug ! ( "...Making: %s in cwd %s" , path. to_str( ) , os:: getcwd( ) . to_str( ) ) ;
74
- assert ! ( os:: mkdir_recursive( & path, ( S_IRUSR | S_IWUSR | S_IXUSR ) as i32 ) ) ;
75
- assert ! ( os:: path_is_dir( & path) ) ;
76
- assert ! ( os:: path_is_dir( & path. pop( ) ) ) ;
77
- let path2 = Path ( "quux/blat" ) ;
78
- debug ! ( "Making: %s in cwd %s" , path2. to_str( ) , os:: getcwd( ) . to_str( ) ) ;
79
- assert ! ( os:: mkdir_recursive( & path2, ( S_IRUSR | S_IWUSR | S_IXUSR ) as i32 ) ) ;
80
- assert ! ( os:: path_is_dir( & path2) ) ;
81
- assert ! ( os:: path_is_dir( & path2. pop( ) ) ) ;
75
+ let root = mkdtemp( & os:: tmpdir( ) , "recursive_mkdir_rel_2" ) .
76
+ expect( "recursive_mkdir_rel_2" ) ;
77
+ assert ! ( do os:: change_dir_locked( & root) {
78
+ let path = Path ( "./frob/baz" ) ;
79
+ debug!( "recursive_mkdir_rel_2: Making: %s in cwd %s [%?]" , path. to_str( ) ,
80
+ os:: getcwd( ) . to_str( ) , os:: path_exists( & path) ) ;
81
+ assert!( os:: mkdir_recursive( & path, ( S_IRUSR | S_IWUSR | S_IXUSR ) as i32 ) ) ;
82
+ assert!( os:: path_is_dir( & path) ) ;
83
+ assert!( os:: path_is_dir( & path. pop( ) ) ) ;
84
+ let path2 = Path ( "quux/blat" ) ;
85
+ debug!( "recursive_mkdir_rel_2: Making: %s in cwd %s" , path2. to_str( ) ,
86
+ os:: getcwd( ) . to_str( ) ) ;
87
+ assert!( os:: mkdir_recursive( & path2, ( S_IRUSR | S_IWUSR | S_IXUSR ) as i32 ) ) ;
88
+ assert!( os:: path_is_dir( & path2) ) ;
89
+ assert!( os:: path_is_dir( & path2. pop( ) ) ) ;
90
+ } ) ;
82
91
}
83
-
84
- }
92
+ }
0 commit comments