-
Notifications
You must be signed in to change notification settings - Fork 70
/
config_errs.t
executable file
·86 lines (62 loc) · 1.75 KB
/
config_errs.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
#!/usr/bin/perl -w
# TODO: this script does not work yet. There are (a) lots of failures
# and (b) the 'plan' line means all tests are effectively ignored from
# 'make test'.
use Test;
plan tests => 0;
exit 0;
# ---------------------------------------------------------------------------
# these items either kill the test or are valid with no arg
my $WHITELIST = qr/^
require_version
|\S+_template
|clear_trusted_networks
|clear_internal_networks
|clear_headers
|descriptions
|test
$/ox;
# ---------------------------------------------------------------------------
BEGIN {
if (-e 't/test_dir') { # if we are running "t/rule_names.t", kluge around ...
chdir 't';
}
if (-e 'test_dir') { # running from test directory, not ..
unshift(@INC, '../blib/lib');
}
}
my $prefix = '.';
if (-e 'test_dir') { # running from test directory, not ..
$prefix = '..';
}
use strict;
use SATest; sa_t_init("config_errs");
use Test;
use Mail::SpamAssassin;
# initialize SpamAssassin
my $sa = create_saobj({'dont_copy_prefs' => 1});
$sa->init(0); # parse rules
my @want = ();
my $cf = '';
foreach my $cmd (@{$sa->{conf}{registered_commands}}) {
my $name = $cmd->{setting};
next if ($name =~ $WHITELIST);
$cf .= "$name\n";
push (@want, qr/failed to parse line, (?:no value provided|\"\" is not valid) for \"$name\", skipping: / ); # "
}
plan tests => $#want+3;
tstlocalrules ($cf);
my $fh = IO::File->new_tmpfile();
ok($fh);
open(STDERR, ">&=".fileno($fh)) || die "Cannot reopen STDERR";
sarun ("-L < data/nice/001", \&patterns_run_cb);
ok(1);
seek($fh, 0, 0);
my $error = do {
local $/;
<$fh>;
};
print "# $error\n";
foreach my $item (@want) {
ok ($error =~ $item) or print "(wanted: $item)\n";
}