aboutsummaryrefslogtreecommitdiff
path: root/src/path/filepath/path_test.go
diff options
context:
space:
mode:
authorManlio Perillo <manlio.perillo@gmail.com>2021-04-07 16:48:41 +0200
committerTobias Klauser <tobias.klauser@gmail.com>2021-04-10 08:13:32 +0000
commit11f159456b1dba3ec499da916852dd188d1e04a7 (patch)
tree6db4787c1913a1df154b01091c940e82f136169c /src/path/filepath/path_test.go
parent6382ec1aba1b1c7380cb525217c1bd645c4fd41b (diff)
downloadgo-11f159456b1dba3ec499da916852dd188d1e04a7.tar.xz
path/filepath: replace os.MkdirTemp with T.TempDir
Add the tempDirCanonical function, for tests that need a temporary directory that does not contain symlinks. Updates #45402 Change-Id: I3d08ef32ef911331544acce3d7d013b4c3382960 Reviewed-on: https://go-review.googlesource.com/c/go/+/308011 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org> Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
Diffstat (limited to 'src/path/filepath/path_test.go')
-rw-r--r--src/path/filepath/path_test.go13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/path/filepath/path_test.go b/src/path/filepath/path_test.go
index bb6bc0dd87..cd107b6c85 100644
--- a/src/path/filepath/path_test.go
+++ b/src/path/filepath/path_test.go
@@ -449,6 +449,19 @@ func chtmpdir(t *testing.T) (restore func()) {
}
}
+// tempDirCanonical returns a temporary directory for the test to use, ensuring
+// that the returned path does not contain symlinks.
+func tempDirCanonical(t *testing.T) string {
+ dir := t.TempDir()
+
+ cdir, err := filepath.EvalSymlinks(dir)
+ if err != nil {
+ t.Errorf("tempDirCanonical: %v", err)
+ }
+
+ return cdir
+}
+
func TestWalk(t *testing.T) {
walk := func(root string, fn fs.WalkDirFunc) error {
return filepath.Walk(root, func(path string, info fs.FileInfo, err error) error {