You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spamassassin.apache.org by jm...@apache.org on 2009/11/17 01:06:03 UTC
svn commit: r881065 - in /spamassassin/trunk: ./ MANIFEST
lib/Mail/SpamAssassin/Plugin/OneLineBodyRuleType.pm t/sa_compile.t
xt/50_sa_compile.t
Author: jm
Date: Tue Nov 17 00:06:03 2009
New Revision: 881065
URL: http://svn.apache.org/viewvc?rev=881065&view=rev
Log:
bug 6214: sa-compile broken by change from bug 6060, fix (and add test)
Added:
spamassassin/trunk/t/sa_compile.t
spamassassin/trunk/xt/50_sa_compile.t (with props)
Modified:
spamassassin/trunk/ (props changed)
spamassassin/trunk/MANIFEST
spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/OneLineBodyRuleType.pm
Modified: spamassassin/trunk/MANIFEST
URL: http://svn.apache.org/viewvc/spamassassin/trunk/MANIFEST?rev=881065&r1=881064&r2=881065&view=diff
==============================================================================
--- spamassassin/trunk/MANIFEST (original)
+++ spamassassin/trunk/MANIFEST Tue Nov 17 00:06:03 2009
@@ -519,3 +519,4 @@
t/stop_always_matching_regexps.t
t/cross_user_config_leak.t
t/if_can.t
+t/sa_compile.t
Modified: spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/OneLineBodyRuleType.pm
URL: http://svn.apache.org/viewvc/spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/OneLineBodyRuleType.pm?rev=881065&r1=881064&r2=881065&view=diff
==============================================================================
--- spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/OneLineBodyRuleType.pm (original)
+++ spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/OneLineBodyRuleType.pm Tue Nov 17 00:06:03 2009
@@ -125,7 +125,7 @@
pre_loop_body => sub
{
my ($self, $pms, $conf, %opts) = @_;
- $self->add_evalstr ('
+ $self->add_evalstr($pms, '
my $bodytext = $self->get_decoded_stripped_body_text_array();
$self->{main}->call_plugins("run_body_fast_scan", {
Added: spamassassin/trunk/t/sa_compile.t
URL: http://svn.apache.org/viewvc/spamassassin/trunk/t/sa_compile.t?rev=881065&view=auto
==============================================================================
--- spamassassin/trunk/t/sa_compile.t (added)
+++ spamassassin/trunk/t/sa_compile.t Tue Nov 17 00:06:03 2009
@@ -0,0 +1,133 @@
+#!/usr/bin/perl
+
+use lib '.'; use lib 't';
+$ENV{'TEST_PERL_TAINT'} = 'no'; # inhibit for this test
+use SATest; sa_t_init("sa_compile");
+use Test;
+
+use constant TEST_ENABLED => conf_bool('run_long_tests');
+BEGIN {
+ if (-e 't/test_dir') {
+ chdir 't';
+ }
+ if (-e 'test_dir') {
+ unshift(@INC, '../blib/lib');
+ }
+ plan tests => ((TEST_ENABLED && !$RUNNING_ON_WINDOWS) ? 5 : 0);
+};
+
+exit unless (TEST_ENABLED && !$RUNNING_ON_WINDOWS);
+
+# -------------------------------------------------------------------
+
+my $INST_FROM_SCRATCH = 1; # set to 0 to short-circuit
+#my $INST_FROM_SCRATCH = 0; # set to 0 to short-circuit
+
+sub system_or_die;
+use Cwd;
+my $cwd = getcwd;
+my $builddir = "$cwd/log/d.$testname/build";
+my $instbase = "$cwd/log/d.$testname/inst";
+
+if ($INST_FROM_SCRATCH) {
+ system_or_die "cd .. && make tardist";
+ system("rm -rf $builddir");
+ system("mkdir -p $builddir");
+ system_or_die "cd $builddir && gunzip -cd $cwd/../Mail-SpamAssassin-*.tar.gz | tar xf -";
+ system_or_die "cd $builddir && mv Mail-SpamAssassin-* x";
+}
+
+sub new_instdir {
+ $instdir = $instbase.".".(shift);
+ print "\nsetting new instdir: $instdir\n";
+ $INST_FROM_SCRATCH and system("rm -rf $instdir; mkdir $instdir");
+}
+
+sub run_makefile_pl {
+ my $args = $_[0];
+ system_or_die "cd $builddir/x && $perl_cmd Makefile.PL ".
+ "$args < /dev/null 2>&1";
+ system_or_die "cd $builddir/x && make install 2>&1";
+ print "current instdir: $instdir\n";
+}
+
+sub set_rules {
+ my $rules = shift;
+ open RULES, ">$instdir/foo/share/spamassassin/20_testrules.cf"
+ or die "cannot write $instdir/foo/share/spamassassin/20_testrules.cf";
+ print RULES qq{
+
+ use_bayes 0
+
+ $rules
+
+ };
+ close RULES or die;
+
+ open RULES, ">$instdir/foo/etc/mail/spamassassin/v330.pre"
+ or die "cannot write $instdir/foo/etc/mail/spamassassin/v330.pre";
+ print RULES qq{
+
+ loadplugin Mail::SpamAssassin::Plugin::MIMEHeader
+ loadplugin Mail::SpamAssassin::Plugin::ReplaceTags
+ loadplugin Mail::SpamAssassin::Plugin::Check
+ loadplugin Mail::SpamAssassin::Plugin::HTTPSMismatch
+ loadplugin Mail::SpamAssassin::Plugin::URIDetail
+ loadplugin Mail::SpamAssassin::Plugin::Bayes
+ loadplugin Mail::SpamAssassin::Plugin::BodyEval
+ loadplugin Mail::SpamAssassin::Plugin::DNSEval
+ loadplugin Mail::SpamAssassin::Plugin::HTMLEval
+ loadplugin Mail::SpamAssassin::Plugin::HeaderEval
+ loadplugin Mail::SpamAssassin::Plugin::MIMEEval
+ loadplugin Mail::SpamAssassin::Plugin::RelayEval
+ loadplugin Mail::SpamAssassin::Plugin::URIEval
+ loadplugin Mail::SpamAssassin::Plugin::WLBLEval
+ loadplugin Mail::SpamAssassin::Plugin::Rule2XSBody
+
+ };
+ close RULES or die;
+}
+
+# -------------------------------------------------------------------
+
+new_instdir("basic");
+$INST_FROM_SCRATCH and run_makefile_pl "PREFIX=$instdir/foo";
+
+# we now have an "installed" version we can run sa-compile with. Ensure
+# sarun() will use it appropriately
+$scr = "$instdir/foo/bin/spamassassin";
+$scr_localrules_args = $scr_cf_args = ""; # use the default rules dir, from our "install"
+
+set_rules q{
+
+ body FOO /You have been selected to receive/
+
+};
+
+# ensure we don't use compiled rules
+system("rm -rf $instdir/foo/var/spamassassin/compiled");
+%patterns = (
+
+ q{ check: tests=FOO }, 'FOO'
+
+);
+ok sarun ("-D -Lt < $cwd/data/spam/001 2>&1", \&patterns_run_cb);
+ok_all_patterns();
+clear_pattern_counters();
+
+# -------------------------------------------------------------------
+
+system_or_die "$instdir/foo/bin/sa-compile --debug --keep-tmps";
+%patterns = (
+
+ q{ able to use 1/1 'body_0' compiled rules }, 'able-to-use',
+ q{ check: tests=FOO }, 'FOO'
+
+);
+$scr = "$instdir/foo/bin/spamassassin";
+$scr_localrules_args = $scr_cf_args = ""; # use the default rules dir, from our "install"
+ok sarun ("-D -Lt < $cwd/data/spam/001 2>&1", \&patterns_run_cb);
+ok_all_patterns();
+
+# -------------------------------------------------------------------
+
Added: spamassassin/trunk/xt/50_sa_compile.t
URL: http://svn.apache.org/viewvc/spamassassin/trunk/xt/50_sa_compile.t?rev=881065&view=auto
==============================================================================
--- spamassassin/trunk/xt/50_sa_compile.t (added)
+++ spamassassin/trunk/xt/50_sa_compile.t Tue Nov 17 00:06:03 2009
@@ -0,0 +1,8 @@
+
+#!/usr/bin/perl
+ (-d "../t") and chdir "..";
+ system( "$^X", "t/sa_compile.t",
+ "--override", "run_long_tests", "1", @ARGV);
+ ($? >> 8 == 0) or die "exec failed";
+
+
Propchange: spamassassin/trunk/xt/50_sa_compile.t
------------------------------------------------------------------------------
svn:executable = *