Skip to content

Commit 0fe28df

Browse files
Improvements to Test Matrix
- 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
1 parent 570196c commit 0fe28df

File tree

13 files changed

+610
-592
lines changed

13 files changed

+610
-592
lines changed

common/betterparser.pm

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ use File::Basename;
1111
use POSIX qw(strftime);
1212
use B qw(perlstring);
1313

14+
use utility::common;
15+
1416
##############################################################################
1517
# Constructor
1618
#
@@ -1456,15 +1458,6 @@ sub DealWithCommandTag ($$$$$\%)
14561458
}
14571459
}
14581460

1459-
# Replace XML Entity References
1460-
sub replace_entities ($) {
1461-
my $str = shift;
1462-
$str =~ s/&lt;/</g;
1463-
$str =~ s/&gt;/>/g;
1464-
$str =~ s/&amp;/&/g;
1465-
return $str;
1466-
}
1467-
14681461
###############################################################################
14691462
# Parse
14701463
# This attempts to find each of the XML tags within the file and process them.
@@ -1518,7 +1511,7 @@ sub Parse ($$\%)
15181511
$preMode = 0;
15191512
}
15201513
else {
1521-
$preModeText .= replace_entities($_);
1514+
$preModeText .= utility::replace_entities($_);
15221515
next;
15231516
}
15241517
}
@@ -1631,7 +1624,7 @@ sub Parse ($$\%)
16311624
if ($inputFromFile =~
16321625
s/^<\s*(?:[^>"]*(?:"(?:[^"\\]*(?:\\(?:0?[xX][[:xdigit:]]{0,2}|0[0-2]?[0-7]{0,2}|.))*)*")*)*>//) {
16331626
if ($tag =~ /<[^<>]+>(.*)<[^<>]+>/) {
1634-
$same_line_tag_contents = replace_entities($1);
1627+
$same_line_tag_contents = utility::replace_entities($1);
16351628
}
16361629

16371630
# OK, we have found a valid closing tag (the >) character. We need to

common/indexparser.pm

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
21
package IndexParser;
32

43
use strict;
54
use warnings;
65

76
use FileHandle;
87

8+
use common::utility;
9+
910
###############################################################################
1011
# Constructor
1112

@@ -26,7 +27,8 @@ sub Parse ($)
2627
{
2728
my $self = shift;
2829
my $file = shift;
29-
my $group_name;
30+
my $preamble = shift;
31+
my $props = shift;
3032

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

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

5658
if(m/<preamble>/) {
57-
$main::preamble = $self->parse_preamble($file_handle);
59+
${$preamble} = $self->parse_preamble($file_handle);
5860
next;
5961
}
6062

@@ -74,6 +76,8 @@ sub Parse ($)
7476
if (m/^\s*<\/intropage>\s*$/i) {
7577
$state = 'none';
7678
}
79+
elsif (utility::parse_prop($_, $props)) {
80+
}
7781
else {
7882
print STDERR "Error: Unexpected in state <$state>: $_\n";
7983
return 0;
@@ -111,7 +115,7 @@ sub parse_comment($\@)
111115
while(1){
112116
$ch = $result->getc();
113117

114-
# determine if we have hit an EOF or not
118+
# determine if we have hit an EOF or not
115119
if( ! defined $ch) {
116120
last; # break out of the whlie loop
117121
}
@@ -128,7 +132,7 @@ sub parse_comment($\@)
128132
if($tag eq "-->") {
129133
last; # break out of the while loop
130134
}
131-
135+
132136
# Pop off the first element of the array and shift everything up
133137
shift(@c);
134138
$i=1;
@@ -160,7 +164,7 @@ sub parse_preamble($\@)
160164
while(1){
161165
$ch = $result->getc();
162166

163-
# determine if we have hit an EOF or not
167+
# determine if we have hit an EOF or not
164168
if( ! defined $ch) {
165169
last; # break out of the whlie loop
166170
}

common/prettify.pm

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -927,6 +927,7 @@ sub new ($)
927927
in_test => undef,
928928
in_tests => 0,
929929
data => {
930+
subsection_count => 0,
930931
buildname => $buildname,
931932
basename => $basename,
932933
tests => [],
@@ -967,13 +968,16 @@ sub Subsection ($)
967968
my $self = shift ();
968969
my $name = shift ();
969970

971+
my $subsec = $self->{data}->{subsection_count} += 1;
972+
970973
$self->{in_test} = undef;
971974
if ($self->{in_tests}) {
972975
my $test = {
973976
name => $name,
974977
extra_name => undef,
975978
result => undef,
976979
time => undef,
980+
subsection => $subsec,
977981
};
978982
$self->{in_test} = $test;
979983
push(@{$self->{data}->{tests}}, $test);

common/scoreparser.pm

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ use warnings;
66

77
use FileHandle;
88

9+
use common::utility;
10+
911
###############################################################################
1012
# Constructor
1113

@@ -28,9 +30,10 @@ sub Parse ($\@)
2830
my $file = shift;
2931
my $data = shift;
3032
my $order = shift;
33+
my $props = shift ();
3134

3235
my $group_name;
33-
my %build_info;
36+
my %build_info = (props=>{});
3437

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

@@ -80,6 +83,8 @@ sub Parse ($\@)
8083
if (m/^\s*<\/scoreboard>\s*$/i) {
8184
$state = 'none';
8285
}
86+
elsif (utility::parse_prop ($_, $props)) {
87+
}
8388
elsif (m/^\s*<group>\s*$/i) {
8489
$state = 'group';
8590
}
@@ -116,7 +121,7 @@ sub Parse ($\@)
116121
$build_info{GROUP} = $group_name;
117122

118123
%{$data->{$build_info{NAME}}} = %build_info;
119-
%build_info = ();
124+
%build_info = (props=>{});
120125

121126
$state = 'group';
122127
}
@@ -171,6 +176,8 @@ sub Parse ($\@)
171176
elsif (m/^\s*<cache\/>\s*$/i) {
172177
$build_info{CACHE} = 1;
173178
}
179+
elsif (parse_prop ($_, $build_info{props})) {
180+
}
174181
else {
175182
print STDERR "Error: $lineno: Unexpected in state <$state>: $_\n";
176183
return 0;

common/utility.pm

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ use warnings;
44
package utility;
55

66
use File::Path qw(rmtree);
7-
87
use JSON::PP;
98

109
sub obj_to_json
@@ -238,4 +237,33 @@ sub remove_tree ($)
238237
return 1;
239238
}
240239

240+
sub replace_entities
241+
{
242+
my $str = shift ();
243+
244+
$str =~ s/&quot;/"/g;
245+
$str =~ s/&apos;/'/g;
246+
$str =~ s/&lt;/</g;
247+
$str =~ s/&gt;/>/g;
248+
$str =~ s/&amp;/&/g;
249+
250+
return $str;
251+
}
252+
253+
sub parse_prop
254+
{
255+
my $line = shift ();
256+
my $props = shift ();
257+
258+
if ($line =~ m/^\s*<prop\s+(\w+)="([^"]*)"\s*\/>\s*$/i) {
259+
if (defined ($props)) {
260+
my $name = $1;
261+
my $value = replace_entities ($2);
262+
$props->{$name} = $value
263+
}
264+
return 1;
265+
}
266+
return 0;
267+
}
268+
241269
1;

docs/scoreboard.txt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,14 @@ Within each group, there can be an unlimited number of builds. Each build
1212
is defined with the <build> element which contains a <name>, a <url>, and an
1313
optional <build_sponsor> and <build_sponsor_url>. The <url> specifies where
1414
the log files, from the autobuild.pl script, are located.
15+
16+
<prop NAME="VALUE"/> elements can be used to provide additonal optional
17+
properties in XML files:
18+
- Index XML file
19+
- <intropage>
20+
- title: Override the default header
21+
- Scoreboard XML file
22+
- <scoreboard>
23+
- matrix_title: Title of Matrix
24+
- matrix_basename: Prefix for all matrix files
25+
- source_link: URL to view source code

matrix.py

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,39 @@
66
from pathlib import Path
77
import enum
88

9-
from testmatrix.HTMLScoreboard import write_html_matrix
10-
from testmatrix.matrix import Builds, Matrix
9+
from testmatrix import Matrix, write_html_files
10+
11+
12+
def opt_or_prop(matrix, args, name):
13+
opt = getattr(args, name)
14+
if opt is not None:
15+
return opt
16+
prop_name = f'matrix_{name}'
17+
if prop_name in matrix.props:
18+
return matrix.props[prop_name]
19+
sys.exit(f'Need to either pass --{name} VALUE or define <prop {prop_name}="VALUE"/> in the '
20+
'scoreboard XML file.')
1121

1222

1323
if __name__ == '__main__':
1424
arg_parser = argparse.ArgumentParser(
15-
description='Generate a test status matrix from autobuild output')
25+
description='Generates a test status matrix from autobuild output.')
1626
arg_parser.add_argument('builds_dir', type=Path,
17-
help='Directory with autobuild/scoreboard build contents')
18-
arg_parser.add_argument('prefix')
27+
help='Directory with the autobuild/scoreboard build contents')
28+
arg_parser.add_argument('--title',
29+
help='Title of the main matrix HTML page. Overrides <prop matrix_title="VALUE"/> in the '
30+
'scoreboard XML files.')
31+
arg_parser.add_argument('--basename',
32+
help='Prefix of all created files. Overrides <prop matrix_basename="VALUE"/> in the '
33+
'scoreboard XML files.')
34+
arg_parser.add_argument('--dump-only', action='store_true',
35+
help='Don\'t create any files, only dump the matrix in the CLI.')
1936
args = arg_parser.parse_args()
2037

21-
builds = Builds(args.builds_dir)
22-
matrix = Matrix(builds)
38+
matrix = Matrix(args.builds_dir)
2339
matrix.dump()
2440

25-
write_html_matrix(matrix, args.prefix)
41+
if not args.dump_only:
42+
write_html_files(matrix,
43+
opt_or_prop(matrix, args, 'title'),
44+
opt_or_prop(matrix, args, 'basename'))

0 commit comments

Comments
 (0)