diff options
| author | Dmitri Shuralyov <dmitshur@golang.org> | 2024-08-20 10:07:05 -0400 |
|---|---|---|
| committer | Gopher Robot <gobot@golang.org> | 2024-08-20 17:15:47 +0000 |
| commit | b292799ddd0e81ef6ffbbe5c7972786673d122f9 (patch) | |
| tree | 05fc7c7596516221091b2da0f5e409cca851beeb /src/testing | |
| parent | 98ed865a9e7525f7a30ec7fc7b360a45e966bf90 (diff) | |
| download | go-b292799ddd0e81ef6ffbbe5c7972786673d122f9.tar.xz | |
testing: use temp dir without symlinks in TestChdir/relative
When paths with symlinks are involved, it's not viable to compare them
with string equality. Don't use a temporary directory with symlinks in
it as input, so the test works in more environments.
For #62516.
Change-Id: I95d774365cc2f90eb0ffcffa61229ed5cee43e3e
Reviewed-on: https://go-review.googlesource.com/c/go/+/607035
Reviewed-by: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Diffstat (limited to 'src/testing')
| -rw-r--r-- | src/testing/testing_test.go | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/testing/testing_test.go b/src/testing/testing_test.go index ff674fc3d1..1dd2039399 100644 --- a/src/testing/testing_test.go +++ b/src/testing/testing_test.go @@ -293,7 +293,11 @@ func TestChdir(t *testing.T) { } defer os.Chdir(oldDir) - tmp := t.TempDir() + // The "relative" test case relies on tmp not being a symlink. + tmp, err := filepath.EvalSymlinks(t.TempDir()) + if err != nil { + t.Fatal(err) + } rel, err := filepath.Rel(oldDir, tmp) if err != nil { t.Fatal(err) |
