]> Cypherpunks repositories - gostls13.git/commitdiff
os: avoid TestFileChdir fail when GOROOT is a symbolic link
authorqiulaidongfeng <2645477756@qq.com>
Mon, 20 Nov 2023 23:08:53 +0000 (23:08 +0000)
committerGopher Robot <gobot@golang.org>
Tue, 21 Nov 2023 16:29:21 +0000 (16:29 +0000)
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: 5cc418e6255f6fa530e5a43e3b4d96759e604571
GitHub-Pull-Request: golang/go#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>

src/os/os_test.go

index ae12b9ce1be036e947502bb6e3b6bb654f88b332..7e0e0b90be0b56c87801695982e5560230f24f3d 100644 (file)
@@ -1620,8 +1620,17 @@ func TestFileChdir(t *testing.T) {
        if err != nil {
                t.Fatalf("Getwd: %s", err)
        }
-       if !equal(wdNew, wd) {
-               t.Fatalf("fd.Chdir failed, got %s, want %s", wdNew, wd)
+
+       wdInfo, err := fd.Stat()
+       if err != nil {
+               t.Fatal(err)
+       }
+       newInfo, err := Stat(wdNew)
+       if err != nil {
+               t.Fatal(err)
+       }
+       if !SameFile(wdInfo, newInfo) {
+               t.Fatalf("fd.Chdir failed: got %s, want %s", wdNew, wd)
        }
 }