GitLab is used only for code review, issue tracking and project management. Canonical locations for source code are still https://gitweb.torproject.org/ https://git.torproject.org/ and git-rw.torproject.org.

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

Stop using the Image::Magick perl module

Instead, use the convert command from ImageMagick. The perl module is
difficult to build (which is also the reason why we didn't have it on
Windows and OSX).
parent bfa64a4c
......@@ -16,7 +16,7 @@ BEGIN {
@ISA = qw(Exporter);
@EXPORT_OK = qw(exit_error system_infos run_alone rm_pidfile winpath
has_bin get_var run_to_file get_nbcpu as_array
clone_strip_coderef last_days);
clone_strip_coderef last_days screenshot_thumbnail);
}
sub exit_error {
......@@ -135,4 +135,13 @@ sub last_days {
return @res;
}
sub screenshot_thumbnail {
my ($dir, $name) = @_;
return if -f "$dir/t-$name";
if (system('convert', '-geometry', '600x600', "$dir/$name",
"$dir/t-$name")) {
print STDERR "Error creating thumbnail for $dir/$name\n";
}
}
1;
......@@ -12,7 +12,7 @@ use Template;
use File::Spec;
use JSON;
use YAML::Syck;
use TBBTestSuite::Common qw(exit_error as_array);
use TBBTestSuite::Common qw(exit_error as_array screenshot_thumbnail);
use TBBTestSuite::Options qw($options);
use TBBTestSuite::Tests;
use TBBTestSuite::TestSuites;
......@@ -27,20 +27,6 @@ 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' && $OSNAME ne 'darwin') {
require TBBTestSuite::Thumbnail;
$screenshot_thumbnail = \&TBBTestSuite::Thumbnail::screenshot_thumbnail;
} else {
$screenshot_thumbnail = sub { };
}
}
my %reports;
my %summaries;
......@@ -345,7 +331,7 @@ sub generate_missing_thumbnails {
foreach my $test (@{$tbbinfos->{tests}}) {
next unless $test->{screenshots};
foreach my $screenshot (@{$test->{screenshots}}) {
$screenshot_thumbnail->($tbbinfos->{'results-dir'}, $screenshot);
screenshot_thumbnail($tbbinfos->{'results-dir'}, $screenshot);
}
}
}
......
......@@ -16,27 +16,13 @@ use File::Temp;
use JSON;
use Digest::SHA qw(sha256_hex);
use LWP::UserAgent;
use TBBTestSuite::Common qw(exit_error winpath clone_strip_coderef);
use TBBTestSuite::Common qw(exit_error winpath clone_strip_coderef screenshot_thumbnail);
use TBBTestSuite::Options qw($options);
use TBBTestSuite::Tests::VirusTotal qw(virustotal_run);
use TBBTestSuite::Tests::Command qw(command_run);
use TBBTestSuite::Tests::TorBootstrap;
use TBBTestSuite::XServer qw(start_X stop_X set_Xmode);
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' && $OSNAME ne 'darwin') {
require TBBTestSuite::Thumbnail;
$screenshot_thumbnail = \&TBBTestSuite::Thumbnail::screenshot_thumbnail;
} else {
$screenshot_thumbnail = sub { };
}
}
sub test_types {
return {
tor_bootstrap => \&TBBTestSuite::Tests::TorBootstrap::start_tor,
......@@ -780,7 +766,7 @@ sub marionette_run {
my $i = 0;
for my $screenshot_file (sort glob "$screenshots_tmp/*.png") {
move($screenshot_file, "$tbbinfos->{'results-dir'}/$test->{name}-$i.png");
$screenshot_thumbnail->($tbbinfos->{'results-dir'}, "$test->{name}-$i.png");
screenshot_thumbnail($tbbinfos->{'results-dir'}, "$test->{name}-$i.png");
push @{$test->{screenshots}}, "$test->{name}-$i.png";
$i++;
}
......
package TBBTestSuite::Thumbnail;
use strict;
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');
$image->Write("$dir/t-$name");
}
1;
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