#! perl -w
# Copyright: 2004-2005 The Perl Foundation.  All Rights Reserved.
# $Id: testall 7989 2005-05-05 16:57:39Z bernhard $

use strict;

use Data::Dumper;
use File::Spec;
use Test::Harness;

=head1 languages harness

There are 3 ways to run a language test: 

=over 4

=item * Overall Harness

C<cd languages && make test>

=item * Per Language Harness

e.g., C<cd languages/tcl && make test>

=item * Run a single test for more detailed output.

e.g., C<cd languages/tcl && t/joe_test.t>

=back

=head1 AUTHOR

  Will "Coke" Coleda
  Jerome Quelin

=cut

=for comment

We are assuming that we are running out of parrot/languages; we are being
called by languages/Makefile with an explicit perl. All languages have 
a Makefile with a "test" target, and any prereqs required by that test
have already been built.

=cut

# Step 1: find harness files for testable languages

# These could all be tested:
#
# BASIC                No t/harness
# befunge              No t/harness
# cola                 No t/harness
# conversion           No t/harness
# forth                No t/harness
# jako                 No t/harness
# lisp                 No t/harness
# miniperl             No t/harness
# ook                  No t/harness
# parakeet             No t/harness
# perl6                t/harness has no --files
# python               needs testing
# regex               No t/harness
# ruby                No t/harness
# tcl                 needs testing

my @unified_testable_languages = qw( bf m4 parrot_compiler scheme urm );
my @harnesses =
    grep {-f $_}
        map { File::Spec->join($_,"t","harness") }
            @unified_testable_languages;

# Step 2: Get a listing of files from these harnesses.

my @testfiles;
foreach my $harness (@harnesses) {
    my $perl = "$^X -I" . File::Spec->join(File::Spec->updir,"lib");
    open(FILES, "$perl $harness --files |");  
    push @testfiles, <FILES>;
    close(FILES);
}
chomp( @testfiles );

# Step 3: test.

runtests(@testfiles);
