develooper Front page | perl.qa | Postings from November 2007

Providing command-line arguments to tests run via 'prove'

Thread Next
From:
James E Keenan
Date:
November 24, 2007 19:05
Subject:
Providing command-line arguments to tests run via 'prove'
Message ID:
20071125030527.1329.qmail@lists.develooper.com
Let's suppose that I have a suite of test files which I customarily run 
with 'prove':

   prove t/*.t

... where the tests in t/ are:

   alpha.t
   beta.t
   gamma.t

Let's further suppose that each of these three tests simulates the 
operation of a Perl program which is normally called with command-line 
arguments or options:

   perl myperlprogram.pl --option1 --option2 arg1 arg2

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.  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

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About