- is(system("$program --help >/dev/null 2>&1"), 0, 'exit value for help screen');
+ is(system("$program --help >/dev/null 2>&1"), 0, 'exit value for help screen');
+ is(system("$program --version >/dev/null 2>&1"), 0, 'exit value for version data');
$ok &= $run_program_fail->($program, '--clean --clean-all', 'mutually exclusive');
$ok &= $run_program_fail->($program, '--clean file1 file2', 'more than one file');
$ok &= $run_program_fail->($program, '--clean-all file1 file2', 'more than one file');
$ok &= $run_program_fail->($program, '- file', 'hyphen cannot be used as color string');
$ok &= $run_program_fail->($program, '-', 'hyphen must be preceeded by color string');
$ok &= $run_program_fail->($program, '--clean --clean-all', 'mutually exclusive');
$ok &= $run_program_fail->($program, '--clean file1 file2', 'more than one file');
$ok &= $run_program_fail->($program, '--clean-all file1 file2', 'more than one file');
$ok &= $run_program_fail->($program, '- file', 'hyphen cannot be used as color string');
$ok &= $run_program_fail->($program, '-', 'hyphen must be preceeded by color string');
- $ok &= $run_program_fail->($program, "$file file", 'file cannot be used as color string');
- $ok &= $run_program_fail->($program, "$file", 'file must be preceeded by color string');
+ $ok &= $run_program_fail->($program, "$file file", 'cannot be used as color string');
+ $ok &= $run_program_fail->($program, "$file", 'must be preceeded by color string');
+ $ok &= $run_program_fail->($program, "$dir", 'is not a valid file type');
$ok &= $run_program_fail->($program, '/black', 'foreground color missing');
$ok &= $run_program_fail->($program, 'white/', 'background color missing');
$ok &= $run_program_fail->($program, 'white/black/yellow', 'one color pair allowed only');
$ok &= $run_program_fail->($program, '/black', 'foreground color missing');
$ok &= $run_program_fail->($program, 'white/', 'background color missing');
$ok &= $run_program_fail->($program, 'white/black/yellow', 'one color pair allowed only');
- is(qx(echo "hello world" | $program none/none), "hello world\n", 'line read from stdin with newline');
- is(qx(echo -n "hello world" | $program none/none), "hello world", 'line read from stdin without newline');
+ is(qx(printf '%s\n' "hello world" | $program none/none), "hello world\n", 'line read from stdin with newline');
+ is(qx(printf %s "hello world" | $program none/none), "hello world", 'line read from stdin without newline');
- is(qx(echo -n "\e[35mhello\e[0m \e[36mworld\e[0m" | $program $switch), 'hello world', "$type colored words");
- is(qx(echo -n "hello world" | $program Magenta | $program $switch), 'hello world', "$type colored line");
+ is(qx(printf %s "\e[35mhello\e[0m \e[36mworld\e[0m" | $program $switch), 'hello world', "$type colored words");
+ is(qx(printf %s "hello world" | $program Magenta | $program $switch), 'hello world', "$type colored line");
is_deeply([split /\n/, qx($program cyan $infile1 | $program $switch)], [split /\n/, $text], "$type colored text");
is_deeply([split /\n/, qx($program cyan $infile1 | $program $switch)], [split /\n/, $text], "$type colored text");
- is(qx(echo -n "\e[4munderline\e[24m" | $program --clean-all), 'underline', 'clean-all color sequences');
+ is(qx(printf %s "\e[4munderline\e[24m" | $program --clean-all), 'underline', 'clean-all color sequences');
- is(qx(echo -n "$short_text" | $program_buf $switch), $short_text, "merge ${\length $short_text} bytes (BUF_SIZE=$BUF_SIZE{short}, $type)");
+ is(qx(printf %s "$short_text" | $program_buf $switch), $short_text, "print ${\length $short_text} bytes (BUF_SIZE=$BUF_SIZE{short}, $type)");
is_deeply([split /\n/, qx(cat $infile2 | $program none/none)], [split /\n/, $repeated], "read ${\length $repeated} bytes (BUF_SIZE=$BUF_SIZE{normal})");
{
is_deeply([split /\n/, qx(cat $infile2 | $program none/none)], [split /\n/, $repeated], "read ${\length $repeated} bytes (BUF_SIZE=$BUF_SIZE{normal})");
{
my $sequences = 0;
$sequences++ while $colored_text =~ /\e\[\d+m/g;
is($sequences, 2, 'count of sequences printed');
}
my $sequences = 0;
$sequences++ while $colored_text =~ /\e\[\d+m/g;
is($sequences, 2, 'count of sequences printed');
}
- is(system("echo \"hello world\" | $program random --exclude-random=black >/dev/null 2>&1"), 0, 'switch exclude-random');
+ is(system(qq(printf '%s\n' "hello world" | $program random --exclude-random=black >/dev/null 2>&1)), 0, 'switch exclude-random');
SKIP: {
skip 'valgrind not found', 1 unless system('which valgrind >/dev/null 2>&1') == 0;
like(qx(valgrind $program none/none $infile1 2>&1 >/dev/null), qr/no leaks are possible/, 'valgrind memleaks');
}
SKIP: {
skip 'valgrind not found', 1 unless system('which valgrind >/dev/null 2>&1') == 0;
like(qx(valgrind $program none/none $infile1 2>&1 >/dev/null), qr/no leaks are possible/, 'valgrind memleaks');
}
- foreach my $color (qw(none black red green yellow blue cyan magenta white default random)) {
- system("echo $color | $program $color");
+ foreach my $color (qw(none black red green yellow blue magenta cyan white default random)) {
+ system(qq(printf '%s\n' "$color" | $program $color));