| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
# $Id: FileRunner.pm,v 1.10 2006/06/16 15:20:56 tonyb Exp $ |
|
2
|
|
|
|
|
|
|
# |
|
3
|
|
|
|
|
|
|
# Copyright (c) 2002-2005 Cunningham & Cunningham, Inc. |
|
4
|
|
|
|
|
|
|
# Released under the terms of the GNU General Public License version 2 or later. |
|
5
|
|
|
|
|
|
|
# |
|
6
|
|
|
|
|
|
|
# Perl translation by Dave W. Smith |
|
7
|
|
|
|
|
|
|
# Modified by Tony Byrne |
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
package Test::C2FIT::FileRunner; |
|
10
|
|
|
|
|
|
|
|
|
11
|
1
|
|
|
1
|
|
5
|
use strict; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
34
|
|
|
12
|
1
|
|
|
1
|
|
822
|
use IO::File; |
|
|
1
|
|
|
|
|
10178
|
|
|
|
1
|
|
|
|
|
165
|
|
|
13
|
1
|
|
|
1
|
|
740
|
use Test::C2FIT::Parse; |
|
|
1
|
|
|
|
|
4
|
|
|
|
1
|
|
|
|
|
51
|
|
|
14
|
1
|
|
|
1
|
|
709
|
use Test::C2FIT::Fixture; |
|
|
1
|
|
|
|
|
4
|
|
|
|
1
|
|
|
|
|
41
|
|
|
15
|
1
|
|
|
1
|
|
10
|
use Error qw( :try ); |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
9
|
|
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub new { |
|
18
|
0
|
|
|
0
|
0
|
|
my $pkg = shift; |
|
19
|
0
|
|
|
|
|
|
return bless { |
|
20
|
|
|
|
|
|
|
input => undef, |
|
21
|
|
|
|
|
|
|
tables => undef, |
|
22
|
|
|
|
|
|
|
output => undef, |
|
23
|
|
|
|
|
|
|
fixture => Test::C2FIT::Fixture->new(), |
|
24
|
|
|
|
|
|
|
@_ |
|
25
|
|
|
|
|
|
|
}, $pkg; |
|
26
|
|
|
|
|
|
|
} |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub run { |
|
29
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
|
30
|
0
|
|
|
|
|
|
my (@argv) = @_; |
|
31
|
0
|
|
|
|
|
|
$self->argv(@argv); |
|
32
|
0
|
|
|
|
|
|
$self->process(); |
|
33
|
0
|
|
|
|
|
|
$self->_exit(); |
|
34
|
|
|
|
|
|
|
} |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub argv { |
|
37
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
|
38
|
0
|
|
|
|
|
|
my (@argv) = @_; |
|
39
|
|
|
|
|
|
|
|
|
40
|
0
|
0
|
|
|
|
|
die "usage: FileRunner.pl input-file output-file\n" |
|
41
|
|
|
|
|
|
|
unless 2 == @argv; |
|
42
|
|
|
|
|
|
|
|
|
43
|
0
|
|
|
|
|
|
$Test::C2FIT::Fixture::summary{'input file'} = $argv[0]; |
|
44
|
0
|
|
|
|
|
|
$Test::C2FIT::Fixture::summary{'output file'} = $argv[1]; |
|
45
|
|
|
|
|
|
|
|
|
46
|
0
|
0
|
|
|
|
|
my $in = IO::File->new( $argv[0], "r" ) or die "$argv[0]: $!\n"; |
|
47
|
0
|
|
|
|
|
|
$self->{'input'} = join( "", <$in> ); |
|
48
|
0
|
0
|
|
|
|
|
my $out = IO::File->new( $argv[1], "w" ) or die "$argv[1]: $!\n"; |
|
49
|
0
|
|
|
|
|
|
$self->{'output'} = $out; |
|
50
|
|
|
|
|
|
|
|
|
51
|
0
|
|
|
|
|
|
my @inputFileStat = stat( $argv[0] ); |
|
52
|
0
|
|
|
|
|
|
my $inputUpdateTime = localtime( $inputFileStat[9] ); |
|
53
|
0
|
|
|
|
|
|
$Test::C2FIT::Fixture::summary{'input update'} = $inputUpdateTime; |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
} |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
sub process { |
|
58
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
|
59
|
|
|
|
|
|
|
|
|
60
|
1
|
|
|
1
|
|
445
|
use Benchmark; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
5
|
|
|
61
|
|
|
|
|
|
|
try { |
|
62
|
0
|
0
|
|
0
|
|
|
if ( $self->{'input'} =~ // ) { |
|
63
|
0
|
|
|
|
|
|
$self->{'tables'} = |
|
64
|
|
|
|
|
|
|
Test::C2FIT::Parse->new( $self->{'input'}, |
|
65
|
|
|
|
|
|
|
[ 'wiki', 'table', 'tr', 'td' ] ); |
|
66
|
0
|
|
|
|
|
|
$self->{'fixture'}->doTables( $self->{'tables'}->parts() ); |
|
67
|
|
|
|
|
|
|
} |
|
68
|
|
|
|
|
|
|
else { |
|
69
|
0
|
|
|
|
|
|
$self->{'tables'} = |
|
70
|
|
|
|
|
|
|
Test::C2FIT::Parse->new( $self->{'input'}, |
|
71
|
|
|
|
|
|
|
[ 'table', 'tr', 'td' ] ); |
|
72
|
0
|
|
|
|
|
|
$self->{'fixture'}->doTables( $self->{'tables'} ); |
|
73
|
|
|
|
|
|
|
} |
|
74
|
|
|
|
|
|
|
} |
|
75
|
|
|
|
|
|
|
otherwise { |
|
76
|
0
|
|
|
0
|
|
|
my $e = shift; |
|
77
|
0
|
|
|
|
|
|
$self->exception($e); |
|
78
|
0
|
|
|
|
|
|
}; |
|
79
|
|
|
|
|
|
|
|
|
80
|
0
|
|
|
|
|
|
$self->{'output'}->print( $self->{'tables'}->asString() ); |
|
81
|
|
|
|
|
|
|
} |
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
sub exception { |
|
84
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
|
85
|
0
|
|
|
|
|
|
my ($exception) = @_; |
|
86
|
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
# $self->{'tables'} = new Parse("Unable to parse input. Input ignored.", undef); |
|
88
|
|
|
|
|
|
|
# $self->{'fixture'}->exception($self->{'tables'}, $exception); |
|
89
|
|
|
|
|
|
|
|
|
90
|
0
|
|
|
|
|
|
print $exception; |
|
91
|
0
|
|
|
|
|
|
exit(-1); |
|
92
|
|
|
|
|
|
|
} |
|
93
|
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
sub _exit { |
|
95
|
0
|
|
|
0
|
|
|
my ($self) = @_; |
|
96
|
0
|
|
|
|
|
|
$self->{'output'}->close(); |
|
97
|
0
|
|
|
|
|
|
my $counts = $self->{fixture}->{counts}; |
|
98
|
0
|
|
|
|
|
|
print STDERR $counts->toString(), "\n"; |
|
99
|
0
|
|
|
|
|
|
exit( $counts->{wrong} + $counts->{exceptions} ); |
|
100
|
|
|
|
|
|
|
} |
|
101
|
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
1; |
|
103
|
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
__END__ |