diff --git a/src/lib/Hydra/Schema/Result/RunCommandLogs.pm b/src/lib/Hydra/Schema/Result/RunCommandLogs.pm index 329d3624..00bfad76 100644 --- a/src/lib/Hydra/Schema/Result/RunCommandLogs.pm +++ b/src/lib/Hydra/Schema/Result/RunCommandLogs.pm @@ -216,7 +216,13 @@ sub completed_with_child_error { # This `& 128` comes from where Perl constructs the CHILD_ERROR # value: # https://github.com/Perl/perl5/blob/a9d7a07c2ebbfd8ee992f1d27ef4cfbed53085b6/perl.h#L3609-L3621 - $core_dumped = ($child_error & 128) == 128; + # + # The `+ 0` is handling another dualvar. It is a bool, but a + # bool false is an empty string in boolean context and 0 in a + # numeric concept. The ORM knows the column is a bool, but + # does not treat the empty string as a bool when talking to + # postgres. + $core_dumped = (($child_error & 128) == 128) + 0; } return $self->update({ diff --git a/t/Schema/Result/RunCommandLogs.t b/t/Schema/Result/RunCommandLogs.t index a84651de..a0823e4c 100644 --- a/t/Schema/Result/RunCommandLogs.t +++ b/t/Schema/Result/RunCommandLogs.t @@ -87,6 +87,19 @@ subtest "The process completed (errored)" => sub { is($runlog->core_dumped, undef, "The core dump is undefined."); }; +subtest "The process completed (status 15, child error 0)" => sub { + my $runlog = new_run_log(); + $runlog->started(); + $runlog->completed_with_child_error(15, 0); + ok(!$runlog->did_succeed(), "The process did not succeed."); + is($runlog->start_time, within(time() - 1, 2), "The start time is recent."); + is($runlog->end_time, within(time() - 1, 2), "The end time is recent."); + is($runlog->error_number, undef, "The error number is undefined"); + is($runlog->exit_code, undef, "The exit code is undefined."); + is($runlog->signal, 15, "Signal 15 was sent."); + is($runlog->core_dumped, 1, "There was no core dump."); +}; + subtest "The process completed (signaled)" => sub { my $runlog = new_run_log(); $runlog->started();