From c8123fe6adb0fc2095131a09df1bb5a82dd3c2a3 Mon Sep 17 00:00:00 2001 From: Steven Schubiger Date: Sun, 18 Aug 2019 21:15:24 +0200 Subject: Add new test files --- t/conf/color.t | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100755 t/conf/color.t (limited to 't/conf/color.t') diff --git a/t/conf/color.t b/t/conf/color.t new file mode 100755 index 0000000..3adfd5b --- /dev/null +++ b/t/conf/color.t @@ -0,0 +1,33 @@ +#!/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 = 3; + +plan tests => $tests; + +SKIP: { + my $program = tmpnam(); + my $conf_file = tmpnam(); + + skip 'compiling failed (color)', $tests unless system(qq($compiler -DTEST -DCONF_FILE_TEST=\"$conf_file\" -o $program $source)) == 0; + + my $infile = $write_to_tmpfile->('foo'); + + open(my $fh, '>', $conf_file) or die "Cannot open `$conf_file' for writing: $!\n"; + print {$fh} "color=green\n"; + close($fh); + + is(qx($program $infile), "\e[32mfoo\e[0m", 'color from config'); + is(qx(printf %s "foo" | $program none/none), 'foo', 'read from stdin'); + is(qx($program none/none $infile), 'foo', 'read from file'); + + unlink $program; + unlink $conf_file; +} -- cgit v1.2.3