Skip to content

Commit

Permalink
Set up the debug gem for test debugging
Browse files Browse the repository at this point in the history
- This processed that we'd requested a debugger, but didn't drop us into
  a debugging console until I
  [stopped the stdin disablement](#16708 (comment)).
  • Loading branch information
issyl0 committed Apr 2, 2024
1 parent de0a7ee commit c8f60ec
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
/Library/Taps
/Library/PinnedTaps
/Library/Homebrew/.byebug_history
/Library/Homebrew/test/.rdbg_history

# Ignore Bundler files
**/.bundle/bin
Expand Down
4 changes: 4 additions & 0 deletions Library/Homebrew/dev-cmd/tests.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ class Tests < AbstractCommand
switch "--online",
description: "Include tests that use the GitHub API and tests that use any of the taps for " \
"official external commands."
switch "--debug",
description: "Enable debugging using ruby/debug."
switch "--changed",
description: "Only runs tests on files that were changed from the master branch."
switch "--fail-fast",
Expand All @@ -43,6 +45,8 @@ def run
# Given we might be testing various commands, we probably want everything (except sorbet-static)
Homebrew.install_bundler_gems!(groups: Homebrew.valid_gem_groups - ["sorbet"])

require "debug" if args.debug?

HOMEBREW_LIBRARY_PATH.cd do
setup_environment!

Expand Down
7 changes: 4 additions & 3 deletions Library/Homebrew/test/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
require "rspec/sorbet"
require "rubocop/rspec/support"
require "find"
require "debug"
require "timeout"

$LOAD_PATH.unshift(File.expand_path("#{ENV.fetch("HOMEBREW_LIBRARY")}/Homebrew/test/support/lib"))
Expand Down Expand Up @@ -229,14 +230,14 @@
@__stdin = $stdin.clone

begin
if !example.metadata.keys.intersect?([:focus, :byebug]) && !ENV.key?("HOMEBREW_VERBOSE_TESTS")
if !example.metadata.keys.include?(:focus) && !ENV.key?("HOMEBREW_VERBOSE_TESTS")
$stdout.reopen(File::NULL)
$stderr.reopen(File::NULL)
$stdin.reopen(File::NULL)
else
# don't retry when focusing/debugging
# don't retry when focusing
config.default_retry_count = 0
end
$stdin.reopen(File::NULL)

begin
timeout = example.metadata.fetch(:timeout, 60)
Expand Down

0 comments on commit c8f60ec

Please sign in to comment.