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

Gregory Szorc gregory.szorc at gmail.com
Fri May 2 13:37:44 CDT 2014


# HG changeset patch
# User Gregory Szorc <gregory.szorc at 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

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


More information about the Mercurial-devel mailing list