Skip to content

Commit

Permalink
Merge pull request #489 from ksss/debug
Browse files Browse the repository at this point in the history
Debug at stop when task fail
  • Loading branch information
hsbt authored Apr 4, 2023
2 parents 693dcf9 + 473acea commit 43c0177
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions lib/rake/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,32 @@ def init(app_name="rake", argv = ARGV)
# Backward compatibility for capistrano
args = handle_options
end
load_debug_at_stop_feature
collect_command_line_tasks(args)
end
end

def load_debug_at_stop_feature
return unless ENV["RAKE_DEBUG"]
require "debug/session"
DEBUGGER__::start no_sigint_hook: true, nonstop: true
Rake::Task.prepend Module.new {
def execute(*)
exception = DEBUGGER__::SESSION.capture_exception_frames(/(exe|bin|lib)\/rake/) do
super
end

if exception
STDERR.puts exception.message
DEBUGGER__::SESSION.enter_postmortem_session exception
raise exception
end
end
}
rescue LoadError
end
private :load_debug_at_stop_feature

# Find the rakefile and then load it and any pending imports.
def load_rakefile
standard_exception_handling do
Expand Down

0 comments on commit 43c0177

Please sign in to comment.