diff --git a/Changes b/Changes index 73e5b0ba0..cda40ae29 100644 --- a/Changes +++ b/Changes @@ -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 diff --git a/lib/Test2/API.pm b/lib/Test2/API.pm index 5c2e9421b..6234de919 100644 --- a/lib/Test2/API.pm +++ b/lib/Test2/API.pm @@ -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;