]> Cypherpunks repositories - gostls13.git/commitdiff
os: make TestMkdirAllWithSymlink more robust
authorBrad Fitzpatrick <bradfitz@golang.org>
Sun, 7 Oct 2012 17:31:56 +0000 (10:31 -0700)
committerBrad Fitzpatrick <bradfitz@golang.org>
Sun, 7 Oct 2012 17:31:56 +0000 (10:31 -0700)
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

index c1e3fb35436b96199956e329330d78c5f9856cfa..96f0f41e639060ff168634f37427d9dcf64ad798 100644 (file)
@@ -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)