[PATCH] tests: fix variable name regular expression in _genrestoreenv()

Adam Simpkins simpkins at fb.com
Thu Jun 29 19:25:49 UTC 2017


# HG changeset patch
# User Adam Simpkins <simpkins at fb.com>
# Date 1498760959 25200
#      Thu Jun 29 11:29:19 2017 -0700
# Node ID ff64000ad1d198932a93630889e8ef1292be8e67
# Parent  78fc540c53e1ee7d3dc6dc7e32b739ce2dfeebf8
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.

diff --git a/tests/run-tests.py b/tests/run-tests.py
--- a/tests/run-tests.py
+++ b/tests/run-tests.py
@@ -905,7 +905,7 @@
 
         # Only restore environment variable names that the shell allows
         # us to export.
-        name_regex = re.compile('[a-zA-Z][a-zA-Z0-9_]*')
+        name_regex = re.compile('^[a-zA-Z][a-zA-Z0-9_]*$')
 
         with open(scriptpath, 'w') as envf:
             for name, value in os.environ.items():


More information about the Mercurial-devel mailing list