http://qs321.pair.com?node_id=117208

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

Hello, I'm writing a module and would like to test it with tests in t/. I need to pass each test the same command line argument. Is there an entry I can make in Makefile.PL that will pass the arg or do I need to write a mother test script that evals the other test scripts? TIA. TG

Replies are listed 'Best First'.
Re: How do I pass command line args to test module?
by thraxil (Prior) on Oct 06, 2001 at 20:36 UTC
Re: How do I pass command line args to test module?
by Anonymous Monk on Oct 06, 2001 at 22:38 UTC
    I figured it out!!!
    
    In the script prior to testing for command line args, I set them
    via the following:
    
    @ARGV = qw(blah);
    
    It seems to work as I wish it to.
    
    TG
    
Re: How do I pass command line args to test module?
by Anonymous Monk on Oct 06, 2001 at 20:46 UTC
    I appreciate your input but...
    
    I did look at Test::Harness and found:
    
      The global variable $Test::Harness::switches is exportable and can be used
      to set perl command line options used for running the test script(s). The
      default value is `-w'.
    
    which I don't think is going to do what I want it to do.  My
    understanding is that $Test::Harness::switches = "-w blah" would
    result in
    
      perl -w blah t/test.t
    
    not
    
      perl -w t/test.t blah  < this is what I want
    
    Also, I want to set a variable in Makefile.PL that will set
    a variable in Makefile to be used by make test.