On Fri Mar 13 07:01:33 2015, JIRA wrote:
Show quoted text> Test::Script won't work without blib directory.
> This should not be required as there are scenarious when one want to use it
> outside of typical CPAN distribution.
I propose the attached patch as a solution. Instead of using -Mblib it uses -I for each directory in @INC. The downside to this approach is that some of the @INC directories in the child process will be repeated, but at least they should be in the right order. I'm filtering out any references as you won't be able to pass sub ref hooks to the child in this way. Might be worth mentioning as a CAVEAT.
diff --git a/lib/Test/Script.pm b/lib/Test/Script.pm
index 734afec..3634c90 100755
--- a/lib/Test/Script.pm
+++ b/lib/Test/Script.pm
@@ -113,7 +113,8 @@ sub script_compiles {
my $args = _script(shift);
my $unix = shift @$args;
my $path = path( $unix );
- my $cmd = [ perl, '-Mblib', '-c', $path, @$args ];
+ my @libs = map { "-I$_" } grep {!ref($_)} @INC;
+ my $cmd = [ perl, @libs, '-c', $path, @$args ];
my $stdin = '';
my $stdout = '';
my $stderr = '';
@@ -153,7 +154,8 @@ sub script_runs {
my $args = _script(shift);
my $unix = shift @$args;
my $path = path( $unix );
- my $cmd = [ perl, '-Mblib', $path, @$args ];
+ my @libs = map { "-I$_" } grep {!ref($_)} @INC;
+ my $cmd = [ perl, @libs, $path, @$args ];
my $stdin = '';
my $stdout = '';
my $stderr = '';