make testr

2 views
Skip to first unread message

Leopold Toetsch

unread,
May 6, 2005, 6:08:36 AM5/6/05
to Perl 6 Internals
"make testr" is broken. We need some replacement for it. It does:

- read a source file
- compile the source to a .pbc file
- load that .pbc file
- run it

It corresponds to this command line:

$ ./parrot -o foo.pbc -r -r foo.imc

This was basically introduced to test running compiled PBCs, but it's
not quite the same, because during compilation parts of the packfile are
already created in memory for an immediate run. This interfers with the
step of loading a .pbc and running that.

I'll not gonna fix this run simulation, instead we should do the following:

- compile the source to a .pbc
- start a fresh parrot and run the .pbc

According to these command two lines:

$ ./parrot -o foo.pbc foo.imc
$ ./parrot foo.pbc

Patches for the test system are welcome.

Thanks,
leo

Dino Morelli

unread,
May 6, 2005, 11:35:31 PM5/6/05
to Leopold Toetsch, Perl 6 Internals

I think this might do it:

---------------------------------------------------------------------------
Index: lib/Parrot/Test.pm
===================================================================
--- lib/Parrot/Test.pm (revision 7995)
+++ lib/Parrot/Test.pm (working copy)
@@ -380,11 +380,13 @@
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"};
+ $cmd = qq{$parrot $args "$code_f";$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};
---------------------------------------------------------------------------


Also: I'm new. I love Perl. Reading about and waiting for Perl 6 has
been killing me. I want to contribute.

So, greetings to the group! :-)


>Thanks,
>leo

-Dino

--
.~. Dino Morelli
/V\ email: dmor...@reactorweb.net
/( )\ weblog: http://categorically.net/d/blog/
^^-^^ preferred distro: Debian GNU/Linux http://www.debian.org

Leopold Toetsch

unread,
May 7, 2005, 5:49:26 AM5/7/05
to Dino Morelli, perl6-i...@perl.org
Dino Morelli <dmor...@reactorweb.net> 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

> I think this might do it:

> ---------------------------------------------------------------------------
> Index: lib/Parrot/Test.pm
> ===================================================================
> --- lib/Parrot/Test.pm (revision 7995)
> +++ lib/Parrot/Test.pm (working copy)
> @@ -380,11 +380,13 @@
> 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"};
> + $cmd = qq{$parrot $args "$code_f";$parrot "$pbc_f"};

Unfortunately this might be not enough.

- is the semicolon portable?

- a few tests create output during compilation:

$ parrot -o s49.pbc t/pmc/sub_49.pir
initial

$ parrot s49.pbc
main

$ parrot t/pmc/sub_49.pir
initial
main

We probably need to capture output twice and concat it. I should have
mentioned that in the first place.

> Also: I'm new. I love Perl. Reading about and waiting for Perl 6 has
> been killing me.

Mail and patch do indicate a certain liveliness ;-)

> ... I want to contribute.

That's great and very welcome, thanks.

> So, greetings to the group! :-)

And greetings back.

> -Dino

leo

Dino Morelli

unread,
May 7, 2005, 11:09:59 AM5/7/05
to Leopold Toetsch, perl6-i...@perl.org
On Sat, 7 May 2005, Leopold Toetsch wrote:

>Dino Morelli <dmor...@reactorweb.net> 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
>

>> I think this might do it: [snip]
>

Ok, I have more code. But I'm unsure about something still. First, the
code:

---------------------------------------------------------------------------
Index: /home/dmorelli/dev/parrot/lib/Parrot/Test.pm
===================================================================
--- /home/dmorelli/dev/parrot/lib/Parrot/Test.pm (revision 7999)
+++ /home/dmorelli/dev/parrot/lib/Parrot/Test.pm (working copy)
@@ -211,17 +211,30 @@
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
+ for (@$command) {
+ system $_;
+
+ # Check the exit code in $? here, bail out as soon as it's bad?
+ }
+
if( $chdir ) {
- chdir $orig_dir;
+ chdir $orig_dir;
}

my $exit_code = $? >> 8;
@@ -380,11 +393,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.

The part I'm unsure of is the exit codes. As it's written above, the
exit code returned from run_command() is from the last command in the
array. If there's a failure somewhere, it keeps chugging along trying to
perform them all.

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. What do you guys
think?


>Unfortunately this might be not enough.
>
>- is the semicolon portable?
>

The above code eliminates the whole semicolon thing, which is a relief.
:-)


>- a few tests create output during compilation:
>
>$ parrot -o s49.pbc t/pmc/sub_49.pir
>initial
>
>$ parrot s49.pbc
>main
>
>$ parrot t/pmc/sub_49.pir
>initial
>main
>
>We probably need to capture output twice and concat it. I should have
>mentioned that in the first place.
>

As far as capturing output goes: I may be missing something, but it
seems like this is functioning correctly even with stuff like sub_49
above simply by system()ing the commands in the array sequentially and
not explicitly grabbing the output.

Probably because everything's still getting sent to STDOUT even though
it's separate system() calls.

Dino Morelli

unread,
May 7, 2005, 10:17:31 PM5/7/05
to Leopold Toetsch, perl6-i...@perl.org
On Sat, 7 May 2005, Dino Morelli wrote:

>On Sat, 7 May 2005, Leopold Toetsch wrote:
>
>>Dino Morelli <dmor...@reactorweb.net> 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 @@

-Dino

Leopold Toetsch

unread,
May 8, 2005, 5:28:14 AM5/8/05
to Dino Morelli, perl6-i...@perl.org
Dino Morelli <dmor...@reactorweb.net> wrote:
> On Sat, 7 May 2005, Dino Morelli wrote:

>>On Sat, 7 May 2005, Leopold Toetsch wrote:

>>>>>$ ./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.

Yep.

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

Thanks, applied.
leo

Reply all
Reply to author
Forward
0 new messages