Skip to content

Commit

Permalink
Fix Grabber to inherit Test::More's $TODO functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
exodist committed Aug 6, 2020
1 parent c24fc9e commit 4b7d8fe
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 5 deletions.
2 changes: 2 additions & 0 deletions Changes
@@ -1,5 +1,7 @@
{{$NEXT}}

- Fix the grabber tool to inherit Test::Builder $TODO functionality

0.000130 2020-05-30 11:11:54-07:00 America/Los_Angeles

- Many documentation fixes
Expand Down
2 changes: 1 addition & 1 deletion dist.ini
Expand Up @@ -27,7 +27,7 @@ repository.type = git

[Prereqs]
perl = 5.008001
Test2::API = 1.302158
Test2::API = 1.302175
Importer = 0.024
Term::Table = 0.013
Sub::Info = 0.002
Expand Down
3 changes: 2 additions & 1 deletion lib/Test2/Tools/Grab.pm
Expand Up @@ -5,11 +5,12 @@ use warnings;
our $VERSION = '0.000131';

use Test2::Util::Grabber;
use Test2::EventFacet::Trace();

our @EXPORT = qw/grab/;
use base 'Exporter';

sub grab { Test2::Util::Grabber->new() }
sub grab { Test2::Util::Grabber->new(trace => Test2::EventFacet::Trace->new(frame => [caller(0)]) ) }

1;

Expand Down
16 changes: 13 additions & 3 deletions lib/Test2/Util/Grabber.pm
Expand Up @@ -5,11 +5,11 @@ use warnings;
our $VERSION = '0.000131';

use Test2::Hub::Interceptor();
use Test2::Util::Trace();
use Test2::EventFacet::Trace();

use Test2::API qw/test2_stack test2_ipc/;

use Test2::Util::HashBase qw/hub finished _events term_size/;
use Test2::Util::HashBase qw/hub finished _events term_size <state <trace/;

sub init {
my $self = shift;
Expand All @@ -32,6 +32,12 @@ sub init {

$self->{+TERM_SIZE} = $ENV{TS_TERM_SIZE};
$ENV{TS_TERM_SIZE} = 80;

my $trace = $self->{+TRACE} ||= Test2::EventFacet::Trace->new(frame => [caller(1)]);
my $state = $self->{+STATE} ||= {};
$hub->clean_inherited(trace => $trace, state => $state);

return;
}

sub flush {
Expand Down Expand Up @@ -63,7 +69,11 @@ sub finish {
$self->{+FINISHED} = 1;
test2_stack()->pop($hub);

my $dbg = Test2::Util::Trace->new(
my $trace = $self->{+TRACE} ||= Test2::EventFacet::Trace->new(frame => [caller(1)]);
my $state = $self->{+STATE} ||= {};
$hub->clean_inherited(trace => $trace, state => $state);

my $dbg = Test2::EventFacet::Trace->new(
frame => [caller(0)],
);
$hub->finalize($dbg, 1)
Expand Down

0 comments on commit 4b7d8fe

Please sign in to comment.