#! perl -w
# $Id: harness,v 1.4 2003/02/08 14:41:36 leo Exp $

#Blatantly stolen from parrot/t/harness by Mike Lambert
#Then blatantly stolen from perl6/t/harness by leo ;-)

use strict;
use lib '../../lib';
use Test::Harness qw(runtests);

#
# Suck the switches into the TEST_PROG_ARGS evar:
#

use Getopt::Std;
my %opts;
getopts('gjPbvdc?hO:', \%opts);
if ($opts{'?'} || $opts{h}) {
	print <<"EOF";
perl t/harness [options] [testfiles]
	-g ... disable CGoto
	-j ... run JIT
	-P ... run Prederef or CGP
	-b ... run bounds checked
	-v ... run verbose
	-d ... run debug
	-c ... assemble to PBC run PBC
	-O[012] optimize
EOF
	exit;
}

my $args = join(' ', map { "-$_" } keys %opts );
$args =~ s/-O/-O$opts{O}/ if ($opts{O});

$ENV{TEST_PROG_ARGS} = $args;

$ENV{PARROT_QUICKTEST} = grep $_ eq 'quick', @ARGV;
@ARGV = grep $_ ne 'quick', @ARGV;

# Pass in a list of tests to run on the command line, else run all the tests.
my @tests = @ARGV ? @ARGV : glob( "t/*/*.t" );
runtests(@tests);
