ddavis2speedray / googletest

Automatically exported from code.google.com/p/googletest
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

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

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
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 commented 9 years ago

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

GoogleCodeExporter commented 9 years ago
Vlad, do we still need/want to do this?

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