From: Jonathan Rockway Date: Thu, 25 Jun 2009 21:47:41 +0000 (-0700) Subject: protect @INC when re-invoking X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=69fbdb1a279690d6a36238a5a16488a44ebf1c90;p=gitmo%2FMooseX-Runnable.git protect @INC when re-invoking --- diff --git a/lib/MooseX/Runnable/Util/ArgParser.pm b/lib/MooseX/Runnable/Util/ArgParser.pm index 833f983..965d39f 100644 --- a/lib/MooseX/Runnable/Util/ArgParser.pm +++ b/lib/MooseX/Runnable/Util/ArgParser.pm @@ -232,7 +232,12 @@ sub guess_cmdline { my @without_plugins = @{$opts{without_plugins} || []}; # invoke mx-run - my @cmdline = ($^X, @perl_flags, $FindBin::Bin.'/'.$FindBin::Script); + my @cmdline = ( + $^X, + (map { "-I$_" } @INC), + @perl_flags, + $FindBin::Bin.'/'.$FindBin::Script, + ); push @cmdline, map { "-I$_" } $self->include_paths; push @cmdline, map { "-M$_" } $self->modules; diff --git a/t/reverse-args.t b/t/reverse-args.t index 4b0086e..16a2dfa 100644 --- a/t/reverse-args.t +++ b/t/reverse-args.t @@ -13,11 +13,12 @@ my $args = MooseX::Runnable::Util::ArgParser->new( local $^X = '/path/to/perl'; local $FindBin::Bin = '/path/to'; local $FindBin::Script = 'mx-run'; +local @INC = ('foobar'); my @cmdline = $args->guess_cmdline( perl_flags => ['--X--'], without_plugins => ['Plugout'], ); is join(' ', @cmdline), - "/path/to/perl --X-- /path/to/mx-run -Ilib -MFoo -MBar +Plugin --with-args -- MyApp --with args", + "/path/to/perl -Ifoobar --X-- /path/to/mx-run -Ilib -MFoo -MBar +Plugin --with-args -- MyApp --with args", 'cmdline reverses reasonably';