xref: /openbsd-src/gnu/usr.bin/perl/cpan/Test-Simple/lib/Test/Tester/CaptureRunner.pm (revision c90a81c56dcebd6a1b73fe4aff9b03385b8e63b3)
1# $Header: /home/fergal/my/cvs/Test-Tester/lib/Test/Tester/CaptureRunner.pm,v 1.3 2003/03/05 01:07:55 fergal Exp $
2use strict;
3
4package Test::Tester::CaptureRunner;
5
6use Test::Tester::Capture;
7require Exporter;
8
9sub new
10{
11	my $pkg = shift;
12	my $self = bless {}, $pkg;
13	return $self;
14}
15
16sub run_tests
17{
18	my $self = shift;
19
20	my $test = shift;
21
22	capture()->reset;
23
24	$self->{StartLevel} = $Test::Builder::Level;
25	&$test();
26}
27
28sub get_results
29{
30	my $self = shift;
31	my @results = capture()->details;
32
33	my $start = $self->{StartLevel};
34	foreach my $res (@results)
35	{
36		next if defined $res->{depth};
37		my $depth = $res->{_depth} - $res->{_level} - $start - 3;
38#		print "my $depth = $res->{_depth} - $res->{_level} - $start - 1\n";
39		$res->{depth} = $depth;
40	}
41
42	return @results;
43}
44
45sub get_premature
46{
47	return capture()->premature;
48}
49
50sub capture
51{
52	return Test::Tester::Capture->new;
53}
54
55__END__
56
57=head1 NAME
58
59Test::Tester::CaptureRunner - Help testing test modules built with Test::Builder
60
61=head1 DESCRIPTION
62
63This stuff if needed to allow me to play with other ways of monitoring the
64test results.
65
66=head1 AUTHOR
67
68Copyright 2003 by Fergal Daly <fergal@esatclear.ie>.
69
70=head1 LICENSE
71
72Under the same license as Perl itself
73
74See http://www.perl.com/perl/misc/Artistic.html
75
76=cut
77