X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FBackgroundJob%2FSelfTest.pm;h=b715f9e07d11605b554888dde60a0cd2d17caf66;hb=11aeaa07186197c61dfe610d2a5c981754fd2e9d;hp=c1c608bbf5f6f6c5140ffa366bc27a7d70bd3e08;hpb=db4680753f5ec1de62bdc0557f850afd810444d1;p=kivitendo-erp.git diff --git a/SL/BackgroundJob/SelfTest.pm b/SL/BackgroundJob/SelfTest.pm index c1c608bbf..b715f9e07 100644 --- a/SL/BackgroundJob/SelfTest.pm +++ b/SL/BackgroundJob/SelfTest.pm @@ -26,7 +26,7 @@ use Rose::Object::MakeMethods::Generic ( 'add_full_diag' => { interface => 'add', hash_key => 'full_diag' }, ], scalar => [ - qw(diag tester config aggreg), + qw(diag tester config aggreg module_nr), ], ); @@ -48,18 +48,11 @@ sub setup { sub run { my $self = shift; - my $db_obj = shift; - # options - my $options = $db_obj->data_as_hash; $self->setup; return 1 unless $self->modules; - - $main::lxdebug->message(0, 'optioni' . Dumper($self->modules)); foreach my $module ($self->modules) { - next unless $module eq $options->{module}; - $main::lxdebug->message(0, 'hieur' . $module); $self->run_module($module); } @@ -70,8 +63,9 @@ sub run { $self->aggreg->failed, $self->aggreg->todo_passed, ); - - if (!$self->aggreg->all_passed || $self->config->{send_email_on_success}) { + # if (!$self->aggreg->all_passed || $self->config->{send_email_on_success}) { + # all_passed is not set or calculated (anymore). it is safe to check only for probs or errors + if ($self->aggreg->failed || $self->config->{send_email_on_success}) { $self->_send_email; } @@ -94,6 +88,9 @@ sub run_module { $module =~ s/[^\w:]//g; $module = "SL::BackgroundJob::SelfTest::$module"; + # increase module nr + $self->module_nr(($self->module_nr || 0) + 1); + # try to load module; (my $file = $module) =~ s|::|/|g; eval { @@ -109,7 +106,7 @@ sub run_module { } or $self->add_errors($::locale->text('Could not load class #1, #2', $module, $@)) && return; $self->add_full_diag($output); - $self->{diag_per_module}{$module} = $output; + $self->{diag_per_module}{$self->module_nr . ': ' . $module} = $output; my $parser = TAP::Parser->new({ tap => $output}); $parser->run; @@ -140,13 +137,14 @@ sub _send_email { $mail->{content_type} = $content_type; $mail->{message} = $$output; - $mail->send; + my $err = $mail->send; + $self->add_errors('Mailer error #1', $err) if $err; + } sub _prepare_report { my ($self) = @_; - my $user = $self->_email_user; my $template = Template->new({ 'INTERPOLATE' => 0, 'EVAL_PERL' => 0, 'ABSOLUTE' => 1, @@ -193,14 +191,4 @@ SL::BackgroundJob::SelfTest - pluggable self testing use SL::BackgroundJob::SelfTest; SL::BackgroundJob::SelfTest->new->run;; -=head1 DESCRIPTION - - - -=head1 FUNCTIONS - -=head1 BUGS - -=head1 AUTHOR - =cut