Revision history for Perl extension MooseX-Getopt
+{{$NEXT}}
+ * Now bails with exit status 0, rather than dying, when printing
+ --usage/--help information. (Karen Etheridge)
+
0.40 Fri 13 Apr 2012
* Fix tests when MooseX::ConfigFromFile is installed, with
Getopt::Long::Descriptive >= 0.091. RT#76287
use strict;
use warnings;
use Test::More 0.88;
-use Test::Fatal;
+use Test::Trap;
{
package MyScript;
{
local $MyScript::usage; local @MyScript::warnings; local @MyScript::exception;
local @ARGV = ('--help');
- like exception { MyScript->new_with_options }, qr/A foo/;
+ trap { MyScript->new_with_options };
+ like($trap->stdout, qr/A foo/);
is $MyScript::usage, 1;
}
{
local $MyScript::usage; local @MyScript::warnings; local @MyScript::exception;
local @ARGV = ('-q'); # Does not exist
- like exception { MyScript->new_with_options }, qr/A foo/;
+ trap { MyScript->new_with_options };
+ like($trap->die, qr/A foo/);
is_deeply \@MyScript::warnings, [
'Unknown option: q
'
# This inconsistency is the underlying cause of RT#52474, RT#57683, RT#47865.
+# Update: since 0.41, usage info is printed to stdout, not stderr.
+
use strict; use warnings;
-use Test::More tests => 6;
-use Test::Fatal;
+use Test::More tests => 18;
+use Test::Trap;
{
package MyClass;
#Unknown option: ?
#usage: test1.t
-# after fix, prints this on stderr:
+# after fix, prints this on stdout (formerly stderr):
#usage: test1.t [-?] [long options...]
# -? --usage --help Prints this usage information.
foreach my $args ( ['--help'], ['--usage'], ['--?'], ['-?'] )
{
local @ARGV = @$args;
+ note "Setting \@ARGV to @$args";
+
+ trap { MyClass->new_with_options() };
- is exception { MyClass->new_with_options() },
+ is($trap->leaveby, 'exit', 'bailed with an exit code');
+ is($trap->exit, 0, '...of 0');
+ is(
+ $trap->stdout,
$usage_text,
- 'Help request detected; usage information properly printed';
+ 'Usage information printed to STDOUT',
+ );
+ is($trap->stderr, '', 'there was no STDERR output');
}
-