Commit edf1c038 authored by Rob Pike's avatar Rob Pike

os: remove use of _test

Part of issue 2573.

R=dsymonds, golang-dev
CC=golang-dev
https://golang.org/cl/5674064
parent 7e8a3694
...@@ -985,25 +985,24 @@ func TestAppend(t *testing.T) { ...@@ -985,25 +985,24 @@ func TestAppend(t *testing.T) {
} }
func TestStatDirWithTrailingSlash(t *testing.T) { func TestStatDirWithTrailingSlash(t *testing.T) {
// Create new dir, in _test so it will get // Create new temporary directory and arrange to clean it up.
// cleaned up by make if not by us. path, err := ioutil.TempDir("", "/_TestStatDirWithSlash_")
path := "_test/_TestStatDirWithSlash_"
err := MkdirAll(path, 0777)
if err != nil { if err != nil {
t.Fatalf("MkdirAll %q: %s", path, err) t.Fatalf("TempDir: %s", err)
} }
defer RemoveAll(path) defer RemoveAll(path)
// Stat of path should succeed. // Stat of path should succeed.
_, err = Stat(path) _, err = Stat(path)
if err != nil { if err != nil {
t.Fatal("stat failed:", err) t.Fatalf("stat %s failed: %s", path, err)
} }
// Stat of path+"/" should succeed too. // Stat of path+"/" should succeed too.
_, err = Stat(path + "/") path += "/"
_, err = Stat(path)
if err != nil { if err != nil {
t.Fatal("stat failed:", err) t.Fatalf("stat %s failed: %s", path, err)
} }
} }
......
...@@ -12,14 +12,13 @@ import ( ...@@ -12,14 +12,13 @@ import (
) )
func TestMkdirAll(t *testing.T) { func TestMkdirAll(t *testing.T) {
// Create new dir, in _test so it will get tmpDir := TempDir()
// cleaned up by make if not by us. path := tmpDir + "_/_TestMkdirAll_/dir/./dir2"
path := "_test/_TestMkdirAll_/dir/./dir2"
err := MkdirAll(path, 0777) err := MkdirAll(path, 0777)
if err != nil { if err != nil {
t.Fatalf("MkdirAll %q: %s", path, err) t.Fatalf("MkdirAll %q: %s", path, err)
} }
defer RemoveAll("_test/_TestMkdirAll_") defer RemoveAll(tmpDir + "/_TestMkdirAll_")
// Already exists, should succeed. // Already exists, should succeed.
err = MkdirAll(path, 0777) err = MkdirAll(path, 0777)
...@@ -63,7 +62,7 @@ func TestMkdirAll(t *testing.T) { ...@@ -63,7 +62,7 @@ func TestMkdirAll(t *testing.T) {
} }
if runtime.GOOS == "windows" { if runtime.GOOS == "windows" {
path := `_test\_TestMkdirAll_\dir\.\dir2\` path := tmpDir + `\_TestMkdirAll_\dir\.\dir2\`
err := MkdirAll(path, 0777) err := MkdirAll(path, 0777)
if err != nil { if err != nil {
t.Fatalf("MkdirAll %q: %s", path, err) t.Fatalf("MkdirAll %q: %s", path, err)
...@@ -72,8 +71,9 @@ func TestMkdirAll(t *testing.T) { ...@@ -72,8 +71,9 @@ func TestMkdirAll(t *testing.T) {
} }
func TestRemoveAll(t *testing.T) { func TestRemoveAll(t *testing.T) {
tmpDir := TempDir()
// Work directory. // Work directory.
path := "_test/_TestRemoveAll_" path := tmpDir + "/_TestRemoveAll_"
fpath := path + "/file" fpath := path + "/file"
dpath := path + "/dir" dpath := path + "/dir"
...@@ -170,19 +170,22 @@ func TestMkdirAllWithSymlink(t *testing.T) { ...@@ -170,19 +170,22 @@ func TestMkdirAllWithSymlink(t *testing.T) {
return return
} }
err := Mkdir("_test/dir", 0755) tmpDir := TempDir()
dir := tmpDir + "/dir"
err := Mkdir(dir, 0755)
if err != nil { 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 { 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) err = MkdirAll(path, 0755)
if err != nil { if err != nil {
t.Errorf("MkdirAll %q: %s", path, err) t.Errorf("MkdirAll %q: %s", path, err)
......
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