Giter Club home page Giter Club logo

Comments (17)

junegunn avatar junegunn commented on May 24, 2024

I can't reproduce the problem

$ go test -trimpath ./...
?       github.com/junegunn/fzf/src/protector   [no test files]
ok      github.com/junegunn/fzf (cached)
ok      github.com/junegunn/fzf/src     (cached)
ok      github.com/junegunn/fzf/src/algo        (cached)
ok      github.com/junegunn/fzf/src/tui (cached)
ok      github.com/junegunn/fzf/src/util        (cached)

$ go version
go version go1.20.13 darwin/arm64

$ echo $GOPATH
/Users/jg/gosrc

$ unset GOPATH

$ go test -trimpath ./...
go: downloading github.com/rivo/uniseg v0.4.7
go: downloading golang.org/x/sys v0.19.0
go: downloading golang.org/x/term v0.19.0
go: downloading github.com/mattn/go-isatty v0.0.20
go: downloading github.com/charlievieth/fastwalk v1.0.3
go: downloading github.com/mattn/go-shellwords v1.0.12
?       github.com/junegunn/fzf/src/protector   [no test files]
ok      github.com/junegunn/fzf 1.540s
ok      github.com/junegunn/fzf/src     0.524s
ok      github.com/junegunn/fzf/src/algo        1.058s
ok      github.com/junegunn/fzf/src/tui 0.833s
ok      github.com/junegunn/fzf/src/util        0.485s

from fzf.

Foxboron avatar Foxboron commented on May 24, 2024

Huh, how weird. I can reproduce this on my local system + my build container. I'll probably need to dig into this more to figure out what the problem is then.

from fzf.

junegunn avatar junegunn commented on May 24, 2024

I tried again with a fresh copy, and it works just fine.

$ unset GOPATH
$ git clone https://github.com/junegunn/fzf.git
Cloning into 'fzf'...
remote: Enumerating objects: 14063, done.
remote: Counting objects: 100% (2603/2603), done.
remote: Compressing objects: 100% (390/390), done.
remote: Total 14063 (delta 2404), reused 2324 (delta 2201), pack-reused 11460
Receiving objects: 100% (14063/14063), 5.48 MiB | 24.09 MiB/s, done.
Resolving deltas: 100% (9062/9062), done.
$ cd fzf
$ go test -trimpath ./...
?       github.com/junegunn/fzf/src/protector   [no test files]
ok      github.com/junegunn/fzf 1.546s
ok      github.com/junegunn/fzf/src     (cached)
ok      github.com/junegunn/fzf/src/algo        (cached)
ok      github.com/junegunn/fzf/src/tui (cached)
ok      github.com/junegunn/fzf/src/util        (cached)
$ go version
go version go1.20.13 darwin/arm64

from fzf.

Foxboron avatar Foxboron commented on May 24, 2024

Is suspect you have GOROOT set? What does env say?

from fzf.

junegunn avatar junegunn commented on May 24, 2024

I don't have it.

$ unset GOPATH
$ env | grep GO
$

By the way, what's the point of setting -trimpath when running go test?

from fzf.

Foxboron avatar Foxboron commented on May 24, 2024

By the way, what's the point of setting -trimpath when running go test?

We are setting a global GOFLAGS for the build which contains -trimpath.

from fzf.

junegunn avatar junegunn commented on May 24, 2024

Reopening it as I can reproduce it on an Ubuntu 24.04 image with go 1.22.2.

from fzf.

junegunn avatar junegunn commented on May 24, 2024

@charlievieth Hi, any idea why this test doesn't work on some systems?

from fzf.

junegunn avatar junegunn commented on May 24, 2024

Reopening it as I can reproduce it on an Ubuntu 24.04 image with go 1.22.2.

Setting GOROOT fixed the issue:

GOROOT=$(go env GOROOT) go test -trimpath ./...

from fzf.

Foxboron avatar Foxboron commented on May 24, 2024

Right, but GOROOT is a new requirement so this is either something missing in the test (API breakage?) or something amiss with the library being used (regression?)

from fzf.

junegunn avatar junegunn commented on May 24, 2024

I've no idea to be honest. The test code was written by @charlievieth and I'm not fully familiar with the libraries used in it. Considering that it works without GOROOT on macOS, maybe it's a bug in the Go distribution or the Linux package?

Anyway, this GOROOT requirement doesn't apply to build command, and it actually makes more sense to not use -trimpath in test context (see golang/vscode-go#2737), I think it's fine.

from fzf.

charlievieth avatar charlievieth commented on May 24, 2024

Thank you for flaggifng this and I'll take a look at fixing this with -trimpath when I have some cycles but that might be a few days. Basically, the goal of this test is to ensure that os.Exit is not called, I could look at how golang.org/x/tools/go/analysis works since it performs similar analysis and see if it handles -trimpath being set.

That said, I'm not sure -trimpath provides much benefit when running tests - IIRC it's mostly for distributing builds.

from fzf.

Foxboron avatar Foxboron commented on May 24, 2024

Thank you for flaggifng this and I'll take a look at fixing this with -trimpath when I have some cycles but that might be a few days.

Thanks for looking at it. I tried looking at the code initially but didn't get very far.

That said, I'm not sure -trimpath provides much benefit when running tests - IIRC it's mostly for distributing builds.

I don't disagree on this, but build systems in distros sets a global GOFLAGS variable and having to replace out -trimpath because the test fails when it's set is not optimal.

from fzf.

junegunn avatar junegunn commented on May 24, 2024

build systems in distros sets a global GOFLAGS variable and having to replace out -trimpath

How about setting GOROOT as well instead of removing -trimpath? Seems like an easier and safer approach.

from fzf.

Foxboron avatar Foxboron commented on May 24, 2024

GOROOT=$(go env GOROOT) is inherently redundant, I'm curious why this has regressed.

from fzf.

junegunn avatar junegunn commented on May 24, 2024

A quick research.

build.ImportDir refers to runtime.GOROOT(),

and this is the definition of runtime.GOROOT():

But go env seems to do more work to than just referring to it to locate the real GOROOT.

So that I think explains why the test requires GOROOT. So until they clear up the differences, GOROOT=$(go env GOROOT) is the only option. It may seem redundant, but it isn't for now, and it's safe and future-proof.

from fzf.

charlievieth avatar charlievieth commented on May 24, 2024

Created #3758 to resolve this issue. Testing it locally with go test -trimpath works on my mac.

from fzf.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.