Perl Prove TAP :: Color output (color) for windows (win32)

I am trying to get color output using the / TAP :: Harness proof method with Perl active in Windows 7.

Actual tests run fine, namely that there is no color output.

I get a similar problem using Strawberry Perl and WinXP.

I can not use * nix and cygwin or other third parties xterm, both of which make color output.

I know its a little picky thing, but I think I became addicted to green :-)

Is there a simple fix? - I could not see anything on the Activate state website - I was thinking about raising an error. Any debugging guide or check?

Should I write my own formatter?

Thanks in advance for your help.

More information on installed modules and approaches ...

They are installed and, as far as I know, work

Win32::Console::ANSI; Term::ANSIColor; 

This test script worked:

  #!/usr/bin/perl use strict; use warnings; use Win32::Console::ANSI; use Term::ANSIColor; print "One fish\n"; print "Two fish\n"; print color("red"), "Red Fish\n", color("reset"); print color("blue"), "Blue Fish\n", color("reset"); 

I tried:

 prove prove -c 

and using the following test harnesses with and without a format I was assuming color was turned on by default.

 #!/usr/bin/perl use strict; use warnings; use TAP::Harness; my @tests = glob( 't/*.t' ); my $harness = TAP::Harness->new(); $harness->runtests( @tests ); 

I also installed the HTML formatter and it seems to work.

  prove --formatter=TAP::Formatter::HTML 

Duration:

 prove --formatter=TAP::Formatter::Color 

gives Unable to find the "verbosity" method of an object method through the package "TAP :: Formatter :: Color" on page x: /Perl/site/lib/TAP/Harness.pm 679.

Thanks Mike

+4
source share
1 answer

This seems to be a bug in TAP :: Formatter :: Color. It attaches to the STDOUT handle of the console, but the messages to be colored are on STDERR.

It:

 my $console = Win32::Console->new( STD_OUTPUT_HANDLE() ); 

It should be instead:

 my $console = Win32::Console->new( STD_ERROR_HANDLE() ); 

Also, despite what the documentation says, --color not standard on Windows. The application :: Prove (which is something like a β€œprove” executable file) explicitly sets the default parameter to false for Windows:

 sub _color_default { my $self = shift; return -t STDOUT && !$ENV{HARNESS_NOTTY} && !IS_WIN32; } 
+5
source

Source: https://habr.com/ru/post/1497186/


All Articles