Configure SimpleCov to no longer use at_exit hack; use JSON reporter

Signed-off-by: Clinton Wolfe <clintoncwolfe@gmail.com>
This commit is contained in:
Clinton Wolfe 2022-02-06 22:09:38 -05:00
parent 9d671d3d37
commit 042e813623
2 changed files with 7 additions and 21 deletions

View file

@ -36,7 +36,8 @@ group :test do
gem "pry", "~> 0.10"
gem "rake", ">= 10"
gem "ruby-progressbar", "~> 1.8"
gem "simplecov", "~> 0.18"
gem "simplecov", "~> 0.21"
gem "simplecov_json_formatter"
gem "webmock", "~> 3.0"
end

View file

@ -1,8 +1,8 @@
# frozen_string_literal: true
# Load default formatter gem
require "simplecov-html"
require "pathname"
require "simplecov_json_formatter"
require "simplecov/profiles/root_filter"
require "simplecov/profiles/test_frameworks"
require "simplecov/profiles/bundler_filter"
@ -10,33 +10,18 @@ require "simplecov/profiles/rails"
# Default configuration
SimpleCov.configure do
formatter SimpleCov::Formatter::HTMLFormatter
formatter SimpleCov::Formatter::JSONFormatter
load_profile "bundler_filter"
# Exclude files outside of SimpleCov.root
load_profile "root_filter"
# We don't actually tolerate anything this low, we just don't want a nonizero exit under any cirumstances
minimum_coverage 50
end
# Gotta stash this a-s-a-p, see the CommandGuesser class and i.e. #110 for further info
SimpleCov::CommandGuesser.original_run_command = "#{$PROGRAM_NAME} #{ARGV.join(" ")}"
at_exit do
if defined? Minitest
Minitest.after_run do
simplecov_at_exit
end
else
simplecov_at_exit
end
end
def simplecov_at_exit
# If we are in a different process than called start, don't interfere.
return if SimpleCov.pid != Process.pid
SimpleCov.set_exit_exception
SimpleCov.run_exit_tasks!
end
# Autoload config from ~/.simplecov if present
require "simplecov/load_global_config"