Remove need to explicitly set VAGRANT_HOME before running tests (#1580)

Ensure that the tests always set VAGRANT_HOME into the environment to
prevent the global plugin manager from trying to load the plugins under
this directory.
This commit is contained in:
Darragh Bailey
2022-09-06 12:30:18 +01:00
committed by GitHub
parent 316ca8e1d4
commit 1db6618f76
8 changed files with 26 additions and 7 deletions

View File

@@ -38,13 +38,12 @@ rescue LoadError
end
end
require 'vagrant-libvirt'
require 'vagrant-spec/unit'
Dir[File.dirname(__FILE__) + '/support/**/*.rb'].each { |f| require f }
RSpec.configure do |config|
# set VAGRANT_HOME before any thing that requires vagrant is loaded to prevent
# the global plugin manager from trying to use the default VAGRANT_HOME.
temp_dir = Dir.mktmpdir("rspec-")
ENV['VAGRANT_HOME'] = temp_dir
# ensure that setting of LIBVIRT_DEFAULT_URI in the environment is not picked
# up directly by tests, instead they must set as needed. Some build envs will
# may have it set to 'qemu:///session'.
@@ -52,6 +51,10 @@ RSpec.configure do |config|
ENV.delete('LIBVIRT_DEFAULT_URI')
end
config.after(:suite) do
FileUtils.remove_entry temp_dir
end
config.mock_with :rspec do |mocks|
mocks.verify_partial_doubles = true
end
@@ -59,3 +62,7 @@ RSpec.configure do |config|
# don't run acceptance tests by default
config.filter_run_excluding :acceptance => true
end
require 'vagrant-spec/unit'
Dir[File.dirname(__FILE__) + '/support/**/*.rb'].each { |f| require f }

View File

@@ -3,6 +3,7 @@
require 'spec_helper'
require 'support/sharedcontext'
require 'vagrant-libvirt'
require 'vagrant-libvirt/plugin'