switch to File.open for downloader temp file path to prevent minitar issues on windows
This commit is contained in:
parent
35e9fa53d4
commit
0c00201a6b
|
@ -9,3 +9,4 @@ _site/*
|
||||||
*.org
|
*.org
|
||||||
.yardoc/
|
.yardoc/
|
||||||
doc/
|
doc/
|
||||||
|
*~
|
|
@ -51,11 +51,16 @@ module Vagrant
|
||||||
|
|
||||||
def with_tempfile
|
def with_tempfile
|
||||||
logger.info "Creating tempfile for storing box file..."
|
logger.info "Creating tempfile for storing box file..."
|
||||||
Tempfile.open(BASENAME, @runner.env.tmp_path) do |tempfile|
|
# create, write only, fail if the file exists
|
||||||
yield tempfile
|
File.open(file_temp_path, File::WRONLY|File::EXCL|File::CREAT) do |tempfile|
|
||||||
|
yield tempfile
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def file_temp_path
|
||||||
|
File.join(@runner.env.tmp_path, BASENAME + Time.now.to_i.to_s)
|
||||||
|
end
|
||||||
|
|
||||||
def download_to(f)
|
def download_to(f)
|
||||||
logger.info "Copying box to temporary location..."
|
logger.info "Copying box to temporary location..."
|
||||||
downloader.download!(@runner.uri, f)
|
downloader.download!(@runner.uri, f)
|
||||||
|
|
|
@ -81,13 +81,15 @@ class DownloadBoxActionTest < Test::Unit::TestCase
|
||||||
|
|
||||||
context "tempfile" do
|
context "tempfile" do
|
||||||
should "create a tempfile in the vagrant tmp directory" do
|
should "create a tempfile in the vagrant tmp directory" do
|
||||||
Tempfile.expects(:open).with(Vagrant::Actions::Box::Download::BASENAME, @runner.env.tmp_path).once
|
File.expects(:open).with { |name, bitmask|
|
||||||
|
name =~ /#{Vagrant::Actions::Box::Download::BASENAME}/ && name =~ /#{@runner.env.tmp_path}/
|
||||||
|
}.once
|
||||||
@action.with_tempfile
|
@action.with_tempfile
|
||||||
end
|
end
|
||||||
|
|
||||||
should "yield the tempfile object" do
|
should "yield the tempfile object" do
|
||||||
@tempfile = mock("tempfile")
|
@tempfile = mock("tempfile")
|
||||||
Tempfile.expects(:open).yields(@tempfile)
|
File.expects(:open).yields(@tempfile)
|
||||||
|
|
||||||
@action.with_tempfile do |otherfile|
|
@action.with_tempfile do |otherfile|
|
||||||
assert @tempfile.equal?(otherfile)
|
assert @tempfile.equal?(otherfile)
|
||||||
|
|
|
@ -153,12 +153,13 @@ class EnvironmentTest < Test::Unit::TestCase
|
||||||
|
|
||||||
context "loading the root path" do
|
context "loading the root path" do
|
||||||
setup do
|
setup do
|
||||||
@env.cwd = "/foo"
|
@env.cwd = "/foo"
|
||||||
end
|
end
|
||||||
|
|
||||||
should "default the path to the cwd instance var if nil" do
|
should "default the path to the cwd instance var if nil" do
|
||||||
@path = mock("path")
|
@path = mock("path")
|
||||||
@path.stubs(:root?).returns(true)
|
@path.stubs(:root?).returns(true)
|
||||||
|
File.expects(:expand_path).with(@env.cwd).returns(@env.cwd)
|
||||||
Pathname.expects(:new).with(@env.cwd).returns(@path)
|
Pathname.expects(:new).with(@env.cwd).returns(@path)
|
||||||
@env.load_root_path!(nil)
|
@env.load_root_path!(nil)
|
||||||
end
|
end
|
||||||
|
@ -181,7 +182,8 @@ class EnvironmentTest < Test::Unit::TestCase
|
||||||
|
|
||||||
search_seq = sequence("search_seq")
|
search_seq = sequence("search_seq")
|
||||||
paths.each do |path|
|
paths.each do |path|
|
||||||
File.expects(:exist?).with("#{path}/#{Vagrant::Environment::ROOTFILE_NAME}").returns(false).in_sequence(search_seq)
|
# NOTE File.expect(:expand_path) causes tests to hang in windows below is the interim solution
|
||||||
|
File.expects(:exist?).with("#{File.expand_path(path)}/#{Vagrant::Environment::ROOTFILE_NAME}").returns(false).in_sequence(search_seq)
|
||||||
end
|
end
|
||||||
|
|
||||||
assert !@env.load_root_path!(paths.first)
|
assert !@env.load_root_path!(paths.first)
|
||||||
|
@ -203,7 +205,8 @@ class EnvironmentTest < Test::Unit::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
should "should set the path for the rootfile" do
|
should "should set the path for the rootfile" do
|
||||||
path = "/foo"
|
# NOTE File.expect(:expand_path) causes tests to hang in windows below is the interim solution
|
||||||
|
path = File.expand_path("/foo")
|
||||||
File.expects(:exist?).with("#{path}/#{Vagrant::Environment::ROOTFILE_NAME}").returns(true)
|
File.expects(:exist?).with("#{path}/#{Vagrant::Environment::ROOTFILE_NAME}").returns(true)
|
||||||
|
|
||||||
assert @env.load_root_path!(Pathname.new(path))
|
assert @env.load_root_path!(Pathname.new(path))
|
||||||
|
|
Loading…
Reference in New Issue