Skip to content

Commit

Permalink
Improvements to Test Matrix
Browse files Browse the repository at this point in the history
- Status box links to output of tests
- Test name links to source code
- Add skip counts
- Add time

- Also:
    - Control header name of index page in scoreboard.pl
    - Don't exit with status on with -i or -z options of scoreboard.pl
  • Loading branch information
iguessthislldo committed Sep 16, 2024
1 parent 570196c commit 0fe28df
Show file tree
Hide file tree
Showing 13 changed files with 610 additions and 592 deletions.
15 changes: 4 additions & 11 deletions common/betterparser.pm
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ use File::Basename;
use POSIX qw(strftime);
use B qw(perlstring);

use utility::common;

##############################################################################
# Constructor
#
Expand Down Expand Up @@ -1456,15 +1458,6 @@ sub DealWithCommandTag ($$$$$\%)
}
}

# Replace XML Entity References
sub replace_entities ($) {
my $str = shift;
$str =~ s/&lt;/</g;
$str =~ s/&gt;/>/g;
$str =~ s/&amp;/&/g;
return $str;
}

###############################################################################
# Parse
# This attempts to find each of the XML tags within the file and process them.
Expand Down Expand Up @@ -1518,7 +1511,7 @@ sub Parse ($$\%)
$preMode = 0;
}
else {
$preModeText .= replace_entities($_);
$preModeText .= utility::replace_entities($_);
next;
}
}
Expand Down Expand Up @@ -1631,7 +1624,7 @@ sub Parse ($$\%)
if ($inputFromFile =~
s/^<\s*(?:[^>"]*(?:"(?:[^"\\]*(?:\\(?:0?[xX][[:xdigit:]]{0,2}|0[0-2]?[0-7]{0,2}|.))*)*")*)*>//) {
if ($tag =~ /<[^<>]+>(.*)<[^<>]+>/) {
$same_line_tag_contents = replace_entities($1);
$same_line_tag_contents = utility::replace_entities($1);
}

# OK, we have found a valid closing tag (the >) character. We need to
Expand Down
16 changes: 10 additions & 6 deletions common/indexparser.pm
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@

package IndexParser;

use strict;
use warnings;

use FileHandle;

use common::utility;

###############################################################################
# Constructor

Expand All @@ -26,7 +27,8 @@ sub Parse ($)
{
my $self = shift;
my $file = shift;
my $group_name;
my $preamble = shift;
my $props = shift;

my $file_handle = new FileHandle ($file, 'r');

Expand Down Expand Up @@ -54,7 +56,7 @@ sub Parse ($)
next if (m/^\s*$/);

if(m/<preamble>/) {
$main::preamble = $self->parse_preamble($file_handle);
${$preamble} = $self->parse_preamble($file_handle);
next;
}

Expand All @@ -74,6 +76,8 @@ sub Parse ($)
if (m/^\s*<\/intropage>\s*$/i) {
$state = 'none';
}
elsif (utility::parse_prop($_, $props)) {
}
else {
print STDERR "Error: Unexpected in state <$state>: $_\n";
return 0;
Expand Down Expand Up @@ -111,7 +115,7 @@ sub parse_comment($\@)
while(1){
$ch = $result->getc();

# determine if we have hit an EOF or not
# determine if we have hit an EOF or not
if( ! defined $ch) {
last; # break out of the whlie loop
}
Expand All @@ -128,7 +132,7 @@ sub parse_comment($\@)
if($tag eq "-->") {
last; # break out of the while loop
}

# Pop off the first element of the array and shift everything up
shift(@c);
$i=1;
Expand Down Expand Up @@ -160,7 +164,7 @@ sub parse_preamble($\@)
while(1){
$ch = $result->getc();

# determine if we have hit an EOF or not
# determine if we have hit an EOF or not
if( ! defined $ch) {
last; # break out of the whlie loop
}
Expand Down
4 changes: 4 additions & 0 deletions common/prettify.pm
Original file line number Diff line number Diff line change
Expand Up @@ -927,6 +927,7 @@ sub new ($)
in_test => undef,
in_tests => 0,
data => {
subsection_count => 0,
buildname => $buildname,
basename => $basename,
tests => [],
Expand Down Expand Up @@ -967,13 +968,16 @@ sub Subsection ($)
my $self = shift ();
my $name = shift ();

my $subsec = $self->{data}->{subsection_count} += 1;

$self->{in_test} = undef;
if ($self->{in_tests}) {
my $test = {
name => $name,
extra_name => undef,
result => undef,
time => undef,
subsection => $subsec,
};
$self->{in_test} = $test;
push(@{$self->{data}->{tests}}, $test);
Expand Down
11 changes: 9 additions & 2 deletions common/scoreparser.pm
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ use warnings;

use FileHandle;

use common::utility;

###############################################################################
# Constructor

Expand All @@ -28,9 +30,10 @@ sub Parse ($\@)
my $file = shift;
my $data = shift;
my $order = shift;
my $props = shift ();

my $group_name;
my %build_info;
my %build_info = (props=>{});

my $file_handle = new FileHandle ($file, 'r');

Expand Down Expand Up @@ -80,6 +83,8 @@ sub Parse ($\@)
if (m/^\s*<\/scoreboard>\s*$/i) {
$state = 'none';
}
elsif (utility::parse_prop ($_, $props)) {
}
elsif (m/^\s*<group>\s*$/i) {
$state = 'group';
}
Expand Down Expand Up @@ -116,7 +121,7 @@ sub Parse ($\@)
$build_info{GROUP} = $group_name;

%{$data->{$build_info{NAME}}} = %build_info;
%build_info = ();
%build_info = (props=>{});

$state = 'group';
}
Expand Down Expand Up @@ -171,6 +176,8 @@ sub Parse ($\@)
elsif (m/^\s*<cache\/>\s*$/i) {
$build_info{CACHE} = 1;
}
elsif (parse_prop ($_, $build_info{props})) {
}
else {
print STDERR "Error: $lineno: Unexpected in state <$state>: $_\n";
return 0;
Expand Down
30 changes: 29 additions & 1 deletion common/utility.pm
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ use warnings;
package utility;

use File::Path qw(rmtree);

use JSON::PP;

sub obj_to_json
Expand Down Expand Up @@ -238,4 +237,33 @@ sub remove_tree ($)
return 1;
}

sub replace_entities
{
my $str = shift ();

$str =~ s/&quot;/"/g;
$str =~ s/&apos;/'/g;
$str =~ s/&lt;/</g;
$str =~ s/&gt;/>/g;
$str =~ s/&amp;/&/g;

return $str;
}

sub parse_prop
{
my $line = shift ();
my $props = shift ();

if ($line =~ m/^\s*<prop\s+(\w+)="([^"]*)"\s*\/>\s*$/i) {
if (defined ($props)) {
my $name = $1;
my $value = replace_entities ($2);
$props->{$name} = $value
}
return 1;
}
return 0;
}

1;
11 changes: 11 additions & 0 deletions docs/scoreboard.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,14 @@ Within each group, there can be an unlimited number of builds. Each build
is defined with the <build> element which contains a <name>, a <url>, and an
optional <build_sponsor> and <build_sponsor_url>. The <url> specifies where
the log files, from the autobuild.pl script, are located.

<prop NAME="VALUE"/> elements can be used to provide additonal optional
properties in XML files:
- Index XML file
- <intropage>
- title: Override the default header
- Scoreboard XML file
- <scoreboard>
- matrix_title: Title of Matrix
- matrix_basename: Prefix for all matrix files
- source_link: URL to view source code
35 changes: 27 additions & 8 deletions matrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,39 @@
from pathlib import Path
import enum

from testmatrix.HTMLScoreboard import write_html_matrix
from testmatrix.matrix import Builds, Matrix
from testmatrix import Matrix, write_html_files


def opt_or_prop(matrix, args, name):
opt = getattr(args, name)
if opt is not None:
return opt
prop_name = f'matrix_{name}'
if prop_name in matrix.props:
return matrix.props[prop_name]
sys.exit(f'Need to either pass --{name} VALUE or define <prop {prop_name}="VALUE"/> in the '
'scoreboard XML file.')


if __name__ == '__main__':
arg_parser = argparse.ArgumentParser(
description='Generate a test status matrix from autobuild output')
description='Generates a test status matrix from autobuild output.')
arg_parser.add_argument('builds_dir', type=Path,
help='Directory with autobuild/scoreboard build contents')
arg_parser.add_argument('prefix')
help='Directory with the autobuild/scoreboard build contents')
arg_parser.add_argument('--title',
help='Title of the main matrix HTML page. Overrides <prop matrix_title="VALUE"/> in the '
'scoreboard XML files.')
arg_parser.add_argument('--basename',
help='Prefix of all created files. Overrides <prop matrix_basename="VALUE"/> in the '
'scoreboard XML files.')
arg_parser.add_argument('--dump-only', action='store_true',
help='Don\'t create any files, only dump the matrix in the CLI.')
args = arg_parser.parse_args()

builds = Builds(args.builds_dir)
matrix = Matrix(builds)
matrix = Matrix(args.builds_dir)
matrix.dump()

write_html_matrix(matrix, args.prefix)
if not args.dump_only:
write_html_files(matrix,
opt_or_prop(matrix, args, 'title'),
opt_or_prop(matrix, args, 'basename'))
Loading

0 comments on commit 0fe28df

Please sign in to comment.