-
-
Notifications
You must be signed in to change notification settings - Fork 611
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
Add environment variable support for Go tests #15963
Labels
Comments
I just ran into this trying out pants with a personal project. Mind if I try my hand at a PR? |
Please go for it, @wfscheper! Let me know if you have questions. If you're not yet on it, we're a friendly bunch on Slack :) https://www.pantsbuild.org/docs/getting-help |
Eric-Arellano
pushed a commit
that referenced
this issue
Jul 5, 2022
This addresses #15963 by plumbing through `[test].extra_env_vars` and adding the `test_extra_env_vars` field to `go_package`. [ci skip-rust] [ci skip-build-wheels]
Eric-Arellano
pushed a commit
to Eric-Arellano/pants
that referenced
this issue
Jul 5, 2022
This addresses pantsbuild#15963 by plumbing through `[test].extra_env_vars` and adding the `test_extra_env_vars` field to `go_package`. [ci skip-rust] [ci skip-build-wheels]
cczona
pushed a commit
to cczona/pants
that referenced
this issue
Sep 1, 2022
…16455) The implementation approach is based on the recommendations found in pantsbuild#15963 and, since this affects to several targets, similar as in pantsbuild#16387, where a base class for the field is created in core and then extended for each of the different target types.
Closing since this was already implemented by #16013. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
With Python, we support setting env variables two ways:
[test].extra_env_vars
extra_env_vars
fieldNeither is hooked up for Go, which is pure oversight.
Hook up
[test].extra_env_vars
TestExtraEnv
in the@rule
signaturepants/src/python/pants/backend/go/goals/test.py
Lines 149 to 152 in bf25e12
Like this:
pants/src/python/pants/backend/python/goals/pytest_runner.py
Lines 167 to 177 in 209b354
Process
'senv
field totest_extra_env.env
https://github.com/pantsbuild/pants/blob/bf25e129288e80116220292786f7e6018184173e/src/python/pants/backend/go/goals/test.py#L311-L234
test_test.py
, e.g.pants/src/python/pants/backend/python/goals/pytest_runner_integration_test.py
Lines 402 to 443 in 209b354
Add field
go_package
target, probably calledtest_extra_env_vars
. See this for example:pants/src/python/pants/backend/python/target_types.py
Lines 811 to 820 in 209b354
https://www.pantsbuild.org/docs/target-api for general docs on Target API
pants/src/python/pants/backend/python/goals/pytest_runner.py
Lines 210 to 212 in 209b354
pants/src/python/pants/backend/python/goals/pytest_runner.py
Lines 315 to 322 in 209b354
(You have to update the
FieldSet
to have the field)The text was updated successfully, but these errors were encountered: