Patchwork [029,of,179,tests-refactor] run-tests: add skip processing to Test

login
register
mail settings
Submitter Gregory Szorc
Date May 2, 2014, 6:37 p.m.
Message ID <2abe63ab6518ea458bbf.1399055866@vm-ubuntu-main.gateway.sonic.net>
Download mbox | patch
Permalink /patch/4523/
State Accepted
Commit 6454ddaee991f70c498167c940f91c155f4f1e39
Headers show

Comments

Gregory Szorc - May 2, 2014, 6:37 p.m.
# HG changeset patch
# User Gregory Szorc <gregory.szorc@gmail.com>
# Date 1397965634 25200
#      Sat Apr 19 20:47:14 2014 -0700
# Branch stable
# Node ID 2abe63ab6518ea458bbf25c959992f77d677c4bd
# Parent  3029253df56a97f5622b6383285182133e592994
run-tests: add skip processing to Test

Patch

diff --git a/tests/run-tests.py b/tests/run-tests.py
--- a/tests/run-tests.py
+++ b/tests/run-tests.py
@@ -612,16 +612,33 @@  class Test(object):
 
         killdaemons(env['DAEMON_PIDS'])
 
         result.refout = self._refout
 
         if not self._options.keep_tmpdir:
             shutil.rmtree(testtmp)
 
+        if ret == SKIPPED_STATUS:
+            if out is None: # Debug mode, nothing to parse.
+                missing = ['unknown']
+                failed = None
+            else:
+                missing, failed = parsehghaveoutput(out)
+
+            if not missing:
+                missing = ['irrelevant']
+
+            if failed:
+                return self.fail('hg have failed checking for %s' % failed[-1],
+                                 ret)
+            else:
+                result.skipped = True
+                return self.skip(missing[-1])
+
     def _run(self, testtmp, replacements, env):
         raise NotImplemented('Subclasses must implement Test.run()')
 
     def _getreplacements(self, testtmp):
         port = self._options.port + self._count * 3
         r = [
             (r':%s\b' % port, ':$HGPORT'),
             (r':%s\b' % (port + 1), ':$HGPORT1'),
@@ -692,30 +709,32 @@  class Test(object):
                     rename(self._errpath, self._testpath)
                 else:
                     rename(self._errpath, '%s.out' % self._testpath)
 
                 return '.', self._test, ''
 
         return warned and '~' or '!', self._test, msg
 
+    def skip(self, msg):
+        if self._options.verbose:
+            log("\nSkipping %s: %s" % (self._path, msg))
+
+        return 's', self._test, msg
+
 class TestResult(object):
     """Holds the result of a test execution."""
 
     def __init__(self):
         self.ret = None
         self.out = None
         self.duration = None
         self.exception = None
         self.refout = None
-
-    @property
-    def skipped(self):
-        """Whether the test was skipped."""
-        return self.ret == SKIPPED_STATUS
+        self.skipped = False
 
 class PythonTest(Test):
     """A Python-based test."""
     def _run(self, testtmp, replacements, env):
         py3kswitch = self._options.py3k_warnings and ' -3' or ''
         cmd = '%s%s "%s"' % (PYTHON, py3kswitch, self._path)
         vlog("# Running", cmd)
         if os.name == 'nt':
@@ -1094,17 +1113,17 @@  def runone(options, test, count):
             break
     else:
         return skip("unknown test type")
 
     vlog("# Test", test)
 
     t = runner(test, testpath, options, count, ref, err)
     res = TestResult()
-    t.run(res)
+    result = t.run(res)
 
     if res.exception:
         return t.fail('Exception during execution: %s' % res.exception, 255)
 
     ret = res.ret
     out = res.out
 
     times.append((test, res.duration))
@@ -1115,29 +1134,18 @@  def runone(options, test, count):
 
     if (ret != 0 or out != refout) and not skipped and not options.debug:
         # Save errors to a file for diagnosis
         f = open(err, "wb")
         for line in out:
             f.write(line)
         f.close()
 
-    if skipped:
-        if out is None:                 # debug mode: nothing to parse
-            missing = ['unknown']
-            failed = None
-        else:
-            missing, failed = parsehghaveoutput(out)
-        if not missing:
-            missing = ['irrelevant']
-        if failed:
-            result = t.fail("hghave failed checking for %s" % failed[-1], ret)
-            skipped = False
-        else:
-            result = skip(missing[-1])
+    if result:
+        pass
     elif ret == 'timeout':
         result = t.fail("timed out", ret)
     elif out != refout:
         info = {}
         if not options.nodiff:
             iolock.acquire()
             if options.view:
                 os.system("%s %s %s" % (options.view, ref, err))