[Bps-public-commit] Test-Script-Run branch, master, updated. 987f809ec7701c55a1d49252f88699c841bc2cab
? sunnavy
sunnavy at bestpractical.com
Fri Jun 25 00:12:38 EDT 2010
The branch, master has been updated
via 987f809ec7701c55a1d49252f88699c841bc2cab (commit)
via 6b4b2cc0edf9e1047bb1f6fd086888febc485df7 (commit)
via 9d5a671ca6e28a1055625566d21ef85d65ccfc0e (commit)
via 1648a5f2e79cefffd7f748fe7c303e6afac221ef (commit)
via a1764c84065ce293d44f96e282d6d650675a02d2 (commit)
from cc4bfb16d78cc93702d438c531488b390765d071 (commit)
Summary of changes:
Changes | 4 +++-
MANIFEST | 1 +
META.yml | 2 +-
lib/Test/Script/Run.pm | 22 +++++++++++++++++-----
t/01.run.t | 14 +++++++++++++-
t/{bin/test.pl => script/test_script.pl} | 0
6 files changed, 35 insertions(+), 8 deletions(-)
copy t/{bin/test.pl => script/test_script.pl} (100%)
- Log -----------------------------------------------------------------
commit a1764c84065ce293d44f96e282d6d650675a02d2
Author: sunnavy <sunnavy at bestpractical.com>
Date: Fri Jun 25 12:01:18 2010 +0800
allow bin dirs customization
diff --git a/lib/Test/Script/Run.pm b/lib/Test/Script/Run.pm
index 6c69310..dab81b6 100644
--- a/lib/Test/Script/Run.pm
+++ b/lib/Test/Script/Run.pm
@@ -20,6 +20,8 @@ my (
$last_script_exit_code,
);
+our @BIN_DIRS = ('bin','sbin','script');
+
=head1 NAME
Test::Script::Run - test the script with run
@@ -27,6 +29,8 @@ Test::Script::Run - test the script with run
=head1 SYNOPSIS
use Test::Script::Run;
+ # customized names of bin dirs, default is qw/bin sbin script/;
+ @Test::Script::Run::BIN_DIRS = qw/bin/;
run_ok( 'app_name', [ app's args ], 'you_app runs ok' );
my ( $return, $stdout, $stderr ) = run_script( 'app_name', [ app's args ] );
run_output_matches(
@@ -168,12 +172,20 @@ sub get_perl_cmd {
if (defined $script) {
unless ( File::Spec->file_name_is_absolute($script) ) {
my ( $tmp, $i ) = ( _updir($0), 0 );
- while ( !-d File::Spec->catdir( $tmp, 'bin' ) && $i++ < 10 ) {
+ my $found;
+LOOP:
+ while ( $i++ < 10 ) {
+ for my $bin ( @BIN_DIRS ) {
+ if ( -e File::Spec->catfile( $tmp, $bin, $script ) ) {
+ $script = File::Spec->catfile( $tmp, $bin, $script );
+ $found = 1;
+ last LOOP;
+ }
+ }
$tmp = _updir($tmp);
}
- $base_dir = File::Spec->catdir( $tmp, 'bin' );
- die "couldn't find bin dir" unless -d $base_dir;
+ warn "couldn't find the script" unless $found;
}
}
@@ -187,7 +199,7 @@ sub get_perl_cmd {
}
if (defined $script) {
- push @cmd, $base_dir ? File::Spec->catdir( $base_dir => $script ) : $script;
+ push @cmd, $script;
push @cmd, @_;
}
diff --git a/t/01.run.t b/t/01.run.t
index 6ab04ca..b1a4abf 100644
--- a/t/01.run.t
+++ b/t/01.run.t
@@ -1,7 +1,7 @@
use strict;
use warnings;
-use Test::More tests => 33;
+use Test::More tests => 38;
use Test::Script::Run ':all';
use File::Spec;
@@ -79,3 +79,15 @@ run_ok( $sbin_script, 'sbin script' );
ok( $return, 'return of sbin_script' );
is( $stdout, 'test_sbin_script', 'stdout of sbin_script' );
+
+run_ok( 'test_script.pl', 'run test_script.pl' );
+is( last_script_stdout, "out line 1\nout line 2", 'last stdout' );
+is( last_script_stderr, "err line 1\nerr line 2", 'last stderr' );
+is( last_script_exit_code, 0, 'last exit code' );
+
+is_script_output(
+ 'test.pl', ['out', 'err'],
+ [ 'out' ],
+ [ 'err' ],
+ 'is_script_output'
+);
commit 1648a5f2e79cefffd7f748fe7c303e6afac221ef
Author: sunnavy <sunnavy at bestpractical.com>
Date: Fri Jun 25 12:02:11 2010 +0800
release 0.04
diff --git a/Changes b/Changes
index 624da86..abc4117 100644
--- a/Changes
+++ b/Changes
@@ -1,6 +1,8 @@
Revision history for Test-Script-Run
-0.04
+0.04 Fri Jun 25 12:01:30 CST 2010
+
+ allow customization of bin dir names.
0.03 Tue Nov 17 01:50:40 GMT 2009
Make get_perl_cmd public API
commit 9d5a671ca6e28a1055625566d21ef85d65ccfc0e
Author: sunnavy <sunnavy at bestpractical.com>
Date: Fri Jun 25 12:09:26 2010 +0800
add t/script/
diff --git a/t/script/test_script.pl b/t/script/test_script.pl
new file mode 100644
index 0000000..ce3e0fc
--- /dev/null
+++ b/t/script/test_script.pl
@@ -0,0 +1,7 @@
+use strict;
+use warnings;
+
+my ( $out, $err ) = @ARGV;
+print $out || "out line 1\nout line 2";
+print STDERR $err || "err line 1\nerr line 2";
+
commit 6b4b2cc0edf9e1047bb1f6fd086888febc485df7
Author: sunnavy <sunnavy at bestpractical.com>
Date: Fri Jun 25 12:10:46 2010 +0800
update manifest
diff --git a/MANIFEST b/MANIFEST
index 8c83993..294d7ea 100644
--- a/MANIFEST
+++ b/MANIFEST
@@ -21,6 +21,7 @@ t/01.run.t
t/bin/test.pl
t/bin/test_die.pl
t/sbin/test_sbin.pl
+t/script/test_script.pl
xt/kwalitee.t
xt/perlcritic.t
xt/pod-coverage.t
commit 987f809ec7701c55a1d49252f88699c841bc2cab
Author: sunnavy <sunnavy at bestpractical.com>
Date: Fri Jun 25 12:13:43 2010 +0800
bump to 0.05
diff --git a/META.yml b/META.yml
index 8efc1a4..e825051 100644
--- a/META.yml
+++ b/META.yml
@@ -20,4 +20,4 @@ requires:
Test::Exception: 0
resources:
license: http://dev.perl.org/licenses/
-version: 0.04
+version: 0.05
diff --git a/lib/Test/Script/Run.pm b/lib/Test/Script/Run.pm
index dab81b6..9198d9d 100644
--- a/lib/Test/Script/Run.pm
+++ b/lib/Test/Script/Run.pm
@@ -8,7 +8,7 @@ use IPC::Run3;
use File::Basename;
use File::Spec;
-our $VERSION = '0.04';
+our $VERSION = '0.05';
use base 'Exporter';
our @EXPORT =
qw/run_ok run_not_ok run_script run_output_matches run_output_matches_unordered/;
-----------------------------------------------------------------------
More information about the Bps-public-commit
mailing list