Skip to content

Commit

Permalink
fs: units tests for mkdir_recusive and rmdir_recursive
Browse files Browse the repository at this point in the history
The rmdir test is blocked by #12795 on windows.
  • Loading branch information
lbonn committed Mar 10, 2014
1 parent 2d754b4 commit 164b7c2
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions src/libstd/io/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -968,10 +968,36 @@ mod test {
check!(rmdir(dir));
})

iotest!(fn recursive_mkdir() {
let tmpdir = tmpdir();
let dir = tmpdir.join("d1/d2");
check!(mkdir_recursive(&dir, io::UserRWX));
assert!(dir.is_dir())
})

iotest!(fn recursive_mkdir_slash() {
check!(mkdir_recursive(&Path::new("/"), io::UserRWX));
})

// FIXME(#12795) depends on lstat to work on windows
#[cfg(not(windows))]
iotest!(fn recursive_rmdir() {
let tmpdir = tmpdir();
let d1 = tmpdir.join("d1");
let dt = d1.join("t");
let dtt = dt.join("t");
let d2 = tmpdir.join("d2");
let canary = d2.join("do_not_delete");
check!(mkdir_recursive(&dtt, io::UserRWX));
check!(mkdir_recursive(&d2, io::UserRWX));
check!(File::create(&canary).write(bytes!("foo")));
check!(symlink(&d2, &dt.join("d2")));
check!(rmdir_recursive(&d1));

assert!(!d1.is_dir());
assert!(canary.exists());
})

iotest!(fn unicode_path_is_dir() {
assert!(Path::new(".").is_dir());
assert!(!Path::new("test/stdtest/fs.rs").is_dir());
Expand Down

5 comments on commit 164b7c2

@bors
Copy link
Contributor

@bors bors commented on 164b7c2 Mar 13, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

saw approval from alexcrichton
at lbonn@164b7c2

@bors
Copy link
Contributor

@bors bors commented on 164b7c2 Mar 13, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merging lbonn/rust/unrecurs = 164b7c2 into auto

@bors
Copy link
Contributor

@bors bors commented on 164b7c2 Mar 13, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lbonn/rust/unrecurs = 164b7c2 merged ok, testing candidate = 6ff3c99

@bors
Copy link
Contributor

@bors bors commented on 164b7c2 Mar 13, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fast-forwarding master to auto = 6ff3c99

Please sign in to comment.