-
Notifications
You must be signed in to change notification settings - Fork 50
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
source.CallExprArgs fails to open target source file when built with -trimpath #277
Comments
Thank you for the bug report! I think this would be good to fix. Similar to the bazel fix, would you be able to run the test with some environment variable set to the path of the root of the project. |
@aaron42net @dnephin I'll see if I can come up with a PR. Admittedly, I'm hoping that this fix and my bazel fix will motivate a new patch level version release soon-ish 😅. |
@cstrahan Thank you for offering to fix this! The env var to specify the GO module directory seems like the safe and easy option. Thinking through some more:
Unfortunately I don't think it's safe to assume the directory is still the same directory as the package under test because some tests may run If tests are run in a git checkout, one option would be to use Maybe we can do something using So env var might be the only reliable option. If we detect a relative path for |
@dnephin Perhaps we could do both? That is, if we're comfortable with capturing the current working directory in a static initializer. I would think the odds that another static initializer would How does that sound? And, do you have any suggest for env var name? |
Good point! Capturing the working directory from an |
I had not wanted to use environment variables here, because I thought they would bust the But I'd also prefer to not need to pass environment in the common case. At least in the large monorepo I help maintain, there are zero instances of |
Any update? We are still seeing this issue. |
Similar to #274, the CI system I use has multiple concurrent builds and tests running in the same container, so it does source checkouts in temporary paths. This requires the use of
go test -trimpath
to avoid invalidating the cache every time the path changes.Unfortunately, this also fails with "unable to parse source file" from
source.CallExprArgs
:Instead of the expected useful output:
Here's some simple reproduction code; drop these into an empty directory and run
go mod tidy
. Thefoo_test.go
:And
go.mod
:The fix for #274 at least shows
some message
now, but after even more error messages. Would you be willing to accept a PR with a partial fix for-trimpath
too?Go tests are documented to be run from the same directory as the test binary, so it might be possible to infer a relative directory from that. Suggestions welcome for better ideas.
The text was updated successfully, but these errors were encountered: