~ubuntu-branches/ubuntu/utopic/spamassassin/utopic-updates

« back to all changes in this revision

Viewing changes to t/rule_names.t

  • Committer: Package Import Robot
  • Author(s): Noah Meyerhans
  • Date: 2014-02-14 22:45:15 UTC
  • mfrom: (0.8.1) (0.6.2) (5.1.22 sid)
  • Revision ID: package-import@ubuntu.com-20140214224515-z1es2twos8xh7n2y
Tags: 3.4.0-1
* New upstream version! (Closes: 738963, 738872, 738867)
* Scrub the environment when switching to the debian-spamd user in
  postinst and cron.daily. (Closes: 738951)
* Enhancements to postinst to better manage ownership of
  /var/lib/spamassassin, via Iain Lane <iain.lane@canonical.com>
  (Closes: 738974)

Show diffs side-by-side

added added

removed removed

Lines of Context:
15
15
  $prefix = '..';
16
16
}
17
17
 
 
18
use lib '.'; use lib 't';
 
19
use SATest; sa_t_init("rule_names");
 
20
 
18
21
use strict;
19
 
use SATest; sa_t_init("rule_names");
20
 
use Test;
21
22
use Mail::SpamAssassin;
22
23
 
23
24
BEGIN {
25
26
  or do { require Digest::SHA1; import Digest::SHA1 qw(sha1) }
26
27
}
27
28
 
 
29
our $RUN_THIS_TEST;
 
30
 
 
31
use Test;
 
32
BEGIN {
 
33
  $RUN_THIS_TEST = conf_bool('run_rule_name_tests');
 
34
 
 
35
  plan tests => 0  if !$RUN_THIS_TEST;
 
36
};
 
37
 
 
38
if (!$RUN_THIS_TEST) {
 
39
  print "NOTE: this test requires 'run_rule_name_tests' set to 'y'.\n";
 
40
  exit;
 
41
}
 
42
 
28
43
use vars qw(%patterns %anti_patterns);
29
44
 
30
45
# initialize SpamAssassin
31
46
my $sa = create_saobj({'dont_copy_prefs' => 1});
32
47
 
 
48
# allow_user_rules, otherwise $sa->{conf}->{test_types} will be
 
49
# deleted by SA::Conf::Parser::finish_parsing()
 
50
$sa->{conf}->{allow_user_rules} = 1;
 
51
 
33
52
$sa->init(0); # parse rules
34
53
 
35
54
# get rule names
55
74
  $anti_patterns{"$test,"} = "P_" . $i++;
56
75
}
57
76
 
58
 
our $RUN_THIS_TEST;
59
 
 
60
 
BEGIN {
61
 
  $RUN_THIS_TEST = conf_bool('run_rule_name_tests');
62
 
 
63
 
  plan tests => (!$RUN_THIS_TEST ? 0 : 
64
 
                  scalar(keys %anti_patterns) + scalar(keys %patterns)),
 
77
{ # couldn't call Test::plan in a BEGIN phase, the %patterns and %anti_patterns
 
78
  # must be assembled first in order to get the planned test count
 
79
 
 
80
  plan tests => scalar(keys %anti_patterns) + scalar(keys %patterns),
 
81
 
65
82
  onfail => sub {
66
83
      warn "\n\n   Note: rule_name failures may be only cosmetic" .
67
84
      "\n        but must be fixed before release\n\n";
68
85
  };
69
86
};
70
87
 
71
 
print "NOTE: this test requires 'run_rule_name_tests' set to 'y'.\n";
72
 
exit unless $RUN_THIS_TEST;
73
 
 
74
88
# ---------------------------------------------------------------------------
75
89
 
76
90