mirror of
https://github.com/Homebrew/brew.git
synced 2025-07-14 16:09:03 +08:00
Additional fixes for Ruby 3 compatibility
This commit is contained in:
parent
1a8f9ac700
commit
eac32f0b20
@ -307,7 +307,7 @@ module Cask
|
||||
return
|
||||
end
|
||||
|
||||
command.run(executable_path, script_arguments)
|
||||
command.run(executable_path, **script_arguments)
|
||||
sleep 1
|
||||
end
|
||||
|
||||
@ -430,11 +430,11 @@ module Cask
|
||||
success
|
||||
end
|
||||
|
||||
def uninstall_rmdir(*args)
|
||||
def uninstall_rmdir(*args, **kwargs)
|
||||
return if args.empty?
|
||||
|
||||
ohai "Removing directories if empty:"
|
||||
recursive_rmdir(*args)
|
||||
recursive_rmdir(*args, **kwargs)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -35,8 +35,9 @@ module Cask
|
||||
switch "--dry-run",
|
||||
description: "Show what would be upgraded, but do not actually upgrade anything."
|
||||
|
||||
OPTIONS.each do |option|
|
||||
send(*option)
|
||||
OPTIONS.map(&:dup).each do |option|
|
||||
kwargs = option.pop
|
||||
send(*option, **kwargs)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -223,7 +223,7 @@ class URL < Delegator
|
||||
return @raw_interpolated_url if defined?(@raw_interpolated_url)
|
||||
|
||||
@raw_interpolated_url =
|
||||
Pathname(@caller_location.absolute_path)
|
||||
Pathname(@caller_location.path)
|
||||
.each_line.drop(@caller_location.lineno - 1)
|
||||
.first&.then { |line| line[/url\s+"([^"]+)"/, 1] }
|
||||
end
|
||||
|
@ -134,8 +134,8 @@ module Homebrew
|
||||
end
|
||||
end
|
||||
|
||||
def respond_to_missing?(*)
|
||||
!frozen?
|
||||
def respond_to_missing?(method_name, *)
|
||||
!frozen? || @table.key?(method_name)
|
||||
end
|
||||
|
||||
def method_missing(method_name, *args)
|
||||
|
@ -25,7 +25,7 @@ module Homebrew
|
||||
begin
|
||||
Homebrew.send(cmd_args_method_name) if require?(cmd_path)
|
||||
rescue NoMethodError => e
|
||||
raise if e.name != cmd_args_method_name
|
||||
raise if e.name.to_sym != cmd_args_method_name
|
||||
|
||||
nil
|
||||
end
|
||||
|
@ -182,7 +182,7 @@ module Homebrew
|
||||
end
|
||||
|
||||
# Check style in a single batch run up front for performance
|
||||
style_offenses = Style.check_style_json(style_files, style_options) if style_files
|
||||
style_offenses = Style.check_style_json(style_files, **style_options) if style_files
|
||||
# load licenses
|
||||
spdx_license_data = SPDX.license_data
|
||||
spdx_exception_data = SPDX.exception_data
|
||||
|
@ -72,6 +72,6 @@ module Homebrew
|
||||
options[:except_cops] = %w[FormulaAuditStrict]
|
||||
end
|
||||
|
||||
Homebrew.failed = !Style.check_style_and_print(target, options)
|
||||
Homebrew.failed = !Style.check_style_and_print(target, **options)
|
||||
end
|
||||
end
|
||||
|
@ -99,6 +99,7 @@ module Homebrew
|
||||
HOMEBREW_CACHE
|
||||
HOMEBREW_LOGS
|
||||
HOMEBREW_TEMP
|
||||
HOMEBREW_USE_RUBY_FROM_PATH
|
||||
]
|
||||
Homebrew::EnvConfig::ENVS.keys.map(&:to_s).each do |env|
|
||||
next if allowed_test_env.include?(env)
|
||||
|
@ -174,7 +174,7 @@ module Homebrew
|
||||
|
||||
if block
|
||||
block_return_value = case block.parameters[0]
|
||||
when [:opt, :item], [:rest]
|
||||
when [:opt, :item], [:rest], [:req]
|
||||
regex.present? ? yield(item, regex) : yield(item)
|
||||
when [:opt, :items]
|
||||
regex.present? ? yield(items, regex) : yield(items)
|
||||
|
@ -2,7 +2,7 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
describe Cask::DSL::Appcast do
|
||||
subject(:appcast) { described_class.new(url, params) }
|
||||
subject(:appcast) { described_class.new(url, **params) }
|
||||
|
||||
let(:url) { "https://brew.sh" }
|
||||
let(:uri) { URI(url) }
|
||||
|
@ -28,11 +28,20 @@ describe Cask::Pkg, :cask do
|
||||
expect(file).not_to exist
|
||||
end
|
||||
|
||||
some_specials.each do |file|
|
||||
expect(file).not_to exist
|
||||
end
|
||||
|
||||
some_dirs.each do |dir|
|
||||
expect(dir).not_to exist
|
||||
end
|
||||
|
||||
expect(root_dir).not_to exist
|
||||
ensure
|
||||
some_files&.each { |path| FileUtils.rm_rf(path) }
|
||||
some_specials&.each { |path| FileUtils.rm_rf(path) }
|
||||
some_dirs&.each { |path| FileUtils.rm_rf(path) }
|
||||
FileUtils.rm_rf(root_dir) if root_dir
|
||||
end
|
||||
|
||||
describe "pkgutil" do
|
||||
@ -79,6 +88,9 @@ describe Cask::Pkg, :cask do
|
||||
expect(broken_symlink).not_to exist
|
||||
expect(fake_dir).to exist
|
||||
expect(fake_root).not_to exist
|
||||
ensure
|
||||
FileUtils.rm_rf(fake_dir) if fake_dir
|
||||
FileUtils.rm_rf(fake_root) if fake_root
|
||||
end
|
||||
|
||||
it "snags permissions on ornery dirs, but returns them afterwards" do
|
||||
@ -109,8 +121,12 @@ describe Cask::Pkg, :cask do
|
||||
|
||||
fake_dir.chmod(0777)
|
||||
expect(fake_file).to be_a_file
|
||||
|
||||
FileUtils.rm_r fake_dir
|
||||
ensure
|
||||
if fake_dir
|
||||
fake_dir.chmod(0777)
|
||||
FileUtils.rm_rf(fake_dir)
|
||||
end
|
||||
FileUtils.rm_rf(fake_root) if fake_root
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -58,7 +58,7 @@ describe Resource do
|
||||
|
||||
it "does not mutate the specifications hash" do
|
||||
specs = { using: :git, branch: "master" }
|
||||
resource.url("foo", specs)
|
||||
resource.url("foo", **specs)
|
||||
expect(resource.specs).to eq(branch: "master")
|
||||
expect(resource.using).to eq(:git)
|
||||
expect(specs).to eq(using: :git, branch: "master")
|
||||
|
@ -7,7 +7,7 @@ describe "RuboCop" do
|
||||
context "when calling `rubocop` outside of the Homebrew environment" do
|
||||
before do
|
||||
ENV.each_key do |key|
|
||||
ENV.delete(key) if key.start_with?("HOMEBREW_")
|
||||
ENV.delete(key) if key.start_with?("HOMEBREW_") && key != "HOMEBREW_USE_RUBY_FROM_PATH"
|
||||
end
|
||||
|
||||
ENV["XDG_CACHE_HOME"] = (HOMEBREW_CACHE.realpath/"style").to_s
|
||||
|
@ -51,7 +51,7 @@ describe Homebrew::Settings do
|
||||
end
|
||||
|
||||
it "returns if the repo doesn't have a configuration file" do
|
||||
expect { described_class.write("foo", repo: HOMEBREW_REPOSITORY/"bar") }.not_to raise_error
|
||||
expect { described_class.write("foo", false, repo: HOMEBREW_REPOSITORY/"bar") }.not_to raise_error
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -4,7 +4,7 @@
|
||||
require "system_command"
|
||||
|
||||
class NeverSudoSystemCommand < SystemCommand
|
||||
def self.run(command, options = {})
|
||||
super(command, options.merge(sudo: false))
|
||||
def self.run(command, **options)
|
||||
super(command, **options.merge(sudo: false))
|
||||
end
|
||||
end
|
||||
|
@ -124,7 +124,7 @@ describe SystemCommand do
|
||||
|
||||
shared_examples "it returns '1 2 3 4 5 6'" do
|
||||
describe "its result" do
|
||||
subject { described_class.run(command, options) }
|
||||
subject { described_class.run(command, **options) }
|
||||
|
||||
it { is_expected.to be_a_success }
|
||||
its(:stdout) { is_expected.to eq([1, 3, 5, nil].join("\n")) }
|
||||
@ -136,7 +136,7 @@ describe SystemCommand do
|
||||
it "echoes only STDERR" do
|
||||
expected = [2, 4, 6].map { |i| "#{i}\n" }.join
|
||||
expect {
|
||||
described_class.run(command, options)
|
||||
described_class.run(command, **options)
|
||||
}.to output(expected).to_stderr
|
||||
end
|
||||
|
||||
@ -149,7 +149,7 @@ describe SystemCommand do
|
||||
end
|
||||
|
||||
it "echoes both STDOUT and STDERR" do
|
||||
expect { described_class.run(command, options) }
|
||||
expect { described_class.run(command, **options) }
|
||||
.to output("1\n3\n5\n").to_stdout
|
||||
.and output("2\n4\n6\n").to_stderr
|
||||
end
|
||||
@ -164,7 +164,7 @@ describe SystemCommand do
|
||||
|
||||
it "echoes nothing" do
|
||||
expect {
|
||||
described_class.run(command, options)
|
||||
described_class.run(command, **options)
|
||||
}.to output("").to_stdout
|
||||
end
|
||||
|
||||
@ -179,7 +179,7 @@ describe SystemCommand do
|
||||
it "echoes only STDOUT" do
|
||||
expected = [1, 3, 5].map { |i| "#{i}\n" }.join
|
||||
expect {
|
||||
described_class.run(command, options)
|
||||
described_class.run(command, **options)
|
||||
}.to output(expected).to_stdout
|
||||
end
|
||||
|
||||
@ -198,7 +198,7 @@ describe SystemCommand do
|
||||
|
||||
it "returns without deadlocking" do
|
||||
wait(30).for {
|
||||
described_class.run(command, options)
|
||||
described_class.run(command, **options)
|
||||
}.to be_a_success
|
||||
end
|
||||
end
|
||||
|
@ -4,16 +4,20 @@
|
||||
describe Utils do
|
||||
describe "ruby_check_version_script" do
|
||||
subject do
|
||||
homebrew_env = ENV.select { |key, _| key.start_with?("HOMEBREW_") }
|
||||
Bundler.with_unbundled_env do
|
||||
ENV.update(homebrew_env)
|
||||
quiet_system "#{HOMEBREW_LIBRARY_PATH}/utils/ruby_check_version_script.rb", required_ruby_version
|
||||
end
|
||||
end
|
||||
|
||||
before do
|
||||
ENV.delete("HOMEBREW_DEVELOPER")
|
||||
ENV.delete("HOMEBREW_USE_RUBY_FROM_PATH")
|
||||
end
|
||||
|
||||
describe "succeeds on Homebrew required Ruby version" do
|
||||
let(:required_ruby_version) { HOMEBREW_REQUIRED_RUBY_VERSION }
|
||||
describe "succeeds on the running Ruby version" do
|
||||
let(:required_ruby_version) { RUBY_VERSION }
|
||||
|
||||
it { is_expected.to be true }
|
||||
end
|
||||
|
@ -181,15 +181,15 @@ describe SPDX do
|
||||
end
|
||||
|
||||
it "returns multiple licenses with :any" do
|
||||
expect(described_class.license_expression_to_string(any_of: ["MIT", "0BSD"])).to eq "MIT or 0BSD"
|
||||
expect(described_class.license_expression_to_string({ any_of: ["MIT", "0BSD"] })).to eq "MIT or 0BSD"
|
||||
end
|
||||
|
||||
it "returns multiple licenses with :all" do
|
||||
expect(described_class.license_expression_to_string(all_of: ["MIT", "0BSD"])).to eq "MIT and 0BSD"
|
||||
expect(described_class.license_expression_to_string({ all_of: ["MIT", "0BSD"] })).to eq "MIT and 0BSD"
|
||||
end
|
||||
|
||||
it "returns multiple licenses with plus" do
|
||||
expect(described_class.license_expression_to_string(any_of: ["MIT", "EPL-1.0+"])).to eq "MIT or EPL-1.0+"
|
||||
expect(described_class.license_expression_to_string({ any_of: ["MIT", "EPL-1.0+"] })).to eq "MIT or EPL-1.0+"
|
||||
end
|
||||
|
||||
it "returns license and exception" do
|
||||
|
@ -10,7 +10,7 @@ describe User do
|
||||
|
||||
describe "#gui?" do
|
||||
before do
|
||||
allow(SystemCommand).to receive(:run).with("who", {})
|
||||
allow(SystemCommand).to receive(:run).with("who", any_args)
|
||||
.and_return([who_output, "", instance_double(Process::Status, success?: true)])
|
||||
end
|
||||
|
||||
|
@ -412,7 +412,7 @@ module Utils
|
||||
# Unknown charset in Content-Type header
|
||||
end
|
||||
end
|
||||
file_contents = File.read(file.path, open_args)
|
||||
file_contents = File.read(file.path, **open_args)
|
||||
file_hash = Digest::SHA2.hexdigest(file_contents) if hash_needed
|
||||
end
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user