core: test that forking is allowed in a BatchAction

This commit is contained in:
Mitchell Hashimoto 2014-01-08 21:43:46 -08:00
parent 9649712fce
commit 68a355931c
1 changed files with 19 additions and 0 deletions

View File

@ -1,4 +1,5 @@
require 'thread'
require 'timeout'
require File.expand_path("../../base", __FILE__)
@ -32,5 +33,23 @@ describe Vagrant::BatchAction do
called_actions.include?([machine, "up", nil]).should be
called_actions.include?([machine2, "destroy", nil]).should be
end
it "should handle forks gracefully" do
machine.stub(:action) do |action, opts|
pid = fork
if !pid
# Child process
exit
end
# Parent process, wait for the child to exit
Timeout.timeout(1) do
Process.waitpid(pid)
end
end
subject.action(machine, "up")
subject.run
end
end
end