about summary refs log tree commit diff
path: root/src/libstd
diff options
context:
space:
mode:
authorDawid Ciężarkiewicz <dpc@dpc.pw>2017-03-12 23:07:16 -0700
committerDawid Ciężarkiewicz <dpc@dpc.pw>2017-03-17 20:15:05 -0700
commitf2adee74a318503334c07290ca767fd609aebf1f (patch)
treebdedd9501ced73f474244172ced7cb84c1668aa0 /src/libstd
parent0ec28b796d1206c4442f0269febe2a1cc0794411 (diff)
downloadrust-f2adee74a318503334c07290ca767fd609aebf1f.tar.gz
rust-f2adee74a318503334c07290ca767fd609aebf1f.zip
Add `concurrent_recursive_mkdir` test
Diffstat (limited to 'src/libstd')
-rw-r--r--src/libstd/fs.rs23
1 files changed, 22 insertions, 1 deletions
diff --git a/src/libstd/fs.rs b/src/libstd/fs.rs
index 6a465e38f38..7ba88d6a3e1 100644
--- a/src/libstd/fs.rs
+++ b/src/libstd/fs.rs
@@ -1782,7 +1782,7 @@ impl DirBuilder {
             Err(e) => return Err(e),
         }
         match path.parent() {
-            Some(p) => try!(create_dir_all(p)),
+            Some(p) => try!(self.create_dir_all(p)),
             None => return Err(io::Error::new(io::ErrorKind::Other, "failed to create whole tree")),
         }
         match self.inner.mkdir(path) {
@@ -1809,6 +1809,7 @@ mod tests {
     use rand::{StdRng, Rng};
     use str;
     use sys_common::io::test::{TempDir, tmpdir};
+    use thread;
 
     #[cfg(windows)]
     use os::windows::fs::{symlink_dir, symlink_file};
@@ -2277,6 +2278,26 @@ mod tests {
     }
 
     #[test]
+    fn concurrent_recursive_mkdir() {
+        for _ in 0..100 {
+            let mut dir = tmpdir().join("a");
+            for _ in 0..100 {
+                dir = dir.join("a");
+            }
+            let mut join = vec!();
+            for _ in 0..8 {
+                let dir = dir.clone();
+                join.push(thread::spawn(move || {
+                    check!(fs::create_dir_all(&dir));
+                }))
+            }
+
+            // No `Display` on result of `join()`
+            join.drain(..).map(|join| join.join().unwrap()).count();
+        }
+    }
+
+    #[test]
     fn recursive_mkdir_slash() {
         check!(fs::create_dir_all(&Path::new("/")));
     }