From fafd8b8986f32005a6f6cf81a2e36ea13dce8d81 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Fri, 20 Nov 2015 15:09:17 -0800 Subject: [PATCH] more passing tests on Windows --- test/support/isolated_environment.rb | 4 +++- test/unit/support/shared/base_context.rb | 6 +++++- test/unit/vagrant/environment_test.rb | 6 +++--- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/test/support/isolated_environment.rb b/test/support/isolated_environment.rb index d9a49feee..719966bb2 100644 --- a/test/support/isolated_environment.rb +++ b/test/support/isolated_environment.rb @@ -4,6 +4,8 @@ require "tmpdir" require "log4r" +require "vagrant/util/platform" + # This class manages an isolated environment for Vagrant to # run in. It creates a temporary directory to act as the # working directory as well as sets a custom home directory. @@ -26,7 +28,7 @@ class IsolatedEnvironment @logger = Log4r::Logger.new("test::isolated_environment") # Create a temporary directory for our work - @tempdir = Dir.mktmpdir("vagrant") + @tempdir = Vagrant::Util::Platform.fs_real_path(Dir.mktmpdir("vagrant")) @logger.info("Initialize isolated environment: #{@tempdir}") # Setup the home and working directories diff --git a/test/unit/support/shared/base_context.rb b/test/unit/support/shared/base_context.rb index 295e83b66..631cb7dba 100644 --- a/test/unit/support/shared/base_context.rb +++ b/test/unit/support/shared/base_context.rb @@ -1,6 +1,8 @@ require "tempfile" require "tmpdir" +require "vagrant/util/platform" + require "unit/support/isolated_environment" shared_context "unit" do @@ -83,7 +85,9 @@ shared_context "unit" do @_temp_files << d # Return the pathname - return Pathname.new(d) + result = Pathname.new(Vagrant::Util::Platform.fs_real_path(d)) + yield result if block_given? + return result end # Stub the given environment in ENV, without actually touching ENV. Keys and diff --git a/test/unit/vagrant/environment_test.rb b/test/unit/vagrant/environment_test.rb index 7c79799e1..37a2d0caf 100644 --- a/test/unit/vagrant/environment_test.rb +++ b/test/unit/vagrant/environment_test.rb @@ -69,15 +69,15 @@ describe Vagrant::Environment do describe "#home_path" do it "is set to the home path given" do - Dir.mktmpdir do |dir| + temporary_dir do |dir| instance = described_class.new(home_path: dir) expect(instance.home_path).to eq(Pathname.new(dir)) end end it "is set to the environmental variable VAGRANT_HOME" do - Dir.mktmpdir do |dir| - instance = with_temp_env("VAGRANT_HOME" => dir) do + temporary_dir do |dir| + instance = with_temp_env("VAGRANT_HOME" => dir.to_s) do described_class.new end