diff options
author | Steven Schubiger <stsc@refcnt.org> | 2019-08-18 21:15:24 +0200 |
---|---|---|
committer | Steven Schubiger <stsc@refcnt.org> | 2019-08-18 21:15:24 +0200 |
commit | c8123fe6adb0fc2095131a09df1bb5a82dd3c2a3 (patch) | |
tree | f722ee7b14443ac344d4bb16dabe613a41832201 /t/conf/use.t | |
parent | 25afef6a972cc5761894da143924856eb19cb749 (diff) | |
download | colorize-c8123fe6adb0fc2095131a09df1bb5a82dd3c2a3.tar.gz colorize-c8123fe6adb0fc2095131a09df1bb5a82dd3c2a3.tar.bz2 |
Add new test files
Diffstat (limited to 't/conf/use.t')
-rwxr-xr-x | t/conf/use.t | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/t/conf/use.t b/t/conf/use.t new file mode 100755 index 0000000..0a695df --- /dev/null +++ b/t/conf/use.t @@ -0,0 +1,57 @@ +#!/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 = 21; + +my $conf = <<'EOT'; +attr=underscore +color=yellow # tested also in color.t +omit-color-empty=yes +EOT + +plan tests => $tests; + +SKIP: { + my $program = tmpnam(); + my $conf_file = tmpnam(); + + skip 'compiling failed (use config)', $tests unless system(qq($compiler -DTEST -DCONF_FILE_TEST=\"$conf_file\" -o $program $source)) == 0; + + my $infile1 = $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 $infile1), <<"EOT", 'use config'); +\e[4;33mfoo\e[0m + +\e[4;33mbar\e[0m + +\e[4;33mbaz\e[0m +EOT + my $infile2 = $write_to_tmpfile->('foo'); + + open($fh, '>', $conf_file) or die "Cannot open `$conf_file' for writing: $!\n"; + print {$fh} "exclude-random=black\n"; + close($fh); + + for (my $i = 1; $i <= 20; $i++) { + like(qx($program random $infile2), qr/^\e\[3[1-7]mfoo\e\[0m$/, 'use exclude-random'); + } + + unlink $program; + unlink $conf_file; +} |