Skip to content

Commit 6a8dbbe

Browse files
kolyshkingopherbot
authored andcommitted
path/filepath: fix EvalSymlinks to return ENOTDIR on plan9
CL 155597 added a test to check EvalSymlinks returns ENOTDIR for existing path which ends with a slash. CL 404954 added a separate evalSymlinks implementation for plan9, which has a kludge to ensure the ENOTDIR is returned in the above case. Apparently the added kludge is not working now (and maybe never worked), as seen in [1]: === RUN TestIssue29372 path_test.go:1730: test#0: want "not a directory", got "stat /tmp/TestIssue293724085649913/001/file.txt/: not a directory: '/tmp/TestIssue293724085649913/001/file.txt/'" --- FAIL: TestIssue29372 (0.00s) This happens because on plan9 errors are strings and they contain the file name after the error text, and the check assumes the "not a directory" text is at the end of the message. The fix is to check whether the error is somewhere in the error text, not ends with it (as it is done in other plan9 code, for example, see checkErrMessageContent added in CL 163058). This should fix the above test failure. PS perhaps the kludge should be moved up the call chain to os.Stat/Lstat? [1]: https://ci.chromium.org/ui/p/golang/builders/try/gotip-plan9-amd64/b8704772617873749345/test-results?q=ExactID%3Apath%2Ffilepath.TestIssue29372+VHash%3Aa63f5798e9f8f502 Change-Id: I6afb68be5f65a28929b2f717247ab34ff3b4a812 Reviewed-on: https://go-review.googlesource.com/c/go/+/700775 Auto-Submit: Emmanuel Odeke <[email protected]> Reviewed-by: Michael Knyszek <[email protected]> Reviewed-by: Dmitri Shuralyov <[email protected]> Reviewed-by: Richard Miller <[email protected]> TryBot-Bypass: Dmitri Shuralyov <[email protected]> Reviewed-by: Dmitri Shuralyov <[email protected]>
1 parent bffe7ad commit 6a8dbbe

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/path/filepath/symlink_plan9.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ func evalSymlinks(path string) (string, error) {
1616
// Check validity of path
1717
_, err := os.Lstat(path)
1818
if err != nil {
19-
// Return the same error value as on other operating systems
20-
if strings.HasSuffix(err.Error(), "not a directory") {
19+
// Return the same error value as on other operating systems.
20+
if strings.Contains(err.Error(), "not a directory") {
2121
err = syscall.ENOTDIR
2222
}
2323
return "", err

0 commit comments

Comments
 (0)