Question

What I like to do:

I am using Rex to remotely call tests at servers. I remotely execute the tests with a call the the local prove. I want to gather all the information about the testruns at the different servers at one place. To achieve this I run the tests with prove -a (and maybe also with --merge for capturing STDERR) to create an archive (.tgz). I then download this archive again with Rex to the controlling server. I think this is quite a good plan so far...

My problem now is that I find a lot of hints on creating such a TAP-archive, but none of how I can actually read this archive. Sure, I could open and process it somehow with Archive::Tar or parse it manually with TAP::Parser as suggested by Schwern. But knowing that there are formatters like TAP::Formatter::HTML or TAP::Formatter::JUnit (e.g. for Jenkins) I think there must be a way of using those tools directly on a TAP-archive? When I look up the docs I only find hints on how to use this stuff with prove to format tests while running them. But I need to use this formatters on the archive, I have been running prove already remotely...

So far about the context. My question in short is: How can I use the Perl-TAP-Tools to format TAP coming from a TAP-archive produced by prove?

I am thankful for any little hints. Also if you see a problem in my approach in general.

Was it helpful?

Solution

Renée provided a working solution here: http://www.perl-community.de/bat/poard/thread/18420 (German)

use strict;
use warnings;

use TAP::Harness::Archive;
use TAP::Harness;
use TAP::Formatter::HTML;

my $formatter = TAP::Formatter::HTML->new;

my $harness   = TAP::Harness->new({ formatter => $formatter });

$formatter->really_quiet(1);
$formatter->prepare;

my $session;
my $aggregator = TAP::Harness::Archive->aggregator_from_archive({ 
    archive          => '/must/be/the/complete/path/to/test.tar.gz',
    parser_callbacks => {
        ALL => sub {
            $session->result( $_[0] );
        },
    },
    made_parser_callback => sub {
        $session = $formatter->open_test( $_[1], $_[0] );
    }
});

$aggregator->start;
$aggregator->stop;

$formatter->summary($aggregator);

Tanks a lot! I hope this will help some others too. It seems like this knowledge is not very wide spread yet.

I have made a module to pack this solution in a nice interface: https://metacpan.org/module/Convert::TAP::Archive

So from now on you can just type this:

use Convert::TAP::Archive qw(convert_from_taparchive);

my $html = convert_from_taparchive(
               '/must/be/the/complete/path/to/test.tar.gz',
               'TAP::Formatter::HTML',
           );

The problem with the output is mentioned in the docs. Please provide patches or comments if you know how to fix this (minor) issue. E.g. here: https://github.com/borisdaeppen/Convert-TAP-Archive

OTHER TIPS

Renee pointed me to how Tapper makes it: https://metacpan.org/source/TAPPER/Tapper-TAP-Harness-4.1.1/lib/Tapper/TAP/Harness.pm#L273

Quite some effort to read an archive though...

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top