summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Steven Schubiger <stsc@refcnt.org>2019-08-28 13:57:36 +0200
committerGravatar Steven Schubiger <stsc@refcnt.org>2019-08-28 13:57:36 +0200
commit946a888c6c7aea8af693089bed73673c193899a7 (patch)
treeabe15f1df016a52086a57aaea579318b5a1236aa
parent0cece912fc4a5d40bceb42ba9478539cc1e102b8 (diff)
downloadcolorize-946a888c6c7aea8af693089bed73673c193899a7.tar.gz
colorize-946a888c6c7aea8af693089bed73673c193899a7.tar.bz2
Test --config
-rwxr-xr-xt/conf/param.t47
1 files changed, 47 insertions, 0 deletions
diff --git a/t/conf/param.t b/t/conf/param.t
new file mode 100755
index 0000000..3fe5436
--- /dev/null
+++ b/t/conf/param.t
@@ -0,0 +1,47 @@
+#!/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 = 1;
+
+my $conf = <<'EOT';
+attr=bold
+color=blue
+omit-color-empty=yes
+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 --config=$conf_file $infile), <<"EOT", 'config param');
+\e[1;34mfoo\e[0m
+
+\e[1;34mbar\e[0m
+
+\e[1;34mbaz\e[0m
+EOT
+ unlink $program;
+ unlink $conf_file;
+}