Mercurial > hg
changeset 33203:cf826b9e9ea4
tests: actually restore the original environment before running syshg
Since os.environ may be overridden in run-tests.py, several important
variables such as PATH weren't restored.
I don't like the idea of using the system hg *by default* because the
executable and the configs are out of our control. But I don't mind as
long as the tests pass.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Fri, 30 Jun 2017 21:49:29 +0900 |
parents | 04cf9927f350 |
children | ddd65b4f3ae6 |
files | tests/run-tests.py |
diffstat | 1 files changed, 8 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/tests/run-tests.py Sun Jul 02 20:08:09 2017 -0700 +++ b/tests/run-tests.py Fri Jun 30 21:49:29 2017 +0900 @@ -84,6 +84,7 @@ except NameError: pass +origenviron = os.environ.copy() osenvironb = getattr(os, 'environb', os.environ) processlock = threading.Lock() @@ -907,16 +908,21 @@ # us to export. name_regex = re.compile('^[a-zA-Z][a-zA-Z0-9_]*$') + # Do not restore these variables; otherwise tests would fail. + reqnames = {'PYTHON', 'TESTDIR', 'TESTTMP'} + with open(scriptpath, 'w') as envf: - for name, value in os.environ.items(): + for name, value in origenviron.items(): if not name_regex.match(name): # Skip environment variables with unusual names not # allowed by most shells. continue + if name in reqnames: + continue envf.write('%s=%s\n' % (name, shellquote(value))) for name in testenv: - if name in os.environ: + if name in origenviron or name in reqnames: continue envf.write('unset %s\n' % (name,))