Skip to content

Commit 447965d

Browse files
committed
path/filepath: skip TestIssue29372 on windows, if /tmp has symilinks
TestIssue29372 is broken on windows when temporary directory has symlink in its path. Adjust the test to use filepath.EvalSymlinks of temporary directory, instead of temporary directory on windows. This change is not a proper fix, but at least it makes TestIssue29372 pass on windows-arm. See issue for details. Updates golang#29746 Change-Id: I2af8ebb89da7cb9daf027a5e49e32ee22dbd0e3d Reviewed-on: https://go-review.googlesource.com/c/159578 Run-TryBot: Alex Brainman <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Ian Lance Taylor <[email protected]>
1 parent eafe9a1 commit 447965d

File tree

1 file changed

+18
-4
lines changed

1 file changed

+18
-4
lines changed

src/path/filepath/path_test.go

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1374,13 +1374,27 @@ func TestWalkSymlink(t *testing.T) {
13741374
}
13751375

13761376
func TestIssue29372(t *testing.T) {
1377-
f, err := ioutil.TempFile("", "issue29372")
1377+
tmpDir, err := ioutil.TempDir("", "TestIssue29372")
1378+
if err != nil {
1379+
t.Fatal(err)
1380+
}
1381+
defer os.RemoveAll(tmpDir)
1382+
1383+
if runtime.GOOS == "windows" {
1384+
// This test is broken on windows, if temporary directory
1385+
// is a symlink. See issue 29746.
1386+
// TODO(brainman): Remove this hack once issue #29746 is fixed.
1387+
tmpDir, err = filepath.EvalSymlinks(tmpDir)
1388+
if err != nil {
1389+
t.Fatal(err)
1390+
}
1391+
}
1392+
1393+
path := filepath.Join(tmpDir, "file.txt")
1394+
err = ioutil.WriteFile(path, nil, 0644)
13781395
if err != nil {
13791396
t.Fatal(err)
13801397
}
1381-
f.Close()
1382-
path := f.Name()
1383-
defer os.Remove(path)
13841398

13851399
pathSeparator := string(filepath.Separator)
13861400
tests := []string{

0 commit comments

Comments
 (0)