Commit 45a4eea5 authored by Frédéric Buclin's avatar Frédéric Buclin

Bug 662070: Use say() instead of print() where appropriate

r=glob a=LpSolit
parent 589632e9
...@@ -437,7 +437,7 @@ sub dump { ...@@ -437,7 +437,7 @@ sub dump {
my $data = $self->data; my $data = $self->data;
require Data::Dumper; require Data::Dumper;
print "<pre>Bugzilla::Chart object:\n"; say "<pre>Bugzilla::Chart object:";
print Data::Dumper::Dumper($self); print Data::Dumper::Dumper($self);
print "</pre>"; print "</pre>";
} }
......
...@@ -250,7 +250,7 @@ sub bz_create_database { ...@@ -250,7 +250,7 @@ sub bz_create_database {
if (!$conn_success) { if (!$conn_success) {
$dbh = _get_no_db_connection(); $dbh = _get_no_db_connection();
print "Creating database $db_name...\n"; say "Creating database $db_name...";
# Try to create the DB, and if we fail print a friendly error. # Try to create the DB, and if we fail print a friendly error.
my $success = eval { my $success = eval {
...@@ -483,7 +483,7 @@ sub bz_setup_database { ...@@ -483,7 +483,7 @@ sub bz_setup_database {
my @desired_tables = $self->_bz_schema->get_table_list(); my @desired_tables = $self->_bz_schema->get_table_list();
my $bugs_exists = $self->bz_table_info('bugs'); my $bugs_exists = $self->bz_table_info('bugs');
if (!$bugs_exists) { if (!$bugs_exists) {
print install_string('db_table_setup'), "\n"; say install_string('db_table_setup');
} }
foreach my $table_name (@desired_tables) { foreach my $table_name (@desired_tables) {
...@@ -520,7 +520,7 @@ sub bz_setup_foreign_keys { ...@@ -520,7 +520,7 @@ sub bz_setup_foreign_keys {
my $activity_fk = $self->bz_fk_info('profiles_activity', 'userid'); my $activity_fk = $self->bz_fk_info('profiles_activity', 'userid');
my $any_fks = $activity_fk && $activity_fk->{created}; my $any_fks = $activity_fk && $activity_fk->{created};
if (!$any_fks) { if (!$any_fks) {
print get_text('install_fk_setup'), "\n"; say get_text('install_fk_setup');
} }
my @tables = $self->bz_table_list(); my @tables = $self->bz_table_list();
...@@ -711,12 +711,12 @@ sub bz_alter_column_raw { ...@@ -711,12 +711,12 @@ sub bz_alter_column_raw {
$table, $name, $new_def, $table, $name, $new_def,
defined $set_nulls_to ? $self->quote($set_nulls_to) : undef); defined $set_nulls_to ? $self->quote($set_nulls_to) : undef);
my $new_ddl = $self->_bz_schema->get_type_ddl($new_def); my $new_ddl = $self->_bz_schema->get_type_ddl($new_def);
print "Updating column $name in table $table ...\n"; say "Updating column $name in table $table ...";
if (defined $current_def) { if (defined $current_def) {
my $old_ddl = $self->_bz_schema->get_type_ddl($current_def); my $old_ddl = $self->_bz_schema->get_type_ddl($current_def);
print "Old: $old_ddl\n"; say "Old: $old_ddl";
} }
print "New: $new_ddl\n"; say "New: $new_ddl";
$self->do($_) foreach (@statements); $self->do($_) foreach (@statements);
} }
...@@ -810,7 +810,7 @@ sub _bz_add_table_raw { ...@@ -810,7 +810,7 @@ sub _bz_add_table_raw {
if (Bugzilla->usage_mode == USAGE_MODE_CMDLINE if (Bugzilla->usage_mode == USAGE_MODE_CMDLINE
and !$options->{silently}) and !$options->{silently})
{ {
print install_string('db_table_new', { table => $name }), "\n"; say install_string('db_table_new', { table => $name });
} }
$self->do($_) foreach (@statements); $self->do($_) foreach (@statements);
} }
...@@ -1317,7 +1317,7 @@ sub _bz_init_schema_storage { ...@@ -1317,7 +1317,7 @@ sub _bz_init_schema_storage {
$self->_bz_add_table_raw('bz_schema'); $self->_bz_add_table_raw('bz_schema');
} }
print install_string('db_schema_init'), "\n"; say install_string('db_schema_init');
my $sth = $self->prepare("INSERT INTO bz_schema " my $sth = $self->prepare("INSERT INTO bz_schema "
." (schema_data, version) VALUES (?,?)"); ." (schema_data, version) VALUES (?,?)");
$sth->bind_param(1, $store_me, $self->BLOB_TYPE); $sth->bind_param(1, $store_me, $self->BLOB_TYPE);
......
...@@ -47,7 +47,7 @@ Bugzilla::Field - a particular piece of information about bugs ...@@ -47,7 +47,7 @@ Bugzilla::Field - a particular piece of information about bugs
# Instantiate a Field object for an existing field. # Instantiate a Field object for an existing field.
my $field = new Bugzilla::Field({name => 'qacontact_accessible'}); my $field = new Bugzilla::Field({name => 'qacontact_accessible'});
if ($field->obsolete) { if ($field->obsolete) {
print $field->description . " is obsolete\n"; say $field->description . " is obsolete";
} }
# Validation Routines # Validation Routines
...@@ -1173,8 +1173,8 @@ sub populate_field_definitions { ...@@ -1173,8 +1173,8 @@ sub populate_field_definitions {
undef, $field_description); undef, $field_description);
if ($old_field_id && ($old_field_name ne $new_field_name)) { if ($old_field_id && ($old_field_name ne $new_field_name)) {
print "SQL fragment found in the 'fielddefs' table...\n"; say "SQL fragment found in the 'fielddefs' table...";
print "Old field name: " . $old_field_name . "\n"; say "Old field name: $old_field_name";
# We have to fix saved searches first. Queries have been escaped # We have to fix saved searches first. Queries have been escaped
# before being saved. We have to do the same here to find them. # before being saved. We have to do the same here to find them.
$old_field_name = url_quote($old_field_name); $old_field_name = url_quote($old_field_name);
...@@ -1211,8 +1211,8 @@ sub populate_field_definitions { ...@@ -1211,8 +1211,8 @@ sub populate_field_definitions {
$sth_UpdateSeries->execute($query, $series_id); $sth_UpdateSeries->execute($query, $series_id);
} }
# Now that saved searches have been fixed, we can fix the field name. # Now that saved searches have been fixed, we can fix the field name.
print "Fixing the 'fielddefs' table...\n"; say "Fixing the 'fielddefs' table...";
print "New field name: " . $new_field_name . "\n"; say "New field name: $new_field_name";
$dbh->do('UPDATE fielddefs SET name = ? WHERE id = ?', $dbh->do('UPDATE fielddefs SET name = ? WHERE id = ?',
undef, ($new_field_name, $old_field_id)); undef, ($new_field_name, $old_field_id));
} }
......
...@@ -34,7 +34,7 @@ use Bugzilla::Group; ...@@ -34,7 +34,7 @@ use Bugzilla::Group;
use Bugzilla::Product; use Bugzilla::Product;
use Bugzilla::User; use Bugzilla::User;
use Bugzilla::User::Setting; use Bugzilla::User::Setting;
use Bugzilla::Util qw(get_text); use Bugzilla::Util qw(get_text say);
use Bugzilla::Version; use Bugzilla::Version;
use constant STATUS_WORKFLOW => ( use constant STATUS_WORKFLOW => (
...@@ -188,7 +188,7 @@ sub update_settings { ...@@ -188,7 +188,7 @@ sub update_settings {
my $any_settings = $dbh->selectrow_array( my $any_settings = $dbh->selectrow_array(
'SELECT 1 FROM setting ' . $dbh->sql_limit(1)); 'SELECT 1 FROM setting ' . $dbh->sql_limit(1));
if (!$any_settings) { if (!$any_settings) {
print get_text('install_setting_setup'), "\n"; say get_text('install_setting_setup');
} }
my %settings = %{SETTINGS()}; my %settings = %{SETTINGS()};
...@@ -210,7 +210,7 @@ sub update_system_groups { ...@@ -210,7 +210,7 @@ sub update_system_groups {
# adding groups. # adding groups.
my $editbugs_exists = new Bugzilla::Group({ name => 'editbugs' }); my $editbugs_exists = new Bugzilla::Group({ name => 'editbugs' });
if (!$editbugs_exists) { if (!$editbugs_exists) {
print get_text('install_groups_setup'), "\n"; say get_text('install_groups_setup');
} }
# Create most of the system groups # Create most of the system groups
...@@ -281,7 +281,7 @@ sub init_workflow { ...@@ -281,7 +281,7 @@ sub init_workflow {
my $has_workflow = $dbh->selectrow_array('SELECT 1 FROM status_workflow'); my $has_workflow = $dbh->selectrow_array('SELECT 1 FROM status_workflow');
return if $has_workflow; return if $has_workflow;
print get_text('install_workflow_init'), "\n"; say get_text('install_workflow_init');
my %status_ids = @{ $dbh->selectcol_arrayref( my %status_ids = @{ $dbh->selectcol_arrayref(
'SELECT value, id FROM bug_status', {Columns=>[1,2]}) }; 'SELECT value, id FROM bug_status', {Columns=>[1,2]}) };
...@@ -316,7 +316,7 @@ sub create_admin { ...@@ -316,7 +316,7 @@ sub create_admin {
my $full_name = $answer{'ADMIN_REALNAME'}; my $full_name = $answer{'ADMIN_REALNAME'};
if (!$login || !$password || !$full_name) { if (!$login || !$password || !$full_name) {
print "\n" . get_text('install_admin_setup') . "\n\n"; say "\n" . get_text('install_admin_setup') . "\n";
} }
while (!$login) { while (!$login) {
...@@ -325,7 +325,7 @@ sub create_admin { ...@@ -325,7 +325,7 @@ sub create_admin {
chomp $login; chomp $login;
eval { Bugzilla::User->check_login_name_for_creation($login); }; eval { Bugzilla::User->check_login_name_for_creation($login); };
if ($@) { if ($@) {
print $@ . "\n"; say $@;
undef $login; undef $login;
} }
} }
...@@ -383,7 +383,7 @@ sub make_admin { ...@@ -383,7 +383,7 @@ sub make_admin {
} }
if (Bugzilla->usage_mode == USAGE_MODE_CMDLINE) { if (Bugzilla->usage_mode == USAGE_MODE_CMDLINE) {
print "\n", get_text('install_admin_created', { user => $user }), "\n"; say "\n", get_text('install_admin_created', { user => $user });
} }
} }
...@@ -408,7 +408,7 @@ sub _prompt_for_password { ...@@ -408,7 +408,7 @@ sub _prompt_for_password {
chomp $pass2; chomp $pass2;
eval { validate_password($password, $pass2); }; eval { validate_password($password, $pass2); };
if ($@) { if ($@) {
print "\n$@\n"; say "\n$@";
undef $password; undef $password;
} }
system("stty","echo") unless ON_WINDOWS; system("stty","echo") unless ON_WINDOWS;
...@@ -430,7 +430,7 @@ sub reset_password { ...@@ -430,7 +430,7 @@ sub reset_password {
my $password = _prompt_for_password($prompt); my $password = _prompt_for_password($prompt);
$user->set_password($password); $user->set_password($password);
$user->update(); $user->update();
print "\n", get_text('install_reset_password_done'), "\n"; say "\n", get_text('install_reset_password_done');
} }
1; 1;
......
...@@ -30,7 +30,7 @@ use Bugzilla::Error; ...@@ -30,7 +30,7 @@ use Bugzilla::Error;
use Bugzilla::Install::Requirements (); use Bugzilla::Install::Requirements ();
use Bugzilla::Install::Util qw(indicate_progress); use Bugzilla::Install::Util qw(indicate_progress);
use Bugzilla::Product; use Bugzilla::Product;
use Bugzilla::Util qw(get_text trim generate_random_password); use Bugzilla::Util qw(get_text trim generate_random_password say);
use Bugzilla::User (); use Bugzilla::User ();
use Bugzilla::Status (); use Bugzilla::Status ();
use Bugzilla::Version; use Bugzilla::Version;
...@@ -261,7 +261,7 @@ sub bug_fields { ...@@ -261,7 +261,7 @@ sub bug_fields {
sub users { sub users {
my $self = shift; my $self = shift;
if (!exists $self->{users}) { if (!exists $self->{users}) {
print get_text('migrate_reading_users'), "\n"; say get_text('migrate_reading_users');
$self->{users} = $self->_read_users(); $self->{users} = $self->_read_users();
} }
return $self->{users}; return $self->{users};
...@@ -270,7 +270,7 @@ sub users { ...@@ -270,7 +270,7 @@ sub users {
sub products { sub products {
my $self = shift; my $self = shift;
if (!exists $self->{products}) { if (!exists $self->{products}) {
print get_text('migrate_reading_products'), "\n"; say get_text('migrate_reading_products');
$self->{products} = $self->_read_products(); $self->{products} = $self->_read_products();
} }
return $self->{products}; return $self->{products};
...@@ -279,7 +279,7 @@ sub products { ...@@ -279,7 +279,7 @@ sub products {
sub bugs { sub bugs {
my $self = shift; my $self = shift;
if (!exists $self->{bugs}) { if (!exists $self->{bugs}) {
print get_text('migrate_reading_bugs'), "\n"; say get_text('migrate_reading_bugs');
$self->{bugs} = $self->_read_bugs(); $self->{bugs} = $self->_read_bugs();
} }
return $self->{bugs}; return $self->{bugs};
...@@ -340,7 +340,7 @@ sub reset_serial_values { ...@@ -340,7 +340,7 @@ sub reset_serial_values {
sub translate_all_bugs { sub translate_all_bugs {
my ($self, $bugs) = @_; my ($self, $bugs) = @_;
print get_text('migrate_translating_bugs'), "\n"; say get_text('migrate_translating_bugs');
# We modify the array in place so that $self->bugs will return the # We modify the array in place so that $self->bugs will return the
# modified bugs, in case $self->before_insert wants them. # modified bugs, in case $self->before_insert wants them.
my $num_bugs = scalar(@$bugs); my $num_bugs = scalar(@$bugs);
...@@ -608,7 +608,7 @@ sub create_custom_fields { ...@@ -608,7 +608,7 @@ sub create_custom_fields {
if (!$self->dry_run) { if (!$self->dry_run) {
$created = Bugzilla::Field->create($created); $created = Bugzilla::Field->create($created);
} }
print get_text('migrate_field_created', { field => $created }), "\n"; say get_text('migrate_field_created', { field => $created });
} }
delete $self->{bug_fields}; delete $self->{bug_fields};
} }
...@@ -680,7 +680,7 @@ sub create_legal_values { ...@@ -680,7 +680,7 @@ sub create_legal_values {
sub insert_bugs { sub insert_bugs {
my ($self, $bugs) = @_; my ($self, $bugs) = @_;
my $dbh = Bugzilla->dbh; my $dbh = Bugzilla->dbh;
print get_text('migrate_creating_bugs'), "\n"; say get_text('migrate_creating_bugs');
my $init_statuses = Bugzilla::Status->can_change_to(); my $init_statuses = Bugzilla::Status->can_change_to();
my %allowed_statuses = map { lc($_->name) => 1 } @$init_statuses; my %allowed_statuses = map { lc($_->name) => 1 } @$init_statuses;
......
...@@ -31,13 +31,12 @@ package Bugzilla::Util; ...@@ -31,13 +31,12 @@ package Bugzilla::Util;
use strict; use strict;
use base qw(Exporter); use base qw(Exporter);
@Bugzilla::Util::EXPORT = qw(trick_taint detaint_natural @Bugzilla::Util::EXPORT = qw(trick_taint detaint_natural detaint_signed
detaint_signed
html_quote url_quote xml_quote html_quote url_quote xml_quote
css_class_quote html_light_quote url_decode css_class_quote html_light_quote url_decode
i_am_cgi correct_urlbase remote_ip i_am_cgi correct_urlbase remote_ip
do_ssl_redirect_if_required use_attachbase do_ssl_redirect_if_required use_attachbase
diff_arrays on_main_db diff_arrays on_main_db say
trim wrap_hard wrap_comment find_wrap_point trim wrap_hard wrap_comment find_wrap_point
format_time validate_date validate_time datetime_from format_time validate_date validate_time datetime_from
file_mod_time is_7bit_clean file_mod_time is_7bit_clean
...@@ -341,6 +340,13 @@ sub diff_arrays { ...@@ -341,6 +340,13 @@ sub diff_arrays {
return (\@removed, \@added); return (\@removed, \@added);
} }
# XXX - This is a temporary subroutine till we require Perl 5.10.1.
# This will happen before Bugzilla 5.0rc1.
sub say (@) {
print @_;
print "\n";
}
sub trim { sub trim {
my ($str) = @_; my ($str) = @_;
if ($str) { if ($str) {
......
...@@ -287,10 +287,10 @@ print $cgi->header(-type => $format->{'ctype'}, ...@@ -287,10 +287,10 @@ print $cgi->header(-type => $format->{'ctype'},
# prints out both data structures. # prints out both data structures.
if ($cgi->param('debug')) { if ($cgi->param('debug')) {
require Data::Dumper; require Data::Dumper;
print "<pre>data hash:\n"; say "<pre>data hash:";
print Data::Dumper::Dumper(%data) . "\n\n"; say Data::Dumper::Dumper(%data);
print "data array:\n"; say "\ndata array:";
print Data::Dumper::Dumper(@image_data) . "\n\n</pre>"; say Data::Dumper::Dumper(@image_data) . "\n\n</pre>";
} }
# All formats point to the same section of the documentation. # All formats point to the same section of the documentation.
......
...@@ -60,7 +60,7 @@ sub Status { ...@@ -60,7 +60,7 @@ sub Status {
} }
else { else {
my $start_tag = $alert ? '<p class="alert">' : '<p>'; my $start_tag = $alert ? '<p class="alert">' : '<p>';
print $start_tag . get_string($san_tag, $vars) . "</p>\n"; say $start_tag . get_string($san_tag, $vars) . "</p>";
} }
} }
......
...@@ -23,6 +23,7 @@ use lib qw(. lib); ...@@ -23,6 +23,7 @@ use lib qw(. lib);
use Bugzilla; use Bugzilla;
use Bugzilla::Constants; use Bugzilla::Constants;
use Bugzilla::Util qw(say);
use Socket; use Socket;
...@@ -33,8 +34,8 @@ my $lwp = $@ ? 0 : 1; ...@@ -33,8 +34,8 @@ my $lwp = $@ ? 0 : 1;
if ((@ARGV != 1) || ($ARGV[0] !~ /^https?:/)) if ((@ARGV != 1) || ($ARGV[0] !~ /^https?:/))
{ {
print "Usage: $0 <URL to this Bugzilla installation>\n"; say "Usage: $0 <URL to this Bugzilla installation>";
print "e.g.: $0 http://www.mycompany.com/bugzilla\n"; say "e.g.: $0 http://www.mycompany.com/bugzilla";
exit(1); exit(1);
} }
...@@ -67,26 +68,26 @@ else { ...@@ -67,26 +68,26 @@ else {
# Check $webservergroup against the server's GID # Check $webservergroup against the server's GID
if ($sgid > 0) { if ($sgid > 0) {
if ($webservergroup eq "") { if ($webservergroup eq "") {
print say
"WARNING \$webservergroup is set to an empty string. "WARNING \$webservergroup is set to an empty string.
That is a very insecure practice. Please refer to the That is a very insecure practice. Please refer to the
Bugzilla documentation.\n"; Bugzilla documentation.";
} }
elsif ($webgroupnum == $sgid || Bugzilla->localconfig->{use_suexec}) { elsif ($webgroupnum == $sgid || Bugzilla->localconfig->{use_suexec}) {
print "TEST-OK Webserver is running under group id in \$webservergroup.\n"; say "TEST-OK Webserver is running under group id in \$webservergroup.";
} }
else { else {
print say
"TEST-WARNING Webserver is running under group id not matching \$webservergroup. "TEST-WARNING Webserver is running under group id not matching \$webservergroup.
This if the tests below fail, this is probably the problem. This if the tests below fail, this is probably the problem.
Please refer to the web server configuration section of the Bugzilla guide. Please refer to the web server configuration section of the Bugzilla guide.
If you are using virtual hosts or suexec, this warning may not apply.\n"; If you are using virtual hosts or suexec, this warning may not apply.";
} }
} }
elsif (!ON_WINDOWS) { elsif (!ON_WINDOWS) {
print say
"TEST-WARNING Failed to find the GID for the 'httpd' process, unable "TEST-WARNING Failed to find the GID for the 'httpd' process, unable
to validate webservergroup.\n"; to validate webservergroup.";
} }
...@@ -94,26 +95,26 @@ to validate webservergroup.\n"; ...@@ -94,26 +95,26 @@ to validate webservergroup.\n";
$ARGV[0] =~ s/\/$//; $ARGV[0] =~ s/\/$//;
my $url = $ARGV[0] . "/images/padlock.png"; my $url = $ARGV[0] . "/images/padlock.png";
if (fetch($url)) { if (fetch($url)) {
print "TEST-OK Got padlock picture.\n"; say "TEST-OK Got padlock picture.";
} else { } else {
print say
"TEST-FAILED Fetch of images/padlock.png failed "TEST-FAILED Fetch of images/padlock.png failed
Your web server could not fetch $url. Your web server could not fetch $url.
Check your web server configuration and try again.\n"; Check your web server configuration and try again.";
exit(1); exit(1);
} }
# Try to execute a cgi script # Try to execute a cgi script
my $response = fetch($ARGV[0] . "/testagent.cgi"); my $response = fetch($ARGV[0] . "/testagent.cgi");
if ($response =~ /^OK (.*)$/) { if ($response =~ /^OK (.*)$/) {
print "TEST-OK Webserver is executing CGIs via $1.\n"; say "TEST-OK Webserver is executing CGIs via $1.";
} elsif ($response =~ /^#!/) { } elsif ($response =~ /^#!/) {
print say
"TEST-FAILED Webserver is fetching rather than executing CGI files. "TEST-FAILED Webserver is fetching rather than executing CGI files.
Check the AddHandler statement in your httpd.conf file.\n"; Check the AddHandler statement in your httpd.conf file.";
exit(1); exit(1);
} else { } else {
print "TEST-FAILED Webserver is not executing CGI files.\n"; say "TEST-FAILED Webserver is not executing CGI files.";
} }
# Make sure that the web server is honoring .htaccess files # Make sure that the web server is honoring .htaccess files
...@@ -122,13 +123,13 @@ $localconfig =~ s~^\./~~; ...@@ -122,13 +123,13 @@ $localconfig =~ s~^\./~~;
$url = $ARGV[0] . "/$localconfig"; $url = $ARGV[0] . "/$localconfig";
$response = fetch($url); $response = fetch($url);
if ($response) { if ($response) {
print say
"TEST-FAILED Webserver is permitting fetch of $url. "TEST-FAILED Webserver is permitting fetch of $url.
This is a serious security problem. This is a serious security problem.
Check your web server configuration.\n"; Check your web server configuration.";
exit(1); exit(1);
} else { } else {
print "TEST-OK Webserver is preventing fetch of $url.\n"; say "TEST-OK Webserver is preventing fetch of $url.";
} }
# Test chart generation # Test chart generation
...@@ -142,8 +143,8 @@ if ($@ eq '') { ...@@ -142,8 +143,8 @@ if ($@ eq '') {
my $gdlib = `gdlib-config --version 2>&1` || ""; my $gdlib = `gdlib-config --version 2>&1` || "";
$gdlib =~ s/\n$//; $gdlib =~ s/\n$//;
if (!$gdlib) { if (!$gdlib) {
print "TEST-WARNING Failed to run gdlib-config; can't compare " . say "TEST-WARNING Failed to run gdlib-config; can't compare " .
"GD versions.\n"; "GD versions.";
} }
else { else {
my $gd = $GD::VERSION; my $gd = $GD::VERSION;
...@@ -154,9 +155,9 @@ if ($@ eq '') { ...@@ -154,9 +155,9 @@ if ($@ eq '') {
$gd =~ s/^([^\.]+)\..*/$1/; $gd =~ s/^([^\.]+)\..*/$1/;
if ($gdlib == $gd) { if ($gdlib == $gd) {
print "TEST-OK $verstring; Major versions match.\n"; say "TEST-OK $verstring; Major versions match.";
} else { } else {
print "TEST-FAILED $verstring; Major versions do not match.\n"; say "TEST-FAILED $verstring; Major versions do not match.";
} }
} }
} }
...@@ -177,17 +178,17 @@ if ($@ eq '') { ...@@ -177,17 +178,17 @@ if ($@ eq '') {
create_file("$datadir/testgd-local.png", $image->png); create_file("$datadir/testgd-local.png", $image->png);
check_image("$datadir/testgd-local.png", 'GD'); check_image("$datadir/testgd-local.png", 'GD');
} else { } else {
print "TEST-FAILED GD doesn't support PNG generation.\n"; say "TEST-FAILED GD doesn't support PNG generation.";
} }
}; };
if ($@ ne '') { if ($@ ne '') {
print "TEST-FAILED GD returned: $@\n"; say "TEST-FAILED GD returned: $@";
} }
# Test Chart # Test Chart
eval 'use Chart::Lines'; eval 'use Chart::Lines';
if ($@) { if ($@) {
print "TEST-FAILED Chart::Lines is not installed.\n"; say "TEST-FAILED Chart::Lines is not installed.";
} else { } else {
eval { eval {
my $chart = Chart::Lines->new(400, 400); my $chart = Chart::Lines->new(400, 400);
...@@ -199,16 +200,16 @@ if ($@ eq '') { ...@@ -199,16 +200,16 @@ if ($@ eq '') {
check_image("$datadir/testchart-local.png", "Chart"); check_image("$datadir/testchart-local.png", "Chart");
}; };
if ($@ ne '') { if ($@ ne '') {
print "TEST-FAILED Chart returned: $@\n"; say "TEST-FAILED Chart returned: $@";
} }
} }
eval 'use Template::Plugin::GD::Image'; eval 'use Template::Plugin::GD::Image';
if ($@) { if ($@) {
print "TEST-FAILED Template::Plugin::GD is not installed.\n"; say "TEST-FAILED Template::Plugin::GD is not installed.";
} }
else { else {
print "TEST-OK Template::Plugin::GD is installed.\n"; say "TEST-OK Template::Plugin::GD is installed.";
} }
} }
...@@ -262,10 +263,10 @@ sub check_image { ...@@ -262,10 +263,10 @@ sub check_image {
my ($local_file, $library) = @_; my ($local_file, $library) = @_;
my $filedata = read_file($local_file); my $filedata = read_file($local_file);
if ($filedata =~ /^\x89\x50\x4E\x47\x0D\x0A\x1A\x0A/) { if ($filedata =~ /^\x89\x50\x4E\x47\x0D\x0A\x1A\x0A/) {
print "TEST-OK $library library generated a good PNG image.\n"; say "TEST-OK $library library generated a good PNG image.";
unlink $local_file; unlink $local_file;
} else { } else {
print "TEST-WARNING $library library did not generate a good PNG.\n"; say "TEST-WARNING $library library did not generate a good PNG.";
} }
} }
......
...@@ -94,5 +94,5 @@ foreach my $email (sort (keys %bugs)) { ...@@ -94,5 +94,5 @@ foreach my $email (sort (keys %bugs)) {
MessageToMTA($msg); MessageToMTA($msg);
print "$email " . join(" ", @{$bugs{$email}}) . "\n"; say "$email " . join(" ", @{$bugs{$email}});
} }
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