- Timestamp:
- 01/30/08 18:16:57 (12 months ago)
- Location:
- status
- Files:
-
- 2 modified
-
report.pl (modified) (2 diffs)
-
templates/tests.tt (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
status/report.pl
r1149 r1150 7 7 use Template; 8 8 9 my $file = $ARGV[0];9 my (%results, %test_names); 10 10 11 die 'No input file specified' unless $file; 12 die "That file doesn't exist" unless -e $file; 13 die "That isn't a plain file" unless -f _; 14 die "That file isn't readable" unless -r _; 11 foreach (glob "reports/*") { 12 my ($report_name) = $_ =~ m{reports/test-results-(.*)\.txt}; 13 14 $results{$report_name} = load_report($_); 15 } 15 16 16 open (my $RESULTS, '<', $file) or die "Can't open $file: $!"; 17 my @lines = <$RESULTS>; 18 close $RESULTS; 19 20 my (%tests, $current_test); 21 22 foreach (@lines) { 23 chomp; 24 25 if (m{^t/(.*?)\.}) { 26 $current_test = $1; 27 } elsif (/^ok$/) { 28 $tests{$current_test} = 100; 29 } elsif (/Failed .*? tests, (.*?)% okay/) { 30 $tests{$current_test} = $1; 31 } 32 } 17 my %report_data = ( 18 'results' => \%results, 19 'test_names' => [ sort keys %test_names ], 20 ); 33 21 34 22 my $tt = Template->new({ … … 36 24 }); 37 25 38 $tt->process('tests.tt', { 'tests' => \%tests }) or die $tt->error; 26 $tt->process('tests.tt', { 'data' => \%report_data }) or die $tt->error; 27 28 # ---------------------------------------------------------------------------- 29 30 sub load_report { 31 my $file = shift; 32 33 die 'No input file specified' unless $file; 34 die "That file doesn't exist" unless -e $file; 35 die "That isn't a plain file" unless -f _; 36 die "That file isn't readable" unless -r _; 37 38 open (my $RESULTS, '<', $file) or die "Can't open $file: $!"; 39 my @lines = <$RESULTS>; 40 close $RESULTS; 41 42 my (%tests, $current_test); 43 44 # XXX: Test files get added, removed, renamed, etc. A mechanism is necessary 45 # here to cope with this. 46 47 foreach (@lines) { 48 chomp; 49 50 if (m{^t/(.*?)\.}) { 51 $current_test = $1; 52 $test_names{$current_test} = 1; 53 } elsif (/^ok$/) { 54 $tests{$current_test} = 100; 55 } elsif (/Failed .*? tests, (.*?)% okay/) { 56 $tests{$current_test} = $1; 57 } 58 } 59 60 \%tests; 61 } -
status/templates/tests.tt
r1148 r1150 14 14 background: #3c3; 15 15 } 16 </style> 16 17 </head> 17 18 <body> 18 19 <h1>Test Results</h1> 19 <table> 20 [% FOREACH test IN tests.keys.sort %] 20 21 <table border="1"> 21 22 <tr> 22 <td>[% test %]</td> 23 <td>[% tests.$test %]%</td> 23 <td></td> 24 [% FOREACH test_name IN data.test_names %] 25 <th>[% test_name.replace('_', ' ') %]</th> 26 [%- END %] 24 27 </tr> 25 [% END %] 28 [% FOREACH test_date IN data.results.keys %] 29 [% day_results = data.results.$test_date %] 30 <tr> 31 <td>[% test_date %]</td> 32 [% FOREACH datum IN day_results.keys.sort %] 33 <td>[% day_results.$datum %]%</td> 34 [% END %] 35 </tr> 36 [%- END %] 26 37 </table> 38 27 39 </body> 28 40 </html>
