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

Debug at stop when task fail #489

Merged
merged 4 commits into from
Apr 4, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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