#! perl

# $Id: harness 25841 2008-02-18 16:02:59Z particle $

use FindBin;
use File::Spec;
use lib qw( ../../lib );

our %harness_args;

BEGIN {
    our %harness_args = (
        language  => 'perl6',
        compiler  => 'perl6.pbc',
    );

    ##  if we aren't fudging tests, we're done here
    return if $ARGV[0] ne '--fudge';

    my $fudge = shift @ARGV;

    my $impl    = 'rakudo';
    my @tfiles = sort map { -d $_ ? all_in($_) : $_ } map glob, @ARGV;
    print "$^X t/spec/fudgeall $impl @tfiles\n";

    $harness_args{arguments} =
        [ split ' ', `$^X t/spec/fudgeall $impl @tfiles` ];


    # Stolen directly from 'prove'
    # adapted to return only files ending in '.t'
    sub all_in {
        my $start = shift;

        my @hits = ();

        local *DH;
        if ( opendir( DH, $start ) ) {
            my @files = sort readdir DH;
            closedir DH;
            for my $file ( @files ) {
                next if $file eq File::Spec->updir || $file eq File::Spec->curdir;
                next if $file eq ".svn";
                next if $file eq "CVS";

                my $currfile = File::Spec->catfile( $start, $file );
                if ( -d $currfile ) {
                    push( @hits, all_in( $currfile ) ) if $recurse;
                } else {
                    push( @hits, $currfile ) if $currfile =~ /\.t$/;
                }
            }
        } else {
            warn "$start: $!\n";
        }

        return @hits;
    }

}

use Parrot::Test::Harness %harness_args;

# Set up PERL6LIB environment path so the "use" tests can find libraries
$ENV{PERL6LIB} = "$Bin/01-sanity";



