How to send command line options into test scripts?

Discussion in 'Perl Misc' started by yusuf, Aug 9, 2006.

  1. yusuf

    yusuf Guest

    Hi,

    Does anyone know how to send command line options into test scripts
    from prove?

    For instance, I want to call the test file "t" with the options:

    --log somefile --output=true

    but I can't seem to find out how to do it from prove. I tried using the
    $Test::Harness::switches var, but that does not seem to do it.

    I didn't post any code because this is not a code question.
     
    yusuf, Aug 9, 2006
    #1
    1. Advertising

  2. yusuf

    Matt Garrish Guest

    yusuf wrote:

    >
    > Does anyone know how to send command line options into test scripts
    > from prove?
    >


    >
    > I didn't post any code because this is not a code question.


    Then it's not a question to post to a perl coding group, is it?

    Matt
     
    Matt Garrish, Aug 9, 2006
    #2
    1. Advertising

  3. yusuf

    yusuf Guest

    > Then it's not a question to post to a perl coding group, is it?

    But its a perl question right? Which group should it go to?
     
    yusuf, Aug 9, 2006
    #3
  4. yusuf

    Matt Garrish Guest

    yusuf wrote:
    [context restored]
    > Matt wrote:
    > > yusuf wrote:
    > >
    > > >
    > > > Does anyone know how to send command line options into test scripts
    > > > from prove?

    > >
    > > Then it's not a question to post to a perl coding group, is it?

    >
    > But its a perl question right? Which group should it go to?


    It's no more relevant than asking how ppm works. I suspect there's a
    Perl question you're trying to ask, but since you refuse outright to
    post any code (or even give an explanation of what you're doing) I
    doubt you'll find anyone inclined to help you get to it.

    Why out of curiosity would you post one vague snippet of code and then
    claim it's not a code question?

    Matt
     
    Matt Garrish, Aug 10, 2006
    #4
  5. yusuf

    DJ Stunks Guest

    yusuf wrote:
    > Hi,
    >
    > Does anyone know how to send command line options into test scripts
    > from prove?
    >
    > For instance, I want to call the test file "t" with the options:
    >
    > --log somefile --output=true
    >
    > but I can't seem to find out how to do it from prove. I tried using the
    > $Test::Harness::switches var, but that does not seem to do it.
    >
    > I didn't post any code because this is not a code question.


    Perl does not exist independent of code; Perl IS code.

    -jp

    PS - There is no spoon.
     
    DJ Stunks, Aug 10, 2006
    #5
  6. yusuf

    yusuf Guest

    > Why out of curiosity would you post one vague snippet of code and then
    > claim it's not a code question?


    I didn't post any code. They were command line argument examples. I
    can't post any code because I don't know how to code the thing I need.
    The thing I need is to:

    - From 'prove' which uses Test::Harness, when I call the different test
    files in runtests(). How do I send in command line arguments to those
    test files.
     
    yusuf, Aug 10, 2006
    #6
  7. yusuf

    Matt Garrish Guest

    yusuf wrote:

    > > Why out of curiosity would you post one vague snippet of code and then
    > > claim it's not a code question?

    >
    > I didn't post any code.


    Then explain "I tried using the $Test::Harness::switches var".

    Switches, if you read the documentation, is for setting the
    command-line switches for perl.

    > They were command line argument examples. I
    > can't post any code because I don't know how to code the thing I need.
    > The thing I need is to:
    >
    > - From 'prove' which uses Test::Harness, when I call the different test
    > files in runtests(). How do I send in command line arguments to those
    > test files.


    Well, if you've read the documentation you know it's not when you call
    prove, because prove just runs your tests. Why is your test data not
    self-contained in the test file? Do you know why you're using this
    approach and not the debugger? I'm beginning to have my doubts.

    Matt
     
    Matt Garrish, Aug 10, 2006
    #7
  8. yusuf

    yusuf Guest


    > Well, if you've read the documentation you know it's not when you call
    > prove, because prove just runs your tests. Why is your test data not
    > self-contained in the test file? Do you know why you're using this
    > approach and not the debugger? I'm beginning to have my doubts.


    I can't use preconfigured tests because the tests have to run against
    running baseline and candidate processes. So the controller script will
    start the baseline and candidate process and then it needs to send in
    the process id of each to the test scripts.

    I am not using the Test module to test perl class files, but against my
    own executables.
     
    yusuf, Aug 10, 2006
    #8
  9. yusuf

    Mumia W. Guest

    On 08/10/2006 12:07 AM, yusuf wrote:
    > [...]
    > I am not using the Test module to test perl class files, but against my
    > own executables.
    >


    Then create stub scripts that supply the correct parameters.
     
    Mumia W., Aug 10, 2006
    #9
  10. yusuf

    yusuf Guest


    > Then create stub scripts that supply the correct parameters.


    But wouldn't the stub scripts have to still be called by runtests()?
    The whole issue is how to call the test files from runtests(), and
    still pass in parameters. Even if I have stub scripts how will I send
    in the parameters to the stub scripts, because the pid being sent in
    will survive over multiple tests.
     
    yusuf, Aug 10, 2006
    #10
  11. yusuf

    yusuf Guest

    Since people love code so much, here is an example of what I would like
    to happen (if it did not error out):

    test.pl:

    #!/usr/bin/perl



    use strict;
    use warnings;



    use Test::Harness;



    my @a = ('t -x HELLO');



    runtests(@a);

    t:
    #!/usr/bin/perl



    use strict;
    use warnings;



    use Test::More tests => 1;



    use Getopt::Std;



    my %opts;



    getopts('x:',\%opts);



    print "X";
    print $opts{x};



    ok(1);
     
    yusuf, Aug 10, 2006
    #11
  12. yusuf

    Mumia W. Guest

    On 08/10/2006 12:43 PM, yusuf wrote:
    > Mumia W. wrote:
    >> Then create stub scripts that supply the correct parameters.

    >
    > But wouldn't the stub scripts have to still be called by runtests()?
    > The whole issue is how to call the test files from runtests(), and
    > still pass in parameters. Even if I have stub scripts how will I send
    > in the parameters to the stub scripts, because the pid being sent in
    > will survive over multiple tests.
    >


    The stub scripts contain the parameters needed by the
    executable you're testing. Each stub script will contain
    /different/ parameters.

    And please don't snip attributions.
     
    Mumia W., Aug 10, 2006
    #12
  13. yusuf <> wrote:

    > Since people love code so much,



    So long!


    --
    Tad McClellan SGML consulting
    Perl programming
    Fort Worth, Texas
     
    Tad McClellan, Aug 10, 2006
    #13
  14. yusuf

    Matt Garrish Guest

    yusuf wrote:

    > Since people love code so much, here is an example of what I would like
    > to happen (if it did not error out):
    >


    And here I was thinking you were an obnoxious prick at the beginning of
    the thread. Way to up the ante.

    Matt
     
    Matt Garrish, Aug 10, 2006
    #14
  15. yusuf

    yusuf Guest


    > And here I was thinking you were an obnoxious prick at the beginning of
    > the thread. Way to up the ante.


    What the heck is your problem? I have been providing everything that
    people requested. Instead of help, I've gotten stupid comments. If you
    don't want to help just shut up and move along.
     
    yusuf, Aug 10, 2006
    #15
  16. yusuf

    yusuf Guest

    =
    > So long!


    Why are you so rude? Not like you helped any.
     
    yusuf, Aug 10, 2006
    #16
  17. yusuf

    Matt Garrish Guest

    yusuf wrote:

    > If you don't want to help just shut up and move along.


    Why, this isn't your personal help desk?

    Best of luck finding the help the world owes you, though.

    Matt
     
    Matt Garrish, Aug 10, 2006
    #17
  18. yusuf <> wrote:
    >=
    >> So long!

    >
    > Why are you so rude?



    It is a response to _your_ rudeness.


    > Not like you helped any.



    And I'm glad I didn't too!

    Thanks for making me feel better about that.


    --
    Tad McClellan SGML consulting
    Perl programming
    Fort Worth, Texas
     
    Tad McClellan, Aug 11, 2006
    #18
  19. yusuf

    yusuf Guest

    > It is a response to _your_ rudeness.

    Well, it wasn't my intention to be rude. Sorry if you felt that way.
     
    yusuf, Aug 11, 2006
    #19
  20. yusuf

    Keith Keller Guest

    On 2006-08-10, yusuf <> wrote:
    >
    > Well, it wasn't my intention to be rude. Sorry if you felt that way.


    If it wasn't your intention to be rude, you might consider reading
    and following the Posting Guidelines that are posted periodically
    to the newsgroup.

    --keith

    --
    -francisco.ca.us
    (try just my userid to email me)
    AOLSFAQ=http://wombat.san-francisco.ca.us/cgi-bin/fom
    see X- headers for PGP signature information
     
    Keith Keller, Aug 11, 2006
    #20
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    8
    Views:
    395
    Fabio Fracassi
    May 4, 2005
  2. hue

    Parse command line options

    hue, Apr 18, 2005, in forum: Python
    Replies:
    5
    Views:
    399
  3. Replies:
    3
    Views:
    317
    Roland Pibinger
    Jan 11, 2007
  4. holger krekel
    Replies:
    0
    Views:
    411
    holger krekel
    Jan 18, 2010
  5. hiral
    Replies:
    2
    Views:
    263
    Steven D'Aprano
    Mar 14, 2011
Loading...

Share This Page