svn commit: r1935148 - spamassassin/trunk/t
[email protected] Mon, 08 Jun 2026 15:09:31 -0000
| Newsgroups | gmane.mail.spam.spamassassin.cvs |
|---|---|
| Message-ID | <178093137103.4108650.14218994887691121010@svn03-he-fi> |
Author: gbechis
Date: Mon Jun 8 15:09:30 2026
New Revision: 1935148
Log:
move `check_examined` sub to a common file
Modified:
spamassassin/trunk/t/SATest.pm
spamassassin/trunk/t/bayessql.t
spamassassin/trunk/t/neuralnetwork.t
Modified: spamassassin/trunk/t/SATest.pm
==============================================================================
--- spamassassin/trunk/t/SATest.pm Mon Jun 8 15:03:46 2026 (r1935147)
+++ spamassassin/trunk/t/SATest.pm Mon Jun 8 15:09:30 2026 (r1935148)
@@ -1247,6 +1247,25 @@ sub untaint_cmd {
}
}
+# check examined tokens
+sub check_examined_token {
+ local ($_);
+ my $string = shift;
+
+ if (defined $string) {
+ $_ = $string;
+ } else {
+ $_ = join ('', <IN>);
+ }
+
+ if ($_ =~ /(?:Forgot|Learned) tokens from \d+ message\(s\) \((\d+) message\(s\) examined\)/) {
+ #print STDERR "examined $1 messages\n";
+ if (defined $wanted_examined && $wanted_examined == $1) {
+ $found{'Acted on message'}++;
+ }
+ }
+}
+
END {
# Cleanup workdir (but not if inside forked process)
if (defined $workdir && !$keep_workdir && $$ == $mainpid) {
Modified: spamassassin/trunk/t/bayessql.t
==============================================================================
--- spamassassin/trunk/t/bayessql.t Mon Jun 8 15:03:46 2026 (r1935147)
+++ spamassassin/trunk/t/bayessql.t Mon Jun 8 15:09:30 2026 (r1935148)
@@ -347,27 +347,27 @@ tstprefs ("
%patterns = ( 1 => 'Acted on message' );
$wanted_examined = count_files("data/spam");
-ok(salearnrun("-L --spam data/spam", \&check_examined));
+ok(salearnrun("-L --spam data/spam", \&check_examined_token));
ok_all_patterns();
$wanted_examined = count_files("data/nice");
-ok(salearnrun("-L --ham data/nice", \&check_examined));
+ok(salearnrun("-L --ham data/nice", \&check_examined_token));
ok_all_patterns();
$wanted_examined = count_files("data/welcomelists");
-ok(salearnrun("-L --ham data/welcomelists", \&check_examined));
+ok(salearnrun("-L --ham data/welcomelists", \&check_examined_token));
ok_all_patterns();
$wanted_examined = 3;
-ok(salearnrun("-L --ham --mbox data/nice.mbox", \&check_examined));
+ok(salearnrun("-L --ham --mbox data/nice.mbox", \&check_examined_token));
ok_all_patterns();
$wanted_examined = 3;
-ok(salearnrun("-L --ham --mbox < data/nice.mbox", \&check_examined));
+ok(salearnrun("-L --ham --mbox < data/nice.mbox", \&check_examined_token));
ok_all_patterns();
$wanted_examined = 3;
-ok(salearnrun("-L --forget --mbox data/nice.mbox", \&check_examined));
+ok(salearnrun("-L --forget --mbox data/nice.mbox", \&check_examined_token));
ok_all_patterns();
%patterns = ( 'non-token data: bayes db version' => 'db version' );
@@ -462,24 +462,6 @@ $sa->finish_learner();
}
#---------------------------------------------------------------------------
-sub check_examined {
- local ($_);
- my $string = shift;
-
- if (defined $string) {
- $_ = $string;
- } else {
- $_ = join ('', <IN>);
- }
-
- if ($_ =~ /(?:Forgot|Learned) tokens from \d+ message\(s\) \((\d+) message\(s\) examined\)/) {
- #print STDERR "examined $1 messages\n";
- if (defined $wanted_examined && $wanted_examined == $1) {
- $found{'Acted on message'}++;
- }
- }
-}
-
sub count_files {
my $cnt = 0;
find({wanted => sub { $cnt++ if -f $_; }, no_chdir => 1}, $_[0]);
Modified: spamassassin/trunk/t/neuralnetwork.t
==============================================================================
--- spamassassin/trunk/t/neuralnetwork.t Mon Jun 8 15:03:46 2026 (r1935147)
+++ spamassassin/trunk/t/neuralnetwork.t Mon Jun 8 15:09:30 2026 (r1935148)
@@ -12,24 +12,6 @@ use constant HAS_SQLITE => eval { requir
plan tests => 18;
-sub check_examined {
- local ($_);
- my $string = shift;
-
- if (defined $string) {
- $_ = $string;
- } else {
- $_ = join ('', <IN>);
- }
-
- if ($_ =~ /(?:Forgot|Learned) tokens from \d+ message\(s\) \((\d+) message\(s\) examined\)/) {
- #print STDERR "examined $1 messages\n";
- if (defined $wanted_examined && $wanted_examined == $1) {
- $found{'Acted on message'}++;
- }
- }
-}
-
sub nn_reinit {
my $extra = shift || '';
rmtree("$userstate/NN") if -d "$userstate/NN";
@@ -55,8 +37,8 @@ sub nn_reinit {
}
nn_reinit();
-ok(salearnrun("-L --spam data/spam/001", \&check_examined));
-ok(salearnrun("-L --ham data/nice/001", \&check_examined));
+ok(salearnrun("-L --spam data/spam/001", \&check_examined_token));
+ok(salearnrun("-L --ham data/nice/001", \&check_examined_token));
%patterns = ( q{ 1.0 NN_SPAM }, '' );
%anti_patterns = ( q{ -1.0 NN_HAM }, '' );