This is a bit of a strange request and while I can add this to Test::Harness, 
I'm not sure that it's wise.

Here's the scenario:

  use Test::Most;

  if ( !$ENV{PROFILE_TESTS}) {
      plan skip_all => 'PROFILE_TESTS environment variable set';
  }
  else {
      plan tests => 3_000_000;
      run_hideously_expensive_tests();
  }

Basically, if I'm running a *single* test, I always the test to run, regardless 
of whether or not I remembered to meet the special conditions.  Running a 
single test means that I really, honestly, want to run that test.  I get 
tripped up by this all the time.  Here are conditions I see crop up in tests:

  POD_COVERAGE # run if true
  FAST_TESTS # run unless true
  PROFILE_TESTS # run if true

The (anti?) pattern is that if a given environment variable is set, we run the 
test or don't run the test. Here's what I want:

  prove t/some/test.t

... and have that test DWIM.

 
Why this doesn't work is that the test has to be able to say "run me anyway!", 
but it doesn't (and usually shouldn't) know if other tests are being run at the 
same time.

However, "prove" shouldn't have special-case knowledge of, say, setting 
environment variables or anything like that.

We could potentially have Test::Harness set an environment variable specifying 
how many tests are run and do this:

  use Test::Skipall 
      if => sub {  !$ENV{PROFILE_TESTS} },
      message => 'PROFILE_TESTS environment variable set';

And internally it would not skip_all if "TEST_PROGRAMS_TO_RUN" (or whatever 
it's named) is not equal to 1.  It scratches a huge itch of mine, but I don't 
know if anyone else would benefit or if this is the right approach.

Cheers,
Ovid
--
Buy the book         - http://www.oreilly.com/catalog/perlhks/
Tech blog            - http://use.perl.org/~Ovid/journal/
Twitter              - http://twitter.com/OvidPerl
Official Perl 6 Wiki - http://www.perlfoundation.org/perl6

Reply via email to