File tree Expand file tree Collapse file tree 2 files changed +11
-9
lines changed Expand file tree Collapse file tree 2 files changed +11
-9
lines changed Original file line number Diff line number Diff line change @@ -262,12 +262,12 @@ pub fn chdir<P: ?Sized + NixPath>(path: &P) -> Result<()> {
262
262
/// use tempdir::TempDir;
263
263
///
264
264
/// fn main() {
265
- /// let mut tmp_dir = TempDir::new("test_mkdir").unwrap().into_path ();
266
- /// tmp_dir.push ("new_dir");
265
+ /// let tmp_dir1 = TempDir::new("test_mkdir").unwrap();
266
+ /// let tmp_dir2 = tmp_dir1.path().join ("new_dir");
267
267
///
268
268
/// // create new directory and give read, write and execute rights to the owner
269
- /// match unistd::mkdir(&tmp_dir , stat::S_IRWXU) {
270
- /// Ok(_) => println!("created {:?}", tmp_dir ),
269
+ /// match unistd::mkdir(&tmp_dir2 , stat::S_IRWXU) {
270
+ /// Ok(_) => println!("created {:?}", tmp_dir2 ),
271
271
/// Err(err) => println!("Error creating directory: {}", err),
272
272
/// }
273
273
/// }
Original file line number Diff line number Diff line change @@ -143,19 +143,21 @@ macro_rules! execve_test_factory(
143
143
144
144
#[ test]
145
145
fn test_getcwd ( ) {
146
- let mut tmp_dir = TempDir :: new ( "test_getcwd" ) . unwrap ( ) . into_path ( ) ;
147
- assert ! ( chdir( tmp_dir. as_path ( ) ) . is_ok( ) ) ;
146
+ let tmp_dir = TempDir :: new ( "test_getcwd" ) . unwrap ( ) ;
147
+ assert ! ( chdir( tmp_dir. path ( ) ) . is_ok( ) ) ;
148
148
assert_eq ! ( getcwd( ) . unwrap( ) , current_dir( ) . unwrap( ) ) ;
149
149
150
150
// make path 500 chars longer so that buffer doubling in getcwd kicks in.
151
151
// Note: One path cannot be longer than 255 bytes (NAME_MAX)
152
152
// whole path cannot be longer than PATH_MAX (usually 4096 on linux, 1024 on macos)
153
+ let mut inner_tmp_dir = tmp_dir. path ( ) . to_path_buf ( ) ;
153
154
for _ in 0 ..5 {
154
155
let newdir = iter:: repeat ( "a" ) . take ( 100 ) . collect :: < String > ( ) ;
155
- tmp_dir. push ( newdir) ;
156
- assert ! ( mkdir( tmp_dir. as_path( ) , stat:: S_IRWXU ) . is_ok( ) ) ;
156
+ //inner_tmp_dir = inner_tmp_dir.join(newdir).path();
157
+ inner_tmp_dir. push ( newdir) ;
158
+ assert ! ( mkdir( inner_tmp_dir. as_path( ) , stat:: S_IRWXU ) . is_ok( ) ) ;
157
159
}
158
- assert ! ( chdir( tmp_dir . as_path( ) ) . is_ok( ) ) ;
160
+ assert ! ( chdir( inner_tmp_dir . as_path( ) ) . is_ok( ) ) ;
159
161
assert_eq ! ( getcwd( ) . unwrap( ) , current_dir( ) . unwrap( ) ) ;
160
162
}
161
163
You can’t perform that action at this time.
0 commit comments