Skip to content

Commit 78d037b

Browse files
qiulaidongfenggopherbot
authored andcommitted
os: avoid TestFileChdir fail when GOROOT is a symbolic link
If GOROOT is a symbolic link, the paths obtained from the first and second Getwd of TestFileChdir are different, and this CL fixes the test failure in this situation. Fixes #64281 Change-Id: I53026b6c54a54be08833396e2c7081ca3ab8c282 GitHub-Last-Rev: 5cc418e GitHub-Pull-Request: #64001 Reviewed-on: https://go-review.googlesource.com/c/go/+/540521 Reviewed-by: Michael Knyszek <mknyszek@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Auto-Submit: Bryan Mills <bcmills@google.com> Reviewed-by: Bryan Mills <bcmills@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
1 parent 8be8bfe commit 78d037b

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

src/os/os_test.go

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1620,8 +1620,17 @@ func TestFileChdir(t *testing.T) {
16201620
if err != nil {
16211621
t.Fatalf("Getwd: %s", err)
16221622
}
1623-
if !equal(wdNew, wd) {
1624-
t.Fatalf("fd.Chdir failed, got %s, want %s", wdNew, wd)
1623+
1624+
wdInfo, err := fd.Stat()
1625+
if err != nil {
1626+
t.Fatal(err)
1627+
}
1628+
newInfo, err := Stat(wdNew)
1629+
if err != nil {
1630+
t.Fatal(err)
1631+
}
1632+
if !SameFile(wdInfo, newInfo) {
1633+
t.Fatalf("fd.Chdir failed: got %s, want %s", wdNew, wd)
16251634
}
16261635
}
16271636

0 commit comments

Comments
 (0)