mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Remove debugger support
bebugger doesn't work with Ruby 2.2 so we don't need to support it anymore
This commit is contained in:
parent
cf01d01bd9
commit
93559da482
14 changed files with 8 additions and 138 deletions
4
Gemfile
4
Gemfile
|
@ -68,8 +68,8 @@ group :test do
|
||||||
gem 'stackprof'
|
gem 'stackprof'
|
||||||
end
|
end
|
||||||
|
|
||||||
# platforms :mri_19, :mri_20 do
|
# platforms :mri do
|
||||||
# gem 'debugger'
|
# gem 'byebug'
|
||||||
# end
|
# end
|
||||||
|
|
||||||
gem 'benchmark-ips'
|
gem 'benchmark-ips'
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
require 'active_support/core_ext/kernel/agnostics'
|
require 'active_support/core_ext/kernel/agnostics'
|
||||||
require 'active_support/core_ext/kernel/concern'
|
require 'active_support/core_ext/kernel/concern'
|
||||||
require 'active_support/core_ext/kernel/debugger' if RUBY_VERSION < '2.0.0'
|
|
||||||
require 'active_support/core_ext/kernel/reporting'
|
require 'active_support/core_ext/kernel/reporting'
|
||||||
require 'active_support/core_ext/kernel/singleton_class'
|
require 'active_support/core_ext/kernel/singleton_class'
|
||||||
|
|
|
@ -1,10 +1,3 @@
|
||||||
module Kernel
|
require 'active_support/deprecation'
|
||||||
unless respond_to?(:debugger)
|
|
||||||
# Starts a debugging session if the +debugger+ gem has been loaded (call rails server --debugger to load it).
|
ActiveSupport::Deprecation.warn("This file is deprecated and will be removed in Rails 5.1 with no replacement.")
|
||||||
def debugger
|
|
||||||
message = "\n***** Debugger requested, but was not available (ensure the debugger gem is listed in Gemfile/installed as gem): Start server with --debugger to enable *****\n"
|
|
||||||
defined?(Rails.logger) ? Rails.logger.info(message) : $stderr.puts(message)
|
|
||||||
end
|
|
||||||
alias breakpoint debugger unless respond_to?(:breakpoint)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
|
@ -65,27 +65,3 @@ class MockStdErr
|
||||||
puts(message)
|
puts(message)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
class KernelDebuggerTest < ActiveSupport::TestCase
|
|
||||||
def test_debugger_not_available_message_to_stderr
|
|
||||||
old_stderr = $stderr
|
|
||||||
$stderr = MockStdErr.new
|
|
||||||
debugger
|
|
||||||
assert_match(/Debugger requested/, $stderr.output.first)
|
|
||||||
ensure
|
|
||||||
$stderr = old_stderr
|
|
||||||
end
|
|
||||||
|
|
||||||
def test_debugger_not_available_message_to_rails_logger
|
|
||||||
rails = Class.new do
|
|
||||||
def self.logger
|
|
||||||
@logger ||= MockStdErr.new
|
|
||||||
end
|
|
||||||
end
|
|
||||||
Object.const_set(:Rails, rails)
|
|
||||||
debugger
|
|
||||||
assert_match(/Debugger requested/, rails.logger.output.first)
|
|
||||||
ensure
|
|
||||||
Object.send(:remove_const, :Rails)
|
|
||||||
end
|
|
||||||
end if RUBY_VERSION < '2.0.0'
|
|
||||||
|
|
|
@ -63,7 +63,6 @@ Here's how it loads the middlewares:
|
||||||
```ruby
|
```ruby
|
||||||
def middleware
|
def middleware
|
||||||
middlewares = []
|
middlewares = []
|
||||||
middlewares << [Rails::Rack::Debugger] if options[:debugger]
|
|
||||||
middlewares << [::Rack::ContentLength]
|
middlewares << [::Rack::ContentLength]
|
||||||
Hash.new(middlewares)
|
Hash.new(middlewares)
|
||||||
end
|
end
|
||||||
|
|
|
@ -18,14 +18,6 @@ module Rails
|
||||||
opt.on("-e", "--environment=name", String,
|
opt.on("-e", "--environment=name", String,
|
||||||
"Specifies the environment to run this console under (test/development/production).",
|
"Specifies the environment to run this console under (test/development/production).",
|
||||||
"Default: development") { |v| options[:environment] = v.strip }
|
"Default: development") { |v| options[:environment] = v.strip }
|
||||||
opt.on("--debugger", 'Enables the debugger.') do |v|
|
|
||||||
if RUBY_VERSION < '2.0.0'
|
|
||||||
options[:debugger] = v
|
|
||||||
else
|
|
||||||
puts "=> Notice: debugger option is ignored since Ruby 2.0 and " \
|
|
||||||
"it will be removed in future versions."
|
|
||||||
end
|
|
||||||
end
|
|
||||||
opt.parse!(arguments)
|
opt.parse!(arguments)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -76,25 +68,7 @@ module Rails
|
||||||
Rails.env = environment
|
Rails.env = environment
|
||||||
end
|
end
|
||||||
|
|
||||||
if RUBY_VERSION < '2.0.0'
|
|
||||||
def debugger?
|
|
||||||
options[:debugger]
|
|
||||||
end
|
|
||||||
|
|
||||||
def require_debugger
|
|
||||||
require 'debugger'
|
|
||||||
puts "=> Debugger enabled"
|
|
||||||
rescue LoadError
|
|
||||||
puts "You're missing the 'debugger' gem. Add it to your Gemfile, bundle it and try again."
|
|
||||||
exit(1)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def start
|
def start
|
||||||
if RUBY_VERSION < '2.0.0'
|
|
||||||
require_debugger if debugger?
|
|
||||||
end
|
|
||||||
|
|
||||||
set_environment! if environment?
|
set_environment! if environment?
|
||||||
|
|
||||||
if sandbox?
|
if sandbox?
|
||||||
|
|
|
@ -28,14 +28,6 @@ module Rails
|
||||||
opts.on("-c", "--config=file", String,
|
opts.on("-c", "--config=file", String,
|
||||||
"Uses a custom rackup configuration.") { |v| options[:config] = v }
|
"Uses a custom rackup configuration.") { |v| options[:config] = v }
|
||||||
opts.on("-d", "--daemon", "Runs server as a Daemon.") { options[:daemonize] = true }
|
opts.on("-d", "--daemon", "Runs server as a Daemon.") { options[:daemonize] = true }
|
||||||
opts.on("-u", "--debugger", "Enables the debugger.") do
|
|
||||||
if RUBY_VERSION < '2.0.0'
|
|
||||||
options[:debugger] = true
|
|
||||||
else
|
|
||||||
puts "=> Notice: debugger option is ignored since Ruby 2.0 and " \
|
|
||||||
"it will be removed in future versions."
|
|
||||||
end
|
|
||||||
end
|
|
||||||
opts.on("-e", "--environment=name", String,
|
opts.on("-e", "--environment=name", String,
|
||||||
"Specifies the environment to run this server under (test/development/production).",
|
"Specifies the environment to run this server under (test/development/production).",
|
||||||
"Default: development") { |v| options[:environment] = v }
|
"Default: development") { |v| options[:environment] = v }
|
||||||
|
@ -86,9 +78,6 @@ module Rails
|
||||||
|
|
||||||
def middleware
|
def middleware
|
||||||
middlewares = []
|
middlewares = []
|
||||||
if RUBY_VERSION < '2.0.0'
|
|
||||||
middlewares << [Rails::Rack::Debugger] if options[:debugger]
|
|
||||||
end
|
|
||||||
middlewares << [::Rack::ContentLength]
|
middlewares << [::Rack::ContentLength]
|
||||||
|
|
||||||
# FIXME: add Rack::Lock in the case people are using webrick.
|
# FIXME: add Rack::Lock in the case people are using webrick.
|
||||||
|
@ -112,7 +101,6 @@ module Rails
|
||||||
DoNotReverseLookup: true,
|
DoNotReverseLookup: true,
|
||||||
environment: (ENV['RAILS_ENV'] || ENV['RACK_ENV'] || "development").dup,
|
environment: (ENV['RAILS_ENV'] || ENV['RACK_ENV'] || "development").dup,
|
||||||
daemonize: false,
|
daemonize: false,
|
||||||
debugger: false,
|
|
||||||
pid: File.expand_path("tmp/pids/server.pid"),
|
pid: File.expand_path("tmp/pids/server.pid"),
|
||||||
config: File.expand_path("config.ru")
|
config: File.expand_path("config.ru")
|
||||||
})
|
})
|
||||||
|
|
|
@ -23,13 +23,8 @@ source 'https://rubygems.org'
|
||||||
|
|
||||||
group :development, :test do
|
group :development, :test do
|
||||||
<% if RUBY_ENGINE == 'ruby' -%>
|
<% if RUBY_ENGINE == 'ruby' -%>
|
||||||
<%- if RUBY_VERSION < '2.0.0' -%>
|
|
||||||
# Call 'debugger' anywhere in the code to stop execution and get a debugger console
|
|
||||||
gem 'debugger'
|
|
||||||
<%- else -%>
|
|
||||||
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
|
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
|
||||||
gem 'byebug'
|
gem 'byebug'
|
||||||
<%- end -%>
|
|
||||||
|
|
||||||
# Access an IRB console on exception pages or by using <%%= console %> in views
|
# Access an IRB console on exception pages or by using <%%= console %> in views
|
||||||
<%- if options.dev? || options.edge? -%>
|
<%- if options.dev? || options.edge? -%>
|
||||||
|
|
|
@ -39,11 +39,7 @@ end
|
||||||
<% end -%>
|
<% end -%>
|
||||||
<% if RUBY_ENGINE == 'ruby' -%>
|
<% if RUBY_ENGINE == 'ruby' -%>
|
||||||
# To use a debugger
|
# To use a debugger
|
||||||
<%- if RUBY_VERSION < '2.0.0' -%>
|
|
||||||
# gem 'debugger', group: [:development, :test]
|
|
||||||
<%- else -%>
|
|
||||||
# gem 'byebug', group: [:development, :test]
|
# gem 'byebug', group: [:development, :test]
|
||||||
<%- end -%>
|
|
||||||
<% end -%>
|
<% end -%>
|
||||||
|
|
||||||
<% if RUBY_PLATFORM.match(/bccwin|cygwin|emx|mingw|mswin|wince|java/) -%>
|
<% if RUBY_PLATFORM.match(/bccwin|cygwin|emx|mingw|mswin|wince|java/) -%>
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
module Rails
|
module Rails
|
||||||
module Rack
|
module Rack
|
||||||
autoload :Debugger, "rails/rack/debugger" if RUBY_VERSION < '2.0.0'
|
|
||||||
autoload :Logger, "rails/rack/logger"
|
autoload :Logger, "rails/rack/logger"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,24 +1,3 @@
|
||||||
module Rails
|
require 'active_support/deprecation'
|
||||||
module Rack
|
|
||||||
class Debugger
|
|
||||||
def initialize(app)
|
|
||||||
@app = app
|
|
||||||
|
|
||||||
ARGV.clear # clear ARGV so that rails server options aren't passed to IRB
|
ActiveSupport::Deprecation.warn("This file is deprecated and will be removed in Rails 5.1 with no replacement.")
|
||||||
|
|
||||||
require 'debugger'
|
|
||||||
|
|
||||||
::Debugger.start
|
|
||||||
::Debugger.settings[:autoeval] = true if ::Debugger.respond_to?(:settings)
|
|
||||||
puts "=> Debugger enabled"
|
|
||||||
rescue LoadError
|
|
||||||
puts "You're missing the 'debugger' gem. Add it to your Gemfile, bundle it and try again."
|
|
||||||
exit(1)
|
|
||||||
end
|
|
||||||
|
|
||||||
def call(env)
|
|
||||||
@app.call(env)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
|
@ -46,28 +46,6 @@ class Rails::ConsoleTest < ActiveSupport::TestCase
|
||||||
assert_match(/Loading \w+ environment in sandbox \(Rails/, output)
|
assert_match(/Loading \w+ environment in sandbox \(Rails/, output)
|
||||||
end
|
end
|
||||||
|
|
||||||
if RUBY_VERSION < '2.0.0'
|
|
||||||
def test_debugger_option
|
|
||||||
console = Rails::Console.new(app, parse_arguments(["--debugger"]))
|
|
||||||
assert console.debugger?
|
|
||||||
end
|
|
||||||
|
|
||||||
def test_no_options_does_not_set_debugger_flag
|
|
||||||
console = Rails::Console.new(app, parse_arguments([]))
|
|
||||||
assert !console.debugger?
|
|
||||||
end
|
|
||||||
|
|
||||||
def test_start_with_debugger
|
|
||||||
stubbed_console = Class.new(Rails::Console) do
|
|
||||||
def require_debugger
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
rails_console = stubbed_console.new(app, parse_arguments(["--debugger"]))
|
|
||||||
silence_stream(STDOUT) { rails_console.start }
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def test_console_with_environment
|
def test_console_with_environment
|
||||||
start ["-e production"]
|
start ["-e production"]
|
||||||
assert_match(/\sproduction\s/, output)
|
assert_match(/\sproduction\s/, output)
|
||||||
|
|
|
@ -403,10 +403,7 @@ class AppGeneratorTest < Rails::Generators::TestCase
|
||||||
if defined?(JRUBY_VERSION) || RUBY_ENGINE == "rbx"
|
if defined?(JRUBY_VERSION) || RUBY_ENGINE == "rbx"
|
||||||
assert_file "Gemfile" do |content|
|
assert_file "Gemfile" do |content|
|
||||||
assert_no_match(/byebug/, content)
|
assert_no_match(/byebug/, content)
|
||||||
assert_no_match(/debugger/, content)
|
|
||||||
end
|
end
|
||||||
elsif RUBY_VERSION < '2.0.0'
|
|
||||||
assert_gem 'debugger'
|
|
||||||
else
|
else
|
||||||
assert_gem 'byebug'
|
assert_gem 'byebug'
|
||||||
end
|
end
|
||||||
|
|
|
@ -74,10 +74,7 @@ class PluginGeneratorTest < Rails::Generators::TestCase
|
||||||
if defined?(JRUBY_VERSION) || RUBY_ENGINE == "rbx"
|
if defined?(JRUBY_VERSION) || RUBY_ENGINE == "rbx"
|
||||||
assert_file "Gemfile" do |content|
|
assert_file "Gemfile" do |content|
|
||||||
assert_no_match(/byebug/, content)
|
assert_no_match(/byebug/, content)
|
||||||
assert_no_match(/debugger/, content)
|
|
||||||
end
|
end
|
||||||
elsif RUBY_VERSION < '2.0.0'
|
|
||||||
assert_file "Gemfile", /# gem 'debugger'/
|
|
||||||
else
|
else
|
||||||
assert_file "Gemfile", /# gem 'byebug'/
|
assert_file "Gemfile", /# gem 'byebug'/
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue