Patchwork [043,of,179,tests-refactor] run-tests: move computation of test paths into Test.__init__

login
register
mail settings
Submitter Gregory Szorc
Date May 2, 2014, 6:38 p.m.
Message ID <17b756f8c979486ff5ef.1399055880@vm-ubuntu-main.gateway.sonic.net>
Download mbox | patch
Permalink /patch/4538/
State Accepted
Commit 3cd2d2de4060116ddf020be5cdb17cff4a3a6ff6
Headers show

Comments

Gregory Szorc - May 2, 2014, 6:38 p.m.
# HG changeset patch
# User Gregory Szorc <gregory.szorc@gmail.com>
# Date 1397969595 25200
#      Sat Apr 19 21:53:15 2014 -0700
# Branch stable
# Node ID 17b756f8c979486ff5ef6a597566743226f82422
# Parent  f3d000a783487cedcb60436074661785c4518ffb
run-tests: move computation of test paths into Test.__init__

Patch

diff --git a/tests/run-tests.py b/tests/run-tests.py
--- a/tests/run-tests.py
+++ b/tests/run-tests.py
@@ -544,17 +544,20 @@  def outputcoverage(options):
 
 class Test(object):
     """Encapsulates a single, runnable test.
 
     Test instances can be run multiple times via run(). However, multiple
     runs cannot be run concurrently.
     """
 
-    def __init__(self, test, path, options, count, refpath, errpath):
+    def __init__(self, testdir, test, options, count, refpath):
+        path = os.path.join(testdir, test)
+        errpath = os.path.join(testdir, '%s.err' % test)
+
         self._test = test
         self._path = path
         self._options = options
         self._count = count
         self._daemonpids = []
         self._refpath = refpath
         self._errpath = errpath
 
@@ -1127,29 +1130,27 @@  def run(cmd, wd, options, replacements, 
 def runone(options, test, count):
     '''returns a result element: (code, test, msg)'''
 
     def skip(msg):
         if options.verbose:
             log("\nSkipping %s: %s" % (testpath, msg))
         return 's', test, msg
 
-    testpath = os.path.join(TESTDIR, test)
-    err = os.path.join(TESTDIR, test + ".err")
     lctest = test.lower()
 
     for ext, cls, out in testtypes:
         if lctest.endswith(ext):
             runner = cls
             ref = os.path.join(TESTDIR, test + out)
             break
     else:
         return skip("unknown test type")
 
-    t = runner(test, testpath, options, count, ref, err)
+    t = runner(TESTDIR, test, options, count, ref)
     result = t.run()
 
     del t # For cleanup side-effects.
 
     return result
 
 _hgpath = None