tirwhan has asked for the wisdom of the Perl Monks concerning the following question:
Hello monkses,
I'm currently finishing off a module I plan to release on CPAN. It would be beneficial if the test suite included tests against a live server (simulated tests are also included, but not as good as the real thing). For this I need to prompt the user for some information, to see whether he has such a server available and what it's address etc. are.
I gather that putting interactivity into the general test suite is a big no-no (it breaks the automated smoke tests for one), so I've been thinking about how I could do this and come up with the following:
use Test::More qw(no_plan); use strict; use warnings; SKIP: { skip qq(Won't run automatically, execute "export MyModOPTRUN=yes" +to enable interactive test) unless ($ENV{MyModOPTRUN} && $ENV{MyModOPTRUN} eq "yes"); warn "\nEnter your innermost secret:\n"; my $secret = (<STDIN>); ok ($secret,"Yep, that's it"); }
Obviously replacing "MyMod" with the actual name of my module. This will produce
t/02.optional....ok 1/1 skipped: Not running automatically, execute "export MyModO +PTRUN=yes" to enable interactive test All tests successful, 1 subtest skipped. Files=1, Tests=1, 0 wallclock secs ( 0.00 cusr + 0.01 csys = 0.01 C +PU)
When run without the environment variable set, which should be all right I think.
Are there any problems with this approach? Does the "export" syntax even work on non-*NIX-shells? If not, is there an equivalent (I can test for $^O and adjust the skip message accordingly)? Is there a better way to do this?
Thanks in advance
|
|---|