Patchwork run-tests: print diff to stderr instead to stdout

login
register
mail settings
Submitter Simon Heimberg
Date Feb. 10, 2014, 1:27 p.m.
Message ID <12df27e151f1d72a180a.1392038820@lapsi.heimberg.home>
Download mbox | patch
Permalink /patch/3538/
State Deferred
Headers show

Comments

Simon Heimberg - Feb. 10, 2014, 1:27 p.m.
# HG changeset patch
# User Simon Heimberg <simohe@besonet.ch>
# Date 1391878137 -3600
# Node ID 12df27e151f1d72a180ab1e40222a9d88110e096
# Parent  289c3b0e73da58ed81a0be54956034437572b98d
run-tests: print diff to stderr instead to stdout

On buildbot, this has the advantage that the diff output is colured red. This
visual structuring makes the result easier to read.
Matt Mackall - Feb. 10, 2014, 11:24 p.m.
On Mon, 2014-02-10 at 14:27 +0100, Simon Heimberg wrote:
> # HG changeset patch
> # User Simon Heimberg <simohe@besonet.ch>
> # Date 1391878137 -3600
> # Node ID 12df27e151f1d72a180ab1e40222a9d88110e096
> # Parent  289c3b0e73da58ed81a0be54956034437572b98d
> run-tests: print diff to stderr instead to stdout

This will make people (like me) who do 'run-tests | less' sad, which
seems to counter the marginal goodness of this patch. Perhaps we can
post-process this in some fashion.

> On buildbot, this has the advantage that the diff output is colured red. This
> visual structuring makes the result easier to read.
> 
> diff -r 289c3b0e73da -r 12df27e151f1 tests/run-tests.py
> --- a/tests/run-tests.py	Sam Feb 08 10:41:17 2014 +0100
> +++ b/tests/run-tests.py	Sam Feb 08 17:48:57 2014 +0100
> @@ -299,9 +299,10 @@
>      return missing, failed
>  
>  def showdiff(expected, output, ref, err):
> -    print
> +    sys.stderr.write('\n')
>      for line in difflib.unified_diff(expected, output, ref, err):
> -        sys.stdout.write(line)
> +        sys.stderr.write(line)
> +    sys.stderr.flush()
>  
>  verbose = False
>  def vlog(*msg):
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel
Simon Heimberg - Feb. 11, 2014, 8:22 a.m.
--On 2014-02-10 17:24 -0600 Matt Mackall <mpm@selenic.com> wrote:
> On Mon, 2014-02-10 at 14:27 +0100, Simon Heimberg wrote:
>> # HG changeset patch
>> # User Simon Heimberg <simohe@besonet.ch>
>> # Date 1391878137 -3600
>> # Node ID 12df27e151f1d72a180ab1e40222a9d88110e096
>> # Parent  289c3b0e73da58ed81a0be54956034437572b98d
>> run-tests: print diff to stderr instead to stdout
>
> This will make people (like me) who do 'run-tests | less' sad, which
> seems to counter the marginal goodness of this patch. Perhaps we can
> post-process this in some fashion.

Right. Myself too. Of course we could use 2>&1 at the end. But I would 
often forget it.

We could post-process it on buildbot, when logging or when displaying. But 
I do not have a buildbot installation. If we go in this direction, we 
probably should public the master buildbot configuration somewhere (tracked 
by hg).


>
>> On buildbot, this has the advantage that the diff output is colured red.
>> This visual structuring makes the result easier to read.
>>
>> diff -r 289c3b0e73da -r 12df27e151f1 tests/run-tests.py
>> --- a/tests/run-tests.py	Sam Feb 08 10:41:17 2014 +0100
>> +++ b/tests/run-tests.py	Sam Feb 08 17:48:57 2014 +0100
>> @@ -299,9 +299,10 @@
>>      return missing, failed
>>
>>  def showdiff(expected, output, ref, err):
>> -    print
>> +    sys.stderr.write('\n')
>>      for line in difflib.unified_diff(expected, output, ref, err):
>> -        sys.stdout.write(line)
>> +        sys.stderr.write(line)
>> +    sys.stderr.flush()
>>
>>  verbose = False
>>  def vlog(*msg):
>> _______________________________________________
>> Mercurial-devel mailing list
>> Mercurial-devel@selenic.com
>> http://selenic.com/mailman/listinfo/mercurial-devel
>
> --
> Mathematics is the supreme nostalgia of our time.

Patch

diff -r 289c3b0e73da -r 12df27e151f1 tests/run-tests.py
--- a/tests/run-tests.py	Sam Feb 08 10:41:17 2014 +0100
+++ b/tests/run-tests.py	Sam Feb 08 17:48:57 2014 +0100
@@ -299,9 +299,10 @@ 
     return missing, failed
 
 def showdiff(expected, output, ref, err):
-    print
+    sys.stderr.write('\n')
     for line in difflib.unified_diff(expected, output, ref, err):
-        sys.stdout.write(line)
+        sys.stderr.write(line)
+    sys.stderr.flush()
 
 verbose = False
 def vlog(*msg):