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
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 26 additions and 7 deletions

View File

@ -2,7 +2,9 @@
require 'log4r'
require 'vagrant-libvirt/util/erb_template'
require 'vagrant-libvirt/util/resolvers'
require 'vagrant-libvirt/util/storage_util'
module VagrantPlugins
module ProviderLibvirt

View File

@ -8,6 +8,8 @@ rescue LoadError
require 'rexml/rexml'
end
require 'vagrant-libvirt/util/domain_flags'
module VagrantPlugins
module ProviderLibvirt
module Action

View File

@ -5,6 +5,8 @@ require 'open3'
require 'json'
require 'vagrant-libvirt/util/byte_number'
require 'vagrant-libvirt/util/storage_util'
require 'vagrant-libvirt/util/ui'
module VagrantPlugins
module ProviderLibvirt

View File

@ -3,6 +3,7 @@
require 'fileutils'
require 'log4r'
require 'vagrant-libvirt/util/ui'
require 'vagrant-libvirt/util/unindent'
module VagrantPlugins

View File

@ -7,7 +7,9 @@ require 'digest/md5'
require 'vagrant/util/subprocess'
require 'vagrant/errors'
require 'vagrant-libvirt/errors'
require 'vagrant-libvirt/util/erb_template'
module VagrantPlugins
module SyncedFolder9P

View File

@ -5,9 +5,11 @@ require 'ostruct'
require 'nokogiri'
require 'digest/md5'
require 'vagrant/util/subprocess'
require 'vagrant/errors'
require 'vagrant/util/subprocess'
require 'vagrant-libvirt/errors'
require 'vagrant-libvirt/util/erb_template'
module VagrantPlugins
module SyncedFolderVirtioFS

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'