Permalink
Browse files

Merge pull request #254 from omarkhan/master

foreman run should exit with the same code as its command
  • Loading branch information...
2 parents 68f098c + 574e852 commit 85e62dfbeb84791831f8e856bcc50ba82e16cba5 @ddollar committed Aug 24, 2012
Showing with 12 additions and 0 deletions.
  1. +1 −0 lib/foreman/cli.rb
  2. +5 −0 spec/foreman/cli_spec.rb
  3. +6 −0 spec/spec_helper.rb
View
@@ -86,6 +86,7 @@ def run(*args)
end
end
Process.wait(pid)
+ exit $?.exitstatus
end
desc "version", "Display Foreman gem version"
View
@@ -72,6 +72,11 @@
it "includes the environment" do
forked_foreman("run #{resource_path("bin/env FOO")} -e #{resource_path(".env")}").should == "bar\n"
end
+
+ it "exits with the same exit code as the command" do
+ fork_and_get_exitstatus("run echo 1").should == 0
+ fork_and_get_exitstatus("run date 'invalid_date'").should == 1
+ end
end
describe "version" do
View
@@ -58,6 +58,12 @@ def fork_and_capture(&blk)
end
end
+def fork_and_get_exitstatus(args)
+ pid = Process.spawn("bundle exec bin/foreman #{args}", :out => "/dev/null", :err => "/dev/null")
+ Process.wait(pid)
+ $?.exitstatus
+end
+
def mock_exit(&block)
block.should raise_error(SystemExit)
end

0 comments on commit 85e62df

Please sign in to comment.