Permalink
Browse files

Add Test::Builder->store_events and use Test::More store_events => 1

Makes turning on events a little easier and it was easy to add.

Signed-off-by: Michael G. Schwern <schwern@pobox.com>
  • Loading branch information...
1 parent c227244 commit c3ee922320de0fe24dbf463103915dce044f6387 @schwern schwern committed May 3, 2013
Showing with 43 additions and 4 deletions.
  1. +29 −4 lib/Test/Builder.pm
  2. +14 −0 t/Builder/store_events.t
View
@@ -357,10 +357,11 @@ If you call C<plan()>, don't call any of the other methods below.
=cut
my %plan_cmds = (
- no_plan => \&no_plan,
- skip_all => \&skip_all,
- tests => \&_plan_tests,
- coordinate_forks => \&coordinate_forks,
+ no_plan => \&no_plan,
+ skip_all => \&skip_all,
+ tests => \&_plan_tests,
+ coordinate_forks => \&coordinate_forks,
+ store_events => \&store_events,
);
sub plan {
@@ -1810,6 +1811,30 @@ sub is_passing {
}
+=item B<store_events>
+
+ $tb->store_events($storage_on_or_off);
+ $storage_on_or_off = $tb->store_events;
+
+Gets/sets whether test events are stored.
+
+To save memory, it defaults to being off.
+
+See L<MEMORY> for more details.
+
+=cut
+
+sub store_events {
+ my $self = shift;
+
+ if( @_ ) {
+ $self->history->store_events(shift);
+ }
+
+ return $self->history->store_events;
+}
+
+
=item B<summary>
my @tests = $Test->summary;
@@ -0,0 +1,14 @@
+#!/usr/bin/env perl
+
+use strict;
+use warnings;
+
+use lib 't/lib';
+
+use Test::More store_events => 1;
+
+my $tb = Test::More->builder;
+ok $tb->store_events, "event storage is on";
+is_deeply [$tb->summary], [1];
+
+done_testing;

0 comments on commit c3ee922

Please sign in to comment.