Patchwork [2,of,2] run-tests: write .err files earlier

login
register
mail settings
Submitter Gregory Szorc
Date May 28, 2014, 2:21 a.m.
Message ID <1ac177bc77504f242ed9.1401243693@vm-ubuntu-main.gateway.sonic.net>
Download mbox | patch
Permalink /patch/4873/
State Accepted
Commit 609a642dff61b3cb226e2bc0e535cfd9f4dd7ba9
Headers show

Comments

Gregory Szorc - May 28, 2014, 2:21 a.m.
# HG changeset patch
# User Gregory Szorc <gregory.szorc@gmail.com>
# Date 1401243672 25200
#      Tue May 27 19:21:12 2014 -0700
# Node ID 1ac177bc77504f242ed9cee799f68ee48af60b9f
# Parent  e5fa751068fd637301a48a43f642e2d8abb31fa4
run-tests: write .err files earlier

Earlier refactoring of run-tests.py accidentally broke --interactive
and external diff generation by not having .err files written before
they are consulted. This patch fixes that.
Matt Mackall - May 28, 2014, 6:57 p.m.
On Tue, 2014-05-27 at 19:21 -0700, Gregory Szorc wrote:
> # HG changeset patch
> # User Gregory Szorc <gregory.szorc@gmail.com>
> # Date 1401243672 25200
> #      Tue May 27 19:21:12 2014 -0700
> # Node ID 1ac177bc77504f242ed9cee799f68ee48af60b9f
> # Parent  e5fa751068fd637301a48a43f642e2d8abb31fa4
> run-tests: write .err files earlier
> 
> Earlier refactoring of run-tests.py accidentally broke --interactive
> and external diff generation by not having .err files written before
> they are consulted. This patch fixes that.

These are queued for default, thanks.

On the topic of .err files and your patches to remove them: I actually
use these fairly often without premeditation after a test run, so having
them go away would be a problem for me.

Patch

diff --git a/tests/run-tests.py b/tests/run-tests.py
--- a/tests/run-tests.py
+++ b/tests/run-tests.py
@@ -529,23 +529,24 @@  class Test(unittest.TestCase):
             self.fail('timed out')
         elif ret is False:
             raise WarnTest('no result code from test')
         elif out != self._refout:
+            # Diff generation may rely on written .err file.
+            if (ret != 0 or out != self._refout) and not self._skipped \
+                and not self._debug:
+                f = open(self.errpath, 'wb')
+                for line in out:
+                    f.write(line)
+                f.close()
+
             # The result object handles diff calculation for us.
             self._result.addOutputMismatch(self, ret, out, self._refout)
 
             if ret:
                 msg = 'output changed and ' + describe(ret)
             else:
                 msg = 'output changed'
 
-            if (ret != 0 or out != self._refout) and not self._skipped \
-                and not self._debug:
-                f = open(self.errpath, 'wb')
-                for line in out:
-                    f.write(line)
-            f.close()
-
             self.fail(msg)
         elif ret:
             self.fail(describe(ret))