Skip to content

Commit

Permalink
tests: add diagnostics
Browse files Browse the repository at this point in the history
  • Loading branch information
sni committed Sep 30, 2024
1 parent 0e6910f commit 21b76ad
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
3 changes: 2 additions & 1 deletion t/090-external.t
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,9 @@ my $logarchive = '/tmp/test.'.$<.'.log';
unlink($logarchive);
$job = Thruk::Utils::External::perl($c, { expr => 'my($rc, $out) = Thruk::Utils::IO::cmd(["'.$cat.'", "'.$tempfile.'"], {no_decode => 1}); print $out; return $rc;', background => 1, log_archive => $logarchive });
TestUtils::wait_for_job($job);
my $jobdir = $c->config->{'var_path'}."/jobs/".$job;
($out,$err,$time,$dir,$stash,$rc,$profile,$start,$end,$perl_res) = Thruk::Utils::External::get_result($c, $job);
is(length($out), 10260038, "output ok");
is(length($out), 10260038, "output ok") || TestUtils::bail_out_diag("job failed", `ls -la $jobdir`, `ls -la $logarchive`);
is($err, "", "err output empty");
is($rc, 1, "exit code 1");
is($perl_res, 0, "perl result is 0");
Expand Down
25 changes: 25 additions & 0 deletions t/TestUtils.pm
Original file line number Diff line number Diff line change
Expand Up @@ -1114,6 +1114,31 @@ sub bail_out_cmd {
return;
}

#########################

=head2 bail_out_diag
print diagnostic output and bail out
=cut
sub bail_out_diag {
my($msg, @details) = @_;

diag("\n######################################################\n");
chomp($msg);
diag($msg."\n");
for my $d (@details) {
my $m = (ref $d ? Dumper($d) : $d);
chomp($m);
diag($m."\n");
}

diag(Carp::longmess("started here:"));
diag("\n######################################################\n");
BAIL_OUT($msg);
return;
}

#########################
sub set_test_user_token {
return if $test_token;
Expand Down

0 comments on commit 21b76ad

Please sign in to comment.