NAME

TAP::Harness::Archive::MultipleHarnesses - Create an archive of multiple harnesses of TAP test results

SYNOPSIS

    use TAP::Harness::Archive::MultipleHarnesses;
    my $archive = TAP::Harness::Archive::MultipleHarnesses->new(\%args);
    $archive->runtests(\@targets);

DESCRIPTION

This package subclasses Michael Peters' TAP::Harness::Archive package from CPAN. It provides its own runtests() method for the case where you need to create an archive of test results generated by running multiple harnesses sequentially.

For a discussion of use cases for this functionality, see the documentation for TAP::Harness::ReportByDescription.

    perldoc TAP::Harness::ReportByDescription

METHODS

new()

Inherited from Test::Harness::Archive.

runtests()

Replaces Test::Harness::Archive::runtests(). Note that its interface is different from other packages' runtests() interface: It takes a reference to an array of hash references rather than a simple array.

Each hash reference holds information on how a particular set of tests is to be run. The various sets are run and placed into the archive in the order in which they appear in the array.

Each hash reference needs three elements:

  • tests

    A list of tests to be run (typically expressed as a list of file glob patterns).

  • rule

    A reference to a subroutine which will be run before a given set of tests is executed. The purpose of this subroutine is to set up the environmental variables as needed for a particular subharness.

  • label

    A string describing a particular subharness which will be combined with a particular test file's name to form the description of the test both in STDOUT and in the test archive.

summary()

Inherited from Test::Harness::Archive.

EXAMPLE

Adapted (simplified) from Parrot's t/fullharness.

    use Parrot::Harness::Smoke qw( collect_test_environment_data );
    use TAP::Harness::Archive::MultipleHarnesses;

    sub set_runcore_target {
        my ($target)  = @_;
        return {
            label   => "test$target",
            rule    => sub { set_runcore_environmental_args($target) },
            tests   => [
                        map { [ $_, "test${alt}__$_", ] } 
                            @Parrot::Harness::TestSets::runcore_test_files
                       ],
        };
    }
    my @targets = map { set_runcore_target($_) } ( qw| b f r | );
    my %env_data = collect_test_environment_data();

    my $archive = TAP::Harness::Archive::MultipleHarnesses->new( {
        verbosity        => $ENV{HARNESS_VERBOSE},
        archive          => 'parrot_test_run.tar.gz',
        merge            => 1,
        jobs             => $ENV{TEST_JOBS} || 1,
        extra_properties => \%env_data,
        extra_files      => [ 'myconfig', 'config_lib.pir' ],
    } );
    my $overall_aggregator = $archive->runtests(\@targets);
    $archive->summary($overall_aggregator);

AUTHOR

This code was derived from Michael Peters' Test::Harness::Archive distribution on CPAN, as well as examples in the documentation for TAP::Harness, TAP::Parser, TAP::Parser::Aggregator and other CPAN modules. Documentation and code assemblage by James E Keenan.

LICENSE

This is free software and is released under the same terms as Perl itself.