Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
added roast-alike tests
  • Loading branch information
FROGGS committed Mar 25, 2013
1 parent 5b9b18e commit 8a71fa1
Show file tree
Hide file tree
Showing 4 changed files with 709 additions and 1 deletion.
23 changes: 22 additions & 1 deletion Makefile
@@ -1,6 +1,14 @@
NQP = nqp
PARROT = parrot
RM_F = perl -MExtUtils::Command -e rm_f
PERL = perl
RM_F = $(PERL) -MExtUtils::Command -e rm_f

# We need to tweak that some day
HAS_ICU = 0

# NOTE: eventually, we should remove --keep-exit-code and --fudge
# as the goal is that all tests must pass without fudge
HARNESS_WITH_FUDGE = $(PERL) t/harness --fudge --keep-exit-code --icu=$(HAS_ICU)

all: blib/perl5.pbc

Expand All @@ -26,3 +34,16 @@ clean:

test:
PERL6LIB=blib prove -e perl6 t/v5/basic.t

testable : all spectest_checkout spectest_update

spectest_checkout : t/spec
t/spec :
git clone git://github.com/rakudo-p5/roast5.git t/spec
-cd t/spec/ && git config remote.origin.pushurl git@github.com:rakudo-p5/roast5.git

spectest_update :
-cd t/spec && git pull

spectest: testable t/spectest.data
$(HARNESS_WITH_FUDGE) --tests-from-file=t/spectest.data
22 changes: 22 additions & 0 deletions t/fudgeandrun
@@ -0,0 +1,22 @@
#! /usr/bin/env perl
use strict;
use warnings;

my @OPTS = ('--keep-exit-code', 'v5');

if (@ARGV) {
my $file = $ARGV[0];
if (! -e $file) {
my $spec = "t/spec/$file";
if (-e $spec) {
$ARGV[0] = $spec;
}
}
}

my $nt = `t/spec/fudge @OPTS @ARGV`;
# uninstalled rakudo doesn't know how to find Test.pm
# ... or any other modules
my $pwd = `pwd`; chomp $pwd;
$ENV{PERL6LIB}="$pwd/blib:.";
system("perl6", split ' ', $nt);
159 changes: 159 additions & 0 deletions t/harness
@@ -0,0 +1,159 @@
#! perl

# note: Due to a limitation in Getopt::Long options that should be passed
# through to fudgeall have to come after all other options

use strict;
use warnings;

use FindBin;
use File::Spec;
use Getopt::Long qw(:config pass_through);
use Pod::Usage;

my $slash = $^O eq 'MSWin32' ? '\\' : '/';
$ENV{'HARNESS_PERL'} = "perl6";
my $path_sep = $^O eq 'MSWin32' ? ';' : ':';
$ENV{'PERL6LIB'} = join $path_sep, qw/ blib . /;
use Test::Harness;
$Test::Harness::switches = '';

GetOptions(
'tests-from-file=s' => \my $list_file,
'fudge' => \my $do_fudge,
'verbosity=i' => \$Test::Harness::verbose,
'jobs:1' => \my $jobs,
'icu:1' => \my $do_icu,
'long:1' => \my $do_long,
'stress:1' => \my $do_stress,
'archive=s' => \my $archive,
'parrot_revision=s' => \my $parrot_revision,
'help|h' => sub { pod2usage(1); },
) or pod2usage(2);

$do_long = 1 unless defined $do_long;
$do_stress = 0 unless defined $do_stress;

my @pass_through_options = grep m/^--?[^-]/, @ARGV;
my @files = grep m/^[^-]/, @ARGV;

if ($list_file) {
open(my $f, '<', $list_file)
or die "Can't open file '$list_file' for reading: $!";
while (<$f>) {
next if m/^\s*#/;
next unless m/\S/;
s/^\s+//;
s/\s+\z//;
my ($fn, $fudgespec) = split /\s+#\s*/;
if ($fudgespec) {
next if ($fudgespec =~ m/icu/) && !$do_icu;
next if ($fudgespec =~ m/long/) && !$do_long;
next if ($fudgespec =~ m/stress/) && !$do_stress;
}
$fn = "t/spec/$fn" unless $fn =~ m/^t\Q$slash\Espec\Q$slash\E/;
$fn =~ s{/}{$slash}g;
if ( -r $fn ) {
push @files, $fn;
} else {
warn "Missing test file: $fn\n";
}
}
close $f or die $!;
}

my @tfiles = map { all_in($_) } sort @files;

if ($do_fudge) {
@tfiles = fudge(@tfiles);
}

my $tap_harness_class = 'TAP::Harness';
$tap_harness_class .= '::Archive' if $archive;

my $extra_properties;
if ($archive) {
$extra_properties->{'Parrot Revision'} = $parrot_revision
if $parrot_revision;
$extra_properties->{'Submitter'} = $ENV{SMOLDER_SUBMITTER}
if $ENV{SMOLDER_SUBMITTER};
}

if (eval "require $tap_harness_class;") {
my %harness_options = (
exec => [$ENV{HARNESS_PERL}],
verbosity => 0+$Test::Harness::verbose,
jobs => $jobs || $ENV{TEST_JOBS} || 1,
ignore_exit => 1,
merge => 1,
$archive ? ( archive => $archive ) : (),
$extra_properties ? ( extra_properties => $extra_properties ) : (),
);
$tap_harness_class->new( \%harness_options )->runtests(@tfiles);
}
elsif ($archive) {
die "Can't load $tap_harness_class, which is needed for smolder submissions: $@";
}
else {
runtests(@tfiles);
}

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

return $start unless -d $start;

my @skip = ( File::Spec->updir, File::Spec->curdir, qw( .svn CVS .git ) );
my %skip = map {($_,1)} @skip;

my @hits = ();

if ( opendir( my $dh, $start ) ) {
my @files = sort readdir $dh;
closedir $dh or die $!;
for my $file ( @files ) {
next if $skip{$file};

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

return @hits;
}

sub fudge {
my $impl = 'v5';
my $cmd = join ' ', $^X, 't/spec/fudgeall',
@pass_through_options, $impl, @_;
return split ' ', `$cmd`;
}

=head1 NAME
t/harness - run the harness tests for Rakudo.
=head1 SYNOPSIS
t/harness [options] [files]
Options:
--help / -h - display the help message.
--tests-from-file=[filename] - get the tests from the filename.
--fudge - fudge (?)
--verbosity=[level] - set the verbosity level.
--jobs - number of jobs.
--icu - do icu.
--long - do long.
--stress - perform the stress tests/
--archive=[archive] - write to an archive.
--parrot_revision=[rev] - test with Parrot revision.

0 comments on commit 8a71fa1

Please sign in to comment.