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

Set up Byebug debugger #7577

Merged
merged 2 commits into from
May 19, 2020
Merged

Conversation

vidusheeamoli
Copy link
Contributor

  • Have you followed the guidelines in our Contributing document?
  • Have you checked to ensure there aren't other open Pull Requests for the same change?
  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your changes? Here's an example.
  • Have you successfully run brew style with your changes locally?
  • Have you successfully run 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.

Copy link
Member

@MikeMcQuaid MikeMcQuaid left a 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!

@@ -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")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
unless (example.metadata.keys & [:focus, :byebug]).any? || ENV.key?("VERBOSE_TESTS")
if (example.metadata.keys & [:focus, :byebug]).empty? || !ENV.key?("VERBOSE_TESTS")

Copy link
Member

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?

Copy link
Contributor Author

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.

Copy link
Member

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!

@@ -15,6 +15,7 @@
require "active_support/core_ext/array/access"
require "active_support/i18n"
require "active_support/inflector/inflections"
require "byebug"
Copy link
Member

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.

@@ -23,6 +23,7 @@
require "tab"
require "mktemp"
require "find"
require "byebug"
Copy link
Member

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!

Copy link
Contributor Author

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.

@@ -67,6 +68,11 @@ def tests
FileUtils.rm_f "test/coverage/.resultset.json"
end

if args.byebug?
require "byebug"
ENV["HOMEBREW_DEBUG"] = "1"
Copy link
Member

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 😭

@@ -13,6 +13,10 @@ gem "rspec-wait", require: false
gem "rubocop"
gem "simplecov", require: false

group :development, :test do
Copy link
Member

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.

@MikeMcQuaid
Copy link
Member

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-*/
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@MikeMcQuaid
Copy link
Member

Thanks again @vidusheeamoli!

@MikeMcQuaid MikeMcQuaid merged commit 0e9897c into Homebrew:master May 19, 2020
@vidusheeamoli vidusheeamoli deleted the add-byebug branch May 19, 2020 10:48
@BrewTestBot BrewTestBot added the outdated PR was locked due to age label Dec 30, 2020
@Homebrew Homebrew locked as resolved and limited conversation to collaborators Dec 30, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
outdated PR was locked due to age
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants