File: recreate.t

package info (click to toggle)
spamassassin 4.0.2-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 25,732 kB
  • sloc: perl: 89,143; ansic: 5,193; sh: 3,737; javascript: 339; sql: 295; makefile: 209; python: 49
file content (71 lines) | stat: -rwxr-xr-x 1,633 bytes parent folder | download | duplicates (3)
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
#!/usr/bin/perl -T

use Data::Dumper;
use lib '.'; use lib 't';
use SATest; sa_t_init("recreate");
use Test::More tests => 9;

use strict;
use warnings;
use Mail::SpamAssassin;

our $warning = 0;

$SIG{'__WARN__'} = sub {
  print STDERR @_;

  # certain warnings can be ignored for this test
  if ($_[0] =~ m{plugin: failed to parse plugin.*: Can.t locate } ||
      $_[0] =~ m{is more clearly written simply as .* in regex} ||
      $_[0] =~ m{Ranges of ASCII printables should be some subset of .* in regex})
  {
    print STDERR "[ignored warning, not recreate-related]\n";
  } else {
    ++$warning; 
  }
};

my $spamtest = Mail::SpamAssassin->new({
    rules_filename => $localrules,
    site_rules_filename => $siterules,
    userprefs_filename  => $userrules,
    local_tests_only    => 1,
    debug             => 0,
    dont_copy_prefs   => 1,
});

$spamtest->init(0); # parse rules
ok($spamtest);
open (IN, "<data/spam/009");
my $dataref = [<IN>];
close IN;
my $mail   = $spamtest->parse($dataref);
ok($mail);
my $status = $spamtest->check($mail);
ok($status);
my $output = $status->get_report();
ok($output);

$status->finish();
$mail->finish();
$spamtest->finish();

$spamtest = Mail::SpamAssassin->new({
    rules_filename => $localrules,
    site_rules_filename => $siterules,
    userprefs_filename  => $userrules,
    local_tests_only    => 1,
    debug             => 0,
    dont_copy_prefs   => 1,
});

$spamtest->init(0); # parse rules
ok($spamtest);
$mail   = $spamtest->parse($dataref);
ok($mail);
$status = $spamtest->check($mail);
ok($status);
$output = $status->get_report();
ok($output);

ok($warning == 0);