-
Notifications
You must be signed in to change notification settings - Fork 70
/
strip2.t
executable file
·90 lines (76 loc) · 1.91 KB
/
strip2.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#!/usr/bin/perl
use lib '.'; use lib 't';
use SATest; sa_t_init("strip2");
use Test;
# ---------------------------------------------------------------------------
use File::Copy;
use File::Compare qw(compare_text);
my @files = qw(
data/spam/002
data/spam/004
data/spam/011
data/spam/badmime2.txt
data/spam/015
data/spam/016
data/spam/017
);
my $MUNGED = 'log/strip2.munged';
my $INPUT;
plan tests => 2 + 2 * @files;
# Make sure all the files can do "report_safe 0" and "report_safe 1"
foreach $INPUT (@files) {
tstprefs ("
$default_cf_lines
report_safe 0
body TEST_ALWAYS /./
score TEST_ALWAYS 100
");
# create report_safe 0 output
sarun ("-L < $INPUT");
if (move("log/$testname.${Test::ntest}", $MUNGED)) {
sarun ("-d < $MUNGED");
ok(!compare_text($INPUT,"log/$testname.${Test::ntest}"));
}
else {
warn "move failed: $!\n";
ok(0);
}
tstprefs ("
$default_cf_lines
report_safe 1
body TEST_ALWAYS /./
score TEST_ALWAYS 100
");
# create report_safe 1 and -t output
sarun ("-L -t < $INPUT");
if (move("log/$testname.${Test::ntest}", $MUNGED)) {
sarun ("-d < $MUNGED");
ok(!compare_text($INPUT,"log/$testname.${Test::ntest}"));
}
else {
warn "move failed: $!\n";
ok(0);
}
}
# "report_safe 2" will work if "report_safe 1" works.
# normal mode should always work, don't test multiple files.
$INPUT = $files[0];
tstprefs ("
$default_cf_lines
report_safe 2
body TEST_ALWAYS /./
score TEST_ALWAYS 100
");
# create report_safe 2 output
sarun ("-L < $INPUT");
if (move("log/$testname.${Test::ntest}", $MUNGED)) {
sarun ("-d < $MUNGED");
ok(!compare_text($INPUT,"log/$testname.${Test::ntest}"));
}
else {
warn "move failed: $!\n";
ok(0);
}
# Work directly on regular message, as though it was not spam
sarun ("-d < $INPUT");
ok(!compare_text($INPUT,"log/$testname.${Test::ntest}"));