File: check_implemented.t

package info (click to toggle)
spamassassin 3.4.0-6
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 8,296 kB
  • ctags: 2,968
  • sloc: perl: 54,007; ansic: 3,397; sh: 590; makefile: 195; sql: 176; python: 17
file content (75 lines) | stat: -rwxr-xr-x 1,562 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#!/usr/bin/perl

# detect use of dollar-ampersand somewhere in the perl interpreter;
# once it is used once, it slows down every regexp match thereafter.

BEGIN {
  if (-e 't/test_dir') { # if we are running "t/rule_tests.t", kluge around ...
    chdir 't';
  }

  if (-e 'test_dir') {            # running from test directory, not ..
    unshift(@INC, '../blib/lib');
    unshift(@INC, '../lib');
  }
}

my $prefix = '.';
if (-e 'test_dir') {            # running from test directory, not ..
  $prefix = '..';
}

use lib '.'; use lib 't';
use SATest; sa_t_init("check_implemented");
use Test;
use Carp qw(croak);

BEGIN {
  plan tests => 2;
};

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

use strict;
require Mail::SpamAssassin;

# kill all 'loadplugin' lines
foreach my $file 
        (<log/localrules.tmp/*.pre>, <log/test_rules_copy/*.pre>) #*/
{
  rename $file, "$file.bak" or die "rename $file failed";
  open IN, "<$file.bak" or die "cannot read $file.bak";
  open OUT, ">$file" or die "cannot write $file";
  while (<IN>) {
    s/^loadplugin/###loadplugin/g;
    print OUT;
  }
  close IN;
  close OUT;
}

my $sa = create_saobj({
  'dont_copy_prefs' => 1,
  'local_tests_only' => 1
});

$sa->init(1);
ok($sa);

open (IN, "<data/spam/009");
my $mail = $sa->parse(\*IN);
close IN;

$SIG{'__WARN__'} = sub {
  return if /no loaded plugin/;
  print STDERR @_;
};

eval {
  my $status = $sa->check($mail);
  ok 0;       # should never get this far
};

print "got warning: '$@'\n";
ok ($@ =~ /no loaded plugin implements/);