Kosmetik: POD bei SelfTest: keine leeren Abschnitte
[kivitendo-erp.git] / SL / BackgroundJob / SelfTest.pm
index 2f88833..d5811fd 100644 (file)
@@ -63,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;
   }
 
@@ -95,11 +96,10 @@ sub run_module {
   } or $self->add_errors($::locale->text('Could not load class #1 (#2): "#3"', $module, $file, $@)) && return;
 
   eval {
-    my $worker = $module->new;
-    $worker->tester($self->tester);
-
-    $worker->run;
-    1;
+    $self->tester->subtest($module => sub {
+      $module->new->run;
+    });
+  1
   } or $self->add_errors($::locale->text('Could not load class #1, #2', $module, $@)) && return;
 
   $self->add_full_diag($output);
@@ -134,13 +134,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,
@@ -187,14 +188,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