diff options
author | Russ Cox <rsc@golang.org> | 2020-12-02 12:49:20 -0500 |
---|---|---|
committer | Russ Cox <rsc@golang.org> | 2020-12-04 16:49:30 +0000 |
commit | 478bde3a4388997924a02ee9296864866d8ba3ba (patch) | |
tree | f474d0ffa817826e9d07f79a0df463da23060a32 /src/embed | |
parent | 5d4569197eeef42862b8ea87a7e8ccda1cd061a0 (diff) | |
download | go-478bde3a4388997924a02ee9296864866d8ba3ba.tar.gz go-478bde3a4388997924a02ee9296864866d8ba3ba.zip |
io/fs: add Sub
Sub provides a convenient way to refer to a subdirectory
automatically in future operations, like Unix's chdir(2).
The CL also includes updates to fstest to check Sub implementations.
As part of updating fstest, I changed the meaning of TestFS's
expected list to introduce a special case: if you list no expected files,
that means the FS must be empty. In general it's OK not to list all
the expected files, but if you list none, that's almost certainly a
mistake - if your FS were broken and empty, you wouldn't find out.
Making no expected files mean "must be empty" makes the mistake
less likely - if your file system ever worked, then your test will keep
it working.
That change found a testing bug: embedtest was making exactly
that mistake.
Fixes #42322.
Change-Id: I63fd4aa866b30061a0e51ca9a1927e576d6ec41e
Reviewed-on: https://go-review.googlesource.com/c/go/+/274856
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Diffstat (limited to 'src/embed')
-rw-r--r-- | src/embed/internal/embedtest/embed_test.go | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/embed/internal/embedtest/embed_test.go b/src/embed/internal/embedtest/embed_test.go index b1707a4c04..c6a7bea7a3 100644 --- a/src/embed/internal/embedtest/embed_test.go +++ b/src/embed/internal/embedtest/embed_test.go @@ -65,7 +65,7 @@ func TestGlobal(t *testing.T) { testFiles(t, global, "testdata/hello.txt", "hello, world\n") testFiles(t, global, "testdata/glass.txt", "I can eat glass and it doesn't hurt me.\n") - if err := fstest.TestFS(global); err != nil { + if err := fstest.TestFS(global, "concurrency.txt", "testdata/hello.txt"); err != nil { t.Fatal(err) } |