Patchwork [7,of,7] tests: conditionalize color output on abort

login
register
mail settings
Submitter Matt Harbison
Date Aug. 18, 2018, 7:17 p.m.
Message ID <37ffffeb716e10bbc1d5.1534619826@Envy>
Download mbox | patch
Permalink /patch/33884/
State Accepted
Headers show

Comments

Matt Harbison - Aug. 18, 2018, 7:17 p.m.
# HG changeset patch
# User Matt Harbison <matt_harbison@yahoo.com>
# Date 1534619704 14400
#      Sat Aug 18 15:15:04 2018 -0400
# Node ID 37ffffeb716e10bbc1d5052923b7d0ff14090485
# Parent  5acb07cbe379202759848a2cb9d5da24df01f1a1
tests: conditionalize color output on abort

This broke in afc4ad706f9c.  I'm not sure why other aborts don't need to be
conditionalized, but `hg help foo` does abort in red for both msys and cmd.exe.
Yuya Nishihara - Aug. 20, 2018, 12:56 p.m.
On Sat, 18 Aug 2018 15:17:06 -0400, Matt Harbison wrote:
> # HG changeset patch
> # User Matt Harbison <matt_harbison@yahoo.com>
> # Date 1534619704 14400
> #      Sat Aug 18 15:15:04 2018 -0400
> # Node ID 37ffffeb716e10bbc1d5052923b7d0ff14090485
> # Parent  5acb07cbe379202759848a2cb9d5da24df01f1a1
> tests: conditionalize color output on abort
> 
> This broke in afc4ad706f9c.  I'm not sure why other aborts don't need to be
> conditionalized, but `hg help foo` does abort in red for both msys and cmd.exe.
> 
> diff --git a/tests/test-extension.t b/tests/test-extension.t
> --- a/tests/test-extension.t
> +++ b/tests/test-extension.t
> @@ -1255,8 +1255,10 @@ Broken disabled extension and command:
>    >     pass
>    > EOF
>    $ hg --config extensions.path=./path.py help foo > /dev/null
> -  abort: no such help topic: foo
> -  (try 'hg help --keyword foo')
> +  abort: no such help topic: foo (no-windows !)
> +  (try 'hg help --keyword foo') (no-windows !)
> +  \x1b[0;31mabort: no such help topic: foo\x1b[0m (esc) (windows !)
> +  \x1b[0;31m(try 'hg help --keyword foo')\x1b[0m (esc) (windows !)

That might be because stdout is redirected to "nul" and "nul" is a tty on
Windows!
Matt Harbison - Aug. 21, 2018, 1:55 a.m.
On Mon, 20 Aug 2018 08:56:42 -0400, Yuya Nishihara <yuya@tcha.org> wrote:

> On Sat, 18 Aug 2018 15:17:06 -0400, Matt Harbison wrote:
>> # HG changeset patch
>> # User Matt Harbison <matt_harbison@yahoo.com>
>> # Date 1534619704 14400
>> #      Sat Aug 18 15:15:04 2018 -0400
>> # Node ID 37ffffeb716e10bbc1d5052923b7d0ff14090485
>> # Parent  5acb07cbe379202759848a2cb9d5da24df01f1a1
>> tests: conditionalize color output on abort
>>
>> This broke in afc4ad706f9c.  I'm not sure why other aborts don't need  
>> to be
>> conditionalized, but `hg help foo` does abort in red for both msys and  
>> cmd.exe.
>>
>> diff --git a/tests/test-extension.t b/tests/test-extension.t
>> --- a/tests/test-extension.t
>> +++ b/tests/test-extension.t
>> @@ -1255,8 +1255,10 @@ Broken disabled extension and command:
>>    >     pass
>>    > EOF
>>    $ hg --config extensions.path=./path.py help foo > /dev/null
>> -  abort: no such help topic: foo
>> -  (try 'hg help --keyword foo')
>> +  abort: no such help topic: foo (no-windows !)
>> +  (try 'hg help --keyword foo') (no-windows !)
>> +  \x1b[0;31mabort: no such help topic: foo\x1b[0m (esc) (windows !)
>> +  \x1b[0;31m(try 'hg help --keyword foo')\x1b[0m (esc) (windows !)
>
> That might be because stdout is redirected to "nul" and "nul" is a tty on
> Windows!

That's... interesting.  Dropping the redirect works.  I'll send a followup.

Patch

diff --git a/tests/test-extension.t b/tests/test-extension.t
--- a/tests/test-extension.t
+++ b/tests/test-extension.t
@@ -1255,8 +1255,10 @@  Broken disabled extension and command:
   >     pass
   > EOF
   $ hg --config extensions.path=./path.py help foo > /dev/null
-  abort: no such help topic: foo
-  (try 'hg help --keyword foo')
+  abort: no such help topic: foo (no-windows !)
+  (try 'hg help --keyword foo') (no-windows !)
+  \x1b[0;31mabort: no such help topic: foo\x1b[0m (esc) (windows !)
+  \x1b[0;31m(try 'hg help --keyword foo')\x1b[0m (esc) (windows !)
   [255]
 
   $ cat > throw.py <<EOF
diff --git a/tests/test-help.t b/tests/test-help.t
--- a/tests/test-help.t
+++ b/tests/test-help.t
@@ -1481,8 +1481,10 @@  Test -e / -c / -k combinations
   $ hg help -c commit > /dev/null
   $ hg help -e -c commit > /dev/null
   $ hg help -e commit > /dev/null
-  abort: no such help topic: commit
-  (try 'hg help --keyword commit')
+  abort: no such help topic: commit (no-windows !)
+  (try 'hg help --keyword commit') (no-windows !)
+  \x1b[0;31mabort: no such help topic: commit\x1b[0m (esc) (windows !)
+  \x1b[0;31m(try 'hg help --keyword commit')\x1b[0m (esc) (windows !)
   [255]
 
 Test keyword search help