# $Id: harness,v 1.3 2004/09/23 08:38:06 leo Exp $
=head1 NAME
languages/m4/t/harness - A harness for Parrot m4
=head1 SYNOPSIS
cd languages && perl -I../lib m4/t/harness -files
cd languages && perl -I../lib m4/t/harness
cd languages && perl -I../lib m4/t/harness \
m4/t/basic/006_define_with_rest \
m4/t/regex/003_two_compiles.t
=head1 DESCRIPTION
Conformant to a recent post on p6i, if I'm called with a single
argument of "-files", I just return a list of files to process.
This list is one per line, and is relative to the languages dir.
If I'm called with no args, I run all tests.
Otherwise I try to run the list of passed tests.
=cut
# pragmata
use strict;
use Test::Harness();
use File::Spec;
my $language = 'm4';
if ( grep { m/^-files$/ } @ARGV )
{
# Only the Makefile in 'parrot/languages' uses -file
my $dir = File::Spec->catfile( $language, 't' );
my @files = glob( File::Spec->catfile( $dir, '*/*.t' ) );
print join( "\n", @files );
print "\n" if scalar(@files);
}
else
{
my @files;
if ( scalar(@ARGV) )
{
# Someone specified tests for me to run.
@files = grep { -f $_ } @ARGV
}
else
{
# Propably called out of 'parrot/languages'
@files = glob( "m4/t/*/*.t" );
}
Test::Harness::runtests( @files ) if scalar(@files);
}
=head1 HISTORY
Mostly taken from tcl/t/harness.
=head1 SEE ALSO
L<languages/tcl/t/harness>, L<languages/python/t/harness>
=head1 AUTHOR
Bernhard.Schmalhofer@gmx.de
=cut