X-Git-Url: http://git.refcnt.org/?p=colorize.git;a=blobdiff_plain;f=test.pl;h=0ed74368197340b7bb1a66cce8a99a04198fe811;hp=f0bea0b706b02a9615f6fdde6dd94587ea4842f5;hb=39e705d6643c6d4cc20a78a9fe4518ade2538955;hpb=fd286538c23b3d28dc7aa0165fdb54456042d0fe diff --git a/test.pl b/test.pl index f0bea0b..0ed7436 100755 --- a/test.pl +++ b/test.pl @@ -7,12 +7,13 @@ use constant true => 1; use constant false => 0; use Colorize::Common qw(:defaults $compiler_flags %BUF_SIZE $valgrind_command $write_to_tmpfile); +use File::Find; use File::Temp qw(tmpnam); use Getopt::Long qw(:config no_auto_abbrev no_ignore_case); use Test::Harness qw(runtests); use Test::More; -my $tests = 29; +my $tests = 30; my $valgrind_cmd = ''; { @@ -28,8 +29,9 @@ my $valgrind_cmd = ''; } { - my @test_files = glob('t/*.t'); - eval { runtests(@test_files) } or warn $@; + my @test_files; + find ({ wanted => sub { push @test_files, $File::Find::name if /\.t$/ } }, 't'); + eval { runtests(sort @test_files) } or warn $@; } plan tests => $tests; @@ -135,7 +137,7 @@ SKIP: { { # Check that a 'none' foreground color (with a background color present) # will be substituted by 'default'. - my $colored_text = qx(printf '%s' "foo bar baz" | $valgrind_cmd$program none/black); + my $colored_text = qx(printf %s "foo bar baz" | $valgrind_cmd$program none/black); is($colored_text, "\e[40m\e[39mfoo bar baz\e[0m", 'no color sequences printed'); } @@ -143,6 +145,13 @@ SKIP: { is(system(qq(printf '%s\n' "hello world" | $valgrind_cmd$program random --exclude-random=black >/dev/null)), 0, 'switch exclude-random'); + { + my $infile = $write_to_tmpfile->("foo\n\nbar"); + is_deeply([split /\n/, qx($valgrind_cmd$program yellow --omit-color-empty $infile)], + [split /\n/, "\e[33mfoo\e[0m\n\n\e[33mbar\e[0m"], + 'switch omit-color-empty'); + } + SKIP: { skip 'valgrind not found', 1 unless system('which valgrind >/dev/null 2>&1') == 0; like(qx(valgrind $program none/none $infile1 2>&1 >/dev/null), qr/no leaks are possible/, 'valgrind memleaks');