[omd-commits] OMD Git: omd: tests: added failed command line to output
git version control
git at mathias-kettner.de
Sat Dec 18 20:57:29 CET 2010
Module: omd
Branch: master
Commit: 66702a208fcd80801d01d4af5414e8fea5b72732
URL: http://omdistro.org/projects/omd/repository/revisions/66702a208fcd80801d01d4af5414e8fea5b72732
Author: Sven Nierlein <sven at nierlein.de>
Date: Sat Dec 18 20:57:05 2010 +0100
tests: added failed command line to output
---
t/10-omd_testsite.t | 5 ++++-
t/TestUtils.pm | 20 +++++---------------
t/test_all.sh | 2 +-
3 files changed, 10 insertions(+), 17 deletions(-)
diff --git a/t/10-omd_testsite.t b/t/10-omd_testsite.t
index 494006e..89ee8b5 100644
--- a/t/10-omd_testsite.t
+++ b/t/10-omd_testsite.t
@@ -12,7 +12,7 @@ BEGIN {
use lib "$FindBin::Bin/lib/lib/perl5";
}
-plan( tests => 44 );
+plan( tests => 47 );
my $omd_bin = TestUtils::get_omd_bin();
@@ -23,6 +23,9 @@ my $site2 = 'testsite2';
my $site3 = 'testsite3';
my $tests = [
{ cmd => $omd_bin." versions", like => '/^\d+\.\d+/' },
+ { cmd => $omd_bin." rm $site", stdin => "yes\n", 'exit' => undef, errlike => undef },
+ { cmd => $omd_bin." rm $site2", stdin => "yes\n", 'exit' => undef, errlike => undef },
+ { cmd => $omd_bin." rm $site2", stdin => "yes\n", 'exit' => undef, errlike => undef },
{ cmd => $omd_bin." create $site", like => '/Successfully created site '.$site.'./' },
{ cmd => $omd_bin." sites", like => '/^'.$site.'\s+\d+\.\d+/' },
{ cmd => $omd_bin." start $site", like => '/Starting nagios/' },
diff --git a/t/TestUtils.pm b/t/TestUtils.pm
index 9c295e7..19b0a51 100644
--- a/t/TestUtils.pm
+++ b/t/TestUtils.pm
@@ -14,6 +14,7 @@ use Data::Dumper;
use LWP::UserAgent;
use File::Temp qw/ :POSIX /;
use Test::Cmd;
+use HTML::Lint;
if($> != 0) {
plan( skip_all => "creating testsites requires root permission" );
@@ -21,14 +22,6 @@ if($> != 0) {
our $omd_symlink_created = 0;
##################################################
-# HTML::Lint installed?
-my $use_html_lint = 0;
-eval {
- require HTML::Lint;
- $use_html_lint = 1;
-};
-
-##################################################
=head2 get_omd_bin
@@ -42,7 +35,7 @@ sub get_omd_bin {
$omd_bin = $ENV{'OMD_BIN'} || 'destdir/opt/omd/versions/default/bin/omd';
- # check /omd
+ # first check /omd
if( ! -e '/omd' ) {
if($omd_bin eq '/usr/bin/omd') {
BAIL_OUT('Broken installation, got /usr/bin/omd but no /omd')
@@ -117,13 +110,13 @@ sub test_command {
# exit code?
$test->{'exit'} = 0 unless exists $test->{'exit'};
if(defined $test->{'exit'}) {
- ok($rc == $test->{'exit'}, "exit code: ".$rc." == ".$test->{'exit'});
+ ok($rc == $test->{'exit'}, "exit code: ".$rc." == ".$test->{'exit'}) || diag("\ncmd: '".$test->{'cmd'}."' failed\n");
}
# matches on stdout?
if(defined $test->{'like'}) {
for my $expr (ref $test->{'like'} eq 'ARRAY' ? @{$test->{'like'}} : $test->{'like'} ) {
- like($t->stdout, $expr, "stdout like ".$expr);
+ like($t->stdout, $expr, "stdout like ".$expr) || diag("\ncmd: '".$test->{'cmd'}."' failed\n");
}
}
@@ -131,7 +124,7 @@ sub test_command {
$test->{'errlike'} = '/^$/' unless exists $test->{'errlike'};
if(defined $test->{'errlike'}) {
for my $expr (ref $test->{'errlike'} eq 'ARRAY' ? @{$test->{'errlike'}} : $test->{'errlike'} ) {
- like($t->stderr, $expr, "stderr like ".$expr);
+ like($t->stderr, $expr, "stderr like ".$expr) || diag("\ncmd: '".$test->{'cmd'}."' failed");
}
}
@@ -218,9 +211,6 @@ sub test_url {
# html valitidy
SKIP: {
if($page->{'content_type'} =~ 'text\/html') {
- if($use_html_lint == 0) {
- skip "no HTML::Lint installed", 2;
- }
my $lint = new HTML::Lint;
isa_ok( $lint, "HTML::Lint" );
diff --git a/t/test_all.sh b/t/test_all.sh
index 0546c4e..e18f0a3 100755
--- a/t/test_all.sh
+++ b/t/test_all.sh
@@ -30,7 +30,7 @@ if [ ! -z $OMD_PACKAGE ]; then
fi
if [ -z $OMD_BIN ]; then
- OMD_BIN=destdir/usr/bin/omd
+ OMD_BIN=destdir/opt/omd/versions/default/bin/omd
fi
OMD_BIN=$OMD_BIN PERL_DL_NONLAZY=1 /usr/bin/env perl "-MExtUtils::Command::MM" "-e" "test_harness(0)" t/*.t
More information about the omd-commits
mailing list