[Bps-public-commit] Prophet branch, master, updated. b71474289444f930c8d81169642d244b0fbe8f92

spang at bestpractical.com spang at bestpractical.com
Thu Aug 6 08:21:25 EDT 2009


The branch, master has been updated
       via  b71474289444f930c8d81169642d244b0fbe8f92 (commit)
       via  5c7a252cc92acce2557d8a999d37cef20b23f7bd (commit)
      from  51be121777504879ccc884ac896c91cc8e1fe5b8 (commit)

Summary of changes:
 lib/Prophet/CLI/Command/Init.pm |    2 +-
 t/usage.t                       |   34 +++++++++++++++++++++++++++++-----
 2 files changed, 30 insertions(+), 6 deletions(-)

- Log -----------------------------------------------------------------
commit 5c7a252cc92acce2557d8a999d37cef20b23f7bd
Author: Christine Spang <spang at bestpractical.com>
Date:   Thu Aug 6 13:07:56 2009 +0100

    Noting useful use of env var in init usage message isn't actually useful in an interactive shell.

diff --git a/lib/Prophet/CLI/Command/Init.pm b/lib/Prophet/CLI/Command/Init.pm
index 2322400..e03247b 100644
--- a/lib/Prophet/CLI/Command/Init.pm
+++ b/lib/Prophet/CLI/Command/Init.pm
@@ -9,7 +9,7 @@ sub usage_msg {
     $env_var =~ s/ //;
 
     return <<"END_USAGE";
-usage: [${env_var}=/path/to/new/repo] ${cmd}init
+usage: ${cmd}init
 END_USAGE
 }
 
diff --git a/t/usage.t b/t/usage.t
index 9b5ff3e..88b0b04 100644
--- a/t/usage.t
+++ b/t/usage.t
@@ -104,7 +104,7 @@ my @cmds = (
     },
     {
         cmd     => [ 'init', '-h' ],
-        error   => [ 'usage: [USAGE.T_REPO=/path/to/new/repo] usage.t init' ],
+        error   => [ 'usage: usage.t init' ],
         comment => 'init usage',
     },
     {

commit b71474289444f930c8d81169642d244b0fbe8f92
Author: Christine Spang <spang at bestpractical.com>
Date:   Thu Aug 6 13:08:20 2009 +0100

    Make sure that usage messages don't print a script name when in an interactive shell.

diff --git a/t/usage.t b/t/usage.t
index 88b0b04..fdd6905 100644
--- a/t/usage.t
+++ b/t/usage.t
@@ -2,7 +2,7 @@
 use warnings;
 use strict;
 
-use Prophet::Test tests => 36;
+use Prophet::Test tests => 72;
 use File::Temp qw(tempdir);
 
 $ENV{'PROPHET_REPO'} = tempdir( CLEANUP => ! $ENV{PROPHET_DEBUG}  ) . '/repo-' . $$;
@@ -206,9 +206,11 @@ my @cmds = (
     {
         cmd     => [ 'settings', '-h' ],
         error   => [
-            'usage: usage.t settings [--show]',
-            '       usage.t settings [--edit]',
-            '       usage.t settings --set -- setting "new value"',
+            'usage: usage.t settings [show]',
+            '       usage.t settings edit',
+            '       usage.t settings set -- setting "new value"',
+            '',
+            'Note that setting values must be valid JSON.',
         ],
         comment => 'settings usage',
     },
@@ -257,6 +259,8 @@ my @cmds = (
     },
 );
 
+my $in_interactive_shell = 0;
+
 for my $item ( @cmds ) {
     my $exp_error
         = defined $item->{error}
@@ -265,3 +269,23 @@ for my $item ( @cmds ) {
     my ($got_output, $got_error) = run_command( @{$item->{cmd}} );
     is( $got_error, $exp_error, $item->{comment} );
 }
+
+$in_interactive_shell = 1;
+
+for my $item ( @cmds ) {
+    my $exp_error
+        = defined $item->{error}
+        ? (join "\n", @{$item->{error}}) . "\n"
+        : '';
+    # in an interactive shell, usage messages shouldn't be printing a command
+    # name
+    $exp_error =~ s/usage.t //g;
+    my ($got_output, $got_error) = run_command( @{$item->{cmd}} );
+    is( $got_error, $exp_error, $item->{comment} );
+}
+
+no warnings 'redefine';
+sub Prophet::CLI::interactive_shell {
+    return $in_interactive_shell;
+}
+

-----------------------------------------------------------------------



More information about the Bps-public-commit mailing list