in <https://github.com/pantsbuild/pants/pull/10715...
# development
h
in https://github.com/pantsbuild/pants/pull/10715/commits/02fc57568aca7482ed7f39ae90426de855a77686#diff-baef024aa6bde7184b0b627e23ae4f95R327 I'm adding a new option on
TestSubsystem
,
--extra-env-vars
, and invoking that option causes some of the tests in
test_test.py
to fail
it looks like it the culprit might be this line in `test_test.py`: https://github.com/pantsbuild/pants/blob/master/src/python/pants/core/goals/test_test.py#L119
which seems to be explicitly overriding some of the options defined on the subsystem
I'm getting errors that look like:
Copy code
src/python/pants/core/goals/test_test.py:266:                                                                                                                                                                        
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _                                                                                                                                      
src/python/pants/core/goals/test_test.py:202: in run_test_rule                  
    union_membership=union_membership,                                                                    
src/python/pants/testutil/rule_runner.py:372: in run_rule_with_mocks
    res = rule_coroutine.send(rule_input)                                                                 
src/python/pants/core/goals/test.py:376: in run_tests                                                                                                                                                                
    if test_subsystem.extra_env_vars:                                                                                                                                                                                
src/python/pants/core/goals/test.py:337: in extra_env_vars
    return cast(List[str], self.options.extra_env_vars)
src/python/pants/option/option_value_container.py:129: in __getattr__
    return self._get_underlying_value(key)                                                                                                                                                                           
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _                                                                                                                                      
                                                     
self = <pants.option.option_value_container.OptionValueContainer object at 0x7f23be63de48>
key = 'extra_env_vars'                                                                                    
                                                                                                                                                                                                                     
    def _get_underlying_value(self, key: Key):                                                                                                                                                                       
        # Note that the key may exist with a value of None, so we can't just
        # test self._value_map.get() for None.
        if key not in self._value_map:                                                                    
>           raise AttributeError(key)                                                                                                                                                                                
E           AttributeError: extra_env_vars
h
Yep, you have to provide an explicit value for every option created via
create_subsystem()
h
I'm wondering if there's a reason
create_goal_subsystem
has to work this way, or if it shoudl try to detect options that are set via
register_options
h
I don’t think there’s a particular reason, other than likely the difficulty of doing that
h
the option I added has a default, which is why I was confused for a bit
makes sense