You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spamassassin.apache.org by ms...@apache.org on 2004/01/18 19:21:14 UTC
svn commit: rev 6209 - incubator/spamassassin/trunk/t
Author: mss
Date: Sun Jan 18 10:21:14 2004
New Revision: 6209
Added:
incubator/spamassassin/trunk/t/SATest.pl (contents, props changed)
Modified:
incubator/spamassassin/trunk/t/SATest.pm
Log:
Add workaround for systems/shells (esp. Windows) which do not support calls a la 'cmd >file 2>&1 &'. Hope this really works under Windows, will test it in afew hours.
Added: incubator/spamassassin/trunk/t/SATest.pl
==============================================================================
--- (empty file)
+++ incubator/spamassassin/trunk/t/SATest.pl Sun Jan 18 10:21:14 2004
@@ -0,0 +1,30 @@
+#!/usr/bin/perl
+# Copyright (c) 2004 Malte S. Stretz
+
+my %opts;
+my @args;
+{
+ my $opts = 1;
+ foreach (@ARGV) {
+ if ($opts) {
+ $opts = 0 if /^--$/;
+ $opts{$1} = $2 if /^-([a-zA-Z])(.+)$/;
+ } else {
+ push (@args, $_);
+ }
+ }
+}
+
+if ($opts{'M'} eq 'redirect') {
+ my $stdout = $opts{'o'} || die "No -o";
+ my $stderr = $opts{'O'} || die "No -O";
+ open (STDOUT, ">$stdout") || die "Could not redirect STDOUT to $stdout: $!";
+ open (STDERR, ">$stderr") || die "Could not redirect STDERR to $stderr: $!";
+
+ $| = 1;
+ exec { $args[0] } @args;
+ die "Could not exec " . join(' ', @args) . ": $!";
+}
+else {
+ die "Unknown mode: $mode\n";
+}
\ No newline at end of file
Modified: incubator/spamassassin/trunk/t/SATest.pm
==============================================================================
--- incubator/spamassassin/trunk/t/SATest.pm (original)
+++ incubator/spamassassin/trunk/t/SATest.pm Sun Jan 18 10:21:14 2004
@@ -72,13 +72,13 @@
for $file (<../rules/*.cf>) {
$base = basename $file;
copy ($file, "log/test_rules_copy/$base")
- or warn "cannot copy $file to log/test_rules_copy/$base";
+ or warn "cannot copy $file to log/test_rules_copy/$base";
}
mkdir ("log/localrules.tmp", 0755);
copy ("../rules/user_prefs.template", "log/test_rules_copy/99_test_default.cf")
- or die "user prefs copy failed";
+ or die "user prefs copy failed";
open (PREFS, ">>log/test_rules_copy/99_test_default.cf");
print PREFS $default_cf_lines;
@@ -269,8 +269,21 @@
warn "oops! SATest.pm: a test prefs file was created, but spamd isn't reading it\n";
}
- print ("\t$spamdargs > log/$testname.spamd 2>&1 &\n");
- system ("$spamdargs > log/$testname.spamd 2>&1 &");
+ my $spamd_stdout = "log/$testname-spamd.out";
+ my $spamd_stderr = "log/$testname-spamd.err";
+ my $spamd_stdlog = "log/$testname-spamd.log";
+ my $spamd_cmd = join(' ',
+ $Config{perlpath},
+ qq{SATest.pl},
+ qq{-Mredirect},
+ qq{-o${spamd_stdout}},
+ qq{-O${spamd_stderr}},
+ qq{--},
+ qq{$spamdargs},
+ qq{&},
+ );
+ print ("\t${spamd_cmd}\n");
+ system ($spamd_cmd);
# now find the PID
$spamd_pid = 0;
@@ -281,7 +294,7 @@
while ($spamd_pid <= 0) {
my $spamdlog = '';
- if (open (IN, "<log/$testname.spamd")) {
+ if (open (IN, "<${spamd_stderr}")) {
while (<IN>) {
/Address already in use/ and $retries = 0;
/server pid: (\d+)/ and $spamd_pid = $1;