Test counts

Ovid publiustemp-tapx at yahoo.com
Sun Nov 18 15:46:03 EST 2007


Hi all,

I was looking at what it takes to add test program count inteformation and I'm stuck.

Let's say you have 340 test programs and they take 22 minutes to run (these are real numbers driving my test case).

So before each test, you'd like to add something like this (the '4' would need to be calculated on the fly):

  sprintf "[%04d/%04d]" => $parser->current_test_num, $parser->test_count;

That would have test lines like this (ignoring the timing information), assuming we're on test 217 out of 340:

  [217/340] t/acceptable/customer.............. 13/22

I'm trying to figure out *where* to store that information.  It seems to me that TAP::Harness::make_parser is the right place:

  sub make_parser {
      my ( $self, $test ) = @_;

      my $args = $self->_get_parser_args($test);
      $self->_make_callback( 'parser_args', $args, $test );
      my $parser = TAP::Parser->new($args);

      $self->_make_callback( 'made_parser', $parser, $test );
      my $session = $self->formatter->open_test( $test, $parser );

      return ( $parser, $session );
  }

Prior to this, in TAP::Harness::aggregate_tests(), we'd have a call to:

    TAP::Parser->total_test_programs( scalar @tests );

And every time TAP::Parser->new is called, it would increment its current test count by one (this would make it work with parrallel tests, right?).

The the Console class would then have its _format_name method altered to include the above info, read from the parser.

This seems a bit strange to me and I don't know how it would work with the parallel tests.  Also, storing test count information in the parser just seems wrong.  However, if I reframe that and think "it's OK for the parser to know how many times it's been called", then it seems reasonable (also, it could possibly throw an exception if it's called more times than the total number of test programs).

Is this sane? It feels wrong to me, but that's only a gut feeling.

Cheers,
Ovid

--
Buy the book  - http://www.oreilly.com/catalog/perlhks/
Perl and CGI  - http://users.easystreet.com/ovid/cgi_course/
Personal blog - http://publius-ovidius.livejournal.com/
Tech blog     - http://use.perl.org/~Ovid/journal/




More information about the tapx-dev mailing list