print --usage, --help to stdout not stderr
[gitmo/MooseX-Getopt.git] / t / 109_help_flag.t
index 580884e..eb75961 100644 (file)
 
 # 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;
@@ -31,7 +33,7 @@ use Test::Fatal;
 #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.
 
@@ -43,10 +45,17 @@ my $usage_text = $obj->usage->text;
 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');
 }
 
-