Set up the debug
gem for test debugging
- This processed that we'd requested a debugger, but didn't drop us into a debugging console until I [stopped the stdin disablement](https://github.com/Homebrew/brew/issues/16708#issuecomment-1953483970). Usage: ``` ❯ git diff diff --git a/Library/Homebrew/test/migrator_spec.rb b/Library/Homebrew/test/migrator_spec.rb index 87fadd5e95..db4700810a 100644 --- a/Library/Homebrew/test/migrator_spec.rb +++ b/Library/Homebrew/test/migrator_spec.rb @@ -69,6 +69,8 @@ RSpec.describe Migrator do tab.source["tap"] = "homebrew/core" tab.write + binding.break + expect do described_class.new(new_formula, "oldname") end.to raise_error(Migrator::MigratorDifferentTapsError) issyl0 at pictor in /opt/homebrew on bye-byebug ❯ brew tests --only=migrator --debug Randomized with seed 59158 1 process for 1 spec, ~ 1 spec per process .==> Relinking newname .==> Unlinking oldname ...==> Moving oldname versions to /private/tmp/homebrew-tests-20240403-85464-3uogqr/cellar/newname ....==> Migrating formula oldname to newname ==> Unlinking oldname ==> Moving oldname versions to /private/tmp/homebrew-tests-20240403-85464-3uogqr/cellar/newname ==> Relinking newname ....[67, 76] in ~/migrator_spec.rb 67| tab = Tab.empty 68| tab.tabfile = HOMEBREW_CELLAR/"oldname/0.1/INSTALL_RECEIPT.json" 69| tab.source["tap"] = "homebrew/core" 70| tab.write 71| => 72| binding.break 73| 74| expect do 75| described_class.new(new_formula, "oldname") 76| end.to raise_error(Migrator::MigratorDifferentTapsError) =>#0 block in <top (required)> (3 levels) at ~/migrator_spec.rb:72 #1 [C] BasicObject#instance_exec at /opt/homebrew/Library/Homebrew/vendor/bundle/ruby/3.1.0/gems/rspec-core-3.13.0/lib/rspec/core/example.rb:263 # and 68 frames (use `bt' command for all frames) (rdbg@/opt/homebrew/Library/Homebrew/vendor/bundle/ruby/3.1.0/bin/rspec#85464) p tab (rdbg@/opt/homebrew/Library/Homebrew/vendor/bundle/ruby/3.1.0/bin/rspec#85464) p # command(rdbg@/opt/homebrew/Library/Homebrew/vendor/bundle/ruby/3.1.0/bin/rspec#85464) p # command t # command ta # command tab # command(rdbg@/opt/homebrew/Library/Homebrew/vendor/bundle/ruby/3.1.0/bin/rspec#85464) p tab # command => #<Tab:0x0000000107156be0 @aliases=[], @arch=nil, @built_as_bottle=false, @built_on={"os"=>"Macintosh", "os_version"=>"macOS 14", "cpu_family"=>"arm_firestorm_icestorm"}, @compiler=:clang, @homebrew_version="4.2.16-55-gc8f60ec-dirty", @installed_as_dependency=false, @installed_on_request=false, @loaded_from_api=false, @poured_from_bottle=false, @runtime_dependencies=nil, @source={"path"=>nil, "tap"=>"homebrew/core", "tap_git_head"=>nil, "spec"=>"stable", "versions"=>{"stable"=>nil, "head"=>nil, "version_scheme"=>0}}, @source_modified_time=0, @stdlib=nil, @tabfile=#<Pathname:/private/tmp/homebrew-tests-20240403-85464-3uogqr/cellar/oldname/0.1/INSTALL_RECEIPT.json>, @time=nil, @unused_options=[], @used_options=[]> (rdbg@/opt/homebrew/Library/Homebrew/vendor/bundle/ruby/3.1.0/bin/rspec#85464) ```
This commit is contained in:
parent
58fbaecedb
commit
1daeb5bee0
1
.gitignore
vendored
1
.gitignore
vendored
@ -21,6 +21,7 @@
|
|||||||
/Library/Taps
|
/Library/Taps
|
||||||
/Library/PinnedTaps
|
/Library/PinnedTaps
|
||||||
/Library/Homebrew/.byebug_history
|
/Library/Homebrew/.byebug_history
|
||||||
|
/Library/Homebrew/test/.rdbg_history
|
||||||
|
|
||||||
# Ignore Bundler files
|
# Ignore Bundler files
|
||||||
**/.bundle/bin
|
**/.bundle/bin
|
||||||
|
@ -21,6 +21,8 @@ module Homebrew
|
|||||||
switch "--online",
|
switch "--online",
|
||||||
description: "Include tests that use the GitHub API and tests that use any of the taps for " \
|
description: "Include tests that use the GitHub API and tests that use any of the taps for " \
|
||||||
"official external commands."
|
"official external commands."
|
||||||
|
switch "--debug",
|
||||||
|
description: "Enable debugging using ruby/debug."
|
||||||
switch "--changed",
|
switch "--changed",
|
||||||
description: "Only runs tests on files that were changed from the master branch."
|
description: "Only runs tests on files that were changed from the master branch."
|
||||||
switch "--fail-fast",
|
switch "--fail-fast",
|
||||||
@ -43,6 +45,8 @@ module Homebrew
|
|||||||
# Given we might be testing various commands, we probably want everything (except sorbet-static)
|
# Given we might be testing various commands, we probably want everything (except sorbet-static)
|
||||||
Homebrew.install_bundler_gems!(groups: Homebrew.valid_gem_groups - ["sorbet"])
|
Homebrew.install_bundler_gems!(groups: Homebrew.valid_gem_groups - ["sorbet"])
|
||||||
|
|
||||||
|
require "debug" if args.debug?
|
||||||
|
|
||||||
HOMEBREW_LIBRARY_PATH.cd do
|
HOMEBREW_LIBRARY_PATH.cd do
|
||||||
setup_environment!
|
setup_environment!
|
||||||
|
|
||||||
|
@ -29,6 +29,7 @@ require "rspec/retry"
|
|||||||
require "rspec/sorbet"
|
require "rspec/sorbet"
|
||||||
require "rubocop/rspec/support"
|
require "rubocop/rspec/support"
|
||||||
require "find"
|
require "find"
|
||||||
|
require "debug"
|
||||||
require "timeout"
|
require "timeout"
|
||||||
|
|
||||||
$LOAD_PATH.unshift(File.expand_path("#{ENV.fetch("HOMEBREW_LIBRARY")}/Homebrew/test/support/lib"))
|
$LOAD_PATH.unshift(File.expand_path("#{ENV.fetch("HOMEBREW_LIBRARY")}/Homebrew/test/support/lib"))
|
||||||
@ -229,14 +230,14 @@ RSpec.configure do |config|
|
|||||||
@__stdin = $stdin.clone
|
@__stdin = $stdin.clone
|
||||||
|
|
||||||
begin
|
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)
|
$stdout.reopen(File::NULL)
|
||||||
$stderr.reopen(File::NULL)
|
$stderr.reopen(File::NULL)
|
||||||
|
$stdin.reopen(File::NULL)
|
||||||
else
|
else
|
||||||
# don't retry when focusing/debugging
|
# don't retry when focusing
|
||||||
config.default_retry_count = 0
|
config.default_retry_count = 0
|
||||||
end
|
end
|
||||||
$stdin.reopen(File::NULL)
|
|
||||||
|
|
||||||
begin
|
begin
|
||||||
timeout = example.metadata.fetch(:timeout, 60)
|
timeout = example.metadata.fetch(:timeout, 60)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user