if ($@) {
$extra_tests = 0;
} else {
- $extra_tests = 2;
+ $extra_tests = 3;
*report = *report_smart;
}
}
sub new { shift->SUPER::new(extra_tests => $extra_tests) }
+my @filtered_reports;
+
sub report_smart {
my ($self, $sess, $report) = @_;
);
if ($valid_trace) {
- my $tb = Test::Builder->new;
- $tb->diag("The subsequent report was correctly caught:\n" . $report->dump);
- $tb->is_eq($data->{leakedbytes}, 10_000, '10_000 bytes leaked');
- $tb->is_eq($data->{leakedblocks}, 1, ' in one block');
+ push @filtered_reports, [
+ $report->dump,
+ $data->{leakedbytes},
+ $data->{leakedblocks},
+ ];
return;
}
}
$self->SUPER::report($sess, $report);
}
+sub DESTROY {
+ return unless $extra_tests;
+
+ my $tb = Test::Builder->new;
+
+ $tb->is_eq(scalar(@filtered_reports), 1, 'caught one extra leak');
+
+ if (@filtered_reports) {
+ my $first = shift @filtered_reports;
+ $tb->diag("The subsequent report was correctly caught:\n" . $first->[0]);
+ $tb->is_eq($first->[1], 10_000, '10_000 bytes leaked');
+ $tb->is_eq($first->[2], 1, ' in one block');
+
+ for my $extra_report (@filtered_reports) {
+ $tb->diag(
+ "The subsequent report should NOT have been caught:\n" . $extra_report->[0]
+ );
+ }
+ } else {
+ $tb->ok(0, 'no extra leak caught, hence no bytes leaked');
+ $tb->ok(0, 'no extra leak caught, hence no block leaked');
+ }
+}
+
1;