tagged release 0.6.4
[parrot.git] / languages / pipp / t / harness
blob152e292138561872b7ca636c7b3b1a0d1cee562c
1 # $Id$
3 =head1 NAME
5 languages/pipp/t/harness - A harness for Pipp
7 =head1 SYNOPSIS
9   cd languages && perl -I../lib pipp/t/harness --files
11   cd languages && perl -I../lib pipp/t/harness 
13   cd languages && perl -I../lib pipp/t/harness --with-php
15   cd languages && perl -I../lib pipp/t/harness --with-phc
17   cd languages && perl -I../lib pipp/t/harness --with-antlr3
19   cd languages && perl -I../lib pipp/t/harness --with-pct
21   cd languages && perl -I../lib pipp/t/harness \
22                    pipp/t/hello.t 
24 =head1 DESCRIPTION
26 If I'm called with a single
27 argument of "--files", I just return a list of files to process.
28 This list is one per line, and is relative to the languages dir.
30 If I'm called with no args, I run the complete suite.
32 Otherwise I run the tests that were passed on the command line.
34 =cut
36 # pragmata
37 use strict;
38 use warnings;
39 use lib '..';
41 use Cwd                   ();
42 use File::Spec;
43 use Test::Harness         ();
45 my $language = 'pipp';
47 if ( grep { m/^--files$/ } @ARGV ) {
48     # Only the Makefile in 'parrot/languages' uses --files
49     my $dir = File::Spec->catfile( $language, 't' );
50     my @files = glob( File::Spec->catfile( $dir, '*/*.t' ) );
51     print join( "\n", @files );
52     print "\n" if scalar(@files);
53 } else { 
54     my @files;
55     # TODO: use Getopt::Long or such
56     my $with_php = ( grep { m/^--with-php$/ } @ARGV ) ? 1 : 0;
57     @ARGV = grep { ! m/^--with-php$/ } @ARGV;
59     my $with_phc = ( grep { m/^--with-phc$/ } @ARGV ) ? 1 : 0;
60     @ARGV = grep { ! m/^--with-phc$/ } @ARGV;
62     my $with_antlr3 = ( grep { m/^--with-antlr3$/ } @ARGV ) ? 1 : 0;
63     @ARGV = grep { ! m/^--with-antlr3$/ } @ARGV;
65     my $with_pct = ( grep { m/^--with-pct$/ } @ARGV ) ? 1 : 0;
66     @ARGV = grep { ! m/^--with-pct$/ } @ARGV;
68     if ( scalar(@ARGV) ) {
69         # Someone specified tests for me to run.
70         @files = grep { -f $_ } @ARGV
71     } else {
72         ( undef, undef, my $current_dir ) = File::Spec->splitpath( Cwd::getcwd() );
73         if ( $current_dir eq 'languages' ) {
74             @files = glob( File::Spec->catfile( $language, 't', '*/*.t' ) );
75         }
76         elsif ( $current_dir eq $language ) {
77             @files = glob( File::Spec->catfile( 't', '*/*.t' ) );
78         }
79         else {
80             die "Where am I?";
81         }
82     }
84     # XXX There should be a better to indicate which implementation should be used
85     if ( $with_php ) {
86        $ENV{PARROT_PIPP_TEST_MODULE} = 'Parrot::Test::Pipp::PHP';
87     }
88     elsif ( $with_phc ) {
89        $ENV{PARROT_PIPP_TEST_MODULE} = 'Parrot::Test::Pipp::Phc';
90     }
91     elsif ( $with_antlr3 ) {
92        $ENV{PARROT_PIPP_TEST_MODULE} = 'Parrot::Test::Pipp::Antlr3';
93     }
94     elsif ( $with_pct ) {
95        $ENV{PARROT_PIPP_TEST_MODULE} = 'Parrot::Test::Pipp::PCT';
96     }
97     else {
98        $ENV{PARROT_PIPP_TEST_MODULE} = 'Parrot::Test::Pipp::PCT';
99     }
101     Test::Harness::runtests( @files ) if scalar( @files );
104 =head1 HISTORY
106 Mostly taken from bc/t/harness.
108 =head1 SEE ALSO
110   F<languages/perl6/t/harness>
112 =head1 AUTHOR
114 Bernhard Schmalhofer - <Bernhard.Schmalhofer@gmx.de>
116 =cut
118 # Local Variables:
119 #   mode: cperl
120 #   cperl-indent-level: 4
121 #   fill-column: 100
122 # End:
123 # vim: expandtab shiftwidth=4: