From 54c109b122b2afe911882cc9f8c2dcaaa7e0005c Mon Sep 17 00:00:00 2001 From: Brad Fitzpatrick Date: Sun, 7 Oct 2012 10:31:56 -0700 Subject: [PATCH] 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 --- src/pkg/os/path_test.go | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/pkg/os/path_test.go b/src/pkg/os/path_test.go index c1e3fb35436..96f0f41e639 100644 --- a/src/pkg/os/path_test.go +++ b/src/pkg/os/path_test.go @@ -5,6 +5,7 @@ package os_test import ( + "io/ioutil" . "os" "path/filepath" "runtime" @@ -171,20 +172,23 @@ func TestMkdirAllWithSymlink(t *testing.T) { return } - tmpDir := TempDir() + tmpDir, err := ioutil.TempDir("", "TestMkdirAllWithSymlink-") + if err != nil { + t.Fatal(err) + } + defer RemoveAll(tmpDir) + dir := tmpDir + "/dir" - err := Mkdir(dir, 0755) + err = Mkdir(dir, 0755) if err != nil { t.Fatalf("Mkdir %s: %s", dir, err) } - defer RemoveAll(dir) link := tmpDir + "/link" err = Symlink("dir", link) if err != nil { t.Fatalf("Symlink %s: %s", link, err) } - defer RemoveAll(link) path := link + "/foo" err = MkdirAll(path, 0755)