Subject: | Add option to keep parser results after running a parser |
By default, it is very difficult to retrieve TAP::Parser::Result objects from a TAP::Parser object
after it has iterated through the results in its run method.
I propose adding a new boolean option to its constructor, labelled "store_results", which would default
to false for efficiency. A new method named "results" would return the array of stored
TAP::Parser::Result objects. A new accessor "store_results" should also be created.
Example code:
my $parser = TAP::Parser->new( { source => $source } );
$parser->store_results(1);
$parser->run();
my @results = $parser->results();
Example use case:
TAP::Harness::Archive (in another project) reads TAP output stored in a tarball, like this:
my $aggregator = TAP::Harness::Archive->aggregator_from_archive({ archive => 'my_tests.tar.gz' } );
for my $description ($aggregate->descriptions) {
my ($parser) = $aggregate->parsers($description);
}
It would be useful if one could retrieve TAP::Parser::Result objects, like this:
my $aggregator = TAP::Harness::Archive->aggregator_from_archive({
archive => 'my_tests.tar.gz',
made_parser_callback => sub { shift->store_results(1) },
});
for my $description ($aggregate->descriptions) {
my ($parser) = $aggregate->parsers($description);
my @results = $parser->results();
}