Skip to content

Commit b292799

Browse files
dmitshurgopherbot
authored andcommitted
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 <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]> Auto-Submit: Dmitri Shuralyov <[email protected]> Reviewed-by: Dmitri Shuralyov <[email protected]>
1 parent 98ed865 commit b292799

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/testing/testing_test.go

+5-1
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,11 @@ func TestChdir(t *testing.T) {
293293
}
294294
defer os.Chdir(oldDir)
295295

296-
tmp := t.TempDir()
296+
// The "relative" test case relies on tmp not being a symlink.
297+
tmp, err := filepath.EvalSymlinks(t.TempDir())
298+
if err != nil {
299+
t.Fatal(err)
300+
}
297301
rel, err := filepath.Rel(oldDir, tmp)
298302
if err != nil {
299303
t.Fatal(err)

0 commit comments

Comments
 (0)