You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spamassassin.apache.org by jm...@apache.org on 2005/05/24 09:43:18 UTC

svn commit: r178134 - in /spamassassin/trunk: MANIFEST t/config_errs.t

Author: jm
Date: Tue May 24 00:43:18 2005
New Revision: 178134

URL: http://svn.apache.org/viewcvs?rev=178134&view=rev
Log:
bug 4347: first blast of a test script to validate config error handling

Added:
    spamassassin/trunk/t/config_errs.t   (with props)
Modified:
    spamassassin/trunk/MANIFEST

Modified: spamassassin/trunk/MANIFEST
URL: http://svn.apache.org/viewcvs/spamassassin/trunk/MANIFEST?rev=178134&r1=178133&r2=178134&view=diff
==============================================================================
--- spamassassin/trunk/MANIFEST (original)
+++ spamassassin/trunk/MANIFEST Tue May 24 00:43:18 2005
@@ -265,6 +265,7 @@
 t/blacklist_autolearn.t
 t/body_mod.t
 t/cidrs.t
+t/config_errs.t
 t/config.dist
 t/data/etc/hello.txt
 t/data/etc/testhost.cert

Added: spamassassin/trunk/t/config_errs.t
URL: http://svn.apache.org/viewcvs/spamassassin/trunk/t/config_errs.t?rev=178134&view=auto
==============================================================================
--- spamassassin/trunk/t/config_errs.t (added)
+++ spamassassin/trunk/t/config_errs.t Tue May 24 00:43:18 2005
@@ -0,0 +1,82 @@
+#!/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
+$/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;
+use vars qw(%patterns %anti_patterns);
+
+# 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: /x); # "
+}
+
+plan tests => (scalar(keys %anti_patterns) + scalar(keys %patterns));
+
+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";
+}
+
+

Propchange: spamassassin/trunk/t/config_errs.t
------------------------------------------------------------------------------
    svn:executable = *