-
Notifications
You must be signed in to change notification settings - Fork 713
Allow version-tagged filepaths in tests #167
Description
(Continued from PR #165).
Description
Go 1.11 will introduce support for versioned modules. When running in module-aware mode, if your package depends on github.com/pkg/errors then Go will download it into a .../github.com/pkg/errors@v0.8.0/ path (or whatever the requested version). This makes format_test.go and stack_test.go fail during go test all because they expect the filepaths to contain /github.com/pkg/errors/.
Steps to reproduce
- Go into an empty directory NOT on GOPATH.
go1.11rc1 mod init github.com/thsnr/gomod.go1.11rc1 get github.com/pkg/errors@v0.0.0-00000000000000-816c9085562cd7ee03e7f8188a1cfd942858cded(must use pinned commit because 0.8.0 fails with another error fixed in master).go1.11rc1 test github.com/pkg/errors(usually run duringgo test all).
Expected results
All tests pass.
Actual results
Some tests fail because they are on a github.com/pkg/errors@v<version> path:
format_test.go:379: test 2: line 2: fmt.Sprintf("%+s", err):
got: "github.com/pkg/errors.init\n\t/home/thsnr/go/pkg/mod/github.com/pkg/errors@v0.0.0-00000000000000-816c9085562cd7ee03e7f8188a1cfd942858cded/stack_test.go"
want: "github.com/pkg/errors.init\n\t.+/github.com/pkg/errors/stack_test.go"
The PR simply proposed allowing version tags in the filepaths in those tests. It was closed because of "a broader problem with assuming the prefix is stable" and "the logic to trim the compile time GOPATH from source file paths" no longer working.
However I am unsure how these issues are relevant as the github.com/pkg/errors package does not assume a stable prefix outside of these tests and no GOPATH trimming is performed: it simply prints the filename reported by Func.FileLine (although see #166).
Opening this issue to continue the discussion from #165.