aboutsummaryrefslogtreecommitdiff
path: root/src/testing/testing_test.go
diff options
context:
space:
mode:
authorTobias Klauser <tklauser@distanz.ch>2021-06-08 15:33:54 +0200
committerDmitri Shuralyov <dmitshur@golang.org>2022-01-26 18:34:58 +0000
commit8144f1dc261315004f12bd7cf1e8c043d74965a6 (patch)
tree15fcb82dfc3e40ab4def8a9767929ab4bb060afa /src/testing/testing_test.go
parent378766af9ed0f2e28d67c2b50e73db7573656669 (diff)
downloadgo-8144f1dc261315004f12bd7cf1e8c043d74965a6.tar.gz
go-8144f1dc261315004f12bd7cf1e8c043d74965a6.zip
[release-branch.go1.16] testing: drop unusual characters from TempDir directory name
Only use safe characters of the test name for the os.MkdirTemp pattern. This currently includes the alphanumeric characters and ASCII punctuation characters known not to interact with globs. For #46624 Fixes #50645 Change-Id: I402c34775b943fed9b97963c52f79245cc16dc1d Reviewed-on: https://go-review.googlesource.com/c/go/+/326010 Trust: Tobias Klauser <tobias.klauser@gmail.com> Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Bryan C. Mills <bcmills@google.com> Reviewed-by: Ian Lance Taylor <iant@golang.org> (cherry picked from commit 97cee43c93cfccded197cd281f0a5885cdb605b4) Reviewed-on: https://go-review.googlesource.com/c/go/+/378914 Trust: Ian Lance Taylor <iant@golang.org> Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
Diffstat (limited to 'src/testing/testing_test.go')
-rw-r--r--src/testing/testing_test.go10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/testing/testing_test.go b/src/testing/testing_test.go
index 0f096980ca..42058ae449 100644
--- a/src/testing/testing_test.go
+++ b/src/testing/testing_test.go
@@ -58,6 +58,9 @@ func TestTempDir(t *testing.T) {
t.Run("test:subtest", testTempDir)
t.Run("test/..", testTempDir)
t.Run("../test", testTempDir)
+ t.Run("test[]", testTempDir)
+ t.Run("test*", testTempDir)
+ t.Run("äöüéè", testTempDir)
}
func testTempDir(t *testing.T) {
@@ -74,7 +77,7 @@ func testTempDir(t *testing.T) {
if err != nil {
t.Fatal(err)
}
- t.Errorf("directory %q stil exists: %v, isDir=%v", dir, fi, fi.IsDir())
+ t.Errorf("directory %q still exists: %v, isDir=%v", dir, fi, fi.IsDir())
default:
if !t.Failed() {
t.Fatal("never received dir channel")
@@ -108,4 +111,9 @@ func testTempDir(t *testing.T) {
if len(files) > 0 {
t.Errorf("unexpected %d files in TempDir: %v", len(files), files)
}
+
+ glob := filepath.Join(dir, "*.txt")
+ if _, err := filepath.Glob(glob); err != nil {
+ t.Error(err)
+ }
}