Merge pull request #254 from omarkhan/master
foreman run should exit with the same code as its command
This commit is contained in:
@@ -86,6 +86,7 @@ class Foreman::CLI < Thor
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
Process.wait(pid)
|
Process.wait(pid)
|
||||||
|
exit $?.exitstatus
|
||||||
end
|
end
|
||||||
|
|
||||||
desc "version", "Display Foreman gem version"
|
desc "version", "Display Foreman gem version"
|
||||||
|
|||||||
@@ -72,6 +72,11 @@ describe "Foreman::CLI", :fakefs do
|
|||||||
it "includes the environment" do
|
it "includes the environment" do
|
||||||
forked_foreman("run #{resource_path("bin/env FOO")} -e #{resource_path(".env")}").should == "bar\n"
|
forked_foreman("run #{resource_path("bin/env FOO")} -e #{resource_path(".env")}").should == "bar\n"
|
||||||
end
|
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
|
end
|
||||||
|
|
||||||
describe "version" do
|
describe "version" do
|
||||||
|
|||||||
@@ -58,6 +58,12 @@ def fork_and_capture(&blk)
|
|||||||
end
|
end
|
||||||
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)
|
def mock_exit(&block)
|
||||||
block.should raise_error(SystemExit)
|
block.should raise_error(SystemExit)
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user