diff options
Diffstat (limited to 'src/libstd')
| -rw-r--r-- | src/libstd/tempfile.rs | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/src/libstd/tempfile.rs b/src/libstd/tempfile.rs index 6da74834b1a..3d4e5bb8b79 100644 --- a/src/libstd/tempfile.rs +++ b/src/libstd/tempfile.rs @@ -27,7 +27,8 @@ pub fn mkdtemp(tmpdir: &Path, suffix: &str) -> Option<Path> { mod tests { use tempfile::mkdtemp; use tempfile; - + use core::os; + #[test] fn test_mkdtemp() { let p = mkdtemp(&Path("."), "foobar").unwrap(); @@ -89,4 +90,27 @@ mod tests { assert!(os::path_is_dir(&path2.pop())); }); } + + // Ideally this would be in core, but needs mkdtemp + #[test] + pub fn test_rmdir_recursive_ok() { + use core::libc::consts::os::posix88::{S_IRUSR, S_IWUSR, S_IXUSR}; + use core::os; + + let rwx = (S_IRUSR | S_IWUSR | S_IXUSR) as i32; + + let tmpdir = mkdtemp(&os::tmpdir(), "test").expect("test_rmdir_recursive_ok: \ + couldn't create temp dir"); + let root = tmpdir.push("foo"); + + debug!("making %s", root.to_str()); + assert!(os::make_dir(&root, rwx)); + assert!(os::make_dir(&root.push("foo"), rwx)); + assert!(os::make_dir(&root.push("foo").push("bar"), rwx)); + assert!(os::make_dir(&root.push("foo").push("bar").push("blat"), rwx)); + assert!(os::remove_dir_recursive(&root)); + assert!(!os::path_exists(&root)); + assert!(!os::path_exists(&root.push("bar"))); + assert!(!os::path_exists(&root.push("bar").push("blat"))); + } } |
