From 6625e6a0d2a4cec99339b8b526035592dcd4418c Mon Sep 17 00:00:00 2001 From: Ton Voon Date: Mon, 24 Sep 2007 18:45:59 +0000 Subject: Help, usage and version output go to stdout now, rather than stderr git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/Nagios-Plugin/trunk@1795 f882894a-f735-0410-b71e-b25c423dba1c --- t/Nagios-Plugin-Getopt-01.t | 3 +++ t/Nagios-Plugin-Getopt-02.t | 3 +++ t/Nagios-Plugin-Getopt-04.t | 3 +++ t/check_stuff.t | 24 +++++++----------------- 4 files changed, 16 insertions(+), 17 deletions(-) (limited to 't') diff --git a/t/Nagios-Plugin-Getopt-01.t b/t/Nagios-Plugin-Getopt-01.t index bad1367..7076d75 100644 --- a/t/Nagios-Plugin-Getopt-01.t +++ b/t/Nagios-Plugin-Getopt-01.t @@ -5,6 +5,9 @@ use strict; use Test::More tests => 76; BEGIN { use_ok('Nagios::Plugin::Getopt') }; +# Needed to get evals to work in testing +Nagios::Plugin::Functions::_use_die(1); + my %PARAM = ( version => '0.01', url => 'http://www.openfusion.com.au/labs/nagios/', diff --git a/t/Nagios-Plugin-Getopt-02.t b/t/Nagios-Plugin-Getopt-02.t index 26e0293..f83b180 100644 --- a/t/Nagios-Plugin-Getopt-02.t +++ b/t/Nagios-Plugin-Getopt-02.t @@ -5,6 +5,9 @@ use strict; use Test::More tests => 14; BEGIN { use_ok('Nagios::Plugin::Getopt') }; +# Needed to get evals to work in testing +Nagios::Plugin::Functions::_use_die(1); + my %PARAM = ( version => '0.01', url => 'http://www.openfusion.com.au/labs/nagios/', diff --git a/t/Nagios-Plugin-Getopt-04.t b/t/Nagios-Plugin-Getopt-04.t index 9092636..115f2a2 100644 --- a/t/Nagios-Plugin-Getopt-04.t +++ b/t/Nagios-Plugin-Getopt-04.t @@ -5,6 +5,9 @@ use strict; use Test::More tests => 11; BEGIN { use_ok('Nagios::Plugin::Getopt') }; +# Needed to get evals to work in testing +Nagios::Plugin::Functions::_use_die(1); + my %PARAM = ( version => '0.01', usage => "Don't use this plugin!", diff --git a/t/check_stuff.t b/t/check_stuff.t index 2d2ce38..64f95ae 100755 --- a/t/check_stuff.t +++ b/t/check_stuff.t @@ -2,7 +2,7 @@ # use strict; use warnings; #use Test::More qw(no_plan); -use Test::More tests => 16; +use Test::More tests => 14; my ($r,$args); my $s = 't/check_stuff.pl'; @@ -22,23 +22,13 @@ $r = `$s`; is $?>>8 , $e{UNKNOWN}, "exits($e{UNKNOWN}) with no args"; like $r, qr/^$n UNKNOWN/, "UNKNOWN with no args"; +$r = `$s -V`; +is $?>>8 , $e{UNKNOWN}, "exits($e{UNKNOWN}) with -V arg"; +like $r, qr/^[\w\.]+ \d+/i, "looks like there's a version"; -#TODO: -SKIP: { - local $TODO = q~d'oh! we'll have to redirect STDERR and check it with like() here instead of checking `` which only gets STDIN. Maybe use IPC::Open3?~; - skip "too noisy, see TODO here", 6; - - $r = `$s -V`; - is $?>>8 , $e{UNKNOWN}, "exits($e{UNKNOWN}) with -V arg"; - like $r, qr/\d+\.\d/i, "looks like there's a version"; # broken - is $r, '', "prints nothing to STDOUT"; - - $r = `$s -h`; - is $?>>8 , $e{UNKNOWN}, "exits($e{UNKNOWN}) with -h arg"; - like $r, qr/usage/i, "looks like there's something helpful"; # broken - is $r, '', "prints nothing to STDOUT"; -} - +$r = `$s -h`; +is $?>>8 , $e{UNKNOWN}, "exits($e{UNKNOWN}) with -h arg"; +like $r, qr/usage/i, "looks like there's something helpful"; # broken $args = " -r 99 "; diag "running `$s $args`" if $ENV{TEST_VERBOSE}; -- cgit v1.2.3-74-g34f1