Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
213 changes: 210 additions & 3 deletions common/prettify.pm
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,194 @@ sub Normal ($)
###############################################################################
###############################################################################

package Prettify::Failed_Tests_HTML;

use strict;
use warnings;

use FileHandle;

###############################################################################

sub new ($)
{
my $proto = shift;
my $class = ref ($proto) || $proto;
my $self = {};
my $basename = shift;
my $buildname = shift;
my $rev_link = shift;

my $path = substr($basename, 0, index($basename, '/'));
my $filename = $path . "/Failed_Tests.html";

$basename =~ s/^.*\///;

$self->{FULLHTML} = $basename . "_Full.html";
$self->{ERROR_COUNTER} = 0;
$self->{WARNING_COUNTER} = 0;
$self->{SECTION_COUNTER} = 0;
$self->{SUBSECTION_COUNTER} = 0;
$self->{TITLE} = "Failed Test Brief Log";
$self->{GIT_CHECKEDOUT_OPENDDS} = "unknown";
$self->{REV_LINK} = $rev_link;

unless (-e $filename) {
my $file_handle = new FileHandle ($filename, 'w');
print {$file_handle} "<h1>$self->{TITLE}</h1>\n";
}

$self->{FH} = new FileHandle ($filename, '>>');
$self->{FILENAME} = $filename;
$self->{BUILDNAME} = $buildname;

bless ($self, $class);
return $self;
}

sub Header ()
{
my $self = shift;

if (defined $self->{LAST_SECTION} && $self->{LAST_SECTION} eq 'Test') {
print {$self->{FH}} "<html>\n";
print {$self->{FH}} "<body bgcolor=\"white\">\n";
}
}

sub Footer ()
{
my $self = shift;

if (defined $self->{LAST_SECTION} && $self->{LAST_SECTION} eq 'Test') {
# In the case where there was no errors or warnings, output a note
if ($self->{ERROR_COUNTER} == 0 && $self->{WARNING_COUNTER} == 0) {
print {$self->{FH}} "No Errors or Warnings detected<br>\n";
}

print {$self->{FH}} "</body>\n";
print {$self->{FH}} "</html>\n";
}
}

sub Section ($)
{
my $self = shift;
my $s = shift;

# Escape any '<' or '>' signs
$s =~ s/</&lt;/g;
$s =~ s/>/&gt;/g;

my $counter = ++$self->{SECTION_COUNTER};

# Save for later use

$self->{LAST_SECTION} = $s;
}

sub Description ($)
{
my $self = shift;

# Ignore
}

sub Timestamp ($)
{
my $self = shift;
# Ignore
}

sub Subsection ($)
{
my $self = shift;
my $s = shift;

# Escape any '<' or '>' signs
$s =~ s/</&lt;/g;
$s =~ s/>/&gt;/g;

my $counter = ++$self->{SUBSECTION_COUNTER};

# Save for later use

$self->{LAST_SUBSECTION} = $s;
}

sub Print_Sections ()
{
my $self = shift;

if (defined $self->{LAST_SECTION} && defined $self->{LAST_SUBSECTION} && $self->{LAST_SECTION} eq 'Test') {
if (defined $self->{BUILDNAME}) {
print {$self->{FH}} "<hr><h2>$self->{BUILDNAME}</h2>\n";
my $rev = substr($self->{GIT_CHECKEDOUT_OPENDDS}, 0, 8);
if ($rev ne "unknown") {
print {$self->{FH}} "Rev: <a href=$self->{REV_LINK}>$rev</a><hr>\n";
}
$self->{BUILDNAME} = undef;
}

print {$self->{FH}} "<a name=\"subsection_$self->{SUBSECTION_COUNTER}\"></a>";
print {$self->{FH}} "<h3>$self->{LAST_SUBSECTION}</h3>\n";
$self->{LAST_SUBSECTION} = undef;
}
}

sub Error ($)
{
my $self = shift;
my $s = shift;

if (defined $self->{LAST_SECTION} && $self->{LAST_SECTION} eq 'Test') {

# Escape any '<' or '>' signs
$s =~ s/</&lt;/g;
$s =~ s/>/&gt;/g;

my $counter = ++$self->{ERROR_COUNTER};

$self->Print_Sections ();

print {$self->{FH}} "<a name=\"error_$counter\"></a>\n";
print {$self->{FH}} "<tt>[<a href=\"$self->{FULLHTML}#error_$counter"
. "\">Details</a>] </tt>";
print {$self->{FH}} "<font color=\"FF0000\"><tt>$s</tt></font><br>\n";
}
}

sub Warning ($)
{
my $self = shift;
my $s = shift;

if (defined $self->{LAST_SECTION} && $self->{LAST_SECTION} eq 'Test') {
# Escape any '<' or '>' signs
$s =~ s/</&lt;/g;
$s =~ s/>/&gt;/g;

my $counter = ++$self->{WARNING_COUNTER};

$self->Print_Sections ();

print {$self->{FH}} "<a name=\"warning_$counter\"></a>\n";
print {$self->{FH}} "<tt>[<a href=\"$self->{FULLHTML}#warning_$counter"
. "\">Details</a>] </tt>";
print {$self->{FH}} "<font color=\"FF7700\"><tt>$s</tt></font><br>\n";
}
}

sub Normal ($)
{
my $self = shift;

# Ignore
}

###############################################################################
###############################################################################

package Prettify::JUnit;

use strict;
Expand Down Expand Up @@ -862,12 +1050,15 @@ use FileHandle;

###############################################################################

sub new ($)
sub new ($$$$$)
{
my $proto = shift;
my $class = ref ($proto) || $proto;
my $self = {};
my $basename = shift;
my $buildname = shift;
my $skip_failed_test_logs = shift;
my $rev_link = shift;

# Initialize some variables

Expand Down Expand Up @@ -897,6 +1088,10 @@ sub new ($)
new Prettify::Totals_HTML ($basename), #Must be 2
new Prettify::Config_HTML ($basename), #Must be 3
);

if (!$skip_failed_test_logs) {
push @{$self->{OUTPUT}}, new Prettify::Failed_Tests_HTML ($basename, $buildname, $rev_link); #Must be 4, if used
}

my $junit = main::GetVariable ('junit_xml_output');
if (defined $junit) {
Expand Down Expand Up @@ -1242,6 +1437,11 @@ sub Setup_Handler ($)
elsif ("$totals->{GIT_CHECKEDOUT_OPENDDS}" eq "Matched")
{
$totals->{GIT_CHECKEDOUT_OPENDDS} = $sha;
if (exists ($self->{OUTPUT}[4]))
{
(@{$self->{OUTPUT}})[4]->{GIT_CHECKEDOUT_OPENDDS} = $sha;
}

}
$self->Output_Normal ($s);
}
Expand Down Expand Up @@ -1372,6 +1572,10 @@ sub Config_Handler ($)
my $revision = $totals->{GIT_REVISIONS}[0];
print "Matched GIT url to revision $revision\n";
$totals->{GIT_CHECKEDOUT_OPENDDS} = $revision;
if (exists ($self->{OUTPUT}[4]))
{
(@{$self->{OUTPUT}})[4]->{GIT_CHECKEDOUT_OPENDDS} = $revision;
}
}
}
elsif ($s =~ m/GIT_COMMIT=(.+)/)
Expand Down Expand Up @@ -1505,13 +1709,16 @@ sub BuildErrors ($)
# In this function we process the log file line by line,
# looking for errors.

sub Process ($)
sub Process ($$$$)
{
my $filename = shift;
my $basename = $filename;
$basename =~ s/\.txt$//;
my $buildname = shift;
my $skip_failed_test_logs = shift;
my $rev_link = shift;

my $processor = new Prettify ($basename);
my $processor = new Prettify ($basename, $buildname, $skip_failed_test_logs, $rev_link);

my $input = new FileHandle ($filename, 'r');

Expand Down
59 changes: 57 additions & 2 deletions scoreboard.pl
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ ($$)

### Print timestamp

print $indexhtml "<br><a href=\"Failed_Tests.html\">Failed Test Brief Log</a><br>\n";
print $indexhtml '<br>Last updated at ' . get_time_str() . "<br>\n";

### Print the Footer
Expand Down Expand Up @@ -539,7 +540,27 @@ ($)
}

print " Prettifying\n" if($verbose);
Prettify::Process ("$directory/$buildname/$filename");

my $diffRev = '';
if (defined $builds{$buildname}->{SUBVERSION_CHECKEDOUT_OPENDDS} &&
!($builds{$buildname}->{SUBVERSION_CHECKEDOUT_OPENDDS} =~ /None/)) {
$diffRev = $builds{$buildname}->{SUBVERSION_CHECKEDOUT_OPENDDS};
}
else {
$diffRev = 'None';
}
my $diffRoot = $builds{$buildname}->{DIFFROOT};
my $link = '';
my $linktarget = '';
if (defined $main::opt_n) {
$linktarget = "target=\"_blank\""
}
# If we have a diff revision, and a diffroot URL, create a link
if (($diffRev !~ /None/) && ($diffRoot)) {
my $url = $diffRoot . $diffRev;
$link = "<a href='$url' $linktarget>$diffRev</a>";
}
Prettify::Process ("$directory/$buildname/$filename", $buildname, $use_build_logs, $link);
}
}
}
Expand Down Expand Up @@ -567,6 +588,11 @@ ($)
return;
}

my $failed_tests = $directory . "/Failed_Tests.html";
if (-e $failed_tests) {
unlink $failed_tests;
}

foreach my $buildname (keys %builds) {
my $keep = $keep_default;
my @existing;
Expand Down Expand Up @@ -653,7 +679,28 @@ ($)
if ( -e $file . "_Totals.html" ) {next;}
if ( $post == 1 ) {
print " Prettifying $file.txt\n" if($verbose);
Prettify::Process ("$file.txt");

my $diffRev = '';
if (defined $builds{$buildname}->{SUBVERSION_CHECKEDOUT_OPENDDS} &&
!($builds{$buildname}->{SUBVERSION_CHECKEDOUT_OPENDDS} =~ /None/)) {
$diffRev = $builds{$buildname}->{SUBVERSION_CHECKEDOUT_OPENDDS};
}
else {
$diffRev = 'None';
}
my $diffRoot = $builds{$buildname}->{DIFFROOT};
my $link = '';
my $linktarget = '';
if (defined $main::opt_n) {
$linktarget = "target=\"_blank\""
}
# If we have a diff revision, and a diffroot URL, create a link
if (($diffRev !~ /None/) && ($diffRoot)) {
my $url = $diffRoot . $diffRev;
$link = "<a href='$url' $linktarget>$diffRev</a>";
}

Prettify::Process ("$file.txt", $buildname, $use_build_logs, $link);
$updated++;
} else {
# Create the triggerfile for the next time we run
Expand Down Expand Up @@ -779,6 +826,11 @@ ($)
return;
}

my $failed_tests = $directory . "/Failed_Tests.html";
if (-e $failed_tests) {
unlink $failed_tests;
}

foreach my $buildname (keys %builds) {
### Do we use the local cache or do we work
### with the storage of the build itself?
Expand Down Expand Up @@ -1138,6 +1190,9 @@ ($$$)

### Print timestamp

if (!$use_build_logs) {
print $indexhtml "<br><a href=\"Failed_Tests.html\">Failed Test Brief Log</a><br>\n";
}
print $indexhtml '<br>Last updated at ' . get_time_str() . "<br>\n";

### Print the Footer
Expand Down