Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use croak in OpenQA::Utils::log_fatal #2436

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/OpenQA/Utils.pm
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ sub log_error {
# log_fatal("message"[, param1=>val1, param2=>val2]);
sub log_fatal {
_log_msg('fatal', @_);
die $_[0];
croak $_[0];
}

sub _current_log_level {
Expand Down
4 changes: 3 additions & 1 deletion t/28-logging.t
Original file line number Diff line number Diff line change
Expand Up @@ -154,14 +154,16 @@ subtest 'log fatal to stderr' => sub {
$app->setup_log();
$OpenQA::Utils::app = undef; # To make sure we don't are setting it in other tests
eval { log_fatal('fatal message'); };
my $eval_error = $@;
my $exception_raised = 0;
$exception_raised++ if $@;
$exception_raised++ if $eval_error;
### End of the Testing code ###
# Close the capture (current stdout) and restore STDOUT (by dupping the old STDOUT);
close STDERR;
open(STDERR, '>&', $oldSTDERR) or die "Can't dup \$oldSTDERR: $!";
ok($exception_raised == 1, 'Fatal raised exception');
like($output, qr/\[FATAL\] fatal message/, 'OK fatal');
like($eval_error, qr{fatal message.*t/28-logging.t});

};

Expand Down