Author: earle
Date: 2008-01-30 18:16:57 +0000 (Wed, 30 Jan 2008)
New Revision: 1150
Modified:
status/report.pl
status/templates/tests.tt
Log:
Tabular output.
Modified: status/report.pl
===================================================================
--- status/report.pl 2008-01-30 17:06:49 UTC (rev 1149)
+++ status/report.pl 2008-01-30 18:16:57 UTC (rev 1150)
@@ -6,33 +6,56 @@
use Data::Dumper;
use Template;
-my $file = $ARGV[0];
+my (%results, %test_names);
-die 'No input file specified' unless $file;
-die "That file doesn't exist" unless -e $file;
-die "That isn't a plain file" unless -f _;
-die "That file isn't readable" unless -r _;
+foreach (glob "reports/*") {
+ my ($report_name) = $_ =~ m{reports/test-results-(.*)\.txt};
+
+ $results{$report_name} = load_report($_);
+}
-open (my $RESULTS, '<', $file) or die "Can't open $file: $!";
-my @lines = <$RESULTS>;
-close $RESULTS;
+my %report_data = (
+ 'results' => \%results,
+ 'test_names' => [ sort keys %test_names ],
+);
-my (%tests, $current_test);
-
-foreach (@lines) {
- chomp;
-
- if (m{^t/(.*?)\.}) {
- $current_test = $1;
- } elsif (/^ok$/) {
- $tests{$current_test} = 100;
- } elsif (/Failed .*? tests, (.*?)% okay/) {
- $tests{$current_test} = $1;
- }
-}
-
my $tt = Template->new({
INCLUDE_PATH => 'templates',
});
-$tt->process('tests.tt', { 'tests' => \%tests }) or die $tt->error;
\ No newline at end of file
+$tt->process('tests.tt', { 'data' => \%report_data }) or die $tt->error;
+
+# ----------------------------------------------------------------------------
+
+sub load_report {
+ my $file = shift;
+
+ die 'No input file specified' unless $file;
+ die "That file doesn't exist" unless -e $file;
+ die "That isn't a plain file" unless -f _;
+ die "That file isn't readable" unless -r _;
+
+ open (my $RESULTS, '<', $file) or die "Can't open $file: $!";
+ my @lines = <$RESULTS>;
+ close $RESULTS;
+
+ my (%tests, $current_test);
+
+ # XXX: Test files get added, removed, renamed, etc. A mechanism is necessary
+ # here to cope with this.
+
+ foreach (@lines) {
+ chomp;
+
+ if (m{^t/(.*?)\.}) {
+ $current_test = $1;
+ $test_names{$current_test} = 1;
+ } elsif (/^ok$/) {
+ $tests{$current_test} = 100;
+ } elsif (/Failed .*? tests, (.*?)% okay/) {
+ $tests{$current_test} = $1;
+ }
+ }
+
+ \%tests;
+}
Modified: status/templates/tests.tt
===================================================================
--- status/templates/tests.tt 2008-01-30 17:06:49 UTC (rev 1149)
+++ status/templates/tests.tt 2008-01-30 18:16:57 UTC (rev 1150)
@@ -13,16 +13,28 @@
.pass {
background: #3c3;
}
+</style>
</head>
<body>
<h1>Test Results</h1>
-<table>
-[% FOREACH test IN tests.keys.sort %]
+
+<table border="1">
<tr>
- <td>[% test %]</td>
- <td>[% tests.$test %]%</td>
+ <td></td>
+[% FOREACH test_name IN data.test_names %]
+ <th>[% test_name.replace('_', ' ') %]</th>
+[%- END %]
</tr>
-[% END %]
+[% FOREACH test_date IN data.results.keys %]
+[% day_results = data.results.$test_date %]
+ <tr>
+ <td>[% test_date %]</td>
+ [% FOREACH datum IN day_results.keys.sort %]
+ <td>[% day_results.$datum %]%</td>
+ [% END %]
+ </tr>
+[%- END %]
</table>
+
</body>
</html>
\ No newline at end of file