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