about summary refs log tree commit diff
path: root/src/libstd
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2013-05-01 00:57:35 -0700
committerbors <bors@rust-lang.org>2013-05-01 00:57:35 -0700
commitbfccfdc78065752079a3863db19ca7148ade3e6f (patch)
treeb836a4d48a9eb02362cacad524962a3c2467a6b2 /src/libstd
parent17ca13651a2bc6533413d80eb8941e5ddb20820e (diff)
parent782e06e0e379768d03e35acae16e7ee1e1841633 (diff)
downloadrust-bfccfdc78065752079a3863db19ca7148ade3e6f.tar.gz
rust-bfccfdc78065752079a3863db19ca7148ade3e6f.zip
auto merge of #6144 : catamorphism/rust/mkdir_recursive-breakage, r=thestinger
r? @brson or @thestinger : Added a change_dir_locked function to os, and use it in the
mkdir_recursive tests so that the tests don't clobber each other's
directory changes.
Diffstat (limited to 'src/libstd')
-rw-r--r--src/libstd/tempfile.rs50
1 files changed, 29 insertions, 21 deletions
diff --git a/src/libstd/tempfile.rs b/src/libstd/tempfile.rs
index eec91b68454..6da74834b1a 100644
--- a/src/libstd/tempfile.rs
+++ b/src/libstd/tempfile.rs
@@ -42,13 +42,18 @@ mod tests {
         use core::libc::consts::os::posix88::{S_IRUSR, S_IWUSR, S_IXUSR};
         use core::os;
 
-        let root = mkdtemp(&os::tmpdir(), "temp").expect("recursive_mkdir_rel");
-        os::change_dir(&root);
-        let path = Path("frob");
-        assert!(os::mkdir_recursive(&path,  (S_IRUSR | S_IWUSR | S_IXUSR) as i32));
-        assert!(os::path_is_dir(&path));
-        assert!(os::mkdir_recursive(&path,  (S_IRUSR | S_IWUSR | S_IXUSR) as i32));
-        assert!(os::path_is_dir(&path));
+        let root = mkdtemp(&os::tmpdir(), "recursive_mkdir_rel").
+            expect("recursive_mkdir_rel");
+        assert!(do os::change_dir_locked(&root) {
+            let path = Path("frob");
+            debug!("recursive_mkdir_rel: Making: %s in cwd %s [%?]", path.to_str(),
+                   os::getcwd().to_str(),
+                   os::path_exists(&path));
+            assert!(os::mkdir_recursive(&path,  (S_IRUSR | S_IWUSR | S_IXUSR) as i32));
+            assert!(os::path_is_dir(&path));
+            assert!(os::mkdir_recursive(&path,  (S_IRUSR | S_IWUSR | S_IXUSR) as i32));
+            assert!(os::path_is_dir(&path));
+        });
     }
 
     #[test]
@@ -67,18 +72,21 @@ mod tests {
         use core::libc::consts::os::posix88::{S_IRUSR, S_IWUSR, S_IXUSR};
         use core::os;
 
-        let root = mkdtemp(&os::tmpdir(), "temp").expect("recursive_mkdir_rel_2");
-        os::change_dir(&root);
-        let path = Path("./frob/baz");
-        debug!("...Making: %s in cwd %s", path.to_str(), os::getcwd().to_str());
-        assert!(os::mkdir_recursive(&path, (S_IRUSR | S_IWUSR | S_IXUSR) as i32));
-        assert!(os::path_is_dir(&path));
-        assert!(os::path_is_dir(&path.pop()));
-        let path2 = Path("quux/blat");
-        debug!("Making: %s in cwd %s", path2.to_str(), os::getcwd().to_str());
-        assert!(os::mkdir_recursive(&path2, (S_IRUSR | S_IWUSR | S_IXUSR) as i32));
-        assert!(os::path_is_dir(&path2));
-        assert!(os::path_is_dir(&path2.pop()));
+        let root = mkdtemp(&os::tmpdir(), "recursive_mkdir_rel_2").
+            expect("recursive_mkdir_rel_2");
+        assert!(do os::change_dir_locked(&root) {
+            let path = Path("./frob/baz");
+            debug!("recursive_mkdir_rel_2: Making: %s in cwd %s [%?]", path.to_str(),
+                   os::getcwd().to_str(), os::path_exists(&path));
+            assert!(os::mkdir_recursive(&path, (S_IRUSR | S_IWUSR | S_IXUSR) as i32));
+                assert!(os::path_is_dir(&path));
+            assert!(os::path_is_dir(&path.pop()));
+            let path2 = Path("quux/blat");
+            debug!("recursive_mkdir_rel_2: Making: %s in cwd %s", path2.to_str(),
+                   os::getcwd().to_str());
+            assert!(os::mkdir_recursive(&path2, (S_IRUSR | S_IWUSR | S_IXUSR) as i32));
+                assert!(os::path_is_dir(&path2));
+            assert!(os::path_is_dir(&path2.pop()));
+        });
     }
-
-}
\ No newline at end of file
+}