Skip to content

Commit 570196c

Browse files
Rewrite Most the Python Matrix
The old code relied on parsing the autobuild output like the scoreboard, but because it's a different parser it can have different results. It now uses JSON output from scoreboard to get all of the information it needs. Also completely-removed database parts and anything that doesn't look useful anymore.
1 parent 14f2808 commit 570196c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+598
-2399
lines changed

common/prettify.pm

Lines changed: 119 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,15 @@ sub escape_html_entities_keep_headers_and_links
2323
return $s;
2424
}
2525

26+
sub parse_art_finished
27+
{
28+
if (shift() =~ /^auto_run_tests_finished: (.*) Time:(\d+)s\s+Result:([-\d]+)/)
29+
{
30+
return [$1, $2 + 0, $3 + 0];
31+
}
32+
return undef;
33+
}
34+
2635
###############################################################################
2736
###############################################################################
2837

@@ -883,10 +892,11 @@ sub Normal ($)
883892
return unless defined $test;
884893
my $separator = '=' x 78 . "\n";
885894

886-
if ($line =~ /^auto_run_tests_finished: .*Time:(\d+)s\s+Result:([-\d]+)/)
895+
my $finished = Prettify::parse_art_finished($line);
896+
if ($finished)
887897
{
888-
$test->{TIME} = $1;
889-
$test->{RESULT} = $2;
898+
$test->{TIME} = $finished->[1];
899+
$test->{RESULT} = $finished->[2];
890900
}
891901
elsif ($line ne $separator)
892902
{
@@ -896,6 +906,110 @@ sub Normal ($)
896906
}
897907

898908

909+
###############################################################################
910+
###############################################################################
911+
912+
package Prettify::BuildJson;
913+
914+
use strict;
915+
use warnings;
916+
917+
###############################################################################
918+
919+
sub new ($)
920+
{
921+
my $proto = shift ();
922+
my $class = ref ($proto) || $proto;
923+
my $buildname = shift ();
924+
my $basename = shift ();
925+
926+
return bless ({
927+
in_test => undef,
928+
in_tests => 0,
929+
data => {
930+
buildname => $buildname,
931+
basename => $basename,
932+
tests => [],
933+
},
934+
}, $class);
935+
}
936+
937+
sub Header ()
938+
{
939+
}
940+
941+
sub Footer ()
942+
{
943+
my $self = shift ();
944+
945+
utility::write_obj_to_json ("$self->{data}->{basename}.build.json", $self->{data});
946+
}
947+
948+
sub Section ($)
949+
{
950+
my $self = shift ();
951+
my $name = shift ();
952+
953+
$self->{in_tests} = $name eq 'Test';
954+
$self->{in_test} = undef;
955+
}
956+
957+
sub Description ($)
958+
{
959+
}
960+
961+
sub Timestamp ($)
962+
{
963+
}
964+
965+
sub Subsection ($)
966+
{
967+
my $self = shift ();
968+
my $name = shift ();
969+
970+
$self->{in_test} = undef;
971+
if ($self->{in_tests}) {
972+
my $test = {
973+
name => $name,
974+
extra_name => undef,
975+
result => undef,
976+
time => undef,
977+
};
978+
$self->{in_test} = $test;
979+
push(@{$self->{data}->{tests}}, $test);
980+
}
981+
}
982+
983+
sub Error ($)
984+
{
985+
my $self = shift ();
986+
my $line = shift ();
987+
}
988+
989+
sub Warning ($)
990+
{
991+
my $self = shift ();
992+
my $line = shift ();
993+
}
994+
995+
sub Normal ($)
996+
{
997+
my $self = shift ();
998+
my $line = shift ();
999+
1000+
my $test = $self->{in_test};
1001+
if ($test) {
1002+
my $finished = Prettify::parse_art_finished($line);
1003+
if ($finished) {
1004+
$test->{time} = $finished->[1];
1005+
$test->{result} = $finished->[2];
1006+
}
1007+
elsif ($line =~ /^The CMake name of this test is "(.*)"/) {
1008+
$test->{extra_name} = $1;
1009+
}
1010+
}
1011+
}
1012+
8991013
###############################################################################
9001014
###############################################################################
9011015

@@ -1319,6 +1433,8 @@ sub new ($$$$$$$$)
13191433
push @{$self->{OUTPUT}}, new Prettify::JUnit ($junit);
13201434
}
13211435

1436+
push @{$self->{OUTPUT}}, new Prettify::BuildJson ($buildname, $basename);
1437+
13221438
# Output the header for the files
13231439
foreach my $output (@{$self->{OUTPUT}}) {
13241440
unless ($output) {

common/utility.pm

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,23 @@ package utility;
55

66
use File::Path qw(rmtree);
77

8+
use JSON::PP;
9+
10+
sub obj_to_json
11+
{
12+
return JSON::PP->new->pretty(1)->utf8->encode(shift());
13+
}
14+
15+
sub write_obj_to_json
16+
{
17+
my $path = shift();
18+
my $obj = shift();
19+
20+
open(my $f, '>', $path) or die("Failed to open $path: $!");
21+
print $f (obj_to_json($obj));
22+
close($f);
23+
}
24+
825
# Run command, returns 0 if there was an error. If the second argument is
926
# passed, it's assumed to be an autobuild command result hashref and "failure"
1027
# will be set to "fatal" if it is a total failure is fatal and "non-fatal" if

matrix.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/usr/bin/env python3
2+
3+
import sys
4+
import argparse
5+
import json
6+
from pathlib import Path
7+
import enum
8+
9+
from testmatrix.HTMLScoreboard import write_html_matrix
10+
from testmatrix.matrix import Builds, Matrix
11+
12+
13+
if __name__ == '__main__':
14+
arg_parser = argparse.ArgumentParser(
15+
description='Generate a test status matrix from autobuild output')
16+
arg_parser.add_argument('builds_dir', type=Path,
17+
help='Directory with autobuild/scoreboard build contents')
18+
arg_parser.add_argument('prefix')
19+
args = arg_parser.parse_args()
20+
21+
builds = Builds(args.builds_dir)
22+
matrix = Matrix(builds)
23+
matrix.dump()
24+
25+
write_html_matrix(matrix, args.prefix)

matrix_database/CompilationDB.py

Lines changed: 0 additions & 157 deletions
This file was deleted.

matrix_database/CompilationDBFileHandle.py

Lines changed: 0 additions & 15 deletions
This file was deleted.

0 commit comments

Comments
 (0)