From 8391abc63aa33a0e82cc8faed4d1db7659e99d16 Mon Sep 17 00:00:00 2001 From: Chris Roberts Date: Thu, 5 Apr 2018 10:47:28 -0700 Subject: [PATCH] Properly respect environment variable on checkpoint setup The checkpoint update missed the environment variable check for disabling the checks so this adds in the check and properly disables checks when requested. --- lib/vagrant/util/checkpoint_client.rb | 4 ++++ test/unit/vagrant/util/checkpoint_client_test.rb | 11 ++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/lib/vagrant/util/checkpoint_client.rb b/lib/vagrant/util/checkpoint_client.rb index 7306b2377..2e8f2703b 100644 --- a/lib/vagrant/util/checkpoint_client.rb +++ b/lib/vagrant/util/checkpoint_client.rb @@ -39,6 +39,10 @@ module Vagrant rescue LoadError @logger.warn("checkpoint library not found. disabling.") end + if ENV["VAGRANT_CHECKPOINT_DISABLE"] + @logger.debug("checkpoint disabled via explicit user request") + @enabled = false + end @files = { signature: env.data_dir.join("checkpoint_signature"), cache: env.data_dir.join("checkpoint_cache") diff --git a/test/unit/vagrant/util/checkpoint_client_test.rb b/test/unit/vagrant/util/checkpoint_client_test.rb index c31ad0258..0e38c54d8 100644 --- a/test/unit/vagrant/util/checkpoint_client_test.rb +++ b/test/unit/vagrant/util/checkpoint_client_test.rb @@ -23,7 +23,8 @@ describe Vagrant::Util::CheckpointClient do end describe "#setup" do - before{ subject.setup(env) } + let(:environment){ {} } + before{ with_temp_env(environment){ subject.setup(env) } } it "should enable after setup" do expect(subject.enabled).to be(true) @@ -32,6 +33,14 @@ describe Vagrant::Util::CheckpointClient do it "should generate required paths" do expect(subject.files).not_to be_empty end + + context "with VAGRANT_CHECKPOINT_DISABLE set" do + let(:environment){ {"VAGRANT_CHECKPOINT_DISABLE" => "1"} } + + it "should not be enabled after setup" do + expect(subject.enabled).to be(false) + end + end end describe "#check" do