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 2005/05/17 22:30:51 UTC

svn commit: r170655 - in /spamassassin/trunk/t: data/testplugin.pm spamd_plugin.t

Author: jm
Date: Tue May 17 13:30:50 2005
New Revision: 170655

URL: http://svn.apache.org/viewcvs?rev=170655&view=rev
Log:
spamd_plugin.t: make more platform-agnostic by not using a plugin that requires DB_File, and also test to ensure that plugins are really being called on each subsequent request instead of possibly just on the first one

Modified:
    spamassassin/trunk/t/data/testplugin.pm
    spamassassin/trunk/t/spamd_plugin.t

Modified: spamassassin/trunk/t/data/testplugin.pm
URL: http://svn.apache.org/viewcvs/spamassassin/trunk/t/data/testplugin.pm?rev=170655&r1=170654&r2=170655&view=diff
==============================================================================
--- spamassassin/trunk/t/data/testplugin.pm (original)
+++ spamassassin/trunk/t/data/testplugin.pm Tue May 17 13:30:50 2005
@@ -10,6 +10,7 @@
 package myTestPlugin;
 
 use Mail::SpamAssassin::Plugin;
+use Mail::SpamAssassin::Logger;
 use strict;
 use bytes;
 
@@ -36,7 +37,20 @@
 sub check_test_plugin {
   my ($self, $permsgstatus) = @_;
   print "myTestPlugin eval test called: $self\n";
-  # ... hard work goes here...
+
+  my $file = $ENV{'SPAMD_PLUGIN_COUNTER_FILE'};
+  if ($file) {
+    open (IN, "<$file") or warn;
+    my $count = <IN>; $count += 0;
+    close IN;
+
+    dbg("test: called myTestPlugin, round $count");
+
+    open (OUT, ">$file") or warn;
+    print OUT ++$count;
+    close OUT or warn;
+  }
+
   return 1;
 }
 

Modified: spamassassin/trunk/t/spamd_plugin.t
URL: http://svn.apache.org/viewcvs/spamassassin/trunk/t/spamd_plugin.t?rev=170655&r1=170654&r2=170655&view=diff
==============================================================================
--- spamassassin/trunk/t/spamd_plugin.t (original)
+++ spamassassin/trunk/t/spamd_plugin.t Tue May 17 13:30:50 2005
@@ -3,7 +3,7 @@
 use lib '.'; use lib 't';
 use SATest; sa_t_init("spamd_plugin");
 
-use constant numtests => 7;
+use constant numtests => 6;
 use Test; BEGIN { plan tests => ((!$SKIP_SPAMD_TESTS && !$RUNNING_ON_WINDOWS) ?
                         numtests : 0) };
 
@@ -12,31 +12,40 @@
 # ---------------------------------------------------------------------------
 
 tstlocalrules ('
-    hashcash_accept test@example.com test1@example.com test2@example.com
-    hashcash_doublespend_path log/user_state/hashcash_seen
+        loadplugin myTestPlugin data/testplugin.pm
+        header MY_TEST_PLUGIN eval:check_test_plugin()
 ');
 
+# create a shared counter file for this test
+use Cwd;
+$ENV{'SPAMD_PLUGIN_COUNTER_FILE'} = getcwd."/log/spamd_plugin.tmp";
+open(COUNTER,">log/spamd_plugin.tmp");
+print COUNTER "0";
+close COUNTER;
+
 start_spamd("-D -L --socketpath=log/spamd.sock");
 
 %patterns = (
-q{ X-Spam-Status: Yes, score=}, 'status',
-q{ X-Spam-Flag: YES}, 'flag',
+  q{ test: called myTestPlugin, round 1 }, 'called1'
 );
 ok (spamcrun ("-U log/spamd.sock < data/spam/001", \&patterns_run_cb));
+
+checkfile("spamd_plugin-spamd.err", \&patterns_run_cb);
 ok_all_patterns();
 
 %patterns = (
-q{ HASHCASH_24 }, 'hashcash24',
+  q{ called myTestPlugin, round 2 }, 'called2'
 );
 ok (spamcrun ("-U log/spamd.sock < data/nice/001", \&patterns_run_cb));
+checkfile("spamd_plugin-spamd.err", \&patterns_run_cb);
 ok_all_patterns();
 
 %patterns = (
-q{ HASHCASH_20 }, 'hashcash20',
+  q{ called myTestPlugin, round 3 }, 'called3'
 );
 ok (spamcrun ("-U log/spamd.sock < data/nice/001", \&patterns_run_cb));
+checkfile("spamd_plugin-spamd.err", \&patterns_run_cb);
 ok_all_patterns();
 
 stop_spamd();
-