From 44cf595a7efcd3d7048c745d1d1531696bcb5941 Mon Sep 17 00:00:00 2001 From: Alex Brainman Date: Sat, 5 Jan 2019 18:35:27 +1100 Subject: 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 Reviewed-by: Ian Lance Taylor --- src/path/filepath/path_test.go | 25 ++++++++----------------- 1 file changed, 8 insertions(+), 17 deletions(-) (limited to 'src/path/filepath/path_test.go') diff --git a/src/path/filepath/path_test.go b/src/path/filepath/path_test.go index 1b9f286c4d..cbddda88b6 100644 --- a/src/path/filepath/path_test.go +++ b/src/path/filepath/path_test.go @@ -1382,27 +1382,18 @@ func TestIssue29372(t *testing.T) { path := f.Name() defer os.Remove(path) - isWin := runtime.GOOS == "windows" pathSeparator := string(filepath.Separator) - tests := []struct { - path string - skip bool - }{ - {path + strings.Repeat(pathSeparator, 1), false}, - {path + strings.Repeat(pathSeparator, 2), false}, - {path + strings.Repeat(pathSeparator, 1) + ".", false}, - {path + strings.Repeat(pathSeparator, 2) + ".", false}, - // windows.GetFinalPathNameByHandle return the directory part with trailing dot dot - // C:\path\to\existing_dir\existing_file\.. returns C:\path\to\existing_dir - {path + strings.Repeat(pathSeparator, 1) + "..", isWin}, - {path + strings.Repeat(pathSeparator, 2) + "..", isWin}, + tests := []string{ + path + strings.Repeat(pathSeparator, 1), + path + strings.Repeat(pathSeparator, 2), + path + strings.Repeat(pathSeparator, 1) + ".", + path + strings.Repeat(pathSeparator, 2) + ".", + path + strings.Repeat(pathSeparator, 1) + "..", + path + strings.Repeat(pathSeparator, 2) + "..", } for i, test := range tests { - if test.skip { - continue - } - _, err = filepath.EvalSymlinks(test.path) + _, err = filepath.EvalSymlinks(test) if err != syscall.ENOTDIR { t.Fatalf("test#%d: want %q, got %q", i, syscall.ENOTDIR, err) } -- cgit v1.3