Mailing List Archive

svn commit: r1901954 - in /spamassassin/trunk/t: basic_lint.t extracttext.t make_install.t sa_awl.t sa_awl_welcome_block.t sa_compile.t strip2.t uri_list.t
Author: sidney
Date: Wed Jun 15 22:53:05 2022
New Revision: 1901954

URL: http://svn.apache.org/viewvc?rev=1901954&view=rev
Log:
bug 8003 - Skip tests or portions that cannot run in Windows, change other non-portable things in tests to portable equivalents

Modified:
spamassassin/trunk/t/basic_lint.t
spamassassin/trunk/t/extracttext.t
spamassassin/trunk/t/make_install.t
spamassassin/trunk/t/sa_awl.t
spamassassin/trunk/t/sa_awl_welcome_block.t
spamassassin/trunk/t/sa_compile.t
spamassassin/trunk/t/strip2.t
spamassassin/trunk/t/uri_list.t

Modified: spamassassin/trunk/t/basic_lint.t
URL: http://svn.apache.org/viewvc/spamassassin/trunk/t/basic_lint.t?rev=1901954&r1=1901953&r2=1901954&view=diff
==============================================================================
--- spamassassin/trunk/t/basic_lint.t (original)
+++ spamassassin/trunk/t/basic_lint.t Wed Jun 15 22:53:05 2022
@@ -3,14 +3,18 @@
use lib '.'; use lib 't';
use SATest; sa_t_init("basic_lint");

+use Test::More;
+
@test_locales = qw(C);
-# Test with few random additional locales if available
-my $locales = untaint_cmd("locale -a");
-while ($locales =~ /^((?:C|en_US|fr_FR|zh_CN)\.(?:utf|iso|gb).*)$/gmi) {
- push @test_locales, $1;
+
+if (!$RUNNING_ON_WINDOWS) {
+ # Test with few random additional locales if available
+ my $locales = untaint_cmd("locale -a");
+ while ($locales =~ /^((?:C|en_US|fr_FR|zh_CN)\.(?:utf|iso|gb).*)$/gmi) {
+ push @test_locales, $1;
+ }
}

-use Test::More;
plan tests => scalar(@test_locales);

# ---------------------------------------------------------------------------

Modified: spamassassin/trunk/t/extracttext.t
URL: http://svn.apache.org/viewvc/spamassassin/trunk/t/extracttext.t?rev=1901954&r1=1901953&r2=1901954&view=diff
==============================================================================
--- spamassassin/trunk/t/extracttext.t (original)
+++ spamassassin/trunk/t/extracttext.t Wed Jun 15 22:53:05 2022
@@ -2,13 +2,11 @@

use lib '.'; use lib 't';
use SATest; sa_t_init("extracttext");
-
+use Mail::SpamAssassin::Util;
use Test::More;

-plan skip_all => "Tests don't work on windows" if $RUNNING_ON_WINDOWS;
-
-use constant PDFTOTEXT => eval { $_ = untaint_cmd("which pdftotext"); chomp; -x && $_ };
-use constant TESSERACT => eval { $_ = untaint_cmd("which tesseract"); chomp; -x && $_ };
+use constant PDFTOTEXT => Mail::SpamAssassin::Util::find_executable_in_env_path('pdftotext');
+use constant TESSERACT => Mail::SpamAssassin::Util::find_executable_in_env_path('tesseract');

my $tests = 0;
$tests += 2 if (PDFTOTEXT);

Modified: spamassassin/trunk/t/make_install.t
URL: http://svn.apache.org/viewvc/spamassassin/trunk/t/make_install.t?rev=1901954&r1=1901953&r2=1901954&view=diff
==============================================================================
--- spamassassin/trunk/t/make_install.t (original)
+++ spamassassin/trunk/t/make_install.t Wed Jun 15 22:53:05 2022
@@ -5,16 +5,17 @@ $ENV{'TEST_PERL_TAINT'} = 'no'; # in
use SATest; sa_t_init("make_install");

use Config;
-use Test::More tests => 25;
-
+use Test::More;
+plan skip_all => "Tests don't work on windows" if $RUNNING_ON_WINDOWS;
+plan tests => 25;
# -------------------------------------------------------------------

use Cwd;
my $cwd = getcwd;
my $builddir = "$cwd/$workdir/d.$testname/build";
my $instbase = "$cwd/$workdir/d.$testname/inst";
-untaint_system("rm -rf $instbase $builddir");
-untaint_system("mkdir -p $instbase $builddir");
+rmtree($instbase, $builddir, { safe => 1 });
+mkpath($instbase, $builddir, { error => \my $err_list });

untaint_system("cd .. && make tardist >/dev/null");
$? == 0 or die "tardist failed: $?";

Modified: spamassassin/trunk/t/sa_awl.t
URL: http://svn.apache.org/viewvc/spamassassin/trunk/t/sa_awl.t?rev=1901954&r1=1901953&r2=1901954&view=diff
==============================================================================
--- spamassassin/trunk/t/sa_awl.t (original)
+++ spamassassin/trunk/t/sa_awl.t Wed Jun 15 22:53:05 2022
@@ -19,7 +19,7 @@ tstprefs ("
sarun("--add-addr-to-whitelist whitelist_test\@whitelist.spamassassin.taint.org",
\&patterns_run_cb);

-untaint_system("pwd");
+print cwd() . "\n";
saawlrun("--clean --min 9999 ./$userstate/awltest");

sarun ("-L -t < data/spam/004", \&patterns_run_cb);

Modified: spamassassin/trunk/t/sa_awl_welcome_block.t
URL: http://svn.apache.org/viewvc/spamassassin/trunk/t/sa_awl_welcome_block.t?rev=1901954&r1=1901953&r2=1901954&view=diff
==============================================================================
--- spamassassin/trunk/t/sa_awl_welcome_block.t (original)
+++ spamassassin/trunk/t/sa_awl_welcome_block.t Wed Jun 15 22:53:05 2022
@@ -19,7 +19,7 @@ tstprefs ("
sarun("--add-addr-to-welcomelist whitelist_test\@whitelist.spamassassin.taint.org",
\&patterns_run_cb);

-untaint_system("pwd");
+print cwd() . "\n";
saawlrun("--clean --min 9999 ./$userstate/awltest");

sarun ("-L -t < data/spam/004", \&patterns_run_cb);

Modified: spamassassin/trunk/t/sa_compile.t
URL: http://svn.apache.org/viewvc/spamassassin/trunk/t/sa_compile.t?rev=1901954&r1=1901953&r2=1901954&view=diff
==============================================================================
--- spamassassin/trunk/t/sa_compile.t (original)
+++ spamassassin/trunk/t/sa_compile.t Wed Jun 15 22:53:05 2022
@@ -9,8 +9,6 @@ $ENV{'TEST_PERL_TAINT'} = 'no'; # in
use SATest; sa_t_init("sa_compile");

use Config;
-use File::Basename;
-use File::Path qw/mkpath/;

my $temp_binpath = $Config{sitebinexp};
$temp_binpath =~ s|^\Q$Config{siteprefixexp}\E/||;
@@ -25,10 +23,10 @@ plan tests => 24;

use Cwd;
my $cwd = getcwd;
-my $builddir = "$cwd/$workdir/d.$testname/build";
-my $instbase = "$cwd/$workdir/d.$testname/inst";
-untaint_system("rm -rf $instbase $builddir");
-untaint_system("mkdir -p $instbase $builddir");
+my $builddir = untaint_var("$cwd/$workdir/d.$testname/build");
+my $instbase = untaint_var("$cwd/$workdir/d.$testname/inst");
+rmtree("$instbase", "$builddir", { safe => 1 });
+mkpath("$instbase", "$builddir", { error => \my $err_list });

untaint_system("cd .. && make tardist >/dev/null");
$? == 0 or die "tardist failed: $?";
@@ -61,7 +59,7 @@ meta META2 FOO5 && FOO6 && FOO7 && FOO8
');

# ensure we don't use compiled rules
-untaint_system("rm -rf $instdir/var/spamassassin/compiled");
+rmtree("$instdir/var/spamassassin/compiled", { safe => 1 });

%patterns = (
qr/ check: tests=FOO1,FOO2,FOO3,FOO4,META1\n/, '',
@@ -87,7 +85,7 @@ ok_all_patterns();

# -------------------------------------------------------------------

-untaint_system "rm -rf \$HOME/.spamassassin/sa-compile.cache"; # reset test
+rmtree( glob "~/.spamassassin/sa-compile.cache". { safe => 1 }); # reset test
system_or_die "TMP=$instdir TMPDIR=$instdir $instdir/$temp_binpath/sa-compile --quiet -p $cwd/$workdir/user.cf --keep-tmps -D 2>$instdir/sa-compile.debug"; # --debug
$scr = "$instdir/$temp_binpath/spamassassin";
$scr_localrules_args = $scr_cf_args = ""; # use the default rules dir, from our "install"
@@ -115,7 +113,7 @@ ok_all_patterns();
# -------------------------------------------------------------------

# Cleanup after testing (todo, sa-compile should have option for userstatedir)
-untaint_system "rm -rf \$HOME/.spamassassin/sa-compile.cache";
+rmtree( glob "~/.spamassassin/sa-compile.cache". { safe => 1 }); # reset test

# -------------------------------------------------------------------

@@ -137,7 +135,8 @@ sub re2c_version_new_enough {
sub new_instdir {
$instdir = untaint_var($instbase.".".(shift));
print "\nsetting new instdir: $instdir\n";
- untaint_system("rm -rf $instdir; mkdir $instdir");
+ rmtree("$instdir", { safe => 1 });
+ mkpath($instdir, { error => \my $listerrs });
}

sub run_makefile_pl {

Modified: spamassassin/trunk/t/strip2.t
URL: http://svn.apache.org/viewvc/spamassassin/trunk/t/strip2.t?rev=1901954&r1=1901953&r2=1901954&view=diff
==============================================================================
--- spamassassin/trunk/t/strip2.t (original)
+++ spamassassin/trunk/t/strip2.t Wed Jun 15 22:53:05 2022
@@ -11,6 +11,7 @@ plan tests => 98;

use File::Copy;
use File::Compare qw(compare_text);
+use Text::Diff;

my @files = qw(
data/nice/crlf-endings
@@ -113,11 +114,10 @@ ok (-f $d_output);
ok(!compare_text($input,$d_output))
or diffwarn( $input, $d_output );

-
sub diffwarn {
my ($f1, $f2) = @_;
print STDERR "# Diff is as follows:\n";
- untaint_system "diff -u $f1 $f2 | cat -v >&2";
+ diff ($f1, $f2, { STYLE => 'unified', OUTPUT => \*STDERR });
print "\n\n";
}


Modified: spamassassin/trunk/t/uri_list.t
URL: http://svn.apache.org/viewvc/spamassassin/trunk/t/uri_list.t?rev=1901954&r1=1901953&r2=1901954&view=diff
==============================================================================
--- spamassassin/trunk/t/uri_list.t (original)
+++ spamassassin/trunk/t/uri_list.t Wed Jun 15 22:53:05 2022
@@ -130,8 +130,9 @@ for my $mail ($twoplus, $threeurls, $th
# this is ugly, but it actually demos the bug.
open (my $mfh, ">", "$tmpdir/msg");
print $mfh "$mail";
- my $haverules = ( -f "../rules/25_uribl.cf" ) ;
- my $sarcnt = qx/..\/spamassassin -D all < $tmpdir\/msg 2>&1 |grep -c 'uridnsbl:.*skip'/;
+ my $haverules = ( -f "../rules/25_uribl.cf" );
+ use vars qw($sarcnt);
+ sarun("-D all < $tmpdir/msg 2>&1", \&sarcount);
# test isn't very useful without this component, but this will at least skip the subtest when it can't be run
SKIP: {
skip "No rules found!\n", 1 if (! $haverules );
@@ -139,5 +140,8 @@ for my $mail ($twoplus, $threeurls, $th
warn "Simple grep for http:// found $count URLs, get_uri_list found $ulcnt URLs, spamassassin script found $sarcnt\n";
}
}
+ sub sarcount {
+ $sarcnt = grep(/uridnsbl:.*skip/, <IN>);
+ }
}