On Sat, 7 May 2005, Dino Morelli wrote:

>On Sat, 7 May 2005, Leopold Toetsch wrote:
>
>>Dino Morelli <[EMAIL PROTECTED]> wrote:
>>> On Fri, 6 May 2005, Leopold Toetsch wrote:
>>
>>>>"make testr" is broken. We need some replacement for it. It does:
>>
>>[ and should do ]
>>
>>>>$ ./parrot -o foo.pbc foo.imc
>>>>$ ./parrot foo.pbc
>>
>>
>
>The part I'm unsure of is the exit codes.
>I could change it to watch for a bad code during the for loop with the
>system(), bail out right there and send that code back.

I thought about it and realized that this is wrong. All of the commands
that used to be one line need to be run or the test case won't see the
output it's looking for. Which in some cases is an intentional failure
with nonzero return value.

So, forget I said anything about the exit codes. The real patch:

---------------------------------------------------------------------------
Index: /home/dmorelli/dev/parrot/lib/Parrot/Test.pm
===================================================================
--- /home/dmorelli/dev/parrot/lib/Parrot/Test.pm        (revision 8004)
+++ /home/dmorelli/dev/parrot/lib/Parrot/Test.pm        (working copy)
@@ -211,17 +211,26 @@
     open  STDOUT, ">$out"    or die "Can't redirect stdout to $out" if $out;
     open  STDERR, ">$err"    or die "Can't redirect stderr to $err" if $err;

-    $command = "$ENV{VALGRIND} $command" if defined $ENV{VALGRIND};
+    # If $command isn't already an arrayref (because of a multi-command
+    # test), make it so now so the code below can treat everybody the
+    # same.
+    $command = [$command] unless (ref $command);

+    if (defined $ENV{VALGRIND}) {
+        $_ = "$ENV{VALGRIND} $_" for (@$command);
+    }
+
     my $orig_dir;
     if( $chdir ) {
-       $orig_dir = cwd;
-       chdir $chdir;
+        $orig_dir = cwd;
+        chdir $chdir;
     }
-    system( $command );

+    # Execute all commands
+    system $_ for (@$command);
+
     if( $chdir ) {
-       chdir $orig_dir;
+        chdir $orig_dir;
     }

     my $exit_code = $? >> 8;
@@ -380,11 +389,20 @@
                 if ( $func !~ /^pir_2_pasm_/ &&
                      ( $args =~ s/--run-pbc// || $args =~ s/-r //) ) {
                     my $pbc_f = per_test('.pbc', $test_no);
-                    $args = qq{$args -o "$pbc_f" -r -r};
+                    $args = qq{$args -o "$pbc_f"};
+
+                    # In this case, we need to execute more than one
+                    # command. Instead of a single scalar, build an
+                    # array of commands.
+                    $cmd = [
+                        qq{$parrot $args "$code_f"},
+                        qq{$parrot "$pbc_f"},
+                    ];
+                } else {
+                    $cmd = qq{$parrot $args "$code_f"};
                 }
-                $cmd = qq{$parrot $args "$code_f"};
                 $exit_code = run_command($cmd, CD => $path_to_parrot,
-                                        STDOUT => $out_f, STDERR => $out_f);
+                    STDOUT => $out_f, STDERR => $out_f);
             }

             my $meth = $parrot_test_map{$func};
---------------------------------------------------------------------------

>What I'm doing:
>
>In the -r case, packing the commands into an anon array and assigning
>that ref to $cmd. Passing that ref to run_command()
>
>run_command() then figures out if it's a ref or not and does the right
>thing.  This seemed more sane than modifying the many places that a $cmd
>gets built in this code.
>

-Dino

-- 
 .~.    Dino Morelli
 /V\    email: [EMAIL PROTECTED]
/( )\   weblog: http://categorically.net/d/blog/
^^-^^   preferred distro: Debian GNU/Linux  http://www.debian.org

Reply via email to