[carton] 71/472: Added unit tests for exec

Lucas Kanashiro kanashiro-guest at moszumanska.debian.org
Fri Jul 24 00:38:34 UTC 2015


This is an automated email from the git hooks/post-receive script.

kanashiro-guest pushed a commit to branch master
in repository carton.

commit 7931546be38dfe6cf2d0708261874d6be004ad02
Author: Tatsuhiko Miyagawa <miyagawa at bulknews.net>
Date:   Tue Jun 28 11:15:30 2011 -0400

    Added unit tests for exec
---
 lib/Carton/CLI.pm |  6 +++++-
 xt/cli/exec.t     | 35 +++++++++++++++++++++++++++++++++++
 2 files changed, 40 insertions(+), 1 deletion(-)

diff --git a/lib/Carton/CLI.pm b/lib/Carton/CLI.pm
index c183f95..62f5fae 100644
--- a/lib/Carton/CLI.pm
+++ b/lib/Carton/CLI.pm
@@ -346,10 +346,14 @@ sub cmd_update {
 sub cmd_exec {
     my($self, @args) = @_;
 
+    my $system; # for unit testing
+    $self->parse_options(\@args, "system", \$system); # always run parse_options to allow --
+
     my $path = $self->config->get('path');
     local $ENV{PERL5OPT} = "-Mlib::core::only -Mlib=$path/lib/perl5";
     local $ENV{PATH} = "$path/bin:$ENV{PATH}";
-    exec @args;
+
+    $system ? system(@args) : exec(@args);
 }
 
 sub find_lock {
diff --git a/xt/cli/exec.t b/xt/cli/exec.t
new file mode 100644
index 0000000..bcac34a
--- /dev/null
+++ b/xt/cli/exec.t
@@ -0,0 +1,35 @@
+use strict;
+use Test::More;
+use xt::CLI;
+
+use Test::Requires qw(Capture::Tiny);
+use Capture::Tiny qw(capture_merged);
+
+{
+    my $app = cli();
+
+    ok 1;
+
+    my $out = capture_merged {
+        $app->run("exec", "--system", "--", "perl", "-e", "use Try::Tiny");
+    };
+
+    like $out, qr/Can't locate Try\/Tiny.pm/;
+
+    $app->run("install", "Try::Tiny");
+    $out = capture_merged {
+        $app->run("exec", "--system", "--", "perl", "-e", 'use Try::Tiny; print "OK\n"');
+    };
+
+    like $out, qr/OK/;
+
+    $app->run("install", "Mojolicious");
+    $out = capture_merged {
+        $app->run("exec", "--system", "--", "mojolicious", "version");
+    };
+
+    like $out, qr/Mojolicious/;
+}
+
+done_testing;
+

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-perl/packages/carton.git



More information about the Pkg-perl-cvs-commits mailing list