comparison tests/run-tests.py @ 33140:f458a6701983

tests: fix variable name regular expression in _genrestoreenv() Update the code to correctly anchor the expression on the end of the name, to require that the entire name match this expression. It was already anchored at the start by using re.match(), but this does not anchor it at the end.
author Adam Simpkins <simpkins@fb.com>
date Thu, 29 Jun 2017 11:29:19 -0700
parents 98e2c78e309c
children cf826b9e9ea4
comparison
equal deleted inserted replaced
33139:40ee74bfa111 33140:f458a6701983
903 scriptpath = os.path.join(self._threadtmp, b'restoreenv.sh') 903 scriptpath = os.path.join(self._threadtmp, b'restoreenv.sh')
904 testenv['HGTEST_RESTOREENV'] = scriptpath 904 testenv['HGTEST_RESTOREENV'] = scriptpath
905 905
906 # Only restore environment variable names that the shell allows 906 # Only restore environment variable names that the shell allows
907 # us to export. 907 # us to export.
908 name_regex = re.compile('[a-zA-Z][a-zA-Z0-9_]*') 908 name_regex = re.compile('^[a-zA-Z][a-zA-Z0-9_]*$')
909 909
910 with open(scriptpath, 'w') as envf: 910 with open(scriptpath, 'w') as envf:
911 for name, value in os.environ.items(): 911 for name, value in os.environ.items():
912 if not name_regex.match(name): 912 if not name_regex.match(name):
913 # Skip environment variables with unusual names not 913 # Skip environment variables with unusual names not