]> git.refcnt.org Git - colorize.git/blob - t/conf/param.t
Test --config
[colorize.git] / t / conf / param.t
1 #!/usr/bin/perl
2
3 use strict;
4 use warnings;
5 use lib qw(lib);
6
7 use Colorize::Common qw(:defaults $write_to_tmpfile);
8 use File::Temp qw(tmpnam);
9 use Test::More;
10
11 my $tests = 1;
12
13 my $conf = <<'EOT';
14 attr=bold
15 color=blue
16 omit-color-empty=yes
17 EOT
18
19 plan tests => $tests;
20
21 SKIP: {
22 my $program = tmpnam();
23 my $conf_file = tmpnam();
24 # -DTEST omitted on purpose
25 skip 'compiling failed (config param)', $tests unless system(qq($compiler -o $program $source)) == 0;
26
27 my $infile = $write_to_tmpfile->(<<'EOT');
28 foo
29
30 bar
31
32 baz
33 EOT
34 open(my $fh, '>', $conf_file) or die "Cannot open `$conf_file' for writing: $!\n";
35 print {$fh} $conf;
36 close($fh);
37
38 is(qx($program --config=$conf_file $infile), <<"EOT", 'config param');
39 \e[1;34mfoo\e[0m
40
41 \e[1;34mbar\e[0m
42
43 \e[1;34mbaz\e[0m
44 EOT
45 unlink $program;
46 unlink $conf_file;
47 }