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 2007/01/23 13:48:35 UTC

svn commit: r499007 - /spamassassin/trunk/t/strip2.t

Author: jm
Date: Tue Jan 23 04:48:34 2007
New Revision: 499007

URL: http://svn.apache.org/viewvc?view=rev&rev=499007
Log:
File::Compare actually *creates* nonexistent files, so some error conditions causing strip2.t test failure were masked in a very confusing way.  fix

Modified:
    spamassassin/trunk/t/strip2.t

Modified: spamassassin/trunk/t/strip2.t
URL: http://svn.apache.org/viewvc/spamassassin/trunk/t/strip2.t?view=diff&rev=499007&r1=499006&r2=499007
==============================================================================
--- spamassassin/trunk/t/strip2.t (original)
+++ spamassassin/trunk/t/strip2.t Tue Jan 23 04:48:34 2007
@@ -18,13 +18,12 @@
 	data/spam/016
 	data/spam/017
 	);
-my $MUNGED = 'log/strip2.munged';
-my $INPUT;
+my $input;
 
-plan tests => 2 + 2 * @files;
+plan tests => 8 + 10 * @files;
 
 # Make sure all the files can do "report_safe 0" and "report_safe 1"
-foreach $INPUT (@files) {
+foreach $input (@files) {
   tstprefs ("
         $default_cf_lines
         report_safe 0
@@ -33,14 +32,21 @@
 	");
 
   # create report_safe 0 output
-  sarun ("-L < $INPUT");
-  if (move("log/d.$testname/${Test::ntest}", $MUNGED)) {
-    sarun ("-d < $MUNGED");
-    ok(!compare_text($INPUT,"log/d.$testname/${Test::ntest}"));
-  }
-  else {
-    warn "move failed: $!\n";
-    ok(0);
+  my $d_input = "log/d.$testname/${Test::ntest}";
+  unlink $d_input;
+  ok sarun ("-L < $input");
+
+  # test for existence; compare_text() will _create_ files!  wtf
+  ok (-f $d_input);
+
+  {
+    print "output: $d_input\n";
+    my $d_output = "log/d.$testname/${Test::ntest}";
+    unlink $d_output;
+    ok sarun ("-d < $d_input");
+    ok (-f $d_output);
+    ok(!compare_text($input,$d_output))
+        or diffwarn( $input, $d_output );
   }
 
   tstprefs ("
@@ -51,20 +57,24 @@
 	");
 
   # create report_safe 1 and -t output
-  sarun ("-L -t < $INPUT");
-  if (move("log/d.$testname/${Test::ntest}", $MUNGED)) {
-    sarun ("-d < $MUNGED");
-    ok(!compare_text($INPUT,"log/d.$testname/${Test::ntest}"));
-  }
-  else {
-    warn "move failed: $!\n";
-    ok(0);
+  $d_input = "log/d.$testname/${Test::ntest}";
+  unlink $d_input;
+  ok sarun ("-L -t < $input");
+  ok (-f $d_input);
+  {
+    print "output: $d_input\n";
+    my $d_output = "log/d.$testname/${Test::ntest}";
+    unlink $d_output;
+    ok sarun ("-d < $d_input");
+    ok (-f $d_output);
+    ok(!compare_text($input,$d_output))
+        or diffwarn( $input, $d_output );
   }
 }
 
 # "report_safe 2" will work if "report_safe 1" works.
-# normal mode should always work, don't test multiple files.
-$INPUT = $files[0];
+# normal mode should always work, do not test multiple files.
+$input = $files[0];
 
 tstprefs ("
         $default_cf_lines
@@ -74,17 +84,33 @@
 	");
 
 # create report_safe 2 output
-sarun ("-L < $INPUT");
-if (move("log/d.$testname/${Test::ntest}", $MUNGED)) {
-  sarun ("-d < $MUNGED");
-  ok(!compare_text($INPUT,"log/d.$testname/${Test::ntest}"));
-}
-else {
-  warn "move failed: $!\n";
-  ok(0);
+$d_input = "log/d.$testname/${Test::ntest}";
+unlink $d_input;
+ok sarun ("-L < $input");
+ok (-f $d_input);
+{
+  print "output: $d_input\n";
+  my $d_output = "log/d.$testname/${Test::ntest}";
+  unlink $d_output;
+  ok sarun ("-d < $d_input");
+  ok (-f $d_output);
+  ok(!compare_text($input,$d_output))
+        or diffwarn( $input, $d_output );
 }
 
 # Work directly on regular message, as though it was not spam
-sarun ("-d < $INPUT");
-ok(!compare_text($INPUT,"log/d.$testname/${Test::ntest}"));
+my $d_output = "log/d.$testname/${Test::ntest}";
+unlink $d_output;
+ok sarun ("-d < $input");
+ok (-f $d_output);
+ok(!compare_text($input,$d_output))
+        or diffwarn( $input, $d_output );
+
+
+sub diffwarn {
+  my ($f1, $f2) = @_;
+  print "# Diff is as follows:\n";
+  system "diff -u $f1 $f2";
+  print "\n\n";
+}