From 998c5688e8a5bab24bfac078b2a28a264941533e Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Mon, 1 Dec 2014 21:52:03 -0800 Subject: [PATCH] pushes/atlas: Look for the uploader bin in the embedded dir --- plugins/pushes/atlas/push.rb | 8 +++--- test/unit/plugins/pushes/atlas/push_test.rb | 28 +++++++++++++++++++++ 2 files changed, 33 insertions(+), 3 deletions(-) diff --git a/plugins/pushes/atlas/push.rb b/plugins/pushes/atlas/push.rb index 7dd64a358..0dc90f725 100644 --- a/plugins/pushes/atlas/push.rb +++ b/plugins/pushes/atlas/push.rb @@ -43,10 +43,12 @@ module VagrantPlugins end if Vagrant.in_installer? - # TODO: look up uploader in embedded dir - else - return Vagrant::Util::Which.which(UPLOADER_BIN) + path = File.join( + Vagrant.installer_embedded_dir, "bin", UPLOADER_BIN) + return path if File.file?(path) end + + return Vagrant::Util::Which.which(UPLOADER_BIN) end end end diff --git a/test/unit/plugins/pushes/atlas/push_test.rb b/test/unit/plugins/pushes/atlas/push_test.rb index 40bb9b8d1..2073e5789 100644 --- a/test/unit/plugins/pushes/atlas/push_test.rb +++ b/test/unit/plugins/pushes/atlas/push_test.rb @@ -6,6 +6,8 @@ require Vagrant.source_root.join("plugins/pushes/atlas/push") describe VagrantPlugins::AtlasPush::Push do include_context "unit" + let(:bin) { VagrantPlugins::AtlasPush::Push::UPLOADER_BIN } + let(:env) do double("env", root_path: File.expand_path("..", __FILE__) @@ -99,6 +101,32 @@ describe VagrantPlugins::AtlasPush::Push do expect(subject.uploader_path).to eq("bar") end + it "should look up the uploader in the embedded dir if installer" do + dir = temporary_dir + + allow(Vagrant).to receive(:in_installer?).and_return(true) + allow(Vagrant).to receive(:installer_embedded_dir).and_return(dir.to_s) + + bin_path = dir.join("bin", bin) + bin_path.dirname.mkpath + bin_path.open("w+") { |f| f.write("hi") } + + expect(subject.uploader_path).to eq(bin_path.to_s) + end + + it "should look up the uploader in the PATH if not in the installer" do + dir = temporary_dir + + allow(Vagrant).to receive(:in_installer?).and_return(true) + allow(Vagrant).to receive(:installer_embedded_dir).and_return(dir.to_s) + + expect(Vagrant::Util::Which).to receive(:which). + with(described_class.const_get(:UPLOADER_BIN)). + and_return("bar") + + expect(subject.uploader_path).to eq("bar") + end + it "should return nil if its not found anywhere" do allow(Vagrant).to receive(:in_installer?).and_return(false) allow(Vagrant::Util::Which).to receive(:which).and_return(nil)