From 68a355931cb18c5dce782d715e0248cca82997ab Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Wed, 8 Jan 2014 21:43:46 -0800 Subject: [PATCH] core: test that forking is allowed in a BatchAction --- test/unit/vagrant/batch_action_test.rb | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/test/unit/vagrant/batch_action_test.rb b/test/unit/vagrant/batch_action_test.rb index b43206836..86254e8b8 100644 --- a/test/unit/vagrant/batch_action_test.rb +++ b/test/unit/vagrant/batch_action_test.rb @@ -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