diff options
author | Alex Brainman <alex.brainman@gmail.com> | 2019-01-25 18:22:27 +1100 |
---|---|---|
committer | Alex Brainman <alex.brainman@gmail.com> | 2019-01-27 04:18:10 +0000 |
commit | 447965d4e008764a8635df6ca7d5d2e59c6d4229 (patch) | |
tree | d0a36f0bb85d75e65675a6a022a3f1a485e1c396 | |
parent | eafe9a186c84dcfb7db1038cc43d1f0dfd1ea781 (diff) | |
download | go-447965d4e008764a8635df6ca7d5d2e59c6d4229.tar.gz go-447965d4e008764a8635df6ca7d5d2e59c6d4229.zip |
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 #29746
Change-Id: I2af8ebb89da7cb9daf027a5e49e32ee22dbd0e3d
Reviewed-on: https://go-review.googlesource.com/c/159578
Run-TryBot: Alex Brainman <alex.brainman@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
-rw-r--r-- | src/path/filepath/path_test.go | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/src/path/filepath/path_test.go b/src/path/filepath/path_test.go index cbddda88b6..9c4c7ebedc 100644 --- a/src/path/filepath/path_test.go +++ b/src/path/filepath/path_test.go @@ -1374,13 +1374,27 @@ func TestWalkSymlink(t *testing.T) { } func TestIssue29372(t *testing.T) { - f, err := ioutil.TempFile("", "issue29372") + tmpDir, err := ioutil.TempDir("", "TestIssue29372") + if err != nil { + t.Fatal(err) + } + defer os.RemoveAll(tmpDir) + + if runtime.GOOS == "windows" { + // This test is broken on windows, if temporary directory + // is a symlink. See issue 29746. + // TODO(brainman): Remove this hack once issue #29746 is fixed. + tmpDir, err = filepath.EvalSymlinks(tmpDir) + if err != nil { + t.Fatal(err) + } + } + + path := filepath.Join(tmpDir, "file.txt") + err = ioutil.WriteFile(path, nil, 0644) if err != nil { t.Fatal(err) } - f.Close() - path := f.Name() - defer os.Remove(path) pathSeparator := string(filepath.Separator) tests := []string{ |