Created
September 7, 2018 03:54
-
-
Save isuke/658dc6a61e4a840fd4e9f6e8c96f4750 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # frozen_string_literal: true | |
| def show_backtrace | |
| puts | |
| puts '=' * 80 | |
| Thread.list.each do |thr| | |
| description = thr == Thread.main ? 'Main thread' : thr.inspect | |
| puts | |
| puts "#{description} backtrace: " | |
| puts thr.backtrace.join("\n") | |
| end | |
| puts '=' * 80 | |
| end | |
| if ENV['RSPEC_OUTPUT_BACKTRACE']&.match?(/true/i) | |
| Signal.trap(:INT) do | |
| show_backtrace | |
| abort('abort by INT') | |
| end | |
| Signal.trap(:TERM) do | |
| show_backtrace | |
| abort('abort by TERM') | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment