changeset 21334:6a90ecb6597a

run-tests: move err file saving to Test.run()
author Gregory Szorc <gregory.szorc@gmail.com>
date Sat, 19 Apr 2014 21:14:31 -0700
parents 9a5913beaf77
children 822050714e72
files tests/run-tests.py
diffstat 1 files changed, 16 insertions(+), 20 deletions(-) [+]
line wrap: on
line diff
--- a/tests/run-tests.py	Sat Apr 19 21:10:22 2014 -0700
+++ b/tests/run-tests.py	Sat Apr 19 21:14:31 2014 -0700
@@ -640,8 +640,6 @@
 
         killdaemons(env['DAEMON_PIDS'])
 
-        result.refout = self._refout
-
         if not options.keep_tmpdir:
             shutil.rmtree(testtmp)
 
@@ -661,13 +659,13 @@
                 missing = ['irrelevant']
 
             if failed:
-                return self.fail('hg have failed checking for %s' % failed[-1],
-                                 ret)
+                res = self.fail('hg have failed checking for %s' % failed[-1],
+                                ret)
             else:
                 result.skipped = True
-                return self.skip(missing[-1])
+                res = self.skip(missing[-1])
         elif ret == 'timeout':
-            return self.fail('timed out', ret)
+            res = self.fail('timed out', ret)
         elif out != self._refout:
             info = {}
             if not options.nodiff:
@@ -687,11 +685,20 @@
             else:
                 msg += 'output changed'
 
-            return self.fail(msg, ret)
+            res = self.fail(msg, ret)
         elif ret:
-            return self.fail(describe(ret), ret)
+            res = self.fail(describe(ret), ret)
         else:
-            return self.success()
+            res = self.success()
+
+        if (ret != 0 or out != self._refout) and not result.skipped \
+            and not options.debug:
+            f = open(self._errpath, 'wb')
+            for line in out:
+                f.write(line)
+            f.close()
+
+        return res
 
     def _run(self, testtmp, replacements, env):
         raise NotImplemented('Subclasses must implement Test.run()')
@@ -789,7 +796,6 @@
         self.ret = None
         self.out = None
         self.duration = None
-        self.refout = None
         self.skipped = False
 
 class PythonTest(Test):
@@ -1157,16 +1163,6 @@
     times.append((test, res.duration))
     vlog("# Ret was:", ret)
 
-    skipped = res.skipped
-    refout = res.refout
-
-    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 not options.verbose:
         iolock.acquire()
         sys.stdout.write(result[0])