Make simplecov a source development dependency only (#1418)

Remove the need for downstream packaging to either require or patch
out simplecov from existing files by making it an optional development
dependency.
This commit is contained in:
Darragh Bailey 2021-12-03 12:50:02 +00:00 committed by GitHub
parent 27a541bba9
commit 380b3c2096
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 36 additions and 29 deletions

View File

@ -17,6 +17,8 @@ jobs:
test:
runs-on: ubuntu-latest
env:
VAGRANT_LIBVIRT_REQUIRE_SIMPLECOV: "true"
continue-on-error: ${{ matrix.allow_fail }}
strategy:
fail-fast: false

View File

@ -37,11 +37,9 @@ group :development do
gem 'rexml'
end
if Gem::Version.new(RUBY_VERSION) < Gem::Version.new('2.3.0')
gem 'mime-types', '< 3.4.0'
end
gem 'pry'
gem 'simplecov'
gem 'simplecov-lcov'
end
group :plugins do

View File

@ -1,36 +1,45 @@
# frozen_string_literal: true
require 'simplecov'
require 'simplecov-lcov'
# 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
# patch simplecov configuration
if ! SimpleCov::Configuration.method_defined? :branch_coverage?
module SimpleCov
module Configuration
def branch_coverage?
return false
end
end
end
end
SimpleCov::Formatter::LcovFormatter.config do |config|
config.report_with_single_file = true
config.single_report_path = 'coverage/lcov.info'
end
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
end
SimpleCov::Formatter::LcovFormatter.config do |config|
config.report_with_single_file = true
config.single_report_path = 'coverage/lcov.info'
end
SimpleCov.formatters = SimpleCov::Formatter::MultiFormatter.new(
[
SimpleCov::Formatter::HTMLFormatter,
SimpleCov::Formatter::LcovFormatter,
]
)
SimpleCov.start do
add_filter 'spec/'
end
require 'vagrant-libvirt'
require 'support/environment_helper'
require 'vagrant-spec/unit'
Dir[File.dirname(__FILE__) + '/support/**/*.rb'].each { |f| require f }

View File

@ -23,8 +23,6 @@ Gem::Specification.new do |s|
s.add_development_dependency "rspec-core", ">= 3.5"
s.add_development_dependency "rspec-expectations", ">= 3.5"
s.add_development_dependency "rspec-mocks", ">= 3.5"
s.add_development_dependency "simplecov"
s.add_development_dependency "simplecov-lcov"
s.add_runtime_dependency 'fog-libvirt', '>= 0.6.0'
s.add_runtime_dependency 'fog-core', '~> 2.1'