changeset 21313:a2bd02a3b6d2

run-tests: move t test execution from tsttest() to TTest.run() After this patch, tsttest() only contains output/result processing.
author Gregory Szorc <gregory.szorc@gmail.com>
date Sat, 19 Apr 2014 15:28:31 -0700
parents 986b8a58a6d3
children 76d7967d8f3d
files tests/run-tests.py
diffstat 1 files changed, 25 insertions(+), 24 deletions(-) [+]
line wrap: on
line diff
--- a/tests/run-tests.py	Sat Apr 19 15:19:28 2014 -0700
+++ b/tests/run-tests.py	Sat Apr 19 15:28:31 2014 -0700
@@ -747,28 +747,7 @@
             return '+glob'
     return False
 
-def tsttest(t, test, wd, options, replacements, env):
-    f = open(test)
-    tlines = f.readlines()
-    f.close()
-
-    salt, script, after, expected = t._parsetest(tlines, wd)
-
-    # Write out the script and execute it
-    name = wd + '.sh'
-    f = open(name, 'w')
-    for l in script:
-        f.write(l)
-    f.close()
-
-    cmd = '%s "%s"' % (options.shell, name)
-    vlog("# Running", cmd)
-    exitcode, output = run(cmd, wd, options, replacements, env)
-    # do not merge output if skipped, return hghave message instead
-    # similarly, with --debug, output is None
-    if exitcode == SKIPPED_STATUS or output is None:
-        return exitcode, output
-
+def tsttest(t, wd, options, salt, after, expected, exitcode, output):
     # Merge the script output back into a unified test
 
     warnonly = 1 # 1: not yet, 2: yes, 3: for sure not
@@ -833,8 +812,30 @@
     """A "t test" is a test backed by a .t file."""
 
     def _run(self, testtmp, replacements, env):
-        return tsttest(self, self._path, testtmp, self._options, replacements,
-                       env)
+        f = open(self._path)
+        lines = f.readlines()
+        f.close()
+
+        salt, script, after, expected = self._parsetest(lines, testtmp)
+
+        # Write out the generated script.
+        fname = '%s.sh' % testtmp
+        f = open(fname, 'w')
+        for l in script:
+            f.write(l)
+        f.close()
+
+        cmd = '%s "%s"' % (self._options.shell, fname)
+        vlog("# Running", cmd)
+
+        exitcode, output = run(cmd, testtmp, self._options, replacements, env)
+        # Do not merge output if skipped. Return hghave message instead.
+        # Similarly, with --debug, output is None.
+        if exitcode == SKIPPED_STATUS or output is None:
+            return exitcode, output
+
+        return tsttest(self, testtmp, self._options, salt, after, expected,
+                       exitcode, output)
 
     def _hghave(self, reqs, testtmp):
         # TODO do something smarter when all other uses of hghave are gone.