Skip to content
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

Introduce concept of env to make gpg signing easier to test #80

Open
ezyang opened this issue Aug 1, 2021 · 2 comments
Open

Introduce concept of env to make gpg signing easier to test #80

ezyang opened this issue Aug 1, 2021 · 2 comments
Labels

Comments

@ezyang
Copy link
Owner

ezyang commented Aug 1, 2021

#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.

@chebbyChefNEQ
Copy link
Contributor

chebbyChefNEQ commented Sep 5, 2021

A few implementations come mind

  1. 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 {}
  1. Use https://pypi.org/project/pytest-forked/
    Then,os.environ pollution isolated. Kinda just a hack...

  2. Plumb env thru <command>.main(env={...})
    Is this necessary? I don't see a use case of injecting env var other than testing.

WDYT?

@ezyang
Copy link
Owner Author

ezyang commented Sep 7, 2021

Is this necessary? I don't see a use case of injecting env var other than testing.

Isn't one use case good enough? :)

@ezyang ezyang added the backlog label Dec 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants