foreman run should exit with the same code as its command

This commit is contained in:
Omar Khan
2012-08-24 16:50:05 +01:00
parent 68f098c1d2
commit 574e852710
3 changed files with 12 additions and 0 deletions
+1
View File
@@ -86,6 +86,7 @@ class Foreman::CLI < Thor
end
end
Process.wait(pid)
exit $?.exitstatus
end
desc "version", "Display Foreman gem version"
+5
View File
@@ -72,6 +72,11 @@ describe "Foreman::CLI", :fakefs do
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
+6
View File
@@ -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