Changeset 1150


Ignore:
Timestamp:
Jan 30, 2008, 6:16:57 PM (14 years ago)
Author:
Earle Martin
Message:

Tabular output.

Location:
status
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • status/report.pl

    r1149 r1150  
    77use Template;
    88
    9 my $file = $ARGV[0];
     9my (%results, %test_names);
    1010
    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 _;
     11foreach (glob "reports/*") {
     12        my ($report_name) = $_ =~ m{reports/test-results-(.*)\.txt};
     13       
     14        $results{$report_name} = load_report($_);
     15}
    1516
    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 }
     17my %report_data = (
     18        'results'    => \%results,
     19        'test_names' => [ sort keys %test_names ],
     20);
    3321
    3422my $tt = Template->new({
     
    3624});
    3725
    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
     30sub 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  
    1414        background: #3c3;
    1515}
     16</style>
    1617</head>
    1718<body>
    1819<h1>Test Results</h1>
    19 <table>
    20 [% FOREACH test IN tests.keys.sort %]
     20
     21<table border="1">
    2122        <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 %]
    2427        </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 %]
    2637</table>
     38
    2739</body>
    2840</html>
Note: See TracChangeset for help on using the changeset viewer.