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

Need to simplify Python test scripts to pass required env deltas into Subproces calls #224

Open
GoogleCodeExporter opened this issue Aug 4, 2015 · 2 comments

Comments

@GoogleCodeExporter
Copy link

Currently, the Python scripts need a lot of set-up and tear-down code to 
pass environment variables to child processes. When Hady's patch 
(http://codereview.appspot.com/153042/show) is done, we can add  a 
parameter called update_env to gtest_test_utils.Subprocess that will let 
users modify the environment being passed to Subprocess. With this 
parameter, we can do away with all the SetEnvVar calls and many finally 
sections in the Python tests. We will simply set update_env to set or clear 
the desired env var.

An approximate code for achieving this:

def __init__(self, command, working_dir=None, capture_stderr=True, 
env=None, update_env=None):
  if update_env:
    if env:
      env = env.copy()
    else:
      env = os.environ.copy()

    # Modifies env with values from update_env.
    # None values in update_env cause deletion
    # of keys in env.
    for key in update_env.keys():
      if update_env[key] is None and key in env:
        del env[key]
      else:
        env[key] = update_env[key]

Original issue reported on code.google.com by vladlosev on 16 Nov 2009 at 1:55

@GoogleCodeExporter
Copy link
Author

Original comment by w...@google.com on 26 Feb 2010 at 8:07

  • Added labels: Priority-Low
  • Removed labels: Priority-Medium

@GoogleCodeExporter
Copy link
Author

Vlad, do we still need/want to do this?

Original comment by w...@google.com on 27 Sep 2010 at 7:11

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant