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