--- James E Keenan <[EMAIL PROTECTED]> wrote:
> I know in advance that some of my users call myperlprogram.pl with
> options and some don't -- but I don't know what values they provide
> for
> those options. I would like my tests to be sufficiently flexible as
> to
> be able to handle the various use cases.
>
> I would like to be able to provide the tests run via 'prove' with
> options something like this:
>
> some_variant_of_prove t/*.t --option1 --option2 arg1 arg2
>
> ... where those 4 command-line options/arguments would be available
> to
> *each* of the individual test files in the suite.
Sorry, I just saw this.
What you want is the --exec switch which, I'm embarassed to realize, is
not documented terribly well. Oops.
See examples/README to see how it works. Also, you'll want to
s/runtests/prove/ in that document.
Basically, if you want four args passed to everything, there's a
variety of ways to do that. One is to create an 'exec' program this
way:
#!/usr/bin/perl
use strict;
use warnings;
my $test = shift;
my @args = split ':' => $ENV{TEST_ARGS};
exec( $test, @args ) or die "Cannot exec ($test, @args): $!";
If that's named 'ourtests' *and* made executable, you can run it like
this:
prove --exec ourtests -v t
Cheers,
Ovid
A given test file
> would not necessarily have to respond to those options/arguments, but
> if
> it wanted to, it would do so simply by assigning the contents of the
> test script's @ARGV to some other array.
>
> Can this be done?
>
> Thank you very much.
>
> Jim Keenan
>
--
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/