Unverified Commit 30047d47 authored by boklm's avatar boklm
Browse files

Generate missing thumbnails when receiving a report

The testsuite when running on Windows does not currently generate
thumbnails. So we should generate them on the server when we receive
the report.
parent 4bf9db2f
......@@ -2,6 +2,7 @@ package TBBTestSuite::Reports;
use warnings;
use strict;
use English;
use FindBin;
use File::Temp;
use File::Path qw(make_path);
......@@ -25,6 +26,20 @@ BEGIN {
@EXPORT_OK = qw(load_report report_dir report_path save_report);
}
my $screenshot_thumbnail;
BEGIN {
# For some reason that I did not understand yet, Image::Magick does
# not work on Windows, so we're not creating thumbnails if we're
# on Windows. In that case, the thumbnails should be created by the
# server that receives the results.
if ($OSNAME ne 'cygwin') {
require TBBTestSuite::Thumbnail;
$screenshot_thumbnail = \&TBBTestSuite::Thumbnail::screenshot_thumbnail;
} else {
$screenshot_thumbnail = sub { };
}
}
my %reports;
my %summaries;
......@@ -302,4 +317,19 @@ sub save_report {
YAML::Syck::DumpFile(report_path($report, 'report.yml'), $report);
}
sub generate_missing_thumbnails {
my ($report) = @_;
foreach my $tbbinfos (values %{$report->{tbbfiles}}) {
$tbbinfos->{'results-dir'} =
TBBTestSuite::Reports::report_path($report,
"results-$tbbinfos->{filename}");
foreach my $test (@{$tbbinfos->{tests}}) {
next unless $test->{screenshots};
foreach my $screenshot (@{$test->{screenshots}}) {
$screenshot_thumbnail->($tbbinfos->{'results-dir'}, $screenshot);
}
}
}
}
1;
......@@ -26,6 +26,7 @@ sub receive_report {
exit_error 'Report already exist' if -d "$options->{'reports-dir'}/r/$name";
$tmpdir->unlink_on_destroy(0);
system('mv', $tmpdir, "$options->{'reports-dir'}/r/$name");
TBBTestSuite::Reports::generate_missing_thumbnails($report);
$report->{options} = { %$options, %{$report->{options}} };
TBBTestSuite::Reports::email_report($report)
if @{$report->{options}{'email-to'}};
......
......@@ -5,6 +5,7 @@ use Image::Magick;
sub screenshot_thumbnail {
my ($dir, $name) = @_;
return if -f "$dir/t-$name";
my $image = Image::Magick->new;
$image->Read("$dir/$name");
$image->Scale(geometry => '600x600');
......
......@@ -101,6 +101,11 @@ sub dump_options {
dd $options;
}
sub gen_missing_thumbnails {
my $report = load_report_from_file;
TBBTestSuite::Reports::generate_missing_thumbnails($report);
}
my %actions = (
run_tests => \&run_tests,
list_tests => \&TBBTestSuite::BrowserBundleTests::list_tests,
......@@ -112,6 +117,7 @@ my %actions = (
email_report => \&email_report,
show_report => \&show_report,
dump_options => \&dump_options,
gen_missing_thumbnails => \&gen_missing_thumbnails,
);
sub usage {
......
Markdown is supported
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