Introduce concept of env to make gpg signing easier to test
ezyang opened this issue · comments
#78 is a reasonable implementation given the current code structure but it is not great for testing because it (1) makes use of the ambient Git configuration (which is implemented as a one off function that probes git config), (2) requires us to be able to interpose on Git configuration in testing. The style of testing in ghstack today is that environmental settings are all turned into concrete arguments to the function at main() and that means that calls from testing can override the behavior there; refactor ghstack so that this occurs here as well.
A few implementations come mind
- Inject shell with env override for testing only
class Shell:
def __init__(..., testing=true, testing_env_defaults={}):
self.env_defaults = testing_env_defaults if testing else {}
-
Use https://pypi.org/project/pytest-forked/
Then,os.environ
pollution isolated. Kinda just a hack... -
Plumb env thru
<command>.main(env={...})
Is this necessary? I don't see a use case of injecting env var other than testing.
WDYT?
Is this necessary? I don't see a use case of injecting env var other than testing.
Isn't one use case good enough? :)