Tagging trunk at r29566 so that the revisionpm can later be synched to it.
[parrot.git] / languages / lua / t / harness
blob588c10710072a79badda5c0103fd828b0420cca3
1 # Copyright (C) 2005-2007, The Perl Foundation.
2 # $Id$
4 =head1 NAME
6 languages/lua/t/harness - A harness for Parrot Lua
8 =head1 SYNOPSIS
10     cd languages && perl -I../lib -Ilua/t lua/t/harness --files
12     cd languages && perl -I../lib -Ilua/t lua/t/harness
14     cd languages && perl -I../lib -Ilua/t lua/t/harness lua/t/examples.t
16     cd languages && perl -I../lib lua/t/harness lua/t/pmc/nil.t
18 =head1 DESCRIPTION
20 If I'm called with a single
21 argument of "--files", I just return a list of files to process.
22 This list is one per line, and is relative to the languages dir.
24 If I'm called with no args, I run the complete suite.
26 If I'm called with "--use-lua", I run with the original C<lua>
27 in order to valid of the test suite.
29 If I'm called with "--use-luac-pl", I run with C<luac.pl> (the Lua to PIR
30 compiler written in Perl5).
32 If I'm called with "--use-lua-pbc", I run with C<lua.pbc> (the Lua interpreter
33 written in PIR).
35 Otherwise I run the tests that were passed on the command line.
37 =cut
39 use strict;
40 use warnings;
41 use lib '..';
43 use Cwd();
44 use Data::Dumper;
45 use File::Spec;
46 use Getopt::Long;
47 use Test::Harness();
49 my $language = 'lua';
51 my $opt_files;
52 my ($use_orig_lua, $use_luac_pl, $use_lua_pbc);
53 GetOptions(
54     'files' => \$opt_files,
55     'use-lua' => \$use_orig_lua,
56     'use-luac-pl' => \$use_luac_pl,
57     'use-lua-pbc' => \$use_lua_pbc,
60 if ( $opt_files ) {
62     # Only the Makefile in 'parrot/languages' uses --files
63     my $dir = File::Spec->catfile( $language, 't' );
64     my @files = glob( File::Spec->catfile( $dir, 'pmc', '*.t' ) );
65     push @files, glob( File::Spec->catfile( $dir, 'type', '*.t' ) );
66     push @files, glob( File::Spec->catfile( $dir, '*.t' ) );
67     print join( "\n", @files );
68     print "\n" if scalar(@files);
70 else {
71     my @files;
73     if ( scalar(@ARGV) ) {
75         # Someone specified tests for me to run.
76         @files = grep { -f $_ } @ARGV;
77     }
78     else {
79         ( undef, undef, my $current_dir )
80             = File::Spec->splitpath( Cwd::getcwd() );
81         my $dir;
82         if ( $current_dir eq 'languages' ) {
83             $dir = File::Spec->catfile( $language, 't' );
84         }
85         elsif ( $current_dir eq $language ) {
86             $dir = 't';
87         }
88         if ($dir) {
89             @files = glob( File::Spec->catfile( $dir, '*.t' ) );
90             push @files, glob( File::Spec->catfile( $dir, 'pmc', '*.t' ) )
91                 unless ($use_orig_lua);
92             push @files, glob( File::Spec->catfile( $dir, 'type', '*.t' ) )
93                 unless ($use_orig_lua);
94         }
95     }
97     if ($use_orig_lua) {
98         $ENV{PARROT_LUA_TEST_PROG} = 'lua';
99     }
100     elsif ($use_luac_pl) {
101         $ENV{PARROT_LUA_TEST_PROG} = 'luac.pl';
102     }
103     elsif ($use_lua_pbc) {
104         $ENV{PARROT_LUA_TEST_PROG} = 'lua.pbc';
105     }
107     Test::Harness::runtests(@files) if scalar(@files);
110 =head1 HISTORY
112 Mostly taken from F<languages/bc/t/harness>.
114 =head1 SEE ALSO
116 F<languages/tcl/t/harness>, F<languages/scheme/t/harness>, F<languages/m4/t/harness>, F<languages/python/t/harness>
118 =head1 AUTHOR
120 Francois Perrad
122 =cut
124 # Local Variables:
125 #   mode: cperl
126 #   cperl-indent-level: 4
127 #   fill-column: 100
128 # End:
129 # vim: expandtab shiftwidth=4: