[Piglit] [PATCH 7/9] framework/exectest.py: move more stuff from run to get_command_result

Dylan Baker baker.dylan.c at gmail.com
Wed Apr 9 18:27:25 PDT 2014


This patch completely removes argument for Test.get_command_result.
command was just a copy of self.command, just use self.command
fullenv was based on self.env and is only used as an argument for
get_command_result, so there's no reason to pass it as an argument,
instead compute it inside of get_command_result.
---
 framework/exectest.py | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)

diff --git a/framework/exectest.py b/framework/exectest.py
index b83536a..72061e0 100644
--- a/framework/exectest.py
+++ b/framework/exectest.py
@@ -138,10 +138,6 @@ class Test(object):
         * For 'returncode', the value will be the numeric exit code/value.
         * For 'command', the value will be command line program and arguments.
         """
-        fullenv = os.environ.copy()
-        for e in self.env:
-            fullenv[e] = str(self.env[e])
-
         if self.command is not None:
             command = self.command
 
@@ -157,8 +153,7 @@ class Test(object):
                     err = ""
                     returncode = None
                 else:
-                    out, err, returncode = self.get_command_result(command,
-                                                                   fullenv)
+                    out, err, returncode = self.get_command_result()
 
                 # https://bugzilla.gnome.org/show_bug.cgi?id=680214 is
                 # affecting many developers.  If we catch it
@@ -237,9 +232,12 @@ class Test(object):
         """
         return False
 
-    def get_command_result(self, command, fullenv):
+    def get_command_result(self):
+        fullenv = os.environ.copy()
+        fullenv.update({k: str(v) for k, v in self.env.iteritems()})
+
         try:
-            proc = subprocess.Popen(command,
+            proc = subprocess.Popen(self.command,
                                     stdout=subprocess.PIPE,
                                     stderr=subprocess.PIPE,
                                     env=fullenv,
-- 
1.9.1



More information about the Piglit mailing list