Patchwork tests: fix variable name regular expression in _genrestoreenv()

login
register
mail settings
Submitter Adam Simpkins
Date June 29, 2017, 7:25 p.m.
Message ID <ff64000ad1d198932a93.1498764349@devbig125.prn1.facebook.com>
Download mbox | patch
Permalink /patch/21833/
State Accepted
Headers show

Comments

Adam Simpkins - June 29, 2017, 7:25 p.m.
# HG changeset patch
# User Adam Simpkins <simpkins@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.
Augie Fackler - June 30, 2017, 1:59 p.m.
On Thu, Jun 29, 2017 at 12:25:49PM -0700, Adam Simpkins wrote:
> # HG changeset patch
> # User Adam Simpkins <simpkins@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()

queued, thanks

Patch

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():