Commit 54c109b1 authored by Brad Fitzpatrick's avatar Brad Fitzpatrick

os: make TestMkdirAllWithSymlink more robust

Don't assume the test has a clean environment within /tmp.
Use an actual new tempdir for its tests.

Fixes FreeBSD build failure as seen at:
http://build.golang.org/log/396738676356d7fb6bab6eaf1b97cac820f8a90f

--- FAIL: TestMkdirAllWithSymlink (0.00 seconds)
path_test.go:178:                 Mkdir /tmp/dir: mkdir /tmp/dir: file exists
FAIL
FAIL    os      1.091s

R=golang-dev, minux.ma
CC=golang-dev
https://golang.org/cl/6615057
parent 13576e3b
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
package os_test package os_test
import ( import (
"io/ioutil"
. "os" . "os"
"path/filepath" "path/filepath"
"runtime" "runtime"
...@@ -171,20 +172,23 @@ func TestMkdirAllWithSymlink(t *testing.T) { ...@@ -171,20 +172,23 @@ func TestMkdirAllWithSymlink(t *testing.T) {
return return
} }
tmpDir := TempDir() tmpDir, err := ioutil.TempDir("", "TestMkdirAllWithSymlink-")
if err != nil {
t.Fatal(err)
}
defer RemoveAll(tmpDir)
dir := tmpDir + "/dir" dir := tmpDir + "/dir"
err := Mkdir(dir, 0755) err = Mkdir(dir, 0755)
if err != nil { if err != nil {
t.Fatalf("Mkdir %s: %s", dir, err) t.Fatalf("Mkdir %s: %s", dir, err)
} }
defer RemoveAll(dir)
link := tmpDir + "/link" link := tmpDir + "/link"
err = Symlink("dir", link) err = Symlink("dir", link)
if err != nil { if err != nil {
t.Fatalf("Symlink %s: %s", link, err) t.Fatalf("Symlink %s: %s", link, err)
} }
defer RemoveAll(link)
path := link + "/foo" path := link + "/foo"
err = MkdirAll(path, 0755) err = MkdirAll(path, 0755)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment