Patchwork [1,of,2] tests: save the original PATH and PYTHONPATH variables

login
register
mail settings
Submitter Adam Simpkins
Date June 28, 2017, 12:37 a.m.
Message ID <6ce24ed2fa3f7a10d632.1498610238@devbig125.prn1.facebook.com>
Download mbox | patch
Permalink /patch/21793/
State Accepted
Headers show

Comments

Adam Simpkins - June 28, 2017, 12:37 a.m.
# HG changeset patch
# User Adam Simpkins <simpkins@fb.com>
# Date 1498609471 25200
#      Tue Jun 27 17:24:31 2017 -0700
# Node ID 6ce24ed2fa3f7a10d632f29b0f2a2da100884ba6
# Parent  758dded681beaef7307b660f05c775d5d3ed1f31
tests: save the original PATH and PYTHONPATH variables

When running the tests, define ORIG_PATH and ORIG_PYTHONPATH environment
variables that contain the original contents of PATH and PYTHONPATH, before
they were modified by run-tests.py

This will make it possible for tests to refer to the original contents of these
variables if necessary.  In particular, this is necessary for invoking the
correct version of hg for examining the local repository (the mercurial
repository itself, not the temporary test repositories).  Various tests examine
the local repository to check the file lists and contents of commit messages.

Patch

diff --git a/tests/run-tests.py b/tests/run-tests.py
--- a/tests/run-tests.py
+++ b/tests/run-tests.py
@@ -2274,6 +2274,9 @@ 
             sepb = _bytespath(os.pathsep)
         else:
             sepb = os.pathsep
+        # save the original path, for tests that need to invoke the
+        # system python
+        osenvironb[b"ORIG_PATH"] = osenvironb[b"PATH"]
         path = [self._bindir, runtestdir] + osenvironb[b"PATH"].split(sepb)
         if os.path.islink(__file__):
             # test helper will likely be at the end of the symlink
@@ -2299,6 +2302,7 @@ 
         # are in /opt/subversion.)
         oldpypath = osenvironb.get(IMPL_PATH)
         if oldpypath:
+            osenvironb['ORIG_' + IMPL_PATH] = oldpypath
             pypath.append(oldpypath)
         osenvironb[IMPL_PATH] = sepb.join(pypath)