diff --git a/lib/minitest/simplecov_plugin.rb b/lib/minitest/simplecov_plugin.rb index 96f1938d..ac4cf076 100644 --- a/lib/minitest/simplecov_plugin.rb +++ b/lib/minitest/simplecov_plugin.rb @@ -3,7 +3,7 @@ module Minitest def self.plugin_simplecov_init(_options) Minitest.after_run do - SimpleCov.custom_at_exit if SimpleCov.respond_to?(:custom_at_exit) + SimpleCov.at_exit_behvior if SimpleCov.respond_to?(:at_exit_behvior) end end end diff --git a/lib/simplecov.rb b/lib/simplecov.rb index f8edae47..ac668264 100644 --- a/lib/simplecov.rb +++ b/lib/simplecov.rb @@ -189,6 +189,14 @@ def exit_status_from_exception end end + def at_exit_behvior + # If we are in a different process than called start, don't interfere. + return if SimpleCov.pid != Process.pid + + # If SimpleCov is no longer running then don't run exit tasks + SimpleCov.run_exit_tasks! if SimpleCov.running + end + # @api private # # Called from at_exit block diff --git a/lib/simplecov/defaults.rb b/lib/simplecov/defaults.rb index 2ec88501..364e247f 100644 --- a/lib/simplecov/defaults.rb +++ b/lib/simplecov/defaults.rb @@ -21,21 +21,11 @@ # 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(' ')}" -module SimpleCov - def self.custom_at_exit - # If we are in a different process than called start, don't interfere. - return if SimpleCov.pid != Process.pid - - # If SimpleCov is no longer running then don't run exit tasks - SimpleCov.run_exit_tasks! if SimpleCov.running - end -end - at_exit do # Exit hook for Minitest defined in Minitest plugin next if defined?(Minitest) - SimpleCov.custom_at_exit + SimpleCov.at_exit_behvior end # Autoload config from ~/.simplecov if present