Fix `create_dir_all("")`

Add a test for `""` and `"."`.
This commit is contained in:
Dawid Ciężarkiewicz 2017-03-14 22:03:00 -07:00
parent bcae6a3734
commit b5d590b3f0
1 changed files with 14 additions and 0 deletions

View File

@ -1775,6 +1775,10 @@ impl DirBuilder {
}
fn create_dir_all(&self, path: &Path) -> io::Result<()> {
if path == Path::new("") {
return Ok(())
}
match self.inner.mkdir(path) {
Ok(()) => return Ok(()),
Err(ref e) if e.kind() == io::ErrorKind::NotFound => {}
@ -2302,6 +2306,16 @@ mod tests {
check!(fs::create_dir_all(&Path::new("/")));
}
#[test]
fn recursive_mkdir_dot() {
check!(fs::create_dir_all(&Path::new(".")));
}
#[test]
fn recursive_mkdir_empty() {
check!(fs::create_dir_all(&Path::new("")));
}
#[test]
fn recursive_rmdir() {
let tmpdir = tmpdir();