Skip to content

Commit 6219f6e

Browse files
Add Test for Matrix, Fix Scoreboard Typo
1 parent 0fe28df commit 6219f6e

File tree

10 files changed

+78
-40
lines changed

10 files changed

+78
-40
lines changed

.github/workflows/tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,6 @@ jobs:
1717
- name: Install Perl dependencies
1818
run: |
1919
sudo apt-get update
20-
sudo apt-get install libwww-perl
20+
sudo apt-get install libwww-perl libfile-copy-recursive-perl
2121
- name: Run Tests
2222
run: perl run_tests.pl

common/betterparser.pm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use File::Basename;
1111
use POSIX qw(strftime);
1212
use B qw(perlstring);
1313

14-
use utility::common;
14+
use common::utility;
1515

1616
##############################################################################
1717
# Constructor

common/prettify.pm

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -974,7 +974,6 @@ sub Subsection ($)
974974
if ($self->{in_tests}) {
975975
my $test = {
976976
name => $name,
977-
extra_name => undef,
978977
result => undef,
979978
time => undef,
980979
subsection => $subsec,
@@ -1008,9 +1007,6 @@ sub Normal ($)
10081007
$test->{time} = $finished->[1];
10091008
$test->{result} = $finished->[2];
10101009
}
1011-
elsif ($line =~ /^The CMake name of this test is "(.*)"/) {
1012-
$test->{extra_name} = $1;
1013-
}
10141010
}
10151011
}
10161012

testmatrix/HTMLScoreboard.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import os
1111
import time
1212
import json
13+
import html
1314
from pathlib import Path
1415
from io import StringIO
1516
from contextlib import contextmanager
@@ -114,8 +115,9 @@ def begin(self):
114115
attrs = self._attrs.copy()
115116
if self._classes:
116117
attrs['class'] = ' '.join(self._classes)
117-
if attrs:
118-
rv += ' ' + ' '.join([f'{k}="{v}"' for k, v in attrs.items()])
118+
for k, v in attrs.items():
119+
v = html.escape(str(v))
120+
rv += f' {k}="{html.escape(v)}"'
119121
return rv + '>'
120122

121123
def end(self):
@@ -124,7 +126,8 @@ def end(self):
124126
def __str__(self):
125127
rv = self.begin()
126128
if self.text is not None:
127-
rv += str(self.text) + self.end()
129+
text = str(self.text) if type(self.text) is Tag else html.escape(str(self.text))
130+
rv += text + self.end()
128131
return rv
129132

130133

testmatrix/matrix.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ window.addEventListener('load', (event) => {
22
document.querySelectorAll('.test_results td').forEach((td) => {
33
var buildn = td.getAttribute('build');
44
var build = build_info[buildn];
5-
console.log(build);
65
if (build) {
76
// Put build name in tooltip
87
td.setAttribute('title', `#${buildn} ${build.name}`);
@@ -18,7 +17,6 @@ window.addEventListener('load', (event) => {
1817
url += 'Full';
1918
}
2019
a.href = `${url}.html#subsection_${test_subsec}`;
21-
// a.textContent = td.textContent;
2220
td.replaceChildren(a);
2321
}
2422
}

testmatrix/matrix.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -135,9 +135,6 @@ def __init__(self, name: str, result: int, time: timedelta, misc=None):
135135
if misc is None:
136136
misc = {}
137137
self.name = name
138-
extra_name = misc.get('extra_name', None)
139-
if extra_name:
140-
self.name += ' ' + misc['extra_name']
141138
self.subsection = misc['subsection']
142139
self.result = result
143140
assert type(time) is timedelta

tests/scoreboard/MultiRun/run_test.pl

Lines changed: 23 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,11 @@
55
use strict;
66
use warnings;
77

8+
use File::Path qw(make_path remove_tree);
89
use FindBin;
10+
11+
use File::Copy::Recursive qw(dircopy fcopy);
12+
913
use constant autobuild_root => "$FindBin::Bin/../../../";
1014
$ENV{'PATH'} = "$ENV{'PATH'}:" . autobuild_root;
1115
use lib autobuild_root;
@@ -14,38 +18,30 @@
1418
use common::utility;
1519
use common::test_utils;
1620

17-
use File::Path qw(make_path remove_tree);
18-
1921
my $runs = "runs";
2022
my $run = "$runs/run";
2123
my $run1 = "$runs/run1";
2224
my $run2 = "$runs/run2";
2325

2426
sub run_cmd {
25-
my $cmd = shift;
26-
print "$cmd\n";
27-
return system($cmd);
28-
}
29-
30-
sub copy_to ($;$) {
31-
my $des_dir = shift;
32-
my $src_dir = shift // $run;
33-
run_cmd("cp -R $src_dir $des_dir");
27+
my $cmd = shift();
28+
print("RUN: $cmd\n");
29+
die() if (!utility::run_command($cmd));
3430
}
3531

3632
sub run_scoreboard {
37-
run_cmd("scoreboard.pl -c -f ./test.xml -o test.html -d $run");
33+
run_cmd("scoreboard.pl -c -f ./runs/test.xml -o test.html -d $run");
3834
}
3935

4036
sub compare_runs {
41-
my $r = 0;
42-
my $index = "build1/index.html";
43-
my $total = "build3/2021_03_09_17_33_Totals.html";
44-
$r += compare_files("$run1/$index", "$run2/$index");
45-
$r += compare_files("$run1/$index", "$run/$index");
46-
$r += compare_files("$run1/$total", "$run2/$total");
47-
$r += compare_files("$run1/$total", "$run/$total");
48-
return $r;
37+
my $r = 0;
38+
my $index = "build1/index.html";
39+
my $total = "build3/2021_03_09_17_33_Totals.html";
40+
$r += compare_files("$run1/$index", "$run2/$index");
41+
$r += compare_files("$run1/$index", "$run/$index");
42+
$r += compare_files("$run1/$total", "$run2/$total");
43+
$r += compare_files("$run1/$total", "$run/$total");
44+
return $r;
4945
}
5046

5147
remove_tree($runs);
@@ -55,21 +51,22 @@ sub compare_runs {
5551
}
5652

5753
make_path($runs);
58-
copy_to($run, "../build_logs");
54+
fcopy("../build_logs/test.xml", $runs);
55+
dircopy("../build_logs", $run);
5956

6057
run_scoreboard();
61-
copy_to($run1);
6258

59+
dircopy($run, $run1);
6360
run_scoreboard();
64-
copy_to($run2);
6561

62+
dircopy($run, $run2);
6663
run_scoreboard();
67-
my $exit_status = compare_runs();
6864

65+
my $exit_status = compare_runs();
6966
if ($exit_status) {
70-
print("Test Failed\n");
67+
print("Test Failed\n");
7168
}
7269
else {
73-
print("Test Passed\n");
70+
print("Test Passed\n");
7471
}
7572
exit ($exit_status);
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
<scoreboard>
2+
<prop matrix_title="This title has &lt;HTML&gt; entities &quot;&lt;"/>
3+
<prop matrix_basename="test"/>
4+
<prop source_link="https://github.com/OpenDDS/OpenDDS/blob/master/"/>
5+
26
<group>
37
<name>Group 1</name>
48
<build>

tests/scoreboard/matrix/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/builds
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
eval '(exit $?0)' && eval 'exec perl -S $0 ${1+"$@"}'
2+
& eval 'exec perl -S $0 $argv:q'
3+
if 0;
4+
5+
use strict;
6+
use warnings;
7+
8+
use File::Path qw(make_path remove_tree);
9+
use FindBin;
10+
11+
use File::Copy::Recursive qw(dircopy);
12+
13+
use constant scoreboard_tests => "$FindBin::Bin/../";
14+
use constant build_logs => scoreboard_tests . "build_logs/";
15+
use constant autobuild_root => scoreboard_tests . "../../";
16+
$ENV{'PATH'} = "$ENV{'PATH'}:" . autobuild_root;
17+
use lib autobuild_root;
18+
chdir ($FindBin::Bin);
19+
20+
use common::utility;
21+
use common::test_utils;
22+
23+
sub run_cmd {
24+
my $cmd = shift();
25+
print("RUN: $cmd\n");
26+
die() if (!utility::run_command($cmd));
27+
}
28+
29+
sub run_scoreboard {
30+
my $dest = shift() // 'builds';
31+
my $src = shift() // build_logs;
32+
33+
my $name = 'test';
34+
my $xml = "$src/$name.xml";
35+
my $html = "$name.html";
36+
remove_tree($dest);
37+
dircopy($src, $dest);
38+
run_cmd("scoreboard.pl -c -f $xml -o $html -d $dest");
39+
}
40+
41+
run_scoreboard();
42+
run_cmd("matrix.py builds");

0 commit comments

Comments
 (0)