]> Cypherpunks repositories - gostls13.git/commitdiff
os: remove use of _test
authorRob Pike <r@golang.org>
Thu, 16 Feb 2012 06:05:43 +0000 (17:05 +1100)
committerRob Pike <r@golang.org>
Thu, 16 Feb 2012 06:05:43 +0000 (17:05 +1100)
Part of issue 2573.

R=dsymonds, golang-dev
CC=golang-dev
https://golang.org/cl/5674064

src/pkg/os/os_test.go
src/pkg/os/path_test.go

index a5ffcc05940b85e827d20958d4bed5a7bfe207b2..9a95407ad57ab6406bc136d6f8f99b51a9c5d32a 100644 (file)
@@ -985,25 +985,24 @@ func TestAppend(t *testing.T) {
 }
 
 func TestStatDirWithTrailingSlash(t *testing.T) {
-       // Create new dir, in _test so it will get
-       // cleaned up by make if not by us.
-       path := "_test/_TestStatDirWithSlash_"
-       err := MkdirAll(path, 0777)
+       // Create new temporary directory and arrange to clean it up.
+       path, err := ioutil.TempDir("", "/_TestStatDirWithSlash_")
        if err != nil {
-               t.Fatalf("MkdirAll %q: %s", path, err)
+               t.Fatalf("TempDir: %s", err)
        }
        defer RemoveAll(path)
 
        // Stat of path should succeed.
        _, err = Stat(path)
        if err != nil {
-               t.Fatal("stat failed:", err)
+               t.Fatalf("stat %s failed: %s", path, err)
        }
 
        // Stat of path+"/" should succeed too.
-       _, err = Stat(path + "/")
+       path += "/"
+       _, err = Stat(path)
        if err != nil {
-               t.Fatal("stat failed:", err)
+               t.Fatalf("stat %s failed: %s", path, err)
        }
 }
 
index 18634ba410ede3d23f8f4707181e6b5a99eadb1e..774438067897f74b459df41860ca7c1f02054e3f 100644 (file)
@@ -12,14 +12,13 @@ import (
 )
 
 func TestMkdirAll(t *testing.T) {
-       // Create new dir, in _test so it will get
-       // cleaned up by make if not by us.
-       path := "_test/_TestMkdirAll_/dir/./dir2"
+       tmpDir := TempDir()
+       path := tmpDir + "_/_TestMkdirAll_/dir/./dir2"
        err := MkdirAll(path, 0777)
        if err != nil {
                t.Fatalf("MkdirAll %q: %s", path, err)
        }
-       defer RemoveAll("_test/_TestMkdirAll_")
+       defer RemoveAll(tmpDir + "/_TestMkdirAll_")
 
        // Already exists, should succeed.
        err = MkdirAll(path, 0777)
@@ -63,7 +62,7 @@ func TestMkdirAll(t *testing.T) {
        }
 
        if runtime.GOOS == "windows" {
-               path := `_test\_TestMkdirAll_\dir\.\dir2\`
+               path := tmpDir + `\_TestMkdirAll_\dir\.\dir2\`
                err := MkdirAll(path, 0777)
                if err != nil {
                        t.Fatalf("MkdirAll %q: %s", path, err)
@@ -72,8 +71,9 @@ func TestMkdirAll(t *testing.T) {
 }
 
 func TestRemoveAll(t *testing.T) {
+       tmpDir := TempDir()
        // Work directory.
-       path := "_test/_TestRemoveAll_"
+       path := tmpDir + "/_TestRemoveAll_"
        fpath := path + "/file"
        dpath := path + "/dir"
 
@@ -170,19 +170,22 @@ func TestMkdirAllWithSymlink(t *testing.T) {
                return
        }
 
-       err := Mkdir("_test/dir", 0755)
+       tmpDir := TempDir()
+       dir := tmpDir + "/dir"
+       err := Mkdir(dir, 0755)
        if err != nil {
-               t.Fatal(`Mkdir "_test/dir":`, err)
+               t.Fatalf("Mkdir %s: %s", dir, err)
        }
-       defer RemoveAll("_test/dir")
+       defer RemoveAll(dir)
 
-       err = Symlink("dir", "_test/link")
+       link := tmpDir + "/link"
+       err = Symlink("dir", link)
        if err != nil {
-               t.Fatal(`Symlink "dir", "_test/link":`, err)
+               t.Fatalf("Symlink %s: %s", link, err)
        }
-       defer RemoveAll("_test/link")
+       defer RemoveAll(link)
 
-       path := "_test/link/foo"
+       path := link + "/foo"
        err = MkdirAll(path, 0755)
        if err != nil {
                t.Errorf("MkdirAll %q: %s", path, err)