mirror of
https://github.com/vagrant-libvirt/vagrant-libvirt.git
synced 2025-02-25 18:55:27 -06:00
Ensure the development steps can be successfully executed with system ruby on Fedora 36 to try and help new contributors have an easier on-ramp. Support running acceptance tests locally, though note that it may require rvm if vagrant doesn't support the ruby version used by the distro.
65 lines
1.8 KiB
Ruby
65 lines
1.8 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
require_relative 'acceptance/context'
|
|
|
|
FALSEY_VALUES = %w[f false no n 0].freeze
|
|
|
|
shared_context 'libvirt_acceptance' do
|
|
include_context 'acceptance'
|
|
|
|
# The skeleton paths that will be used to configure environments.
|
|
let(:skeleton_paths) do
|
|
root = File.expand_path('../acceptance/support-skeletons', __dir__)
|
|
config.skeleton_paths.dup.unshift(root)
|
|
end
|
|
|
|
let(:config) do
|
|
c = VagrantPlugins::VagrantLibvirt::Spec::Acceptance::Configuration.new
|
|
c.clean_on_fail = FALSEY_VALUES.include?(ENV.fetch('VAGRANT_SPEC_SKIP_CLEANUP', 'false').to_s.downcase)
|
|
|
|
c
|
|
end
|
|
|
|
before(:each) do
|
|
# allow execution environment to cache boxes used
|
|
symlink_boxes(ENV.fetch('VAGRANT_HOME', File.expand_path('~/.vagrant.d')), environment)
|
|
end
|
|
|
|
after(:each) do
|
|
# ensure we remove the symlink
|
|
boxes_symlink = File.join(environment.homedir, 'boxes')
|
|
File.delete(boxes_symlink) if File.symlink?(boxes_symlink)
|
|
end
|
|
|
|
around do |example|
|
|
vagrant_cwd = ENV.delete('VAGRANT_CWD')
|
|
env_provider_before = ENV.fetch('VAGRANT_DEFAULT_PROVIDER', nil)
|
|
ENV['VAGRANT_DEFAULT_PROVIDER'] = 'libvirt'
|
|
|
|
begin
|
|
example.run
|
|
ensure
|
|
ENV['VAGRANT_CWD'] = vagrant_cwd if vagrant_cwd
|
|
if env_provider_before.nil?
|
|
ENV.delete('VAGRANT_DEFAULT_PROVIDER')
|
|
else
|
|
ENV['VAGRANT_DEFAULT_PROVIDER'] = env_provider_before
|
|
end
|
|
end
|
|
end
|
|
|
|
def duplicate_environment(env, *args)
|
|
dup_env = new_environment(*args)
|
|
symlink_boxes(env.homedir, dup_env)
|
|
|
|
dup_env
|
|
end
|
|
|
|
def symlink_boxes(vagrant_home, target_env)
|
|
return if vagrant_home.nil?
|
|
|
|
# allow use the same boxes location as source environment
|
|
File.symlink File.realpath(File.join(vagrant_home, 'boxes')), File.join(target_env.homedir, 'boxes')
|
|
end
|
|
end
|