Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Steal t/harness from Pipp. Prepare for smolder testing
  • Loading branch information
bschmalhofer committed Feb 8, 2009
1 parent 6162ceb commit 60d67aa
Show file tree
Hide file tree
Showing 3 changed files with 107 additions and 23 deletions.
4 changes: 4 additions & 0 deletions docs/eclectus.pod
Expand Up @@ -36,6 +36,10 @@ This intermediate file can for example be executed with:

../../parrot driver_nqp.pbc t/unary_primitives_0.nqp

=head1 Dependencies

Test::Harness::Archive

=head1 TODO

- support for strings
Expand Down
2 changes: 1 addition & 1 deletion driver_nqp.pir
Expand Up @@ -62,7 +62,7 @@


.sub '__initconst' :init
$P0 = new [ 'EclectusBoolean' ]
$P0 = new 'EclectusBoolean'
$P0 = 1
set_root_global ['_eclectus'], '#t', $P0
$P0 = new 'EclectusBoolean'
Expand Down
124 changes: 102 additions & 22 deletions t/harness
@@ -1,44 +1,124 @@

=head1 NAME

languages/eclectus/t/harness - A harness for Eclectus
t/harness - A testing harness for Eclectus

=head1 SYNOPSIS

cd languages/eclectus && perl t/harness

cd languages && perl -I../lib eclectus/t/harness --files
cd languages/eclectus && perl t/harness --verbose t/pmc/boolean.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.
A harness based on Test::Harness and Test::Harness::Archive.

=cut

# pragmata
use strict;
use warnings;
use 5.008;
use lib qw( ../lib ../../lib ../../lib );
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 ( $send_to_smolder_flag, $archive_flag, $verbose_flag );
GetOptions(
'send-to-smolder' => \$send_to_smolder_flag,
'archive' => \$archive_flag,
'verbose' => \$verbose_flag,
);

my $verbosity = $verbose_flag ? 1 : $ENV{HARNESS_VERBOSE};
$verbosity ||= 0;

{
my $path_to_parrot = Parrot::Test::path_to_parrot();

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() );
@files = glob( File::Spec->catfile( 't', '*/*.t' ) );
}

use Parrot::Test::Harness
language => 'eclectus',
exec => ($^O eq 'MSWin32')
? [ 'csi', '-R', 'alexpander', '-i', '-k', 'none', '-I', 'riaxpander',
'-e', '(load "chicken/prelude.scm")', '-s' ]
: [ 'gosh', '-fcase-fold', '-I', '.', '-I', 'riaxpander', '-l', 'gauche/prelude.scm' ],
files => [ 't/scheme/*.t' ];
my $exec_sub
= sub {
my ( $harness, $test_file ) = @_;


# 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/scheme contains only test scripts written in scheme
if ( $test_file =~ m!t/in_php/.*[.]t$! ) {
if ($^O eq 'MSWin32') {
return [ 'csi', '-R', 'alexpander', '-i', '-k', 'none', '-I', 'riaxpander',
'-e', '(load "chicken/prelude.scm")', '-s', $test_file ];
}
else {
return [ 'gosh', '-fcase-fold', '-I', '.', '-I', 'riaxpander',
'-l', 'gauche/prelude.scm', $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 = ['pipp_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>
F<languages/t/harness>
F<lib/Parrot/Test/Harness>
F<languages/pipp/t/harness>

=head1 AUTHOR

Bernhard Schmalhofer - <Bernhard.Schmalhofer@gmx.de>

=cut

# Local Variables:
# mode: cperl
# cperl-indent-level: 4
# fill-column: 100
# End:
# vim: expandtab shiftwidth=4:

0 comments on commit 60d67aa

Please sign in to comment.