aboutsummaryrefslogtreecommitdiff
path: root/src/path/filepath/path_windows_test.go
diff options
context:
space:
mode:
authorAlex Brainman <alex.brainman@gmail.com>2019-01-05 18:35:27 +1100
committerAlex Brainman <alex.brainman@gmail.com>2019-01-10 08:35:34 +0000
commit44cf595a7efcd3d7048c745d1d1531696bcb5941 (patch)
tree05f200532f0950ece15d871efea5cfb7927dc3c2 /src/path/filepath/path_windows_test.go
parent94d9a2045398b471c8aec0b701cad06536e049b3 (diff)
downloadgo-44cf595a7efcd3d7048c745d1d1531696bcb5941.tar.xz
path/filepath: return special error from EvalSymlinks
CL 155597 attempted to fix #29372. But it failed to make all new test cases pass. Also CL 155597 broke some existing code (see #29449 for details). Make small adjustment to CL 155597 that fixes both #29372 and #29449. Suggested by Ian. Updates #29372 Fixes #29449 Change-Id: I9777a615514d3f152af5acb65fb1239e696607b6 Reviewed-on: https://go-review.googlesource.com/c/156398 Run-TryBot: Alex Brainman <alex.brainman@gmail.com> 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.go32
1 files changed, 27 insertions, 5 deletions
diff --git a/src/path/filepath/path_windows_test.go b/src/path/filepath/path_windows_test.go
index 63eab18116..3fcccfab78 100644
--- a/src/path/filepath/path_windows_test.go
+++ b/src/path/filepath/path_windows_test.go
@@ -536,17 +536,39 @@ func TestNTNamespaceSymlink(t *testing.T) {
}
target := strings.Trim(string(output), " \n\r")
- link := filepath.Join(tmpdir, "link")
- output, err = exec.Command("cmd", "/c", "mklink", "/J", link, target).CombinedOutput()
+ dirlink := filepath.Join(tmpdir, "dirlink")
+ output, err = exec.Command("cmd", "/c", "mklink", "/J", dirlink, target).CombinedOutput()
if err != nil {
- t.Fatalf("failed to run mklink %v %v: %v %q", link, target, err, output)
+ t.Fatalf("failed to run mklink %v %v: %v %q", dirlink, target, err, output)
}
- got, err := filepath.EvalSymlinks(link)
+ got, err := filepath.EvalSymlinks(dirlink)
if err != nil {
t.Fatal(err)
}
if want := vol + `\`; got != want {
- t.Errorf(`EvalSymlinks(%q): got %q, want %q`, link, got, want)
+ t.Errorf(`EvalSymlinks(%q): got %q, want %q`, dirlink, got, want)
+ }
+
+ file := filepath.Join(tmpdir, "file")
+ err = ioutil.WriteFile(file, []byte(""), 0666)
+ if err != nil {
+ t.Fatal(err)
+ }
+
+ target += file[len(filepath.VolumeName(file)):]
+
+ filelink := filepath.Join(tmpdir, "filelink")
+ output, err = exec.Command("cmd", "/c", "mklink", filelink, target).CombinedOutput()
+ if err != nil {
+ t.Fatalf("failed to run mklink %v %v: %v %q", filelink, target, err, output)
+ }
+
+ got, err = filepath.EvalSymlinks(filelink)
+ if err != nil {
+ t.Fatal(err)
+ }
+ if want := file; got != want {
+ t.Errorf(`EvalSymlinks(%q): got %q, want %q`, filelink, got, want)
}
}