On Mar 4, 2007, at 6:33 AM, Dominique Quatravaux wrote:

And what if you are running a variable number of tests depending on
stuff such as compile-time options, maintainer mode enabled or not, or
whatever?

It's really not that hard. It's OK to declare a plan at runtime as long as you declare your plan before you run your first test. If your test program dies before that plan is emitted, the harness will notice that zero tests ran and will complain accordingly.

For example, in CAM::PDF I have a number of test PDF documents that I use to exercise the code, but I only ship a subset of them to CPAN (the rest are too big or are license-incompatible). So, I do roughly like so:

  use Test::More;  # plan declared at runtime below
  my @test_docs = grep { -f $_ } 't/test1.pdf', 't/test2.pdf', ...;

  plan tests => 12 + @test_docs * 20;

  ... run basic tests ...

  for my $pdf_file (@test_docs) {
     ... run per-doc tests ...
  }

Chris

--
Chris Dolan, Equilibrious LLC, http://equilibrious.net/
Public key: http://chrisdolan.net/public.key
vCard: http://chrisdolan.net/ChrisDolan.vcf



Reply via email to