-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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
Set up Byebug debugger #7577
Set up Byebug debugger #7577
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good so far, a few comments!
Library/Homebrew/test/spec_helper.rb
Outdated
@@ -177,7 +177,7 @@ def find_files | |||
@__stdout = $stdout.clone | |||
@__stderr = $stderr.clone | |||
|
|||
unless example.metadata.key?(:focus) || ENV.key?("VERBOSE_TESTS") | |||
unless (example.metadata.keys & [:focus, :byebug]).any? || ENV.key?("VERBOSE_TESTS") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unless (example.metadata.keys & [:focus, :byebug]).any? || ENV.key?("VERBOSE_TESTS") | |
if (example.metadata.keys & [:focus, :byebug]).empty? || !ENV.key?("VERBOSE_TESTS") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What would you think about just using focus
here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be done, but I think we should consider the following 2 points:
focus
restricts which example/spec is being run, hence, if we want to debug a single spec and run all the others,focus
would not let that happen.- Using byebug with focus (a totally different rspec feature) may cause ambiguity.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll look more at the test code for this once the vendored files are gone, a bit hard to read for now!
Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/byebug-11.1.3/lib/byebug.rb
Outdated
Show resolved
Hide resolved
Library/Homebrew/global.rb
Outdated
@@ -15,6 +15,7 @@ | |||
require "active_support/core_ext/array/access" | |||
require "active_support/i18n" | |||
require "active_support/inflector/inflections" | |||
require "byebug" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't include this here unless it's a vendored dependency (which is undesirable for non-developer dependencies). Will need to be an argument or environment variable to install this.
Library/Homebrew/formula.rb
Outdated
@@ -23,6 +23,7 @@ | |||
require "tab" | |||
require "mktemp" | |||
require "find" | |||
require "byebug" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, still can't include it even here 😭. Would need to just be in various dev-cmd
after Homebrew.install_bundler_gems!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@MikeMcQuaid I've made some changes to dev-cmd/tests
for now, and if the approach looks good, I'll go ahead and do this to other commands as well.
Library/Homebrew/dev-cmd/tests.rb
Outdated
@@ -67,6 +68,11 @@ def tests | |||
FileUtils.rm_f "test/coverage/.resultset.json" | |||
end | |||
|
|||
if args.byebug? | |||
require "byebug" | |||
ENV["HOMEBREW_DEBUG"] = "1" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
HOMEBREW_DEBUG
will unfortunately alter the behaviour of tests so probably needs to be unset 😭
Library/Homebrew/Gemfile
Outdated
@@ -13,6 +13,10 @@ gem "rspec-wait", require: false | |||
gem "rubocop" | |||
gem "simplecov", require: false | |||
|
|||
group :development, :test do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd just leave this without a group as we install these unconditionally anyway.
Sorry this is proving so difficult! |
.gitignore
Outdated
@@ -77,6 +78,7 @@ | |||
**/vendor/bundle/ruby/*/gems/mechanize-*/lib/mechanize/u* | |||
**/vendor/bundle/ruby/*/gems/mechanize-*/lib/mechanize/x* | |||
**/vendor/bundle/ruby/*/gems/thread_safe-*/lib/thread_safe/util | |||
**/vendor/bundle/ruby/*/gems/byebug-*/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops looks like this hasn't been quite enough: https://github.com/Homebrew/brew/pull/7577/checks?check_run_id=685031720#step:20:63
Thanks again @vidusheeamoli! |
brew style
with your changes locally?brew tests
with your changes locally?Byebug is an easy to use debugger for Ruby. If used with any spec, it's usage is similar to the
:focus
inclusion filter in rspec.