Patchwork [027,of,179,tests-refactor] run-tests: move success() into Test

login
register
mail settings
Submitter Gregory Szorc
Date May 2, 2014, 6:37 p.m.
Message ID <19a7cd2c17eea63d5ab3.1399055864@vm-ubuntu-main.gateway.sonic.net>
Download mbox | patch
Permalink /patch/4522/
State Accepted
Commit 512968bfb00aac10d65de401ede7242e41423ea6
Headers show

Comments

Gregory Szorc - May 2, 2014, 6:37 p.m.
# HG changeset patch
# User Gregory Szorc <gregory.szorc@gmail.com>
# Date 1397964954 25200
#      Sat Apr 19 20:35:54 2014 -0700
# Branch stable
# Node ID 19a7cd2c17eea63d5ab3b1946aecdd2691222506
# Parent  f2dcc9e961414939d38985099a6d192e176c718b
run-tests: move success() into Test

Patch

diff --git a/tests/run-tests.py b/tests/run-tests.py
--- a/tests/run-tests.py
+++ b/tests/run-tests.py
@@ -668,16 +668,19 @@  class Test(object):
 
         # unset env related to hooks
         for k in env.keys():
             if k.startswith('HG_'):
                 del env[k]
 
         return env
 
+    def success(self):
+        return '.', self._test, ''
+
 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
@@ -1042,19 +1045,16 @@  def runone(options, test, count):
             if answer.lower() in "y yes".split():
                 if test.endswith(".t"):
                     rename(testpath + ".err", testpath)
                 else:
                     rename(testpath + ".err", testpath + ".out")
                 return '.', test, ''
         return warned and '~' or '!', test, msg
 
-    def success():
-        return '.', test, ''
-
     def ignore(msg):
         return 'i', test, msg
 
     def describe(ret):
         if ret < 0:
             return 'killed by signal %d' % -ret
         return 'returned error code %d' % ret
 
@@ -1092,17 +1092,16 @@  def runone(options, test, count):
     else:
         return skip("unknown test type")
 
     vlog("# Test", test)
 
     t = runner(test, testpath, options, count, ref, err)
     res = TestResult()
     t.run(res)
-    del t # For cleanup side-effects.
 
     if res.exception:
         return fail('Exception during execution: %s' % res.exception, 255)
 
     ret = res.ret
     out = res.out
 
     times.append((test, res.duration))
@@ -1147,24 +1146,26 @@  def runone(options, test, count):
         if ret:
             msg += "output changed and " + describe(ret)
         else:
             msg += "output changed"
         result = fail(msg, ret)
     elif ret:
         result = fail(describe(ret), ret)
     else:
-        result = success()
+        result = t.success()
 
     if not options.verbose:
         iolock.acquire()
         sys.stdout.write(result[0])
         sys.stdout.flush()
         iolock.release()
 
+    del t # For cleanup side-effects.
+
     return result
 
 _hgpath = None
 
 def _gethgpath():
     """Return the path to the mercurial package that is actually found by
     the current Python interpreter."""
     global _hgpath