Skip to content

Commit

Permalink
Merge pull request #914 from Test-More/fix_882
Browse files Browse the repository at this point in the history
Fix #882
  • Loading branch information
exodist authored Oct 24, 2023
2 parents ee07627 + e86f0e1 commit c9a986f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
2 changes: 2 additions & 0 deletions Changes
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
{{$NEXT}}

- Fix #882

1.302195 2023-04-28 05:55:54-07:00 America/Los_Angeles

- Fix done_testing(0) producing 2 plans and an incorrect message
Expand Down
11 changes: 9 additions & 2 deletions lib/Test2/API.pm
Original file line number Diff line number Diff line change
Expand Up @@ -380,8 +380,15 @@ sub context {
# Catch an edge case where we try to get context after the root hub has
# been garbage collected resulting in a stack that has a single undef
# hub
if (!$hub && !exists($params{hub}) && @$stack) {
my $msg = Carp::longmess("Attempt to get Test2 context after testing has completed (did you attempt a testing event after done_testing?)");
if (!($hub && $hub->{hid}) && !exists($params{hub}) && @$stack) {
my $msg;

if ($hub && !$hub->{hid}) {
$msg = Carp::longmess("$hub has no hid! (did you attempt a testing event after done_testing?). You may be relying on a tool or plugin that was based off an old Test2 that did not require hids.");
}
else {
$msg = Carp::longmess("Attempt to get Test2 context after testing has completed (did you attempt a testing event after done_testing?)");
}

# The error message is usually masked by the global destruction, so we have to print to STDER
print STDERR $msg;
Expand Down

0 comments on commit c9a986f

Please sign in to comment.