projects
/
kivitendo-erp.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
marei: falsche Ausrichtung extraDescription repariert
[kivitendo-erp.git]
/
SL
/
BackgroundJob
/
SelfTest.pm
diff --git
a/SL/BackgroundJob/SelfTest.pm
b/SL/BackgroundJob/SelfTest.pm
index
6137ced
..
b715f9e
100644
(file)
--- a/
SL/BackgroundJob/SelfTest.pm
+++ b/
SL/BackgroundJob/SelfTest.pm
@@
-13,6
+13,8
@@
use FindBin;
use SL::DB::AuthUser;
use SL::DB::Default;
use SL::Common;
use SL::DB::AuthUser;
use SL::DB::Default;
use SL::Common;
+use SL::Locale::String qw(t8);
+use Carp;
use Rose::Object::MakeMethods::Generic (
array => [
use Rose::Object::MakeMethods::Generic (
array => [
@@
-24,7
+26,7
@@
use Rose::Object::MakeMethods::Generic (
'add_full_diag' => { interface => 'add', hash_key => 'full_diag' },
],
scalar => [
'add_full_diag' => { interface => 'add', hash_key => 'full_diag' },
],
scalar => [
- qw(diag tester config aggreg),
+ qw(diag tester config aggreg
module_nr
),
],
);
],
);
@@
-61,11
+63,13
@@
sub run {
$self->aggreg->failed,
$self->aggreg->todo_passed,
);
$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;
}
$self->_send_email;
}
+ croak t8("Unsuccessfully executed:" . join ("\n", $self->errors)) if $self->errors;
return 1;
}
return 1;
}
@@
-84,6
+88,9
@@
sub run_module {
$module =~ s/[^\w:]//g;
$module = "SL::BackgroundJob::SelfTest::$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 {
# try to load module;
(my $file = $module) =~ s|::|/|g;
eval {
@@
-92,15
+99,14
@@
sub run_module {
} or $self->add_errors($::locale->text('Could not load class #1 (#2): "#3"', $module, $file, $@)) && return;
eval {
} 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);
} 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;
my $parser = TAP::Parser->new({ tap => $output});
$parser->run;
@@
-131,13
+137,14
@@
sub _send_email {
$mail->{content_type} = $content_type;
$mail->{message} = $$output;
$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) = @_;
}
sub _prepare_report {
my ($self) = @_;
- my $user = $self->_email_user;
my $template = Template->new({ 'INTERPOLATE' => 0,
'EVAL_PERL' => 0,
'ABSOLUTE' => 1,
my $template = Template->new({ 'INTERPOLATE' => 0,
'EVAL_PERL' => 0,
'ABSOLUTE' => 1,
@@
-153,8
+160,10
@@
sub _prepare_report {
my %params = (
SELF => $self,
host => hostname,
my %params = (
SELF => $self,
host => hostname,
- database => $::myconfig{dbname},
+ database => $::auth->client->{dbname},
+ client => $::auth->client->{name},
path => $FindBin::Bin,
path => $FindBin::Bin,
+ errors => $self->errors,
);
my $output;
);
my $output;
@@
-182,14
+191,4
@@
SL::BackgroundJob::SelfTest - pluggable self testing
use SL::BackgroundJob::SelfTest;
SL::BackgroundJob::SelfTest->new->run;;
use SL::BackgroundJob::SelfTest;
SL::BackgroundJob::SelfTest->new->run;;
-=head1 DESCRIPTION
-
-
-
-=head1 FUNCTIONS
-
-=head1 BUGS
-
-=head1 AUTHOR
-
=cut
=cut