Changeset 1150 for status/report.pl
- Timestamp:
- 01/30/08 18:16:57 (10 months ago)
- Files:
-
- 1 modified
-
status/report.pl (modified) (2 diffs)
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 }
