[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index][Thread Index][Top&Search][Original]

[PATCH] test.pl updates



The attached patch makes the following updates to test.pl:

1.  Don't executing the END block (installed by test.pl) in the
watchdog process.
2.  The cleanup of the watchdog process needs a wait().  (This was
causing spurious test failures.)
3.  Use which_perl() throughout test.pl (namely _create_runperl() and
watchdog()).
--- perl-current/t/test.pl
+++ perl-current/t/test.pl
@@ -421,7 +421,10 @@
 
 sub _create_runperl { # Create the string to qx in runperl().
     my %args = @_;
-    my $runperl = $^X =~ m/\s/ ? qq{"$^X"} : $^X;
+    my $runperl = which_perl();
+    if ($runperl =~ m/\s/) {
+        $runperl = qq{"$runperl"};
+    }
     #- this allows, for example, to set PERL_RUNPERL_DEBUG=/usr/bin/valgrind
     if ($ENV{PERL_RUNPERL_DEBUG}) {
 	$runperl = "$ENV{PERL_RUNPERL_DEBUG} $runperl";
@@ -474,14 +477,14 @@
 	$args{stdin} =~ s/\r/\\r/g;
 
 	if ($is_mswin || $is_netware || $is_vms) {
-	    $runperl = qq{$^X -e "print qq(} .
+	    $runperl = qq{$Perl -e "print qq(} .
 		$args{stdin} . q{)" | } . $runperl;
 	}
 	elsif ($is_macos) {
 	    # MacOS can only do two processes under MPW at once;
 	    # the test itself is one; we can't do two more, so
 	    # write to temp file
-	    my $stdin = qq{$^X -e 'print qq(} . $args{stdin} . qq{)' > teststdin; };
+	    my $stdin = qq{$Perl -e 'print qq(} . $args{stdin} . qq{)' > teststdin; };
 	    if ($args{verbose}) {
 		my $stdindisplay = $stdin;
 		$stdindisplay =~ s/\n/\n\#/g;
@@ -491,7 +494,7 @@
 	    $runperl .= q{ < teststdin };
 	}
 	else {
-	    $runperl = qq{$^X -e 'print qq(} .
+	    $runperl = qq{$Perl -e 'print qq(} .
 		$args{stdin} . q{)' | } . $runperl;
 	}
     }
@@ -805,14 +808,15 @@
         my $watchdog;
         eval {
             local $SIG{'__WARN__'} = sub {};
-            $watchdog = system(1, $^X, '-e', "sleep($timeout);" .
-                                             "kill('KILL', $pid_to_kill);");
+            $watchdog = system(1, which_perl(), '-e',
+                                                "sleep($timeout);" .
+                                                "kill('KILL', $pid_to_kill);");
         };
 
         # If the above worked, add END block to parent
-        #   to clean up watchdog process
+        #   to terminate and clean up watchdog process
         if (! $@ && ($watchdog > 0)) {
-            eval "END { kill('KILL', $watchdog); }";
+            eval "END { kill('KILL', $watchdog); wait(); }";
         }
         return;
     }
@@ -823,8 +827,9 @@
     eval { $watchdog = fork() };
     if (defined($watchdog)) {
         if ($watchdog) {   # Parent process
-            # Add END block to parent to clean up watchdog process
-            eval "END { kill('KILL', $watchdog); }";
+            # Add END block to parent to terminate and
+            #   clean up watchdog process
+            eval "END { kill('KILL', $watchdog); wait(); }";
             return;
         }
 
@@ -843,6 +848,9 @@
             kill('KILL', $pid_to_kill);
         }
 
+        # Don't execute END block (added at beginning of this file)
+        $NO_ENDING = 1;
+
         # Terminate ourself (i.e., the watchdog)
         POSIX::_exit(1) if (defined(&POSIX::_exit));
         exit(1);

[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index][Thread Index][Top&Search][Original]