Subject: | Use prompt() in Makefile.PL to Allow Automated Tests |
Dear Mark Jason Dominus,
Hi. This is imacat from Taiwan. I'm currently helping to run smoke
tests for CPAN modules. I found that the Makefile.PL of
Net-DHCP-Control-0.09 goes into infinite loop if nothing is read from
keyboard. I would suggest that you use prompt() instead of directly
obtain input from the STDIN, as suggested in the ExtUtils::MakeMaker
document, so that the it won't go into infinite loop.
<<ExtUtils::MakeMaker>>
Other Handy Functions
http://search.cpan.org/perldoc?ExtUtils::MakeMaker#Other_Handy_Functions
Also, I would suggest you to exit() with 0 from the Makefile.PL if
the required answer fails, as suggested by this article:
<<Notes For CPAN Authors>
"How can I stop getting FAIL reports for missing libraries or other
non-Perl dependencies?"
http://cpantest.grango.org/wiki/CPANAuthorNotes
I made a simple patch to Net-DHCP-Control-0.09, in the hope that it
helps. Please tell me if you have any question, or if I could be of any
help. Thank you.
Subject: | Net-DHCP-Control-0.09-prompt.diff |
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
diff -u -r Net-DHCP-Control-0.09.orig/config-tests Net-DHCP-Control-0.09/config-tests
- --- Net-DHCP-Control-0.09.orig/config-tests 2004-03-10 01:09:37.000000000 +0800
+++ Net-DHCP-Control-0.09/config-tests 2008-03-30 01:55:39.000000000 +0800
@@ -1,6 +1,7 @@
#!perl
use Data::Dumper;
+use ExtUtils::MakeMaker;
system("pwd");
@@ -33,9 +34,8 @@
}
write_data() if $CHANGED;
- -print "Hit ENTER to continue, or anything else to manually edit
- -the configuration file.\n";
- -chomp(my $resp = <STDIN>) ;
+$resp = prompt("Hit ENTER to continue, or anything else to manually edit
+the configuration file.\n");
exit 0 if $resp eq "";
my $editor = $ENV{VISUAL} || $ENV{EDITOR} || "/bin/ed";
system($editor, $RESULT);
@@ -51,8 +51,7 @@
}
prompt: {
my $prompt = defined($default) ? "$k [$default]> " : "$k> ";
- - print $prompt;
- - chomp(my $resp = <STDIN>);
+ $resp = prompt($prompt);
$resp =~ s/^\s+//;
$resp =~ s/\s+$//;
@@ -63,7 +62,7 @@
if (defined $default) {
$dhcpCONFIG{$k} = $default;
} else {
- - redo prompt;
+ exit 1;
}
} else {
$dhcpCONFIG{$k} = $resp;
diff -u -r Net-DHCP-Control-0.09.orig/Makefile.PL Net-DHCP-Control-0.09/Makefile.PL
- --- Net-DHCP-Control-0.09.orig/Makefile.PL 2004-03-11 07:40:00.000000000 +0800
+++ Net-DHCP-Control-0.09/Makefile.PL 2008-03-30 01:53:24.000000000 +0800
@@ -2,12 +2,10 @@
use ExtUtils::MakeMaker;
use Config;
- -print qq{
+$resp = prompt(qq{
Part of the test suite performs possibly intrusive tests on
the DHCP server. Would you like me to perform the intrusive tests?
- -(Default is YES) >> };
- -chomp(my $resp = <STDIN>);
- -$resp ||= "yes";
+(Default is YES) >>}, "yes");
if ($resp =~ /^[yY]/) {
open F, ">", ".risky_tests" or die "Couldn't touch .risky_tests: $!\n";
close F;
@@ -15,8 +13,13 @@
1 while unlink ".risky_tests";
}
- -system("$Config{perlpath} ./config-tests") == 0
- - or die "Couldn't run configurator; return status $?\n";
+if (system("$Config{perlpath} ./config-tests") != 0) {
+ if ($? >> 8 == 1) {
+ print "Configurator failed without required answer.\n";
+ exit 0;
+ }
+ die "Couldn't run configurator; return status $?\n";
+}
# See lib/ExtUtils/MakeMaker.pm for details of how to influence
# the contents of the Makefile that is written.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
iEYEARECAAYFAkfugqkACgkQi9gubzC5S1zYHQCeKqsGRh0Mz79LDuqgvjOsqk2x
IV8AoKfN5TuGdDb+GvMysNM4Tc2Hp45u
=xFPL
-----END PGP SIGNATURE-----