Skip to content

Commit

Permalink
Move at exit behavior into mainline SimpleCov not defaults
Browse files Browse the repository at this point in the history
Naming it "custom" is slightly odd, as it's in the defaults
and if people wanted to differ they could define their own
at_exit hook and call whatever they wanted.
  • Loading branch information
PragTob committed Feb 6, 2020
1 parent 8636edf commit a6f5ee7
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 12 deletions.
2 changes: 1 addition & 1 deletion lib/minitest/simplecov_plugin.rb
Expand Up @@ -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
8 changes: 8 additions & 0 deletions lib/simplecov.rb
Expand Up @@ -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
Expand Down
12 changes: 1 addition & 11 deletions lib/simplecov/defaults.rb
Expand Up @@ -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
Expand Down

0 comments on commit a6f5ee7

Please sign in to comment.