aboutsummaryrefslogtreecommitdiffstats
path: root/t/conf/param.t
diff options
context:
space:
mode:
authorGravatar Steven Schubiger <stsc@refcnt.org> 2019-09-13 21:15:22 +0200
committerGravatar Steven Schubiger <stsc@refcnt.org> 2019-09-13 21:15:22 +0200
commitb5ff1ba35b959261c855262b6e820732e72b0bfe (patch)
treeb5b0cdc7ec3438b441e736d56bccf44785ae96ae /t/conf/param.t
parent763a5a99b3af4161cd1dd4c7ee2c450c4b6137a5 (diff)
parent660177bb22c5b8b54c0ec3aabd1930fd49584e23 (diff)
downloadcolorize-b5ff1ba35b959261c855262b6e820732e72b0bfe.tar.gz
colorize-b5ff1ba35b959261c855262b6e820732e72b0bfe.tar.bz2
Merge branch 'config_file'
Diffstat (limited to 't/conf/param.t')
-rwxr-xr-xt/conf/param.t51
1 files changed, 51 insertions, 0 deletions
diff --git a/t/conf/param.t b/t/conf/param.t
new file mode 100755
index 0000000..520df2b
--- /dev/null
+++ b/t/conf/param.t
@@ -0,0 +1,51 @@
+#!/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
+EOT
+
+my $expected = <<"EOT";
+\e[1;34mfoo\e[0m
+
+\e[1;34mbar\e[0m
+
+\e[1;34mbaz\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;
+}