junegunn / fzf

:cherry_blossom: A command-line fuzzy finder
https://junegunn.github.io/fzf/
MIT License
62.32k stars 2.35k forks source link

test: fix TestOSExitNotAllowed to handle empty GOROOT #3758

Closed charlievieth closed 2 months ago

charlievieth commented 2 months ago

When tests are ran the -trimpath flag runtime.GOROOT() returns an empty string. This causes TestOSExitNotAllowed to fail because build.Context.ImportDir() cannot find packages in the standard library (without GOROOT it does not know where to look - see issue https://github.com/junegunn/fzf/issues/3748). This commit fixes that by falling back to go env GOROOT if runtime.GOROOT() returns an empty string. This works because go env GOROOT performs more work to identify the GOROOT than runtime.GOROOT().

This should fix https://github.com/junegunn/fzf/issues/3748.

Foxboron commented 2 months ago

Thanks for working on this :)

junegunn commented 2 months ago

Merged, thanks!