changeset 21361:0fdf92500012

run-tests: move abort global to TestRunner
author Gregory Szorc <gregory.szorc@gmail.com>
date Sun, 20 Apr 2014 00:10:06 -0700
parents becce297ae0c
children ff4ce72cc8d6
files tests/run-tests.py
diffstat 1 files changed, 8 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/tests/run-tests.py	Sun Apr 20 00:06:30 2014 -0700
+++ b/tests/run-tests.py	Sun Apr 20 00:10:06 2014 -0700
@@ -649,7 +649,8 @@
         vlog("# Running", cmd)
         if os.name == 'nt':
             replacements.append((r'\r\n', '\n'))
-        return run(cmd, testtmp, self._options, replacements, env)
+        return run(cmd, testtmp, self._options, replacements, env,
+                   self._runner.abort)
 
 
 needescape = re.compile(r'[\x00-\x08\x0b-\x1f\x7f-\xff]').search
@@ -681,7 +682,8 @@
         cmd = '%s "%s"' % (self._options.shell, fname)
         vlog("# Running", cmd)
 
-        exitcode, output = run(cmd, testtmp, self._options, replacements, env)
+        exitcode, output = run(cmd, testtmp, self._options, replacements, env,
+                               self._runner.abort)
         # Do not merge output if skipped. Return hghave message instead.
         # Similarly, with --debug, output is None.
         if exitcode == SKIPPED_STATUS or output is None:
@@ -929,7 +931,7 @@
         return False
 
 wifexited = getattr(os, "WIFEXITED", lambda x: False)
-def run(cmd, wd, options, replacements, env):
+def run(cmd, wd, options, replacements, env, abort):
     """Run command in a sub-process, capturing the output (stdout and stderr).
     Return a tuple (exitcode, output).  output is None in debug mode."""
     # TODO: Use subprocess.Popen if we're running on Python 2.4
@@ -967,7 +969,7 @@
     if ret:
         killdaemons(env['DAEMON_PIDS'])
 
-    if abort:
+    if abort[0]:
         raise KeyboardInterrupt()
 
     for s, r in replacements:
@@ -992,14 +994,12 @@
     return _hgpath
 
 iolock = threading.Lock()
-abort = False
 
 def scheduletests(runner, tests):
     jobs = runner.options.jobs
     done = queue.Queue()
     running = 0
     count = 0
-    global abort
 
     def job(test, count):
         try:
@@ -1032,7 +1032,7 @@
                 running += 1
                 count += 1
     except KeyboardInterrupt:
-        abort = True
+        runner.abort[0] = True
 
 class TestRunner(object):
     """Holds context for executing tests.
@@ -1062,6 +1062,7 @@
             's': [],
             'i': [],
         }
+        self.abort = [False]
         self._createdfiles = []
 
     def runtests(self, tests):