From 561d4295d24b490807b7abe5acc6a0483720a58b Mon Sep 17 00:00:00 2001 From: Issy Long Date: Sun, 7 Apr 2024 20:17:07 +0100 Subject: [PATCH] Use the `debug` gem from portable Ruby MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - This is cleaner than vendoring a whole bunch of new gems and pinning `psych`. - Thanks for the pointer, Bo! - It doesn't work, though? ``` ❯ brew tests --only=migrator --debug Error: cannot load such file -- debug/debug.so Warning: Removed Sorbet lines from backtrace! Rerun with `--verbose` to see the original backtrace /opt/homebrew/Library/Homebrew/vendor/portable-ruby/3.1.4/lib/ruby/gems/3.1.0/gems/debug-1.6.3/lib/debug/frame_info.rb:16:in `require' /opt/homebrew/Library/Homebrew/vendor/portable-ruby/3.1.4/lib/ruby/gems/3.1.0/gems/debug-1.6.3/lib/debug/frame_info.rb:16:in `rescue in ' /opt/homebrew/Library/Homebrew/vendor/portable-ruby/3.1.4/lib/ruby/gems/3.1.0/gems/debug-1.6.3/lib/debug/frame_info.rb:13:in `' /opt/homebrew/Library/Homebrew/vendor/portable-ruby/3.1.4/lib/ruby/gems/3.1.0/gems/debug-1.6.3/lib/debug/frame_info.rb:3:in `' /opt/homebrew/Library/Homebrew/vendor/portable-ruby/3.1.4/lib/ruby/gems/3.1.0/gems/debug-1.6.3/lib/debug/session.rb:31:in `require_relative' /opt/homebrew/Library/Homebrew/vendor/portable-ruby/3.1.4/lib/ruby/gems/3.1.0/gems/debug-1.6.3/lib/debug/session.rb:31:in `' /opt/homebrew/Library/Homebrew/vendor/portable-ruby/3.1.4/lib/ruby/gems/3.1.0/gems/debug-1.6.3/lib/debug.rb:3:in `require_relative' /opt/homebrew/Library/Homebrew/vendor/portable-ruby/3.1.4/lib/ruby/gems/3.1.0/gems/debug-1.6.3/lib/debug.rb:3:in `' /opt/homebrew/Library/Homebrew/dev-cmd/tests.rb:48:in `require' /opt/homebrew/Library/Homebrew/dev-cmd/tests.rb:48:in `run' /opt/homebrew/Library/Homebrew/brew.rb:89:in `
' ``` --- .gitignore | 4 ---- Library/Homebrew/Gemfile | 2 -- Library/Homebrew/Gemfile.lock | 16 ---------------- Library/Homebrew/dev-cmd/tests.rb | 2 ++ Library/Homebrew/standalone/init.rb | 4 ++++ Library/Homebrew/test/migrator_spec.rb | 2 ++ Library/Homebrew/test/spec_helper.rb | 1 - Library/Homebrew/vendor/bundle/bundler/setup.rb | 11 ----------- completions/fish/brew.fish | 2 +- completions/zsh/_brew | 2 +- docs/Manpage.md | 4 ++++ manpages/brew.1 | 3 +++ 12 files changed, 17 insertions(+), 36 deletions(-) diff --git a/.gitignore b/.gitignore index 7941b6dee2a35..55a5659a8436c 100644 --- a/.gitignore +++ b/.gitignore @@ -77,14 +77,12 @@ **/vendor/bundle/ruby/*/gems/coderay-*/ **/vendor/bundle/ruby/*/gems/colorize-*/ **/vendor/bundle/ruby/*/gems/commander-*/ -**/vendor/bundle/ruby/*/gems/debug-*/ **/vendor/bundle/ruby/*/gems/diff-lcs-*/ **/vendor/bundle/ruby/*/gems/docile-*/ **/vendor/bundle/ruby/*/gems/ecma-re-validator-*/ **/vendor/bundle/ruby/*/gems/erubi-*/ **/vendor/bundle/ruby/*/gems/hana-*/ **/vendor/bundle/ruby/*/gems/highline-*/ -**/vendor/bundle/ruby/*/gems/irb-*/ **/vendor/bundle/ruby/*/gems/jaro_winkler-*/ **/vendor/bundle/ruby/*/gems/json-*/ **/vendor/bundle/ruby/*/gems/json_schemer-*/ @@ -110,7 +108,6 @@ **/vendor/bundle/ruby/*/gems/rbi-*/ **/vendor/bundle/ruby/*/gems/rdoc-*/ **/vendor/bundle/ruby/*/gems/regexp_parser-*/ -**/vendor/bundle/ruby/*/gems/reline-*/ **/vendor/bundle/ruby/*/gems/rexml-*/ **/vendor/bundle/ruby/*/gems/rspec-*/ **/vendor/bundle/ruby/*/gems/rspec-core-*/ @@ -131,7 +128,6 @@ !**/vendor/bundle/ruby/*/gems/sorbet-runtime-*/ **/vendor/bundle/ruby/*/gems/spoom-*/ **/vendor/bundle/ruby/*/gems/stackprof-*/ -**/vendor/bundle/ruby/*/gems/stringio-*/ **/vendor/bundle/ruby/*/gems/strscan-*/ **/vendor/bundle/ruby/*/gems/syntax_tree-*/ **/vendor/bundle/ruby/*/gems/tapioca-*/ diff --git a/Library/Homebrew/Gemfile b/Library/Homebrew/Gemfile index b4bedd6060e6e..533593a96f489 100644 --- a/Library/Homebrew/Gemfile +++ b/Library/Homebrew/Gemfile @@ -48,9 +48,7 @@ group :style, optional: true do gem "rubocop-sorbet", require: false end group :tests, optional: true do - gem "debug", require: false gem "parallel_tests", require: false - gem "psych", "< 5", require: false gem "rspec", require: false gem "rspec-github", require: false gem "rspec_junit_formatter", require: false diff --git a/Library/Homebrew/Gemfile.lock b/Library/Homebrew/Gemfile.lock index 74bda96348c46..254aab24c93a9 100644 --- a/Library/Homebrew/Gemfile.lock +++ b/Library/Homebrew/Gemfile.lock @@ -10,9 +10,6 @@ GEM coderay (1.1.3) commander (4.6.0) highline (~> 2.0.0) - debug (1.9.2) - irb (~> 1.10) - reline (>= 0.3.8) diff-lcs (1.5.1) docile (1.4.0) elftools (1.3.0) @@ -20,10 +17,6 @@ GEM erubi (1.12.0) hana (1.3.7) highline (2.0.3) - io-console (0.7.2) - irb (1.12.0) - rdoc - reline (>= 0.4.2) json (2.7.2) json_schemer (2.1.1) hana (~> 1.3) @@ -54,19 +47,13 @@ GEM pry (0.14.2) coderay (~> 1.1) method_source (~> 1.0) - psych (4.0.6) - stringio public_suffix (5.0.5) racc (1.7.3) rainbow (3.1.1) rbi (0.1.10) prism (>= 0.18.0, < 0.25) sorbet-runtime (>= 0.5.9204) - rdoc (6.6.3.1) - psych (>= 4.0.0) regexp_parser (2.9.0) - reline (0.5.0) - io-console (~> 0.5) rexml (3.2.6) rspec (3.13.0) rspec-core (~> 3.13.0) @@ -149,7 +136,6 @@ GEM sorbet-static-and-runtime (>= 0.5.10187) thor (>= 0.19.2) stackprof (0.2.26) - stringio (3.1.0) tapioca (0.13.1) bundler (>= 2.2.25) netrc (>= 0.11.0) @@ -180,7 +166,6 @@ PLATFORMS DEPENDENCIES addressable bootsnap - debug json_schemer kramdown method_source @@ -190,7 +175,6 @@ DEPENDENCIES patchelf plist pry - psych (< 5) rexml rspec rspec-github diff --git a/Library/Homebrew/dev-cmd/tests.rb b/Library/Homebrew/dev-cmd/tests.rb index 22d85459f0f04..c37c15d50ea31 100644 --- a/Library/Homebrew/dev-cmd/tests.rb +++ b/Library/Homebrew/dev-cmd/tests.rb @@ -45,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! diff --git a/Library/Homebrew/standalone/init.rb b/Library/Homebrew/standalone/init.rb index fafbaa2ab576c..45368cb1fadc2 100644 --- a/Library/Homebrew/standalone/init.rb +++ b/Library/Homebrew/standalone/init.rb @@ -39,6 +39,10 @@ ENV["HOMEBREW_SKIP_INITIAL_GEM_INSTALL"] = "1" end +if Pathname.new(RbConfig.ruby).to_s.include?("/vendor/portable-ruby/") + $LOAD_PATH.unshift "#{RbConfig::CONFIG["rubylibprefix"]}/gems/#{RbConfig::CONFIG["ruby_version"]}/gems/debug-1.6.3/lib" +end + unless $LOAD_PATH.include?(HOMEBREW_LIBRARY_PATH.to_s) # Insert the path after any existing Homebrew paths (e.g. those inserted by tests and parent processes) last_homebrew_path_idx = $LOAD_PATH.rindex do |path| diff --git a/Library/Homebrew/test/migrator_spec.rb b/Library/Homebrew/test/migrator_spec.rb index 87fadd5e95555..4494b919b7345 100644 --- a/Library/Homebrew/test/migrator_spec.rb +++ b/Library/Homebrew/test/migrator_spec.rb @@ -69,6 +69,8 @@ tab.source["tap"] = "homebrew/core" tab.write + binding.b + expect do described_class.new(new_formula, "oldname") end.to raise_error(Migrator::MigratorDifferentTapsError) diff --git a/Library/Homebrew/test/spec_helper.rb b/Library/Homebrew/test/spec_helper.rb index c36ea110f3482..517acadb8cc26 100644 --- a/Library/Homebrew/test/spec_helper.rb +++ b/Library/Homebrew/test/spec_helper.rb @@ -29,7 +29,6 @@ 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")) diff --git a/Library/Homebrew/vendor/bundle/bundler/setup.rb b/Library/Homebrew/vendor/bundle/bundler/setup.rb index e275465816cf8..d339fafafb65a 100644 --- a/Library/Homebrew/vendor/bundle/bundler/setup.rb +++ b/Library/Homebrew/vendor/bundle/bundler/setup.rb @@ -38,17 +38,6 @@ def self.extension_api_version $:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/coderay-1.1.3/lib") $:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/highline-2.0.3/lib") $:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/commander-4.6.0/lib") -$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/extensions/arm64-darwin-20/#{Gem.extension_api_version}/stringio-3.1.0") -$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/stringio-3.1.0/lib") -$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/extensions/arm64-darwin-20/#{Gem.extension_api_version}/psych-4.0.6") -$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/psych-4.0.6/lib") -$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/rdoc-6.6.3.1/lib") -$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/extensions/arm64-darwin-20/#{Gem.extension_api_version}/io-console-0.7.2") -$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/io-console-0.7.2/lib") -$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/reline-0.5.0/lib") -$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/irb-1.12.0/lib") -$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/extensions/arm64-darwin-20/#{Gem.extension_api_version}/debug-1.9.2") -$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/debug-1.9.2/lib") $:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/diff-lcs-1.5.1/lib") $:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/docile-1.4.0/lib") $:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/elftools-1.3.0/lib") diff --git a/completions/fish/brew.fish b/completions/fish/brew.fish index ee2bbcee8706a..ceca1c1ebb78c 100644 --- a/completions/fish/brew.fish +++ b/completions/fish/brew.fish @@ -1469,7 +1469,7 @@ __fish_brew_complete_arg 'test' -a '(__fish_brew_suggest_formulae_installed)' __fish_brew_complete_cmd 'tests' 'Run Homebrew\'s unit and integration tests' __fish_brew_complete_arg 'tests' -l changed -d 'Only runs tests on files that were changed from the master branch' __fish_brew_complete_arg 'tests' -l coverage -d 'Generate code coverage reports' -__fish_brew_complete_arg 'tests' -l debug -d 'Display any debugging information' +__fish_brew_complete_arg 'tests' -l debug -d 'Enable debugging using ruby/debug, or surface the standard `odebug` output' __fish_brew_complete_arg 'tests' -l fail-fast -d 'Exit early on the first failing test' __fish_brew_complete_arg 'tests' -l generic -d 'Run only OS-agnostic tests' __fish_brew_complete_arg 'tests' -l help -d 'Show this message' diff --git a/completions/zsh/_brew b/completions/zsh/_brew index 6337129b279a5..4a4b305525a88 100644 --- a/completions/zsh/_brew +++ b/completions/zsh/_brew @@ -1818,7 +1818,7 @@ _brew_tests() { _arguments \ '(--only)--changed[Only runs tests on files that were changed from the master branch]' \ '--coverage[Generate code coverage reports]' \ - '--debug[Display any debugging information]' \ + '--debug[Enable debugging using ruby/debug, or surface the standard `odebug` output]' \ '--fail-fast[Exit early on the first failing test]' \ '--generic[Run only OS-agnostic tests]' \ '--help[Show this message]' \ diff --git a/docs/Manpage.md b/docs/Manpage.md index 10593c1640506..3376cedafef08 100644 --- a/docs/Manpage.md +++ b/docs/Manpage.md @@ -2650,6 +2650,10 @@ Run Homebrew's unit and integration tests. : Include tests that use the GitHub API and tests that use any of the taps for official external commands. +`--debug` + +: Enable debugging using ruby/debug, or surface the standard `odebug` output. + `--changed` : Only runs tests on files that were changed from the master branch. diff --git a/manpages/brew.1 b/manpages/brew.1 index 949d217fab6f8..f9d224fe8d282 100644 --- a/manpages/brew.1 +++ b/manpages/brew.1 @@ -1688,6 +1688,9 @@ Run only OS\-agnostic tests\. \fB\-\-online\fP Include tests that use the GitHub API and tests that use any of the taps for official external commands\. .TP +\fB\-\-debug\fP +Enable debugging using ruby/debug, or surface the standard \fBodebug\fP output\. +.TP \fB\-\-changed\fP Only runs tests on files that were changed from the master branch\. .TP