run-tests: pass abort into Test.__init__
authorGregory Szorc <gregory.szorc@gmail.com>
Tue, 22 Apr 2014 10:12:19 -0700
changeset 21505 3a1881dbf860
parent 21504 888a5dfe1569
child 21506 bfe2616a2b0e
run-tests: pass abort into Test.__init__
tests/run-tests.py
--- a/tests/run-tests.py	Tue Apr 22 10:05:32 2014 -0700
+++ b/tests/run-tests.py	Tue Apr 22 10:12:19 2014 -0700
@@ -338,7 +338,7 @@
     # Status code reserved for skipped tests (used by hghave).
     SKIPPED_STATUS = 80
 
-    def __init__(self, runner, path, count, tmpdir):
+    def __init__(self, runner, path, count, tmpdir, abort):
         """Create a test from parameters.
 
         runner is a TestRunner instance.
@@ -348,6 +348,9 @@
         count is an identifier used to denote this test instance.
 
         tmpdir is the main temporary directory to use for this test.
+
+        abort is a flag that turns to True if test execution should be aborted.
+        It is consulted periodically during the execution of tests.
         """
 
         self._path = path
@@ -359,6 +362,7 @@
         self._options = runner.options
         self._count = count
         self._threadtmp = tmpdir
+        self._abort = abort
         self._daemonpids = []
 
         self._finished = None
@@ -684,7 +688,7 @@
         vlog("# Running", cmd)
         if os.name == 'nt':
             replacements.append((r'\r\n', '\n'))
-        return run(cmd, self._testtmp, replacements, env, self._runner.abort,
+        return run(cmd, self._testtmp, replacements, env, self._abort,
                    debug=self._options.debug, timeout=self._options.timeout)
 
 class TTest(Test):
@@ -720,7 +724,7 @@
         vlog("# Running", cmd)
 
         exitcode, output = run(cmd, self._testtmp, replacements, env,
-                               self._runner.abort, debug=self._options.debug,
+                               self._abort, debug=self._options.debug,
                                timeout=self._options.timeout)
         # Do not merge output if skipped. Return hghave message instead.
         # Similarly, with --debug, output is None.
@@ -1471,7 +1475,7 @@
         refpath = os.path.join(self.testdir, test)
         tmpdir = os.path.join(self.hgtmp, 'child%d' % count)
 
-        return testcls(self, refpath, count, tmpdir)
+        return testcls(self, refpath, count, tmpdir, self.abort)
 
     def _cleanup(self):
         """Clean up state from this test invocation."""