Skip to content

$ctx->release does not return a true value by default #1073

@karenetheridge

Description

@karenetheridge

problem:

I want to do this in a test file (so as to add a bit of extra code on top for testing various installation scenarios):

  unless (my $return = do './'.$file) {
    warn "couldn't parse $file: '$@'" if $@;
    warn "couldn't do $file: '$!'"    unless defined $return;
    warn "couldn't run $file'"        unless $return;
  }

..except the test is always reported as a failure, because done_testing() doesn't return true.

I think this might be the right place to fix it - what do you think?

diff --git a/lib/Test2/API.pm b/lib/Test2/API.pm
index d09a21f9a..64c0d3361 100644
--- a/lib/Test2/API.pm
+++ b/lib/Test2/API.pm
@@ -580,7 +580,7 @@ Removing the old context and creating a new one...
 
 sub release($;$) {
     $_[0]->release;
-    return $_[1];
+    return $_[1] // 1;
 }
 

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions