quaint-telephone-89068
12/16/2022, 8:03 PM[test].extra_env_vars
2. the extra_env_vars field
Neither is hooked up for Go, which is pure oversight.
Hook up [test].extra_env_vars
1. Request TestExtraEnv in the @rule signature
pants/src/python/pants/backend/go/goals/test.py
Lines 149 to 152 in </pantsbuild/pants/commit/bf25e129288e80116220292786f7e6018184173e|bf25e12>
Like this:
pants/src/python/pants/backend/python/goals/pytest_runner.py
Lines 167 to 177 in </pantsbuild/pants/commit/209b3542d48aad11a4bb88e8e9c62ed776013247|209b354>
2. Set the `Process`'s env field to test_extra_env.env
https://github.com/pantsbuild/pants/blob/bf25e129288e80116220292786f7e6018184173e/src/python/pants/backend/go/goals/test.py#L311-L234
3. Add a test to test_test.py, e.g.
pants/src/python/pants/backend/python/goals/pytest_runner_integration_test.py
Lines 402 to 443 in </pantsbuild/pants/commit/209b3542d48aad11a4bb88e8e9c62ed776013247|209b354>
Add field
1. Register new field to go_package target, probably called test_extra_env_vars. See this for example:
pants/src/python/pants/backend/python/target_types.py
Lines 811 to 820 in </pantsbuild/pants/commit/209b3542d48aad11a4bb88e8e9c62ed776013247|209b354>
https://www.pantsbuild.org/docs/target-api for general docs on Target API
2. Consume in the rule, like this:
pants/src/python/pants/backend/python/goals/pytest_runner.py
Lines 210 to 212 in </pantsbuild/pants/commit/209b3542d48aad11a4bb88e8e9c62ed776013247|209b354>
pants/src/python/pants/backend/python/goals/pytest_runner.py
Lines 315 to 322 in </pantsbuild/pants/commit/209b3542d48aad11a4bb88e8e9c62ed776013247|209b354>
(You have to update the FieldSet to have the field)
3. Update the test from before so that you test the field too, including that the field overrides the option.
pantsbuild/pantsuser
12/16/2022, 8:03 PM