2021-06-30 13:27:03 +01:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
2021-12-03 12:50:02 +00:00
|
|
|
# make simplecov optional
|
|
|
|
|
begin
|
|
|
|
|
require 'simplecov'
|
|
|
|
|
require 'simplecov-lcov'
|
|
|
|
|
|
|
|
|
|
# patch simplecov configuration
|
|
|
|
|
if ! SimpleCov::Configuration.method_defined? :branch_coverage?
|
|
|
|
|
module SimpleCov
|
|
|
|
|
module Configuration
|
|
|
|
|
def branch_coverage?
|
|
|
|
|
return false
|
|
|
|
|
end
|
2021-02-20 15:23:16 +00:00
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
2021-12-03 12:50:02 +00:00
|
|
|
SimpleCov::Formatter::LcovFormatter.config do |config|
|
|
|
|
|
config.report_with_single_file = true
|
|
|
|
|
config.single_report_path = 'coverage/lcov.info'
|
|
|
|
|
end
|
2021-02-20 15:23:16 +00:00
|
|
|
|
2021-12-03 12:50:02 +00:00
|
|
|
SimpleCov.formatters = SimpleCov::Formatter::MultiFormatter.new(
|
|
|
|
|
[
|
|
|
|
|
SimpleCov::Formatter::HTMLFormatter,
|
|
|
|
|
SimpleCov::Formatter::LcovFormatter,
|
|
|
|
|
]
|
|
|
|
|
)
|
|
|
|
|
SimpleCov.start do
|
|
|
|
|
add_filter 'spec/'
|
|
|
|
|
end
|
|
|
|
|
rescue LoadError
|
|
|
|
|
TRUTHY_VALUES = %w(t true yes y 1).freeze
|
|
|
|
|
require_simplecov = ENV.fetch('VAGRANT_LIBVIRT_REQUIRE_SIMPLECOV', 'false').to_s.downcase
|
|
|
|
|
if TRUTHY_VALUES.include?(require_simplecov)
|
|
|
|
|
raise
|
|
|
|
|
end
|
2020-12-15 13:15:06 +00:00
|
|
|
end
|
2016-04-13 12:11:16 +02:00
|
|
|
|
2021-05-15 14:54:10 +01:00
|
|
|
RSpec.configure do |config|
|
2022-09-22 12:35:14 +02:00
|
|
|
require 'tmpdir'
|
|
|
|
|
|
2022-09-06 12:30:18 +01:00
|
|
|
# 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
|
|
|
|
|
|
2021-05-15 14:54:10 +01:00
|
|
|
# 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'.
|
|
|
|
|
config.before(:suite) do
|
|
|
|
|
ENV.delete('LIBVIRT_DEFAULT_URI')
|
|
|
|
|
end
|
2021-11-08 11:31:04 +00:00
|
|
|
|
2022-09-06 12:30:18 +01:00
|
|
|
config.after(:suite) do
|
|
|
|
|
FileUtils.remove_entry temp_dir
|
|
|
|
|
end
|
|
|
|
|
|
2021-11-08 11:31:04 +00:00
|
|
|
config.mock_with :rspec do |mocks|
|
2021-12-03 11:28:21 +00:00
|
|
|
mocks.verify_partial_doubles = true
|
2021-11-08 11:31:04 +00:00
|
|
|
end
|
2022-06-13 23:43:06 +01:00
|
|
|
|
|
|
|
|
# don't run acceptance tests by default
|
|
|
|
|
config.filter_run_excluding :acceptance => true
|
2022-09-22 17:14:49 +01:00
|
|
|
|
|
|
|
|
config.expect_with :rspec do |c|
|
|
|
|
|
c.max_formatted_output_length = 2000 if c.respond_to?("max_formatted_output_length=")
|
|
|
|
|
end
|
2014-07-04 11:09:00 -06:00
|
|
|
end
|
2022-09-06 12:30:18 +01:00
|
|
|
|
|
|
|
|
require 'vagrant-spec/unit'
|
|
|
|
|
|
|
|
|
|
Dir[File.dirname(__FILE__) + '/support/**/*.rb'].each { |f| require f }
|