Unverified Commit ed9ad4ae authored by boklm's avatar boklm
Browse files

When adding a new report, only update index pages that changed

parent 37601431
...@@ -101,6 +101,15 @@ sub report_type { ...@@ -101,6 +101,15 @@ sub report_type {
} }
sub make_reports_index { sub make_reports_index {
my ($changed_report) = @_;
my %pre_reports_index;
my @changed_tags;
my @changed_type;
if ($changed_report) {
@changed_tags = $changed_report->{options}{tags} ?
@{$changed_report->{options}{tags}} : ();
push @changed_type, report_type($changed_report);
}
copy_static; copy_static;
my $template = Template->new( my $template = Template->new(
ENCODING => 'utf8', ENCODING => 'utf8',
...@@ -124,11 +133,6 @@ sub make_reports_index { ...@@ -124,11 +133,6 @@ sub make_reports_index {
foreach my $tag (@$tags) { foreach my $tag (@$tags) {
push @{$reports_by_tag{$type}->{$tag}}, $report; push @{$reports_by_tag{$type}->{$tag}}, $report;
} }
my $testsuite = $TBBTestSuite::Tests::testsuite_types{$type};
if ($testsuite->{pre_reports_index}) {
load_report($report);
$testsuite->{pre_reports_index}(\%reports, $reports{$report});
}
} }
my $vars = { my $vars = {
%template_functions, %template_functions,
...@@ -142,19 +146,20 @@ sub make_reports_index { ...@@ -142,19 +146,20 @@ sub make_reports_index {
$template->process('tests_index.html', { %$vars, tests => $template->process('tests_index.html', { %$vars, tests =>
\@TBBTestSuite::Tests::tests }, 'tests.html') \@TBBTestSuite::Tests::tests }, 'tests.html')
|| exit_error "Template Error:\n" . $template->error; || exit_error "Template Error:\n" . $template->error;
foreach my $type (keys %reports_by_type) { foreach my $type ($changed_report ? @changed_type : keys %reports_by_type) {
my @s = sort { $summaries{$b}->{time} <=> $summaries{$a}->{time} } my @s = sort { $summaries{$b}->{time} <=> $summaries{$a}->{time} }
@{$reports_by_type{$type}}; @{$reports_by_type{$type}};
load_reports(@s); load_reports_for_index(\%pre_reports_index, @s);
$template->process("reports_index_$type.html", $template->process("reports_index_$type.html",
{ %$vars, reports_list => \@s }, "index-$type.html") { %$vars, reports_list => \@s }, "index-$type.html")
|| exit_error "Template Error:\n" . $template->error; || exit_error "Template Error:\n" . $template->error;
} }
foreach my $type (keys %reports_by_tag) { foreach my $type ($changed_report ? @changed_type : keys %reports_by_tag) {
foreach my $tag (keys %{$reports_by_tag{$type}}) { foreach my $tag ($changed_report ? @changed_tags
: keys %{$reports_by_tag{$type}}) {
my @s = sort { $summaries{$b}->{time} <=> $summaries{$a}->{time} } my @s = sort { $summaries{$b}->{time} <=> $summaries{$a}->{time} }
@{$reports_by_tag{$type}->{$tag}}; @{$reports_by_tag{$type}->{$tag}};
load_reports(@s); load_reports_for_index(\%pre_reports_index, @s);
$template->process("reports_index_$type.html", $template->process("reports_index_$type.html",
{ %$vars, reports_list => \@s }, "index-$type-$tag.html") { %$vars, reports_list => \@s }, "index-$type-$tag.html")
|| exit_error "Template Error:\n" . $template->error; || exit_error "Template Error:\n" . $template->error;
...@@ -213,9 +218,15 @@ sub load_report { ...@@ -213,9 +218,15 @@ sub load_report {
return $reports{$report_name} = YAML::LoadFile($reportfile); return $reports{$report_name} = YAML::LoadFile($reportfile);
} }
sub load_reports { sub load_reports_for_index {
foreach my $report (@_) { my ($pre_reports_index, @reports) = @_;
load_report($report); foreach my $rname (@reports) {
my $r = load_report($rname);
my $testsuite = $TBBTestSuite::Tests::testsuite_types{report_type($r)};
if ($testsuite->{pre_reports_index} && !$pre_reports_index->{$rname}) {
$pre_reports_index->{$rname} = 1;
$testsuite->{pre_reports_index}(\%reports, $reports{$rname});
}
} }
} }
......
...@@ -29,6 +29,7 @@ sub receive_report { ...@@ -29,6 +29,7 @@ sub receive_report {
$report->{options} = { %$options, %{$report->{options}} }; $report->{options} = { %$options, %{$report->{options}} };
TBBTestSuite::Reports::email_report($report) TBBTestSuite::Reports::email_report($report)
if @{$report->{options}{'email-to'}}; if @{$report->{options}{'email-to'}};
return $report;
} }
sub update_authkeys { sub update_authkeys {
......
...@@ -53,7 +53,7 @@ sub run_tests { ...@@ -53,7 +53,7 @@ sub run_tests {
save_report($report); save_report($report);
print 'Report directory: ', report_dir($report), "\n"; print 'Report directory: ', report_dir($report), "\n";
TBBTestSuite::Reports::make_report($report); TBBTestSuite::Reports::make_report($report);
TBBTestSuite::Reports::make_reports_index; TBBTestSuite::Reports::make_reports_index($report);
TBBTestSuite::Reports::Send::send_report if $options->{'upload-to'}; TBBTestSuite::Reports::Send::send_report if $options->{'upload-to'};
} }
...@@ -71,8 +71,8 @@ sub make_report { ...@@ -71,8 +71,8 @@ sub make_report {
} }
sub receive_report { sub receive_report {
TBBTestSuite::Reports::Receive::receive_report; my $report = TBBTestSuite::Reports::Receive::receive_report;
TBBTestSuite::Reports::make_reports_index; TBBTestSuite::Reports::make_reports_index($report);
} }
sub email_report { sub email_report {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment