Skip to content

Commit

Permalink
Fix at_exit hook to cooperate with Minitest
Browse files Browse the repository at this point in the history
  • Loading branch information
adam12 committed Dec 1, 2019
1 parent 96729a2 commit 45e95cd
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Unrealeased
## Bugfixes

* Add new instance of `Minitest` constant. The `MiniTest` constant (with the capital T) will be removed in the next major release of Minitest.
* Use `Minitest.after_run` hook to trigger post-run hooks if `Minitest` is present.

0.17.1 (2019-09-16)
===================
Expand Down
12 changes: 11 additions & 1 deletion lib/simplecov/defaults.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,18 @@
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.
next if SimpleCov.pid != Process.pid
return if SimpleCov.pid != Process.pid

SimpleCov.set_exit_exception
SimpleCov.run_exit_tasks!
Expand Down

0 comments on commit 45e95cd

Please sign in to comment.