aboutsummaryrefslogtreecommitdiff
path: root/src/path/filepath/path_windows_test.go
diff options
context:
space:
mode:
authorAlex Brainman <alex.brainman@gmail.com>2017-08-17 20:05:15 +1000
committerAlex Brainman <alex.brainman@gmail.com>2017-09-24 01:58:24 +0000
commit7739b8a97fb767ceb141af05a1213b538c32e8da (patch)
treeaf5a7cf1580f5a7b67c29e63b748b81e8880fbb8 /src/path/filepath/path_windows_test.go
parent18b49db18e02c1590119eeda58673bf93c2e41c9 (diff)
downloadgo-7739b8a97fb767ceb141af05a1213b538c32e8da.tar.xz
path/filepath: simplify TestEvalSymlinks
Change-Id: I4a747fca0db3cbd4972feaddcb625041b648620b Reviewed-on: https://go-review.googlesource.com/56710 Run-TryBot: Alex Brainman <alex.brainman@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
Diffstat (limited to 'src/path/filepath/path_windows_test.go')
-rw-r--r--src/path/filepath/path_windows_test.go58
1 files changed, 58 insertions, 0 deletions
diff --git a/src/path/filepath/path_windows_test.go b/src/path/filepath/path_windows_test.go
index d759a83f38..d1b89bbc71 100644
--- a/src/path/filepath/path_windows_test.go
+++ b/src/path/filepath/path_windows_test.go
@@ -100,6 +100,64 @@ func testWinSplitListTestIsValid(t *testing.T, ti int, tt SplitListTest,
}
}
+func TestWindowsEvalSymlinks(t *testing.T) {
+ testenv.MustHaveSymlink(t)
+
+ tmpDir, err := ioutil.TempDir("", "TestWindowsEvalSymlinks")
+ if err != nil {
+ t.Fatal(err)
+ }
+ defer os.RemoveAll(tmpDir)
+
+ // /tmp may itself be a symlink! Avoid the confusion, although
+ // it means trusting the thing we're testing.
+ tmpDir, err = filepath.EvalSymlinks(tmpDir)
+ if err != nil {
+ t.Fatal(err)
+ }
+
+ if len(tmpDir) < 3 {
+ t.Fatalf("tmpDir path %q is too short", tmpDir)
+ }
+ if tmpDir[1] != ':' {
+ t.Fatalf("tmpDir path %q must have drive letter in it", tmpDir)
+ }
+ test := EvalSymlinksTest{"test/linkabswin", tmpDir[:3]}
+
+ // Create the symlink farm using relative paths.
+ testdirs := append(EvalSymlinksTestDirs, test)
+ for _, d := range testdirs {
+ var err error
+ path := simpleJoin(tmpDir, d.path)
+ if d.dest == "" {
+ err = os.Mkdir(path, 0755)
+ } else {
+ err = os.Symlink(d.dest, path)
+ }
+ if err != nil {
+ t.Fatal(err)
+ }
+ }
+
+ path := simpleJoin(tmpDir, test.path)
+
+ testEvalSymlinks(t, path, test.dest)
+
+ testEvalSymlinksAfterChdir(t, path, ".", test.dest)
+
+ testEvalSymlinksAfterChdir(t,
+ path,
+ filepath.VolumeName(tmpDir)+".",
+ test.dest)
+
+ testEvalSymlinksAfterChdir(t,
+ simpleJoin(tmpDir, "test"),
+ simpleJoin("..", test.path),
+ test.dest)
+
+ testEvalSymlinksAfterChdir(t, tmpDir, test.path, test.dest)
+}
+
// TestEvalSymlinksCanonicalNames verify that EvalSymlinks
// returns "canonical" path names on windows.
func TestEvalSymlinksCanonicalNames(t *testing.T) {