From f3cf23e873d942ce5bec0a0098f3a6742d21433b Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Tue, 16 Apr 2013 15:13:00 -0700 Subject: [PATCH] Ability to specify no parallelism on the environment --- lib/vagrant/environment.rb | 6 ++++-- test/unit/vagrant/environment_test.rb | 9 +++++++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/lib/vagrant/environment.rb b/lib/vagrant/environment.rb index 6a32c1696..339db08ab 100644 --- a/lib/vagrant/environment.rb +++ b/lib/vagrant/environment.rb @@ -197,9 +197,11 @@ module Vagrant # # This handles the case where batch actions are disabled by the # VAGRANT_NO_PARALLEL environmental variable. - def batch + def batch(disable_parallel=false) + disable_parallel ||= !!ENV["VAGRANT_NO_PARALLEL"] + @batch_lock.synchronize do - BatchAction.new(!!ENV["VAGRANT_NO_PARALLEL"]).tap do |b| + BatchAction.new(disable_parallel).tap do |b| # Yield it so that the caller can setup actions yield b diff --git a/test/unit/vagrant/environment_test.rb b/test/unit/vagrant/environment_test.rb index 9c7ec68a4..694700638 100644 --- a/test/unit/vagrant/environment_test.rb +++ b/test/unit/vagrant/environment_test.rb @@ -64,6 +64,15 @@ describe Vagrant::Environment do instance.batch {} end end + + it "should run with disabling parallelization if explicit" do + with_temp_env("VAGRANT_NO_PARALLEL" => nil) do + Vagrant::BatchAction.should_receive(:new).with(true).and_return(batch) + batch.should_receive(:run) + + instance.batch(true) {} + end + end end context "with the disabling env var" do