So I think I have found a bug in TAP::Harness::Archive->aggregator_from_archive(). If the archive has a meta.yml file, there's a corner case where files aren't added properly.

The code block is lines 340-356:

   if( -e $yaml_file) {

       # parse it into a structure
       $meta = YAML::Tiny->new()->read($yaml_file);
die "Could not read YAML $yaml_file: " . YAML::Tiny->errstr if YAML::Tiny->errstr;

       if($args->{meta_yaml_callback}) {
           $args->{meta_yaml_callback}->($meta);
       }
       $meta = $meta->[0];

       if($meta->{file_order} && ref $meta->{file_order} eq 'ARRAY') {
           foreach my $file (@{$meta->{file_order}}) {
               push(@tap_files, $file) if -e $file;
           }
       }
   }


Specifically, at the end, the check to see if $file exists. That's checking the local filesystem for the presence of the actual test file (reminder: the YAML file has an array, 'file_order', which lists the test files in the order of execution - the tarball is created with the absolute path in mind). If we're on the machine where the tests were originally run, chances are that every file is found (not the TAP output, mind you, but the original test file - not what we're looking for, but a happy accident).

On a remote machine, this usually isn't a problem because the test fails entirely (e.g. none of the test files are found), and the function goes on to crawl the tarball for files.

It bit me because the machine I was running things on had a subset of the test files - so my results were erroneously missing large blocks of test output.

Patch attached - makes the handling of test filename versus path-in-unpacked-tarball consistent within the package.

NOTE: it's been a while since I've submitted a patch - if the format isn't quite right, let me know, I'd be happy to re-submit.

Peter


--- lib/TAP/Harness/Archive.pm	2009-07-27 09:28:20.000000000 -0400
+++ lib/TAP/Harness/Archive.pm.fixed	2010-02-26 16:36:38.847317513 -0500
@@ -350,7 +350,8 @@
 
         if($meta->{file_order} && ref $meta->{file_order} eq 'ARRAY') {
             foreach my $file (@{$meta->{file_order}}) {
-                push(@tap_files, $file) if -e $file;
+                my $temp_tap = File::Spec->catfile($dir, $file);
+                push(@tap_files, $file) if -e $temp_tap;
             }
         }
     }
@@ -363,10 +364,12 @@
     # now create the aggregator
     my $aggregator = TAP::Parser::Aggregator->new();
     foreach my $tap_file (@tap_files) {
-        open(my $fh, $tap_file) or die "Could not open $tap_file for reading: $!";
+        my $tarball_tap = File::Spec->catfile($dir, $tap_file);
+        open(my $fh, $tarball_tap) or die "Could not open $tarball_tap for reading: $!";
+
         my $parser = TAP::Parser->new({source => $fh, callbacks => $args->{parser_callbacks}});
         if($args->{made_parser_callback}) {
-            $args->{made_parser_callback}->($parser, $tap_file, File::Spec->catfile($dir, $tap_file));
+            $args->{made_parser_callback}->($parser, $tap_file, $tarball_tap);
         }
         $parser->run;
         $aggregator->add($tap_file, $parser);

Reply via email to