Skip to content

Commit 5c2dbb1

Browse files
authored
Merge pull request DOCGroup#44 from lij-oci/junit_updates
Update JUnit XML Reports
2 parents 3d5d4be + 3728bcb commit 5c2dbb1

2 files changed

Lines changed: 52 additions & 30 deletions

File tree

common/prettify.pm

Lines changed: 36 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ use warnings;
1010

1111
use FileHandle;
1212
use Cwd;
13+
our $path = "";
1314

1415
###############################################################################
1516

@@ -20,6 +21,8 @@ sub new ($)
2021
my $self = {};
2122
my $basename = shift;
2223
my $filename = $basename . "_Full.html";
24+
my $log_root = main::GetVariable('log_root');
25+
$path = ((defined $log_root) ? ($log_root . '/' . $filename) : $filename);
2326
$self->{ERROR_COUNTER} = 0;
2427
$self->{WARNING_COUNTER} = 0;
2528
$self->{SECTION_COUNTER} = 0;
@@ -620,7 +623,6 @@ sub Footer ()
620623
{
621624
my $self = shift;
622625
my $out = $self->{FH};
623-
624626
my $indent = ' ';
625627
print $out $indent, "<testsuite name=\"Autobuild_Tests\" ";
626628
if (defined $self->{TIMESTAMP} and length $self->{TIMESTAMP})
@@ -629,32 +631,30 @@ sub Footer ()
629631
}
630632

631633
my $numtests = @{$self->{TESTS}};
632-
633-
if ($numtests == 0)
634-
{
635-
# Need to insert a dummy testcase to jenkins doesn't think there is
636-
# a failure.
637-
print $out 'tests="1">', "\n", $indent x 2,
638-
'<testcase name="dummy_test"/>', "\n";
634+
if ($numtests > 0) {
635+
print $out "tests=\"$numtests\" failures=\"$self->{FAILED}\" hostname=\"$Prettify::Config_HTML::host\">\n";
639636
}
640-
else
641-
{
642-
print $out "tests=\"$numtests\" failures=\"$self->{FAILED}\">\n";
637+
else { # Insert a dummy testcase so jenkins doesn't think there is a failure.
638+
print $out 'tests="1">', "\n", $indent x 2, '<testcase name="dummy_test"/>', "\n";
643639
}
644640

645-
foreach my $test (@{$self->{TESTS}})
646-
{
647-
my $error = $test->{ERROR} || '';
641+
print $out $indent x 2, "<properties>\n";
642+
foreach my $k (keys %Prettify::commits) {
643+
print $out $indent x 3, "<property name=\"$k\" value=\"$Prettify::commits{$k}\"/>\n";
644+
}
645+
print $out $indent x 3, "<property name=\"log_file\" value=\"$Prettify::Full_HTML::path\"/>\n";
646+
print $out $indent x 2, "</properties>\n";
648647

648+
foreach my $test (@{$self->{TESTS}}) {
649+
my $error = $test->{ERROR} || '';
649650
print $out $indent x 2,
650-
"<testcase name=\"$test->{NAME}\" status=\"$test->{RESULT}\" ",
651-
"time=\"$test->{TIME}\"", ($error eq "" ? "/>\n" : '>');
651+
"<testcase name=\"$test->{NAME}\" status=\"$test->{RESULT}\" ",
652+
"time=\"$test->{TIME}\"", ($error eq "" ? "/>\n" : '>');
652653

653-
if ($error ne "")
654-
{
655-
print $out "<failure>\n", $indent x 3,
656-
"<![CDATA[$error]]></failure><system-out>\n", $indent x 3,
657-
"<![CDATA[$test->{OUT}]]></system-out></testcase>\n";
654+
if ($error ne "") {
655+
print $out "<failure>\n",
656+
$indent x 3, "<![CDATA[$error]]></failure><system-out>\n",
657+
$indent x 3, "<![CDATA[$test->{OUT}]]></system-out></testcase>\n";
658658
}
659659
}
660660

@@ -1117,6 +1117,7 @@ use base qw(common::parse_compiler_output);
11171117
use Data::Dumper;
11181118
use File::Basename;
11191119
use FileHandle;
1120+
our %commits = ();
11201121

11211122
###############################################################################
11221123

@@ -1385,7 +1386,6 @@ sub Normal_Handler ($)
13851386

13861387
sub Setup_Handler ($)
13871388
{
1388-
13891389
my $self = shift;
13901390
my $s = shift;
13911391
if (!defined $s)
@@ -1655,13 +1655,15 @@ sub Config_Handler ($)
16551655
my $revision = $totals->{GIT_REVISIONS}[0];
16561656
print "Matched GIT url to revision $revision\n";
16571657
$totals->{GIT_CHECKEDOUT_ACE} = $revision;
1658+
$commits{'GIT_COMMIT_ACE'} = $revision;
16581659
}
1659-
elsif ($url =~ m/(git|https):\/\/.*\/OpenDDS\.git/i)
1660+
elsif ($url =~ m/(git@|(git|https):\/\/).*\/OpenDDS\.git/i)
16601661
{
16611662
print "Matched GIT url $url\n";
16621663
my $revision = $totals->{GIT_REVISIONS}[0];
16631664
print "Matched GIT url to revision $revision\n";
16641665
$totals->{GIT_CHECKEDOUT_OPENDDS} = $revision;
1666+
$commits{'GIT_COMMIT_OPENDDS'} = $revision;
16651667
if (exists ($self->{OUTPUT}[$self->{FAILED_TESTS_ONLY} ? 0 : 4]))
16661668
{
16671669
(@{$self->{OUTPUT}})[$self->{FAILED_TESTS_ONLY} ? 0 : 4]->{GIT_CHECKEDOUT_OPENDDS} = $revision;
@@ -1929,6 +1931,8 @@ use strict;
19291931
use warnings;
19301932

19311933
use FileHandle;
1934+
our $host = 'localhost';
1935+
my $host_next = 0;
19321936

19331937
sub new ($)
19341938
{
@@ -1976,10 +1980,17 @@ sub Normal ($)
19761980
my $s = shift;
19771981
my $state = shift;
19781982
if (defined $state) {
1979-
$state = lc($state);
1983+
$state = lc($state);
19801984
}
1981-
19821985
if (defined $state && $state eq 'config') {
1986+
if ($host eq 'localhost') {
1987+
if ($host_next == 1) {
1988+
$host = $s;
1989+
}
1990+
elsif ($s eq "<h3>Hostname</h3>") {
1991+
$host_next = 1;
1992+
}
1993+
}
19831994
$s =~ s/</&lt;/g;
19841995
$s =~ s/>/&gt;/g;
19851996
$s =~ s/&lt;\s*(\/?\s*h\d|\/a|a\s*href\s*=\s*\s*"[^"]*")\s*&gt;/<$1>/g;

scoreboard.pl

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@
8080
our $use_local = 0;
8181

8282
our $use_build_logs = 0;
83+
our $junit_xml_output = 0;
8384

8485
our $custom_css = "";
8586

@@ -1590,8 +1591,13 @@ ($$@)
15901591
## for now, implement it as a no-op which returns something which is undefined.
15911592
sub GetVariable ($)
15921593
{
1593-
my %a=();
1594-
return $a{'UNDEFINED'};
1594+
my $v = shift;
1595+
if ($v eq 'junit_xml_output') {
1596+
return $junit_xml_output;
1597+
} else {
1598+
my %a=();
1599+
return $a{'UNDEFINED'};
1600+
}
15951601
}
15961602

15971603
###############################################################################
@@ -1748,14 +1754,14 @@ sub get_time_str
17481754
# be saved by this name and placed in the
17491755
# directory pointed by -d].
17501756

1751-
use vars qw/$opt_b $opt_c $opt_d $opt_f $opt_h $opt_i $opt_o $opt_v $opt_t $opt_z $opt_l $opt_r $opt_s $opt_k $opt_x $opt_j $opt_y $opt_n/;
1757+
use vars qw/$opt_b $opt_c $opt_d $opt_f $opt_h $opt_i $opt_o $opt_v $opt_t $opt_z $opt_l $opt_r $opt_s $opt_k $opt_x $opt_j $opt_y $opt_n $opt_u/;
17521758

1753-
if (!getopts ('bcd:f:hi:o:t:vzlr:s:k:xj:y:n')
1759+
if (!getopts ('bcd:f:hi:o:t:vzlr:s:k:xj:y:n:u')
17541760
|| !defined $opt_d
17551761
|| defined $opt_h) {
17561762
print "scoreboard.pl [-h] -d dir [-v] [-f file] [-i file] [-o file]\n",
17571763
" [-t title] [-z] [-l] [-r file] [-s file] [-c] [-x]\n",
1758-
" [-k num_logs] [-b] [-j filelist] [-y file] [-n]\n";
1764+
" [-k num_logs] [-b] [-j filelist] [-y file] [-n] [-u]\n";
17591765
print "\n";
17601766
print " -h display this help\n";
17611767
print " -d directory where the output files are placed \n";
@@ -1775,6 +1781,7 @@ sub get_time_str
17751781
print " -j comma separated list of input files which for an integrated page has to be generated\n";
17761782
print " -y specify name of file with custom CSS styling";
17771783
print " -n generate build links that open in new tab/window";
1784+
print " -u generate *_JUnit.xml files";
17781785
print " All other options will be ignored \n";
17791786
exit (1);
17801787
}
@@ -1815,6 +1822,10 @@ sub get_time_str
18151822
$use_build_logs = 1;
18161823
}
18171824

1825+
if (defined $opt_u) {
1826+
$junit_xml_output = 1;
1827+
}
1828+
18181829
if (defined $opt_y) {
18191830
open my $css_fh, '<', $opt_y or die "Can't open custom CSS file $opt_y";
18201831
read $css_fh, $custom_css, -s $css_fh;

0 commit comments

Comments
 (0)