diff -r bdbd5e99f85a -r a29ba54493af t/666-pjotr.t --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/t/666-pjotr.t Fri Jan 20 14:17:34 2012 +0100 @@ -0,0 +1,64 @@ +use strict; +use warnings; + +use Test::More; +use Test::Cmd; + +my $test = Test::Cmd->new(prog => "blib/script/checkfs.pjotr", workdir => "", verbose => $ENV{TEST_VERBOSE} > 1); +ok($test, "test environment"); + +# $ENV{HARNESS_ACTIVE} + +my $rc; + +$test->run(); +$rc = $? >> 8; +subtest "run w/o args" => sub { + isnt($rc, 0, "exit !0"); + like($test->stderr, qr/^Usage:/, "Usage"); +}; + +$test->run(args => "-h"); +$rc = $? >> 8; +subtest "run w/ -h" => sub { + is($rc, 0, "exit 0"); + like($test->stdout, qr/^Usage:.*^Options/ms, "Usage and Options"); + is($test->stderr, "", "stderr should be empty"); +}; + + +$test->run(args => "-m"); +$rc = $? >> 8; +subtest "run w/ -m" => sub { + is($rc, 0, "exit 0"); + like($test->stdout, qr/^N.*^S.*^O/msi, "looks like manpage"); + is($test->stderr, "", "stderr should be empty"); +}; + +# create a fake df + +my $filename = "t/test_input.pjotr"; + +subtest "fake df" => sub { + if ($filename) { + my $header; + open(my $fh, '<' . $filename); + while (my $t = <$fh>) { + chomp $t; + if (!$header) { + $header = $t; + next; + } + $t =~ s/^\[(\d+)\]\s+//; + my $ret = $1; + $test->run(args => "-s", stdin => "$header\n$t"); + + $rc = $? >> 8; + is($rc, $ret); + } + close($fh); + } +}; + + +done_testing;