Skip to content

Commit

Permalink
Normalize expected path for chdir tests
Browse files Browse the repository at this point in the history
The expected path comes from a simple string concatenation in shell, but
`os.Getwd` appears to have the normalized working directory, so this can
fail if any parent directory is a symlink.
  • Loading branch information
QuLogic committed Dec 31, 2024
1 parent 0426a5f commit 523bdeb
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions tests/testing/chdir/chdir.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ func main() {
}
if runtime.GOOS == "windows" {
cwd = filepath.ToSlash(cwd)
} else {
expectDir, err = filepath.EvalSymlinks(expectDir)
if err != nil {
log.Fatal(err)
}
}
if cwd != expectDir {
log.Fatalf("expected:\"%v\" != os.Getwd():\"%v\"", expectDir, cwd)
Expand Down

0 comments on commit 523bdeb

Please sign in to comment.