Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Accessor and guard for external at exit handler #874

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions lib/minitest/simplecov_plugin.rb
Expand Up @@ -4,6 +4,8 @@
# https://github.com/seattlerb/minitest#writing-extensions
module Minitest
def self.plugin_simplecov_init(_options)
SimpleCov.external_at_exit = true if SimpleCov.respond_to?(:external_at_exit=)

Minitest.after_run do
SimpleCov.at_exit_behavior if SimpleCov.respond_to?(:at_exit_behavior)
end
Expand Down
8 changes: 6 additions & 2 deletions lib/simplecov/defaults.rb
Expand Up @@ -21,9 +21,13 @@
# 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(' ')}"

class << SimpleCov
attr_accessor :external_at_exit
alias external_at_exit? external_at_exit
end

at_exit do
# Exit hook for Minitest defined in Minitest plugin
next if defined?(Minitest)
next if SimpleCov.external_at_exit?

SimpleCov.at_exit_behavior
end
Expand Down