in reply to Interactivity in tests - done correctly?

On the issue of prompting under test conditions:

If you use ExtUtils::MakeMaker to build your module you can import "prompt" http://search.cpan.org/~mschwern/ExtUtils-MakeMaker-6.48/lib/ExtUtils/MakeMaker.pm#Other_Handy_Functions:

use ExtUtils::MakeMaker 5.16, qw(prompt);

and as far as I am aware the prompt returns the default if no stdin or running in an automated system - like smoking.

Replies are listed 'Best First'.
Re^2: Interactivity in tests - done correctly?
by Anonymous Monk on Jan 22, 2009 at 14:35 UTC
    Even if you don't use ExtUtils::MakeMaker, you should use ExtUtils::MakeMaker::prompt, since every perl comes with ExtUtils::MakeMaker.

      Agreed. I slightly misread the post at first or I would have made that response use prompt.

Re^2: Interactivity in tests - done correctly?
by Sandy (Curate) on Jan 22, 2009 at 19:40 UTC
    I am a little uncertain as what you mean.

    If I use 'prompt' in the Makefile.PL, how can the test scripts get this information.

    I am having a similar requirement as the OP, in that I need username and password to test. I do not want to use an environment variable for the password (although it is a development database, the DBA is very strict about keeping even those passwords very secure).

      Yes, as I said I initially slightly misread the question and hence the reference to Makefile.PL. You can use ExtUtils::MakeMaker->prompt in your test scripts too.

      $ perl -MExtUtils::MakeMaker -le 'print ExtUtils::MakeMaker::prompt("f +red", "default");' fred [default] # I just hit CR here default
Re^2: Interactivity in tests - done correctly?
by tirwhan (Abbot) on Jan 22, 2009 at 20:28 UTC

    Thanks! I came across ExtUtils::MakeMaker::prompt when looking for answers to this question prior to posting (should have mentioned that). Correct me if I'm wrong, but I was under the impression that using E::MM::prompt means that

    a.) Anyone installing the module via Module::Build would not be prompted?

    b.) Everyone installing the module interactively (via Makefile.PL) would be prompted?

    I don't want either of these, I like to provide both a Build.PL and Makefile.PL so people have the choice of install system to use. And I also don't want to prompt every user for this information, I just want to tell the user "you can test this against against a live service if you want, and if you tell me to do so I'll prompt you for the information that's required".

    Not saying your suggestion is a bad one, but if both of these assumptions are true it's just not the right fit for me.


    All dogma is stupid.