[PATCH 085 of 179 tests-refactor] run-tests: move SKIPPED_STATUS into Test class

Gregory Szorc gregory.szorc at gmail.com
Fri May 2 18:38:42 UTC 2014


# HG changeset patch
# User Gregory Szorc <gregory.szorc at gmail.com>
# Date 1398014196 25200
#      Sun Apr 20 10:16:36 2014 -0700
# Branch stable
# Node ID 8f290defff48c8ae762404609c67c70a018cd69f
# Parent  f6820235f603f171f82ba5e1641805ae5b423674
run-tests: move SKIPPED_STATUS into Test class

diff --git a/tests/run-tests.py b/tests/run-tests.py
--- a/tests/run-tests.py
+++ b/tests/run-tests.py
@@ -87,18 +87,16 @@ def Popen4(cmd, wd, timeout, env=None):
                 time.sleep(.1)
             p.timeout = True
             if p.returncode is None:
                 terminate(p)
         threading.Thread(target=t).start()
 
     return p
 
-# reserved exit code to skip test (used by hghave)
-SKIPPED_STATUS = 80
 SKIPPED_PREFIX = 'skipped: '
 FAILED_PREFIX  = 'hghave check failed: '
 PYTHON = sys.executable.replace('\\', '/')
 IMPL_PATH = 'PYTHONPATH'
 if 'java' in sys.platform:
     IMPL_PATH = 'JYTHONPATH'
 
 defaults = {
@@ -347,16 +345,19 @@ def killdaemons(pidfile):
 
 class Test(object):
     """Encapsulates a single, runnable test.
 
     Test instances can be run multiple times via run(). However, multiple
     runs cannot be run concurrently.
     """
 
+    # Status code reserved for skipped tests (used by hghave).
+    SKIPPED_STATUS = 80
+
     def __init__(self, runner, test, count, refpath):
         path = os.path.join(runner.testdir, test)
         errpath = os.path.join(runner.testdir, '%s.err' % test)
 
         self._runner = runner
         self._testdir = runner.testdir
         self._test = test
         self._path = path
@@ -443,17 +444,17 @@ class Test(object):
 
         def describe(ret):
             if ret < 0:
                 return 'killed by signal: %d' % -ret
             return 'returned error code %d' % ret
 
         skipped = False
 
-        if ret == SKIPPED_STATUS:
+        if ret == self.SKIPPED_STATUS:
             if out is None: # Debug mode, nothing to parse.
                 missing = ['unknown']
                 failed = None
             else:
                 missing, failed = TTest.parsehghaveoutput(out)
 
             if not missing:
                 missing = ['irrelevant']
@@ -640,17 +641,17 @@ class TTest(Test):
 
         cmd = '%s "%s"' % (self._options.shell, fname)
         vlog("# Running", cmd)
 
         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:
+        if exitcode == self.SKIPPED_STATUS or output is None:
             return exitcode, output
 
         return self._processoutput(exitcode, output, salt, after, expected)
 
     def _hghave(self, reqs, testtmp):
         # TODO do something smarter when all other uses of hghave are gone.
         tdir = self._testdir.replace('\\', '/')
         proc = Popen4('%s -c "%s/hghave %s"' %



More information about the Mercurial-devel mailing list