Tests break when run as a modules dependency #211
Comments
Thank you for raising this issue. Sadly it’s not feasible to fix this. If you want to run the tests of this project do so in the context of this repo. |
I get the some error in GitHub actions CI. Have you found any solutions? |
@zmrenwu what did you do? What did you see when you did it? |
Everything works fine on local enviroment, but can not run go test in GitHub actions CI. My GitHub action config:
Some GitHub action logs:
Thanks for helps! |
Thanks. I'm not sure what your test runner is doing but the resolution of this issue was -- do not test modules, only test your code. Have you vendored or copied the code for pkg/errors into your codebase? |
No, I don't directly import any code of pkg/errors. |
I'm sorry I'm not sure how to help. go test should only test the code in your module, not the tests in another module as that could lead to arbitrary code execution. @pkg/errors-maintainers do you have any suggestions. |
I was able to recreate the error situation. The issue causing the trouble is here: Given:
Followed by:
The answer is: do not put your |
Go version
go version go1.13 darwin/amd64
Module version
v0.8.1
What went wrong?
The following tests fail when the module is tested as a dependency:
TestStackTraceFormat
TestStackTrace
TestFrameFormat
TestFormatGeneric
TestFormatWithMessage
TestFormatWithStack
TestFormatWrapf
TestFormatWrap
TestFormatErrorf
TestFormatNew
Steps to reproduce
Output:
Cause
When Go modules' tests are run as a dependency (from outside their codebase), they execute in the module cache, which includes the module version in the filepath. This breaks several tests in this package, which expects the package filepath not to include a version.
The text was updated successfully, but these errors were encountered: