On Sun, Jul 13, 2003 at 03:22:43PM +0100, Fergal Daly wrote:
> Hi,
> is it possible with Test::Harness and MakeMaker to pass arguments to my test
> scripts? I think it's not but I just want to check for sure. The module I'm
> working on is getting a new "optimised" mode so I'd like to be able to run
> all the tests twice, once with and once without the optimiser.
>
> One possibilty is to have a file called run_opt which is something like
>
> #! /usr/bin/perl
>
> ($script, $optimise) = $0 =~ /(.*?)(_opt)?/;
>
> system($script, "otimise");
>
> then do
>
> ln -s run_opt script1_opt
> ln -s run_opt script2_opt
> ln -s run_opt script3_opt
> ln -s run_opt script4_opt
>
> But that's a bit of a pain. What will happen to the symbolic links on non-unix
> platforms? I suppose you could do a cp rather a ln -s.
>
> Anyway, it'd be nice to be able to somehow tell Test::Harness to run all these
> scripts multiple times in these different ways. Any chance of that happening?
>
> How about allowing run_tests to accept not just strings but also objects like
>
> {
> script_name => 'script1',
> environments => [
> {
> perl_switches => '-w -MOptimise',
> arguments => [1, 'wibble'],
> env_vars => { BLAH => 1 },
> setup_script => 'setup.pl',
> teardown_script => 'teardown.pl',
> },
> {
> perl_switches => '-w',
> arguments => [0, 'wobble'],
> env_vars => { BLAH => 2 },
> }
> ]
> }
>
> I'm not that bothered about env_vars and setup/teardown stuff but the switches
> and args would be nice. I'll make a patch if there's any chance it would be
> accepted,
The way I deal with this is to make a module that does all the heavy
lifting, give it an appropriate import sub, and then a test reduces to
something like:
use TestX ( opt1 => "x", opt2 => "y" )
That covers everything except the perl switches, but although I've never
needed that functionality, I suppose it could be quite important.
--
Paul Johnson - [EMAIL PROTECTED]
http://www.pjcj.net