-
Notifications
You must be signed in to change notification settings - Fork 70
/
razor2.t
executable file
·54 lines (42 loc) · 1.62 KB
/
razor2.t
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
#!/usr/bin/perl -T
use lib '.'; use lib 't';
use SATest; sa_t_init("razor2");
use constant HAS_RAZOR2 => eval { require Razor2::Client::Agent; };
use constant HAS_RAZOR2_IDENT => eval { -r $ENV{'HOME'}.'/.razor/identity'; };
use Test::More;
plan skip_all => "Net tests disabled" unless conf_bool('run_net_tests');
plan skip_all => "Needs Razor2" unless HAS_RAZOR2;
plan skip_all => "Needs Razor2 Identity File Needed. razor-register / razor-admin -register has not been run, or identity file ($ENV{'HOME'}/.razor/identity) is unreadable." unless HAS_RAZOR2_IDENT;
plan tests => 8;
diag('Note: Failures may not be an SpamAssassin bug, as Razor tests can fail due to problems with the Razor servers.');
# ---------------------------------------------------------------------------
tstprefs ("
full RAZOR2_CHECK eval:check_razor2()
tflags RAZOR2_CHECK net autolearn_body
dns_available no
use_razor2 1
score RAZOR2_CHECK 3.3
");
#RAZOR2 file contains a test string supplied by Razor tech support
#TESTING FOR SPAM
%patterns = (
q{ 3.3 RAZOR2_CHECK }, 'spam',
);
sarun ("-t < data/spam/razor2", \&patterns_run_cb);
ok_all_patterns();
# Same with fork
sarun ("--cf='razor_fork 1' -t < data/spam/razor2", \&patterns_run_cb);
ok_all_patterns();
#TESTING FOR HAM
%patterns = (
'Connection established', 'connection',
'razor2: part=0 engine=8 contested=0 confidence=0', 'result',
);
%anti_patterns = (
q{ 3.3 RAZOR2_CHECK }, 'nonspam',
);
sarun ("-D razor2 -t < data/nice/001 2>&1", \&patterns_run_cb);
ok_all_patterns();
# same with fork
sarun ("-D razor2 --cf='razor_fork 1' -t < data/nice/001 2>&1", \&patterns_run_cb);
ok_all_patterns();