diff options
| author | Russ Cox <rsc@golang.org> | 2013-09-09 16:42:18 -0400 |
|---|---|---|
| committer | Russ Cox <rsc@golang.org> | 2013-09-09 16:42:18 -0400 |
| commit | 5dc8c4dbfb6a04d9eb7a11c9c3fe698d33d0c0ee (patch) | |
| tree | 3db755702968812af6a6b32cd4654b7254f53946 /src/pkg/path/filepath/path_test.go | |
| parent | 10c36fbc9d413062de4a1ecd59b9c5f7dc82b0c9 (diff) | |
| download | go-5dc8c4dbfb6a04d9eb7a11c9c3fe698d33d0c0ee.tar.xz | |
path/filepath: fix race with other tests
Bug3486 tried to walk the entire file tree, but other tests might
be creating and removing files in that tree. In particular, package os
creates and removes files in the os directory, and issue 5863
reports failures due to seeing those files appear and then disappear.
Change the test to walk just the test tree, which should not be
changing.
Fixes #5863.
R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/13467045
Diffstat (limited to 'src/pkg/path/filepath/path_test.go')
| -rw-r--r-- | src/pkg/path/filepath/path_test.go | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/src/pkg/path/filepath/path_test.go b/src/pkg/path/filepath/path_test.go index bbb4e16f2a..d32b70d6e2 100644 --- a/src/pkg/path/filepath/path_test.go +++ b/src/pkg/path/filepath/path_test.go @@ -927,27 +927,32 @@ func TestDriveLetterInEvalSymlinks(t *testing.T) { } func TestBug3486(t *testing.T) { // http://code.google.com/p/go/issues/detail?id=3486 - root, err := filepath.EvalSymlinks(runtime.GOROOT()) + root, err := filepath.EvalSymlinks(runtime.GOROOT() + "/test") if err != nil { t.Fatal(err) } - lib := filepath.Join(root, "lib") - src := filepath.Join(root, "src") - seenSrc := false + bugs := filepath.Join(root, "bugs") + ken := filepath.Join(root, "ken") + seenBugs := false + seenKen := false filepath.Walk(root, func(pth string, info os.FileInfo, err error) error { if err != nil { t.Fatal(err) } switch pth { - case lib: + case bugs: + seenBugs = true return filepath.SkipDir - case src: - seenSrc = true + case ken: + if !seenBugs { + t.Fatal("filepath.Walk out of order - ken before bugs") + } + seenKen = true } return nil }) - if !seenSrc { - t.Fatalf("%q not seen", src) + if !seenKen { + t.Fatalf("%q not seen", ken) } } |
