| 1 | |||||||||||||||
| 2 | package Test::More::Color; | ||||||||||||||
| 3 | |||||||||||||||
| 4 | 1 | ▶ | use strict; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 5 | 1 | ▶ | use warnings; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 6 | |||||||||||||||
| 7 | 1 | our $VERSION = 0.040_000; | |||||||||||||
| 8 | |||||||||||||||
| 9 | =head1 NAME | ||||||||||||||
| 10 | |||||||||||||||
| 11 | Test::More::Color - Very stupid TAP colorer | ||||||||||||||
| 12 | |||||||||||||||
| 13 | =head1 SYNOPSIS | ||||||||||||||
| 14 | |||||||||||||||
| 15 | use Test::More; | ||||||||||||||
| 16 | eval 'use Test::More::Color'; | ||||||||||||||
| 17 | eval 'use Test::More::Color "foreground"'; | ||||||||||||||
| 18 | |||||||||||||||
| 19 | use_ok('Test::More::Color'); | ||||||||||||||
| 20 | |||||||||||||||
| 21 | =cut | ||||||||||||||
| 22 | |||||||||||||||
| 23 | 1 | ▶ | my ( $fg, $old_print ) = ( $ENV{TM_COLOR_FG} || 0 ); | ||||||||||||
|
Condition50%1/2
$ENV{'TM_COLOR_FG'} || 0
MC/DC0%0/1
$ENV{'TM_COLOR_FG'} || 0
$ENV{'TM_COLOR_FG'}
Truth table50%1/2
A
A= $ENV{'TM_COLOR_FG'}
| |||||||||||||||
| 24 | |||||||||||||||
| 25 | 1 | ▶ | sub DEBUG { $ENV{DEBUG_TM_COLOR} || 0 } | ||||||||||||
|
Subroutine
DEBUG: called CC=2 SCAR=7.6
Pod
undocumented
Branch: 1 branch
| |||||||||||||||
| 26 | |||||||||||||||
| 27 | # If exists color libĀ | ||||||||||||||
| 28 | 1 | eval { require Term::ANSIColor }; | |||||||||||||
| 29 | 1 | ▶ | unless ( $@ ) { | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 30 | 1 | ▶ | DEBUG && warn __PACKAGE__, " \&Test::Builder::_print attacks"; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 31 | 1 | ▶ | no strict 'refs'; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 32 | 1 | ▶ | no warnings 'redefine'; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 33 | 1 | $old_print = \&Test::Builder::_print; | |||||||||||||
| 34 | 1 | *Test::Builder::_print = \&color_print; | |||||||||||||
| 35 | 1 | *c = \&Term::ANSIColor::color; | |||||||||||||
| 36 | } | ||||||||||||||
| 37 | |||||||||||||||
| 38 | 0 | ▶ | sub OK { $fg ? c("green") : c("black").c("on_green") } | ||||||||||||
|
Subroutine
OK: not called CC=2 SCAR=17.9
Pod
undocumented
Branch: 1 branch
| |||||||||||||||
| 39 | 0 | ▶ | sub NOT_OK { $fg ? c("red") : c("black").c("on_red"); } | ||||||||||||
|
Subroutine
NOT_OK: not called CC=2 SCAR=17.9
Pod
undocumented
Branch: 1 branch
| |||||||||||||||
| 40 | 0 | ▶ | sub RESET { c("reset"); } | ||||||||||||
|
Subroutine
RESET: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||
| 41 | |||||||||||||||
| 42 | 1 | ▶ | sub import { | ||||||||||||
|
Subroutine
import: called CC=2 SCAR=10.5
| |||||||||||||||
| 43 | 1 | shift; | |||||||||||||
| 44 | 0 | ▶ | map { /^foreground$/ and $fg = 1 } @_; | ||||||||||||
|
Condition0%0/2
/^foreground$/ && ($fg = 1)
MC/DC0%0/1
/^foreground$/ && ($fg = 1)
/^foreground$/
Truth table0%0/2
A
A= /^foreground$/
| |||||||||||||||
| 45 | } | ||||||||||||||
| 46 | |||||||||||||||
| 47 | 0 | ▶ | sub foreground { $fg = 1; } | ||||||||||||
|
Subroutine
foreground: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||
| 48 | |||||||||||||||
| 49 | 0 | ▶ | sub color_print { | ||||||||||||
|
Subroutine
color_print: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||
| 50 | 0 | ▶ | DEBUG && warn __PACKAGE__, "::bgcolor_print ", $_[1]; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 51 | |||||||||||||||
| 52 | # Colorer if don't pipe | ||||||||||||||
| 53 | 0 | ▶ | $_[1] =~ s/^((not)?\s*ok\s*\d+)/( $2 ? NOT_OK : OK ) . $1 . RESET/e | ||||||||||||
|
Branch: 2 branches
| |||||||||||||||
| 54 | unless -p $_[0]->output; | ||||||||||||||
| 55 | 0 | $old_print->(@_); | |||||||||||||
| 56 | } | ||||||||||||||
| 57 | |||||||||||||||
| 58 | =head1 AUTHOR | ||||||||||||||
| 59 | |||||||||||||||
| 60 | coolmen, C<< <coolmen78 at google.com> >> | ||||||||||||||
| 61 | |||||||||||||||
| 62 | =head1 BUGS | ||||||||||||||
| 63 | |||||||||||||||
| 64 | Please report any bugs or feature requests to C<bug-test-more-color at rt.cpan.org>, or through | ||||||||||||||
| 65 | the web interface at L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Test-More-Color>. I will be notified, and then you'll | ||||||||||||||
| 66 | automatically be notified of progress on your bug as I make changes. | ||||||||||||||
| 67 | |||||||||||||||
| 68 | |||||||||||||||
| 69 | |||||||||||||||
| 70 | |||||||||||||||
| 71 | =head1 SUPPORT | ||||||||||||||
| 72 | |||||||||||||||
| 73 | You can find documentation for this module with the perldoc command. | ||||||||||||||
| 74 | |||||||||||||||
| 75 | perldoc Test::More::Color | ||||||||||||||
| 76 | |||||||||||||||
| 77 | |||||||||||||||
| 78 | You can also look for information at: | ||||||||||||||
| 79 | |||||||||||||||
| 80 | =over 4 | ||||||||||||||
| 81 | |||||||||||||||
| 82 | =item * RT: CPAN's request tracker | ||||||||||||||
| 83 | |||||||||||||||
| 84 | L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=Test-More-Color> | ||||||||||||||
| 85 | |||||||||||||||
| 86 | =item * AnnoCPAN: Annotated CPAN documentation | ||||||||||||||
| 87 | |||||||||||||||
| 88 | L<http://annocpan.org/dist/Test-More-Color> | ||||||||||||||
| 89 | |||||||||||||||
| 90 | =item * CPAN Ratings | ||||||||||||||
| 91 | |||||||||||||||
| 92 | L<http://cpanratings.perl.org/d/Test-More-Color> | ||||||||||||||
| 93 | |||||||||||||||
| 94 | =item * Search CPAN | ||||||||||||||
| 95 | |||||||||||||||
| 96 | L<http://search.cpan.org/dist/Test-More-Color/> | ||||||||||||||
| 97 | |||||||||||||||
| 98 | =back | ||||||||||||||
| 99 | |||||||||||||||
| 100 | |||||||||||||||
| 101 | =head1 LICENSE AND COPYRIGHT | ||||||||||||||
| 102 | |||||||||||||||
| 103 | Copyright 2011 coolmen. | ||||||||||||||
| 104 | |||||||||||||||
| 105 | This program is free software; you can redistribute it and/or modify it | ||||||||||||||
| 106 | under the terms of either: the GNU General Public License as published | ||||||||||||||
| 107 | by the Free Software Foundation; or the Artistic License. | ||||||||||||||
| 108 | |||||||||||||||
| 109 | See http://dev.perl.org/licenses/ for more information. | ||||||||||||||
| 110 | |||||||||||||||
| 111 | |||||||||||||||
| 112 | =cut | ||||||||||||||
| 113 | |||||||||||||||
| 114 | 1 | 1; # End of Test::More::Color | |||||||||||||
| 115 | |||||||||||||||