diff options
author | Austin Clements <austin@google.com> | 2021-01-07 17:50:14 -0500 |
---|---|---|
committer | Austin Clements <austin@google.com> | 2021-01-08 16:34:00 +0000 |
commit | 0c5afc4fb7e3349ec4efdce6554f83554e3d087c (patch) | |
tree | 9ea7c12d00da0b5e73ba164656e2087187b6d664 /src/os | |
parent | 32afcc94363e15ee2ef0cffec962191a15e73094 (diff) | |
download | go-0c5afc4fb7e3349ec4efdce6554f83554e3d087c.tar.gz go-0c5afc4fb7e3349ec4efdce6554f83554e3d087c.zip |
testing/fstest,os: clarify racy behavior of TestFS
The testing.TestFS function assumes that the file system it's testing
doesn't change under it. Clarify this in the documentation and fix the
use of os.TestDirFS that's currently susceptible to this race.
Fixes #42637.
Change-Id: Ia7792380726177f8953d150ee87381b66cb01cb3
Reviewed-on: https://go-review.googlesource.com/c/go/+/282452
Trust: Austin Clements <austin@google.com>
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Diffstat (limited to 'src/os')
-rw-r--r-- | src/os/os_test.go | 2 | ||||
-rw-r--r-- | src/os/testdata/dirfs/a | 0 | ||||
-rw-r--r-- | src/os/testdata/dirfs/b | 0 | ||||
-rw-r--r-- | src/os/testdata/dirfs/dir/x | 0 |
4 files changed, 1 insertions, 1 deletions
diff --git a/src/os/os_test.go b/src/os/os_test.go index 765797f5fb..d2e8ed5d82 100644 --- a/src/os/os_test.go +++ b/src/os/os_test.go @@ -2687,7 +2687,7 @@ func TestOpenFileKeepsPermissions(t *testing.T) { } func TestDirFS(t *testing.T) { - if err := fstest.TestFS(DirFS("./signal"), "signal.go", "internal/pty/pty.go"); err != nil { + if err := fstest.TestFS(DirFS("./testdata/dirfs"), "a", "b", "dir/x"); err != nil { t.Fatal(err) } } diff --git a/src/os/testdata/dirfs/a b/src/os/testdata/dirfs/a new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/src/os/testdata/dirfs/a diff --git a/src/os/testdata/dirfs/b b/src/os/testdata/dirfs/b new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/src/os/testdata/dirfs/b diff --git a/src/os/testdata/dirfs/dir/x b/src/os/testdata/dirfs/dir/x new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/src/os/testdata/dirfs/dir/x |