File Coverage

blib/lib/Integrator/Test/TAP/Model/Patch.pm
Criterion Covered Total %
statement 12 44 27.2
branch 0 12 0.0
condition 0 3 0.0
subroutine 4 7 57.1
pod 2 2 100.0
total 18 68 26.4


line stmt bran cond sub pod time code
1             package Integrator::Test::TAP::Model::Patch;
2 2     2   33807 use base 'Test::TAP::Model';
  2         6  
  2         2098  
3            
4 2     2   74950 use warnings;
  2         4  
  2         62  
5 2     2   13 use strict;
  2         5  
  2         93  
6              
7 2     2   10 use vars qw($VERSION);
  2         2  
  2         1340  
8              
9             =head1 NAME
10              
11             Integrator::Test::TAP::Model::Patch - modified version of Test::TAP::Model
12              
13             =head1 VERSION
14              
15             Version 0.01
16              
17             =cut
18              
19             $VERSION = sprintf "%d.%03d", q$Revision: 1.2 $ =~ /(\d+)/g;
20              
21             =head1 SYNOPSIS
22              
23             Very simple wrapper to get the full text output in the diags fields...
24             This is essentially the analyze_file function from Test::Harness::Straps by
25             Michael G Schwern C<< >>, currently maintained by
26             Andy Lester C<< >>.
27              
28             All other functions included here are exported simply to avoid breaking
29             the code.
30              
31             Our intent is to have the modification included in the original code
32             of Test::TAP::Model (maybe with a switch to enable the code...). We use
33             Integrator::Test::TAP::Model in the meantime.
34              
35             =head1 EXPORT
36              
37             =head1 FUNCTIONS
38              
39             =head2 analyze_file
40              
41             This function has been modified to have all test output merged back into
42             STDOUT. Then this merged output is printed both to STDOUT and STDERR.
43              
44             Otherwise, this function does the same thing as Test::TAP::Model::analyze_file.
45              
46             =cut
47              
48             sub analyze_file {
49 0     0 1   my($self, $file) = @_;
50              
51 0 0         unless( -e $file ) {
52 0           $self->{error} = "$file does not exist";
53 0           return;
54             }
55              
56 0 0         unless( -r $file ) {
57 0           $self->{error} = "$file is not readable";
58 0           return;
59             }
60              
61 0           local $ENV{PERL5LIB} = $self->_INC2PERL5LIB;
62 0 0         if ( $Test::Harness::Debug ) {
63 0           local $^W=0; # ignore undef warnings
64 0           print "# PERL5LIB=$ENV{PERL5LIB}\n";
65             }
66              
67             # *sigh* this breaks under taint, but open -| is unportable.
68 0           my $line = $self->_command_line($file);
69              
70             ############unless ( open(FILE, "$line|" )) {
71 0 0         unless ( open(FILE, "$line 2>&1| perl -pe 'print STDERR'|" )) {
72 0           print "can't run $file. $!\n";
73 0           return;
74             }
75              
76 0           my $results = $self->analyze_fh($file, \*FILE);
77 0           my $exit = close FILE;
78              
79 0           $results->set_wait($?);
80 0 0 0       if ( $? && $self->{_is_vms} ) {
81 0           eval q{use vmsish "status"; $results->set_exit($?); };
82             }
83             else {
84 0           $results->set_exit( _wait2exit($?) );
85             }
86 0 0         $results->set_passing(0) unless $? == 0;
87              
88 0           $self->_restore_PERL5LIB();
89              
90 0           return $results;
91             }
92              
93             eval { require POSIX; &POSIX::WEXITSTATUS(0) };
94             if( $@ ) {
95             *_wait2exit = sub { $_[0] >> 8 };
96             }
97             else {
98 0     0     *_wait2exit = sub { POSIX::WEXITSTATUS($_[0]) }
99             }
100              
101             =head2 run_tests
102              
103             This function has been modified to print the file name before
104             launching the tests. Otherwise this function does the same thing as
105             Test::TAP::Model::run_tests.
106              
107             =cut
108              
109             sub run_tests {
110 0     0 1   my $self = shift;
111              
112 0           $self->_init;
113              
114 0           $self->{meat}{start_time} = time;
115              
116 0           foreach my $file (@_) {
117 0           print "$file\n";
118 0           $self->run_test($file);
119             }
120              
121 0           $self->{meat}{end_time} = time;
122             }
123              
124             =head1 AUTHOR
125              
126             This module is very heavily based on Test::TAP:Model from Michael G
127             Schwern C<< >>, and currently maintained by Andy
128             Lester C<< >>.
129              
130             It has been modified by Francois Perron, C<< >>
131              
132             =head1 BUGS
133              
134             Please report any bugs or feature requests to the author through the provided email.
135              
136             =head1 SUPPORT
137              
138             You can find documentation for this module with the perldoc command.
139              
140             perldoc ./lib/Integrator/Test/TAP/Model/Patch.pm
141              
142             =head1 ACKNOWLEDGEMENTS
143              
144             =head1 COPYRIGHT & LICENSE
145              
146             Of course, Test::TAP::Model is Copyrighted to Michael G Schwern C<<
147             >>, and currently maintained by Andy Lester C<<
148             >>.
149              
150             this mod is Copyright 2006 Francois Perron, Cydone Solutions, this module
151             is released under the same terms as perl.
152              
153             =cut
154              
155             1;