Patchwork [3,of,6] run-tests: remove arguments from Test._runcommand

login
register
mail settings
Submitter Gregory Szorc
Date March 29, 2015, 3:15 a.m.
Message ID <37fb7d70143047327da6.1427598908@vm-ubuntu-main.gateway.sonic.net>
Download mbox | patch
Permalink /patch/8338/
State Accepted
Headers show

Comments

Gregory Szorc - March 29, 2015, 3:15 a.m.
# HG changeset patch
# User Gregory Szorc <gregory.szorc@gmail.com>
# Date 1427577177 25200
#      Sat Mar 28 14:12:57 2015 -0700
# Node ID 37fb7d70143047327da622428f8f79d9e690e590
# Parent  ffe2862b3d4c2e9783bf0d1e6f22c764e0542735
run-tests: remove arguments from Test._runcommand

Now that runcommand is part of the Test class, arguments that were
previously coming from Test attributes can now be switched to
lookups inline.

Patch

diff --git a/tests/run-tests.py b/tests/run-tests.py
--- a/tests/run-tests.py
+++ b/tests/run-tests.py
@@ -721,21 +721,21 @@  class Test(unittest.TestCase):
         # unittest differentiates between errored and failed.
         # Failed is denoted by AssertionError (by default at least).
         raise AssertionError(msg)
 
-    def _runcommand(self, cmd, wd, replacements, env, debug=False,
-                    timeout=None):
+    def _runcommand(self, cmd, replacements, env):
         """Run command in a sub-process, capturing the output (stdout and
         stderr).
 
         Return a tuple (exitcode, output). output is None in debug mode.
         """
-        if debug:
-            proc = subprocess.Popen(cmd, shell=True, cwd=wd, env=env)
+        if self._debug:
+            proc = subprocess.Popen(cmd, shell=True, cwd=self._testtmp,
+                                    env=env)
             ret = proc.wait()
             return (ret, None)
 
-        proc = Popen4(cmd, wd, timeout, env)
+        proc = Popen4(cmd, self._testtmp, self._timeout, env)
         def cleanup():
             terminate(proc)
             ret = proc.wait()
             if ret == 0:
@@ -779,10 +779,9 @@  class PythonTest(Test):
         cmd = '%s%s "%s"' % (PYTHON, py3kswitch, self.path)
         vlog("# Running", cmd)
         if os.name == 'nt':
             replacements.append((r'\r\n', '\n'))
-        result = self._runcommand(cmd, self._testtmp, replacements, env,
-                                  debug=self._debug, timeout=self._timeout)
+        result = self._runcommand(cmd, replacements, env)
         if self._aborted:
             raise KeyboardInterrupt()
 
         return result
@@ -827,11 +826,9 @@  class TTest(Test):
 
         cmd = '%s "%s"' % (self._shell, fname)
         vlog("# Running", cmd)
 
-        exitcode, output = self._runcommand(cmd, self._testtmp, replacements,
-                                            env, debug=self._debug,
-                                            timeout=self._timeout)
+        exitcode, output = self._runcommand(cmd, replacements, env)
 
         if self._aborted:
             raise KeyboardInterrupt()