1
0
mirror of https://github.com/golang/go synced 2024-11-26 17:46:57 -07:00

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.
This commit is contained in:
qiulaidongfeng 2023-11-08 19:38:00 +08:00
parent 841e63e480
commit 5cc418e625

View 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)
}
}