File: param.t

package info (click to toggle)
colorize 0.67-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 804 kB
  • sloc: ansic: 1,828; perl: 764; makefile: 31; sh: 7
file content (52 lines) | stat: -rwxr-xr-x 1,023 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/usr/bin/perl

use strict;
use warnings;
use lib qw(lib);

use Colorize::Common qw(:defaults $write_to_tmpfile);
use File::Temp qw(tmpnam);
use Test::More;

my $tests = 2;

my $conf = <<'EOT';
attr=bold
color=blue
omit-color-empty=yes
rainbow-fg=yes
EOT

my $expected = <<"EOT";
\e[1;34mfoo\e[0m

\e[1;35mbar\e[0m

\e[1;36mbaz\e[0m
EOT

plan tests => $tests;

SKIP: {
    my $program = tmpnam();
    my $conf_file = tmpnam();
                                                                    # -DTEST omitted on purpose
    skip 'compiling failed (config param)', $tests unless system(qq($compiler -o $program $source)) == 0;

    my $infile = $write_to_tmpfile->(<<'EOT');
foo

bar

baz
EOT
    open(my $fh, '>', $conf_file) or die "Cannot open `$conf_file' for writing: $!\n";
    print {$fh} $conf;
    close($fh);

    is(qx($program -c $conf_file $infile),       $expected, 'short option');
    is(qx($program --config=$conf_file $infile), $expected, 'long option');

    unlink $program;
    unlink $conf_file;
}