Author: randys
Date: Tue May 9 00:23:55 2006
New Revision: 6274
Modified:
Module-Build/trunk/t/extend.t
Log:
Some tests in t/extend.t which test interactive prompting depend on STDIN being open, particularly Module::Build::Base::_is_interactive() checks the status of STDIN. This will fool some of our tests when, for example, Test::Smoke runs the test suite from a cron job which has no STDIN. Since these tests are not testing the _is_interactive() method itself, we override it to always return true during these tests.
Modified: Module-Build/trunk/t/extend.t
==============================================================================
--- Module-Build/trunk/t/extend.t (original)
+++ Module-Build/trunk/t/extend.t Tue May 9 00:23:55 2006
@@ -230,35 +230,44 @@
$ENV{PERL_MM_USE_DEFAULT} = 1;
- eval{ $mb->y_n("Is this a question?") };
- like $@, qr/ERROR:/, 'Do not allow default-less y_n() for unattended builds';
+ eval{ $mb->y_n('Is this a question?') };
+ like $@, qr/ERROR:/,
+ 'Do not allow default-less y_n() for unattended builds';
eval{ $ans = $mb->prompt('Is this a question?') };
- like $@, qr/ERROR:/, 'Do not allow default-less prompt() for unattended builds';
+ like $@, qr/ERROR:/,
+ 'Do not allow default-less prompt() for unattended builds';
- $ENV{PERL_MM_USE_DEFAULT} = 0;
+ # When running Test::Smoke under a cron job, STDIN will be closed which
+ # will fool our _is_interactive() method causing various failures.
+ {
+ local *{Module::Build::_is_interactive} = sub { 1 };
- $ans = $mb->prompt('Is this a question?');
- print "\n"; # fake <enter> after input
- is $ans, 'y', "prompt() doesn't require default for interactive builds";
+ $ENV{PERL_MM_USE_DEFAULT} = 0;
- $ans = $mb->y_n('Say yes');
- print "\n"; # fake <enter> after input
- ok $ans, "y_n() doesn't require default for interactive build";
+ $ans = $mb->prompt('Is this a question?');
+ print "\n"; # fake <enter> after input
+ is $ans, 'y', "prompt() doesn't require default for interactive builds";
+ $ans = $mb->y_n('Say yes');
+ print "\n"; # fake <enter> after input
+ ok $ans, "y_n() doesn't require default for interactive build";
- # Test Defaults
- *{Module::Build::_readline} = sub { '' };
- $ans = $mb->prompt("Is this a question");
- is $ans, '', "default for prompt() without a default is ''";
+ # Test Defaults
+ *{Module::Build::_readline} = sub { '' };
- $ans = $mb->prompt("Is this a question", 'y');
- is $ans, 'y', " prompt() with a default";
+ $ans = $mb->prompt("Is this a question");
+ is $ans, '', "default for prompt() without a default is ''";
+
+ $ans = $mb->prompt("Is this a question", 'y');
+ is $ans, 'y', " prompt() with a default";
+
+ $ans = $mb->y_n("Is this a question", 'y');
+ ok $ans, " y_n() with a default";
+ }
- $ans = $mb->y_n("Is this a question", 'y');
- ok $ans, " y_n() with a default";
}
# cleanup
|