Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: a432c4ad36
Fetching contributors…

Cannot retrieve contributors at this time

169 lines (136 sloc) 5.181 kb
#! perl
# $Id$
=head1 NAME
languages/ecmascript/t/harness - A harness for JS
=head1 SYNOPSIS
cd languages && perl ecmascript/t/harness --files --master
cd languages/ecmascript && perl t/harness
cd languages/ecmascript && perl t/harness --verbose t/hello.t
=head1 DESCRIPTION
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 the complete suite.
Otherwise I run the tests that were passed on the command line.
=cut
# pragmata
use strict;
use warnings;
use FindBin ();
use lib "$FindBin::Bin/../../../lib", "$FindBin::Bin/../lib";
use Cwd ();
use File::Spec ();
use TAP::Harness 3.12; # support closures for the 'exec' option
use TAP::Harness::Archive 0.12;
use Parrot::Config qw( %PConfig );
use Getopt::Long;
use Parrot::Harness::Smoke;
use Parrot::Test;
my ( $files_flag, $master_flag, $send_to_smolder_flag, $archive_flag, $verbose_flag );
my ( $js_flag, $pjs_flag);
GetOptions(
'files' => \$files_flag,
'master' => \$master_flag, # unused, but passed by languages/t/harness
'send-to-smolder' => \$send_to_smolder_flag,
'archive' => \$archive_flag,
'verbose' => \$verbose_flag,
'with-pjs' => \$pjs_flag,
'with-js' => \$js_flag,
);
my $hll = 'ecmascript';
my $verbosity = $verbose_flag ? 1 : $ENV{HARNESS_VERBOSE};
$verbosity ||= 0;
if ( $files_flag ) {
# Only the Makefile in 'parrot/languages' uses --files for unified testing
my $dir = File::Spec->catfile( $hll, 't' );
# unified testing can't handle test scripts written in JS
my @files = grep { ! m!in_php|pmc|embed! } glob( File::Spec->catfile( $dir, '*/*.t' ) );
print join( "\n", @files );
print "\n" if scalar(@files);
}
else {
my $path_to_parrot = Parrot::Test::path_to_parrot();
my @cmd = ( "$path_to_parrot/parrot$PConfig{exe}", "$path_to_parrot/languages/ecmascript/js.pbc" );
$ENV{PARROT_PIPP_TEST_MODULE} = 'Parrot::Test::JS::PJS';
if ( $js_flag ) {
$ENV{PARROT_PIPP_TEST_MODULE} = 'Parrot::Test::JS::SpiderMonkey';
@cmd = qw{ js } ;
}
elsif ( $pjs_flag ) {
$ENV{PARROT_PIPP_TEST_MODULE} = 'Parrot::Test::JS::PJS';
}
my @files;
if ( scalar(@ARGV) ) {
# Someone specified tests for me to run.
@files = grep { -f $_ } @ARGV
}
else {
( undef, undef, my $current_dir ) = File::Spec->splitpath( Cwd::getcwd() );
if ( $current_dir eq 'languages' ) {
@files = glob( File::Spec->catfile( $hll, 't', '*/*.t' ) );
}
elsif ( $current_dir eq $hll ) {
@files = glob( File::Spec->catfile( 't', '*/*.t' ) );
print glob( File::Spec->catfile( 't', '*.t' ) );
push @files, glob( File::Spec->catfile( 't', '*.t' ) );
}
else {
die "Where am I?";
}
}
my $exec_sub
= sub {
my ( $harness, $test_file ) = @_;
# the directory t/embed contains only PIR test files
return [ "$path_to_parrot/parrot$PConfig{exe}", $test_file ] if $test_file =~ m{t/embed/.*[.]t$};
# the directory t/pmc contains only PIR test files
return [ "$path_to_parrot/parrot$PConfig{exe}", $test_file ] if $test_file =~ m{t/pmc/.*[.]t$};
# the directory t/in_php contains only test scripts written in JS
return [ @cmd, $test_file ] if $test_file =~ m{t/sanity_js/.*[.]t$};
if ($test_file =~ m{^t/(?:[^/])*\.t$!}) {
print "$test_file\n";
return [ @cmd, $test_file ];
}
# all other directories contain test scripts written in Perl
return [ $PConfig{perl}, $test_file ];
};
if ( $archive_flag ) {
my %env_data = Parrot::Harness::Smoke::collect_test_environment_data();
my $report_file = ['js_test_run.tar.gz'];
my $harness = TAP::Harness::Archive->new(
{
exec => $exec_sub,
verbosity => $verbosity,
archive => $report_file->[0],
merge => 1,
extra_properties => \%env_data,
}
);
$harness->runtests(@files);
if ( $send_to_smolder_flag ) {
$env_data{report_file} = $report_file;
$env_data{project_id} = 10;
Parrot::Harness::Smoke::send_archive_to_smolder(%env_data);
}
} else {
my $harness = TAP::Harness->new(
{
exec => $exec_sub,
verbosity => $verbosity,
}
);
$harness->runtests(@files);
}
}
=head1 SEE ALSO
F<languages/perl6/t/harness>
=head1 AUTHOR
Bernhard Schmalhofer - <Bernhard.Schmalhofer@gmx.de>
Kevin Tew - <tewk at tewk dot com>
=cut
# Local Variables:
# mode: cperl
# cperl-indent-level: 4
# fill-column: 100
# End:
# vim: expandtab shiftwidth=4:
Jump to Line
Something went wrong with that request. Please try again.