Subject: | Use prompt() in makeconfig.pl to Allow Automated Tests |
Dear Peter McDermott,
Hi. This is imacat from Taiwan. I'm currently helping to run smoke
tests for CPAN modules. I found that the Makefile.PL of
HTML-Bricks-0.03 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 Mason base directory 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 HTML-Bricks-0.03, 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: | HTML-Bricks-0.03-prompt.diff |
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
diff -u -r HTML-Bricks-0.03.orig/makeconfig.pl HTML-Bricks-0.03/makeconfig.pl
- --- HTML-Bricks-0.03.orig/makeconfig.pl 2001-06-13 00:50:17.000000000 +0800
+++ HTML-Bricks-0.03/makeconfig.pl 2008-03-30 02:10:01.000000000 +0800
@@ -150,8 +150,11 @@
$term = new Term::ReadLine 'name';
while(1) {
- - print "\n$prompt [$default]: ";
- - chomp($dir_name = <STDIN>);
+ $dir_name = prompt("\n$prompt:", $default);
+ if ($dir_name eq $default && !((-e $dir_name) && (-d $dir_name))) {
+ print "Required directory missing.\n";
+ exit 0;
+ }
$dir_name = $default if $dir_name eq '';
@@ -255,9 +258,7 @@
print "\nYour settings are:\n";
print join("\n",grep(/=>/,split("\n",$conf)))."\n\n";
- - my $ans = "yes";
- - print "\nKeep existing config [$ans]: ";
- - chomp($ans = <STDIN>);
+ my $ans = prompt("\nKeep existing config:", "yes");
$modify = $ans=~/n[o]?/i;
}
@@ -311,13 +312,9 @@
print "\n";
- - print "\nwww user name [$www_user]: ";
- - chomp($c{www_user} = <STDIN>);
- - $c{www_user} = $www_user if $c{www_user} eq '';
- -
- - print "\nwww group name [$www_group]: ";
- - chomp($c{www_group} = <STDIN>);
- - $c{www_group} = $www_group if $c{www_group} eq '';
+ $c{www_user} = prompt("\nwww user name:", $www_user);
+
+ $c{www_group} = prompt("\nwww group name:", $www_group);
}
@@ -360,10 +357,7 @@
if (!defined $c{admin_user_name} || $modify) {
my $base = $c{admin_user_name} || "admin";
- - print "\nAdministrator user name [$base]: ";
- - chomp($c{admin_user_name} = <STDIN>);
- -
- - $c{admin_user_name} = $c{admin_user_name} || $base;
+ $c{admin_user_name} = prompt("\nAdministrator user name:", $base);
print "\n";
}
@@ -386,15 +380,10 @@
while(1) {
system "stty -echo";
- - print "Enter administrator password [$default]: ";
- - chomp ($pw = <STDIN>);
- -
- - print "\n";
+ $pw = prompt("Enter administrator password:", $default);
if ($pw ne '') {
- - print "Reenter administrator password: ";
- - chomp ($pw2 = <STDIN>);
- - print "\n";
+ $pw2 = prompt("Reenter administrator password:");
}
else {
$pw = $pw2 = $default;
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
iEYEARECAAYFAkfuhhMACgkQi9gubzC5S1z/QgCfeSpX3yK9Ef6yI1Lc9J7X5HlC
2xQAn1hCZ4Xqx6zUoEVtiG87KZFi2R0A
=Qj+p
-----END PGP SIGNATURE-----