From 5242eeb1f4bc23dd933892a0d3092746f46ad44e Mon Sep 17 00:00:00 2001
From: Don Armstrong <don@donarmstrong.com>
Date: Tue, 24 Jun 2008 18:17:25 -0700
Subject: [PATCH]  * Fix tests for .in renaming  * Fix waitpid resetting $?
 failures

---
 t/06_mail_handling.t |  1 +
 t/07_bugreport.t     |  1 +
 t/09_soap.t          | 13 ++++---------
 t/lib/DebbugsTest.pm | 16 +++++++++-------
 4 files changed, 15 insertions(+), 16 deletions(-)

diff --git a/t/06_mail_handling.t b/t/06_mail_handling.t
index f83eabb9..ccf1ee79 100644
--- a/t/06_mail_handling.t
+++ b/t/06_mail_handling.t
@@ -228,6 +228,7 @@ while (my ($command,$control_command) = splice(@control_commands,0,2)) {
 			      Subject => "Munging a bug with $command",
 			     ],
 		  body => <<EOF) or fail 'message to control@bugs.something failed';
+debug 10
 $control_command->{command} 1$control_command->{value}
 thanks
 EOF
diff --git a/t/07_bugreport.t b/t/07_bugreport.t
index 18ccbc5c..78fbdc74 100644
--- a/t/07_bugreport.t
+++ b/t/07_bugreport.t
@@ -78,3 +78,4 @@ ok($mech->content() =~ qr/\<title\>\#1.+Submitting a bug/i,
    'Title of bug is submitting a bug');
 
 # Other tests for bugs in the page should be added here eventually
+
diff --git a/t/09_soap.t b/t/09_soap.t
index 3154a083..2a04c60e 100644
--- a/t/09_soap.t
+++ b/t/09_soap.t
@@ -6,13 +6,6 @@ use Test::More tests => 4;
 use warnings;
 use strict;
 
-# Here, we're going to shoot messages through a set of things that can
-# happen.
-
-# First, we're going to send mesages to receive.
-# To do so, we'll first send a message to submit,
-# then send messages to the newly created bugnumber.
-
 use IO::File;
 use File::Temp qw(tempdir);
 use Cwd qw(getcwd);
@@ -32,7 +25,7 @@ if ($@) {
      BAIL_OUT($@);
 }
 
-# Output some debugging information if there's an error
+# Output some debugging information if we're debugging
 END{
      if ($ENV{DEBUG}) {
 	  foreach my $key (keys %config) {
@@ -55,7 +48,7 @@ This is a silly bug
 EOF
 
 
-# test bugreport.cgi
+# test the soap server
 
 my $port = 11343;
 
@@ -69,8 +62,10 @@ our $child_pid = undef;
 
 END{
      if (defined $child_pid) {
+	  my $temp_exit = $?;
 	  kill(15,$child_pid);
 	  waitpid(-1,0);
+	  $? = $temp_exit;
      }
 }
 
diff --git a/t/lib/DebbugsTest.pm b/t/lib/DebbugsTest.pm
index 5d04848b..580c41d5 100644
--- a/t/lib/DebbugsTest.pm
+++ b/t/lib/DebbugsTest.pm
@@ -151,16 +151,16 @@ sub send_message{
      my $output='';
      local $SIG{PIPE} = 'IGNORE';
      local $SIG{CHLD} = sub {};
-     my $pid = open3($wfd,$rfd,$rfd,'scripts/receive.in')
-	  or die "Unable to start receive.in: $!";
+     my $pid = open3($wfd,$rfd,$rfd,'scripts/receive')
+	  or die "Unable to start receive: $!";
      print {$wfd} create_mime_message($param{headers},
-					 $param{body}) or die "Unable to to print to receive.in";
-     close($wfd) or die "Unable to close receive.in";
+					 $param{body}) or die "Unable to to print to receive";
+     close($wfd) or die "Unable to close receive";
      my $err = $? >> 8;
      my $childpid = waitpid($pid,0);
      if ($childpid != -1) {
 	  $err = $? >> 8;
-	  print STDERR "receive.in pid: $pid doesn't match childpid: $childpid\n" if $childpid != $pid;
+	  print STDERR "receive pid: $pid doesn't match childpid: $childpid\n" if $childpid != $pid;
      }
      if ($err != 0 ) {
 	  my $rfh =  IO::Handle->new_from_fd($rfd,'r') or die "Unable to create filehandle: $!";
@@ -171,11 +171,11 @@ sub send_message{
 	       print STDERR "Reading from STDOUT/STDERR would have blocked.";
 	  }
 	  print STDERR $output,qq(\n);
-	  die "receive.in failed with exit status $err";
+	  die "receive failed with exit status $err";
      }
      # now we should run processall to see if the message gets processed
      if ($param{run_processall}) {
-	  system('scripts/processall.in') == 0 or die "processall.in failed";
+	  system('scripts/processall') == 0 or die "processall failed";
      }
 }
 
@@ -190,8 +190,10 @@ sub send_message{
      END {
 	  if (defined $child_pid) {
 	       # stop the child
+	       my $temp_exit = $?;
 	       kill(15,$child_pid);
 	       waitpid(-1,0);
+	       $? = $temp_exit;
 	  }
      }
 
-- 
2.39.5