mice has asked for the wisdom of the Perl Monks concerning the following question:

Hi all,
I'm trying to pass the same argument to all tests in a directory. The perl docs tell me to use:
prove -v t/mytest.t :: --input http://example.com
But whenever I do that I get "Unknown option: input". Here's a simplied version of my code:

1. the test harness file
use Test::Harness; my $dir = "my_dir" system("prove -v tests/at_test_level.t :: --input=$dir");

2. the test file
use Test::More tests => 1; use Getopt::Long; use warnings; my $input; GetOptions( "input=s" => \$input ); ok( 1==1, 'test 1 ok' );

I'm new-ish to perl, so it's probably something straightforward. Your help is appreciated!

Replies are listed 'Best First'.
Re: Passing arguments to tests using prove
by Anonymous Monk on Sep 21, 2009 at 15:41 UTC
    Works for me
    #!/usr/bin/perl -- use strict; use warnings; if(not $ENV{VROOM} ){ $ENV{VROOM}=1; use File::Spec; my $self = File::Spec->rel2abs(__FILE__); my $dir = "my_dir"; system("prove -v $self :: --input=$dir"); system('prove', '-v', $self ,'::', "--input=$dir"); } else { use Test::More; use Getopt::Long; plan tests => 1; my $input; GetOptions( "input=s" => \$input ); ok( $input, "got input=$input" ); }
    $ pmvers Test::More App::Prove Getopt::Long Test::More: 0.94 App::Prove: 3.17 Getopt::Long: 2.38 $ prove -V TAP::Harness v3.17 and Perl v5.10.1
      Thanks a lot for your reply! Tried your code, but am still getting "Unknown option: input" when I run it... Hm.
        Do you see how I provided you with version information? You need to do the same :) Its diagnostic
Re: Passing arguments to tests using prove
by ELISHEVA (Prior) on Sep 21, 2009 at 20:46 UTC

    What version are you using? The arguments are only part of a newer version and may not be the version installed on your system. Debian etch, for example, uses v. 1.04 and does not support the arguments. You can see documentation for back versions on line here (CPAN) - and pick the version from the combobox next to the go-to button.

    Best, beth