# New Ticket Created by  Bernhard Schmalhofer 
# Please include the string:  [perl #48226]
# in the subject line of all future correspondence about this issue. 
# <URL: http://rt.perl.org/rt3/Ticket/Display.html?id=48226 >


Hi,

when trying to convert languages/eclectus/t/harnes to Parrot::Test::Harness,
I found that  P::T::H did not pass the 'exec' option  to TAP::Harness.

So I added the 'exec' option, and removed the probably obsolete 
'--gc-debug' hack.

Things look fine on 'Kunbuntu 7.10' with Perl 5.8.8 and Test::Harness 3.04.
Could sombody test-savy have a second look at this patch?

'petite' is available at http://www.scheme.com/petitechezscheme.html

Regards,
   Bernhard

Index: lib/Parrot/Test/Harness.pm
===================================================================
--- lib/Parrot/Test/Harness.pm	(Revision 23505)
+++ lib/Parrot/Test/Harness.pm	(Arbeitskopie)
@@ -7,8 +7,8 @@
 
 =head1 SYNOPSIS
 
-Tell the harness which language (and optionally, compiler) you want to use in a
-file called F<t/harness>:
+Tell the harness which language, and optionally compiler or other executable,
+you want to use in a file called F<t/harness>:
 
   use Parrot::Test::Harness language => 'punie';
 
@@ -16,20 +16,30 @@
 
   use Parrot::Test::Harness language => 'perl6', compiler => 'perl6.pbc';
 
-That's it.  Seriously.
+  # or
 
+  use Parrot::Test::Harness language => 'perl6', compiler => 'perl6.pbc';
+
+  # or
+
+  use Parrot::Test::Harness language => 'eclectus', exec => [ 'petite', '--script' ];
+
+That's it. Seriously.
+
 =head1 DESCRIPTION
 
-This module provides a basic test harness for Parrot-hosted languages.  Right
-now it parameterizes the two parameters that at least three language
+This module provides a basic test harness for Parrot-hosted languages. Right
+now it parameterizes the three parameters that at least four language
 implementations need.
 
 If you really want, you can pass a third option to the C<use> line.
 C<arguments> should be an array reference containing additional arguments (as
 you might find on the command line).
 
-If you don't pass a C<compiler> argument pair, the harness will run the tests
-with C<perl>.  If you I<do> pass the pair, the harness will run the tests with
+If you don't pass a C<compiler> or C<exec> argument pair, the harness will run the tests
+with C<perl>.  If you I<do> pass one of these pairs, the harness can use another executable.
+For C<exec> a reference to a an array of string is expected.
+For C<compiler> the harness will run the tests with
 C<parrot>, calling the C<compiler> file as the first argument.
 
 This means that you can write your tests in your language itself and run them
@@ -38,7 +48,7 @@
 
 =head1 AUTHOR
 
-written by chromatic with most of the intelligence stolen from the Punie
+Written by chromatic with most of the intelligence stolen from the Punie
 harness and most of that probably stolen from Test::Harness
 
 Please send patches and bug reports via Parrot's RT queue or to the mailing
@@ -58,13 +68,14 @@
 sub set_flags {
     my %options = @_;
     $ENV{HARNESS_VERBOSE} = 1;
-    $ENV{HARNESS_PERL} ||= '../../parrot ./' . $options{compiler}
-        if $options{compiler};
+    if ( $options{exec} ) {
+        $ENV{HARNESS_PERL} ||= join q{ }, @{$options{exec}};
+    }
+    elsif ( $options{compiler} ) {
+        $ENV{HARNESS_PERL} ||= join q{}, "../../parrot ./$options{compiler}";
+    }
 
-    # Per Leo on 18APR2005, run the test suite with --gc-debug
-    if ( $ENV{TEST_PROG_ARGS} && $ENV{TEST_PROG_ARGS} !~ /\b--gc-debug\b/ ) {
-        $ENV{TEST_PROG_ARGS} .= " --gc-debug";
-    }
+    return;
 }
 
 sub get_files {
@@ -123,11 +134,12 @@
     exit unless my @files = get_files(%options);
 
     if (eval { require TAP::Harness; 1 }) {
-        my %options = $options{compiler}
-            ? ( exec => [ '../../parrot', './' . $options{compiler} ] )
-            : ();
-        my $harness = TAP::Harness->new( \%options );
-        $harness->runtests( @files );
+        my %options =
+              $options{exec}     ? ( exec => $options{exec} )
+            : $options{compiler} ? ( exec => [ '../../parrot', './' . $options{compiler} ] )
+            :                      ();
+        TAP::Harness->new( \%options )->runtests( @files );
+
         return;
     }
 
Index: languages/eclectus/t/harness
===================================================================
--- languages/eclectus/t/harness	(Revision 23505)
+++ languages/eclectus/t/harness	(Arbeitskopie)
@@ -2,7 +2,7 @@
 
 =head1 NAME
 
-languages/eclectus/t/harness - A harness for scheme
+languages/eclectus/t/harness - A harness for Eclectus
 
 =head1 SYNOPSIS
 
@@ -20,19 +20,12 @@
 use strict;
 use warnings;
 use 5.008;
+use lib qw( ../lib ../../lib ../../lib );
 
-use TAP::Harness ();
-use File::Spec;
+use Parrot::Test::Harness language => 'eclectus', exec => [ 'petite', '--script' ];
 
-my @test_files = glob( File::Spec->catfile( 't', '*.t' ) );
-
-TAP::Harness->new(
-    { exec => [ 'petite', '--script' ],
-    }
-)->runtests(@test_files);
-
 =head1 SEE ALSO
 
-  F<languages/scheme/t/harness>
+  F<languages/perl6/t/harness>
 
 =cut

Reply via email to