mirror of
https://github.com/Homebrew/brew.git
synced 2025-07-14 16:09:03 +08:00
Apply corrections from brew style --fix
This commit is contained in:
parent
cb15b67b8e
commit
4a608bfb11
@ -37,12 +37,12 @@ module Homebrew
|
||||
if casks.any?
|
||||
args = zap ? ["--zap"] : []
|
||||
Kernel.system HOMEBREW_BREW_FILE, "uninstall", "--cask", *args, "--force", *casks
|
||||
puts "Uninstalled #{casks.size} cask#{(casks.size == 1) ? "" : "s"}"
|
||||
puts "Uninstalled #{casks.size} cask#{"s" if casks.size != 1}"
|
||||
end
|
||||
|
||||
if formulae.any?
|
||||
Kernel.system HOMEBREW_BREW_FILE, "uninstall", "--formula", "--force", *formulae
|
||||
puts "Uninstalled #{formulae.size} formula#{(formulae.size == 1) ? "" : "e"}"
|
||||
puts "Uninstalled #{formulae.size} formula#{"e" if formulae.size != 1}"
|
||||
end
|
||||
|
||||
Kernel.system HOMEBREW_BREW_FILE, "untap", *taps if taps.any?
|
||||
|
@ -194,7 +194,7 @@ class Caveats
|
||||
startup = formula.service.requires_root?
|
||||
if Utils::Service.running?(formula)
|
||||
s << "To restart #{formula.full_name} after an upgrade:"
|
||||
s << " #{startup ? "sudo " : ""}brew services restart #{formula.full_name}"
|
||||
s << " #{"sudo " if startup}brew services restart #{formula.full_name}"
|
||||
elsif startup
|
||||
s << "To start #{formula.full_name} now and restart at startup:"
|
||||
s << " sudo brew services start #{formula.full_name}"
|
||||
|
@ -589,7 +589,7 @@ module Homebrew
|
||||
#{leading_spaces}resource "#{resource.name}" do
|
||||
#{leading_spaces} url "#{new_url}"#{new_mirrors.map { |m| "\n#{leading_spaces} mirror \"#{m}\"" }.join}
|
||||
#{leading_spaces} sha256 "#{new_hash}"
|
||||
#{forced_version ? "#{leading_spaces} version \"#{version}\"\n" : ""}
|
||||
#{"#{leading_spaces} version \"#{version}\"\n" if forced_version}
|
||||
#{leading_spaces} livecheck do
|
||||
#{leading_spaces} formula :parent
|
||||
#{leading_spaces} end
|
||||
|
@ -20,7 +20,6 @@ module Homebrew
|
||||
def enqueue(downloadable, force: false)
|
||||
quiet = pool.max_length > 1
|
||||
# Passing in arguments from outside into the future is a common `concurrent-ruby` pattern.
|
||||
# rubocop:disable Lint/ShadowingOuterLocalVariable
|
||||
Concurrent::Promises.future_on(pool, downloadable, force, quiet) do |downloadable, force, quiet|
|
||||
downloadable.clear_cache if force
|
||||
downloadable.fetch(quiet:)
|
||||
|
@ -20,11 +20,11 @@ class File
|
||||
# file.write('hello')
|
||||
# end
|
||||
sig {
|
||||
type_parameters(:out).params(
|
||||
type_parameters(:Out).params(
|
||||
file_name: T.any(Pathname, String),
|
||||
temp_dir: String,
|
||||
_block: T.proc.params(arg0: Tempfile).returns(T.type_parameter(:out)),
|
||||
).returns(T.type_parameter(:out))
|
||||
_block: T.proc.params(arg0: Tempfile).returns(T.type_parameter(:Out)),
|
||||
).returns(T.type_parameter(:Out))
|
||||
}
|
||||
def self.atomic_write(file_name, temp_dir = dirname(file_name), &_block)
|
||||
require "tempfile" unless defined?(Tempfile)
|
||||
|
@ -3,18 +3,18 @@
|
||||
|
||||
class Hash
|
||||
sig {
|
||||
type_parameters(:k2).params(
|
||||
other_hash: T::Hash[T.type_parameter(:k2), T.untyped],
|
||||
type_parameters(:K2).params(
|
||||
other_hash: T::Hash[T.type_parameter(:K2), T.untyped],
|
||||
block: T.nilable(T.proc.params(k: T.untyped, v1: T.untyped, v2: T.untyped).returns(T.untyped)),
|
||||
).returns(T::Hash[T.any(Hash::K, T.type_parameter(:k2)), T.untyped])
|
||||
).returns(T::Hash[T.any(Hash::K, T.type_parameter(:K2)), T.untyped])
|
||||
}
|
||||
def deep_merge(other_hash, &block); end
|
||||
|
||||
sig {
|
||||
type_parameters(:k2).params(
|
||||
other_hash: T::Hash[T.type_parameter(:k2), T.untyped],
|
||||
type_parameters(:K2).params(
|
||||
other_hash: T::Hash[T.type_parameter(:K2), T.untyped],
|
||||
block: T.nilable(T.proc.params(k: T.untyped, v1: T.untyped, v2: T.untyped).returns(T.untyped)),
|
||||
).returns(T::Hash[T.any(Hash::K, T.type_parameter(:k2)), T.untyped])
|
||||
).returns(T::Hash[T.any(Hash::K, T.type_parameter(:K2)), T.untyped])
|
||||
}
|
||||
def deep_merge!(other_hash, &block); end
|
||||
end
|
||||
|
@ -2,16 +2,16 @@
|
||||
|
||||
class Hash
|
||||
sig {
|
||||
type_parameters(:out).params(
|
||||
block: T.proc.params(o: Hash::V).returns(T.type_parameter(:out)),
|
||||
).returns(T::Hash[Hash::K, T.type_parameter(:out)])
|
||||
type_parameters(:Out).params(
|
||||
block: T.proc.params(o: Hash::V).returns(T.type_parameter(:Out)),
|
||||
).returns(T::Hash[Hash::K, T.type_parameter(:Out)])
|
||||
}
|
||||
def deep_transform_values(&block); end
|
||||
|
||||
sig {
|
||||
type_parameters(:out).params(
|
||||
block: T.proc.params(o: Hash::V).returns(T.type_parameter(:out)),
|
||||
).returns(T::Hash[Hash::K, T.type_parameter(:out)])
|
||||
type_parameters(:Out).params(
|
||||
block: T.proc.params(o: Hash::V).returns(T.type_parameter(:Out)),
|
||||
).returns(T::Hash[Hash::K, T.type_parameter(:Out)])
|
||||
}
|
||||
def deep_transform_values!(&block); end
|
||||
end
|
||||
|
@ -3,16 +3,16 @@
|
||||
|
||||
class Hash
|
||||
sig {
|
||||
type_parameters(:out).params(
|
||||
block: T.proc.params(o: K).returns(T.type_parameter(:out)),
|
||||
).returns(T::Hash[T.type_parameter(:out), V])
|
||||
type_parameters(:Out).params(
|
||||
block: T.proc.params(o: K).returns(T.type_parameter(:Out)),
|
||||
).returns(T::Hash[T.type_parameter(:Out), V])
|
||||
}
|
||||
def deep_transform_keys(&block); end
|
||||
|
||||
sig {
|
||||
type_parameters(:out).params(
|
||||
block: T.proc.params(o: K).returns(T.type_parameter(:out)),
|
||||
).returns(T::Hash[T.type_parameter(:out), V])
|
||||
type_parameters(:Out).params(
|
||||
block: T.proc.params(o: K).returns(T.type_parameter(:Out)),
|
||||
).returns(T::Hash[T.type_parameter(:Out), V])
|
||||
}
|
||||
def deep_transform_keys!(&block); end
|
||||
|
||||
|
@ -80,7 +80,7 @@ module Formulary
|
||||
|
||||
module PathnameWriteMkpath
|
||||
refine Pathname do
|
||||
def write(content, offset = nil, **open_args)
|
||||
define_method(:write) do |_content, offset = nil, **open_args|
|
||||
T.bind(self, Pathname)
|
||||
raise "Will not overwrite #{self}" if exist? && !offset && !open_args[:mode]&.match?(/^a\+?$/)
|
||||
|
||||
@ -133,7 +133,7 @@ module Formulary
|
||||
rescue NameError => e
|
||||
class_list = mod.constants
|
||||
.map { |const_name| mod.const_get(const_name) }
|
||||
.select { |const| const.is_a?(Class) }
|
||||
.grep(Class)
|
||||
new_exception = FormulaClassUnavailableError.new(name, path, class_name, class_list)
|
||||
remove_const(namespace)
|
||||
raise new_exception, "", e.backtrace
|
||||
@ -354,13 +354,13 @@ module Formulary
|
||||
link_overwrite overwrite_path
|
||||
end
|
||||
|
||||
def install
|
||||
define_method(:install) do
|
||||
raise "Cannot build from source from abstract formula."
|
||||
end
|
||||
|
||||
@post_install_defined_boolean = json_formula["post_install_defined"]
|
||||
@post_install_defined_boolean = true if @post_install_defined_boolean.nil? # Backwards compatibility
|
||||
def post_install_defined?
|
||||
define_method(:post_install_defined?) do
|
||||
self.class.instance_variable_get(:@post_install_defined_boolean)
|
||||
end
|
||||
|
||||
@ -389,7 +389,7 @@ module Formulary
|
||||
end
|
||||
|
||||
@caveats_string = json_formula["caveats"]
|
||||
def caveats
|
||||
define_method(:caveats) do
|
||||
caveats_string = self.class.instance_variable_get(:@caveats_string)
|
||||
return unless caveats_string
|
||||
|
||||
@ -400,33 +400,33 @@ module Formulary
|
||||
|
||||
@tap_git_head_string = json_formula["tap_git_head"]
|
||||
|
||||
def tap_git_head
|
||||
define_method(:tap_git_head) do
|
||||
self.class.instance_variable_get(:@tap_git_head_string)
|
||||
end
|
||||
|
||||
@oldnames_array = json_formula["oldnames"] || [json_formula["oldname"]].compact
|
||||
def oldnames
|
||||
define_method(:oldnames) do
|
||||
self.class.instance_variable_get(:@oldnames_array)
|
||||
end
|
||||
|
||||
@aliases_array = json_formula.fetch("aliases", [])
|
||||
def aliases
|
||||
define_method(:aliases) do
|
||||
self.class.instance_variable_get(:@aliases_array)
|
||||
end
|
||||
|
||||
@versioned_formulae_array = json_formula.fetch("versioned_formulae", [])
|
||||
def versioned_formulae_names
|
||||
define_method(:versioned_formulae_names) do
|
||||
self.class.instance_variable_get(:@versioned_formulae_array)
|
||||
end
|
||||
|
||||
@ruby_source_path_string = json_formula["ruby_source_path"]
|
||||
def ruby_source_path
|
||||
define_method(:ruby_source_path) do
|
||||
self.class.instance_variable_get(:@ruby_source_path_string)
|
||||
end
|
||||
|
||||
@ruby_source_checksum_string = json_formula.dig("ruby_source_checksum", "sha256")
|
||||
@ruby_source_checksum_string ||= json_formula["ruby_source_sha256"]
|
||||
def ruby_source_checksum
|
||||
define_method(:ruby_source_checksum) do
|
||||
checksum = self.class.instance_variable_get(:@ruby_source_checksum_string)
|
||||
Checksum.new(checksum) if checksum
|
||||
end
|
||||
|
@ -22,7 +22,7 @@ module Ignorable
|
||||
Object.class_eval do
|
||||
alias_method :original_raise, :raise
|
||||
|
||||
def raise(*)
|
||||
define_method(:raise) do |*|
|
||||
callcc do |continuation|
|
||||
super
|
||||
# Handle all possible exceptions.
|
||||
|
@ -465,9 +465,7 @@ module Homebrew
|
||||
|
||||
def collect_dependencies(formulae_installer, dependants)
|
||||
formulae_dependencies = formulae_installer.flat_map do |f|
|
||||
[f.formula, f.compute_dependencies.flatten.filter do |c|
|
||||
c.is_a? Dependency
|
||||
end.flat_map(&:to_formula)]
|
||||
[f.formula, f.compute_dependencies.flatten.grep(Dependency).flat_map(&:to_formula)]
|
||||
end.flatten.uniq
|
||||
formulae_dependencies.concat(dependants.upgradeable) if dependants&.upgradeable
|
||||
formulae_dependencies.uniq
|
||||
|
@ -11,7 +11,8 @@ RSpec.describe Homebrew::AbstractCommand do
|
||||
switch "--foo"
|
||||
flag "--bar="
|
||||
end
|
||||
def run; end
|
||||
define_method(:run) do
|
||||
end
|
||||
end
|
||||
stub_const("TestCat", test_cat)
|
||||
end
|
||||
@ -47,8 +48,10 @@ RSpec.describe Homebrew::AbstractCommand do
|
||||
describe "when command name is overridden" do
|
||||
before do
|
||||
tac = Class.new(described_class) do
|
||||
def self.command_name = "t-a-c"
|
||||
def run; end
|
||||
self.define_singleton_method(:command_name) do
|
||||
"t-a-c"
|
||||
define_method(:run) do
|
||||
end
|
||||
end
|
||||
stub_const("Tac", tac)
|
||||
end
|
||||
|
@ -9,7 +9,7 @@ RSpec.describe Homebrew::API::Cask do
|
||||
stub_const("Homebrew::API::HOMEBREW_CACHE_API", cache_dir)
|
||||
end
|
||||
|
||||
def mock_curl_download(stdout:)
|
||||
define_method(:mock_curl_download) do |stdout:|
|
||||
allow(Utils::Curl).to receive(:curl_download) do |*_args, **kwargs|
|
||||
kwargs[:to].write stdout
|
||||
end
|
||||
|
@ -9,7 +9,7 @@ RSpec.describe Homebrew::API::Formula do
|
||||
stub_const("Homebrew::API::HOMEBREW_CACHE_API", cache_dir)
|
||||
end
|
||||
|
||||
def mock_curl_download(stdout:)
|
||||
define_method(:mock_curl_download) do |stdout:|
|
||||
allow(Utils::Curl).to receive(:curl_download) do |*_args, **kwargs|
|
||||
kwargs[:to].write stdout
|
||||
end
|
||||
|
@ -8,12 +8,12 @@ RSpec.describe Homebrew::API do
|
||||
let(:json_hash) { JSON.parse(json) }
|
||||
let(:json_invalid) { '{"foo":"bar"' }
|
||||
|
||||
def mock_curl_output(stdout: "", success: true)
|
||||
define_method(:mock_curl_output) do |stdout: "", success: true|
|
||||
curl_output = instance_double(SystemCommand::Result, stdout:, success?: success)
|
||||
allow(Utils::Curl).to receive(:curl_output).and_return curl_output
|
||||
end
|
||||
|
||||
def mock_curl_download(stdout:)
|
||||
define_method(:mock_curl_download) do |stdout:|
|
||||
allow(Utils::Curl).to receive(:curl_download) do |*_args, **kwargs|
|
||||
kwargs[:to].write stdout
|
||||
end
|
||||
|
@ -286,7 +286,7 @@ RSpec.describe Homebrew::Bundle::Commands::Cleanup do
|
||||
vscode_extensions_to_uninstall: [])
|
||||
end
|
||||
|
||||
def sane?
|
||||
define_method(:sane?) do
|
||||
expect(described_class).to receive(:system_output_no_stderr).and_return("cleaned")
|
||||
end
|
||||
|
||||
|
@ -4,7 +4,7 @@ require "bundle"
|
||||
require "bundle/dsl"
|
||||
|
||||
RSpec.describe Homebrew::Bundle::Dsl do
|
||||
def dsl_from_string(string)
|
||||
define_method(:dsl_from_string) do |string|
|
||||
described_class.new(StringIO.new(string))
|
||||
end
|
||||
|
||||
|
@ -3,7 +3,7 @@
|
||||
require "cask/audit"
|
||||
|
||||
RSpec.describe Cask::Audit, :cask do
|
||||
def include_msg?(problems, msg)
|
||||
define_method(:include_msg?) do |problems, msg|
|
||||
if msg.is_a?(Regexp)
|
||||
Array(problems).any? { |problem| msg.match?(problem[:message]) }
|
||||
else
|
||||
@ -11,11 +11,11 @@ RSpec.describe Cask::Audit, :cask do
|
||||
end
|
||||
end
|
||||
|
||||
def passed?(audit)
|
||||
define_method(:passed?) do |audit|
|
||||
!audit.errors?
|
||||
end
|
||||
|
||||
def outcome(audit)
|
||||
define_method(:outcome) do |audit|
|
||||
if passed?(audit)
|
||||
"passed"
|
||||
else
|
||||
@ -150,7 +150,7 @@ RSpec.describe Cask::Audit, :cask do
|
||||
describe "#run!" do
|
||||
subject(:run) { audit.run! }
|
||||
|
||||
def tmp_cask(name, text)
|
||||
define_method(:tmp_cask) do |name, text|
|
||||
path = Pathname.new "#{dir}/#{name}.rb"
|
||||
path.open("w") do |f|
|
||||
f.write text
|
||||
|
@ -305,7 +305,7 @@ RSpec.describe Cask::DSL, :cask, :no_api do
|
||||
expect(cask.caveats).to be_empty
|
||||
|
||||
cask = Cask::Cask.new("cask-with-caveats") do
|
||||
def caveats
|
||||
define_method(:caveats) do
|
||||
<<~EOS
|
||||
When you install this Cask, you probably want to know this.
|
||||
EOS
|
||||
|
@ -21,7 +21,7 @@ RSpec.describe Caveats do
|
||||
f = formula do
|
||||
url "foo-1.0"
|
||||
|
||||
def caveats
|
||||
define_method(:caveats) do
|
||||
"something"
|
||||
end
|
||||
end
|
||||
@ -214,7 +214,7 @@ RSpec.describe Caveats do
|
||||
url "foo-1.0"
|
||||
keg_only "some reason"
|
||||
|
||||
def caveats
|
||||
define_method(:caveats) do
|
||||
"something else"
|
||||
end
|
||||
|
||||
|
@ -3,7 +3,7 @@
|
||||
require "formula"
|
||||
|
||||
RSpec.describe Formula do
|
||||
def formula(&block)
|
||||
define_method(:formula) do |&block|
|
||||
super do
|
||||
url "file://#{TEST_FIXTURE_DIR}/tarballs/testball-0.1.tbz"
|
||||
instance_eval(&block)
|
||||
|
@ -204,7 +204,7 @@ RSpec.describe Cleaner do
|
||||
end
|
||||
|
||||
describe "::skip_clean" do
|
||||
def stub_formula_skip_clean(skip_paths)
|
||||
define_method(:stub_formula_skip_clean) do |skip_paths|
|
||||
formula("cleaner_test") do
|
||||
url "foo-1.0"
|
||||
|
||||
|
@ -3,12 +3,12 @@
|
||||
require "cli/named_args"
|
||||
|
||||
RSpec.describe Homebrew::CLI::NamedArgs do
|
||||
def setup_unredable_formula(name)
|
||||
define_method(:setup_unredable_formula) do |name|
|
||||
error = FormulaUnreadableError.new(name, RuntimeError.new("testing"))
|
||||
allow(Formulary).to receive(:factory).with(name, any_args).and_raise(error)
|
||||
end
|
||||
|
||||
def setup_unredable_cask(name)
|
||||
define_method(:setup_unredable_cask) do |name|
|
||||
error = Cask::CaskUnreadableError.new(name, "testing")
|
||||
allow(Cask::CaskLoader).to receive(:load).with(name, any_args).and_raise(error)
|
||||
|
||||
|
@ -5,8 +5,7 @@ require "cmd/shared_examples/args_parse"
|
||||
require "tab"
|
||||
|
||||
RSpec.describe Homebrew::Cmd::TabCmd do
|
||||
def installed_on_request?(formula)
|
||||
# `brew` subprocesses can change the tab, invalidating the cached values.
|
||||
define_method(:installed_on_request?) do |formula|
|
||||
Tab.clear_cache
|
||||
Tab.for_formula(formula).installed_on_request
|
||||
end
|
||||
|
@ -19,7 +19,7 @@ RSpec.describe Homebrew::Cmd::Untap do
|
||||
|
||||
describe "#installed_formulae_for", :integration_test do
|
||||
shared_examples "finds installed formulae in tap", :no_api do
|
||||
def load_formula(name:, with_formula_file: false, mock_install: false)
|
||||
define_method(:load_formula) do |name:, with_formula_file: false, mock_install: false|
|
||||
formula = if with_formula_file
|
||||
path = setup_test_formula(name, tap:)
|
||||
Formulary.factory(path)
|
||||
@ -85,7 +85,7 @@ RSpec.describe Homebrew::Cmd::Untap do
|
||||
|
||||
describe "#installed_casks_for", :cask do
|
||||
shared_examples "finds installed casks in tap", :no_api do
|
||||
def load_cask(token:, with_cask_file: false, mock_install: false)
|
||||
define_method(:load_cask) do |token:, with_cask_file: false, mock_install: false|
|
||||
cask_loader = Cask::CaskLoader::FromContentLoader.new(<<~RUBY, tap:)
|
||||
cask '#{token}' do
|
||||
version "1.2.3"
|
||||
|
@ -12,7 +12,7 @@ RSpec.describe Homebrew::Cmd::UpdateReport do
|
||||
let(:tap) { CoreTap.instance }
|
||||
let(:reporter_class) do
|
||||
Class.new(described_class) do
|
||||
def initialize(tap)
|
||||
define_method(:initialize) do |tap|
|
||||
@tap = tap
|
||||
|
||||
ENV["HOMEBREW_UPDATE_BEFORE#{tap.repository_var_suffix}"] = "12345678"
|
||||
@ -25,7 +25,7 @@ RSpec.describe Homebrew::Cmd::UpdateReport do
|
||||
let(:reporter) { reporter_class.new(tap) }
|
||||
let(:hub) { ReporterHub.new }
|
||||
|
||||
def perform_update(fixture_name = "")
|
||||
define_method(:perform_update) do |fixture_name = ""|
|
||||
allow(Formulary).to receive(:factory).and_return(instance_double(Formula, pkg_version: "1.0"))
|
||||
allow(FormulaVersions).to receive(:new).and_return(instance_double(FormulaVersions, formula_at_revision: "2.0"))
|
||||
|
||||
|
@ -25,7 +25,7 @@ RSpec.describe Homebrew::Completions do
|
||||
end
|
||||
|
||||
context "when linking or unlinking completions" do
|
||||
def setup_completions(external:)
|
||||
define_method(:setup_completions) do |external:|
|
||||
internal_bash_completion = internal_path/"completions/bash"
|
||||
external_bash_completion = external_path/"completions/bash"
|
||||
|
||||
@ -39,19 +39,19 @@ RSpec.describe Homebrew::Completions do
|
||||
end
|
||||
end
|
||||
|
||||
def setup_completions_setting(state, setting: "linkcompletions")
|
||||
define_method(:setup_completions_setting) do |state, setting: "linkcompletions"|
|
||||
HOMEBREW_REPOSITORY.cd do
|
||||
system "git", "config", "--replace-all", "homebrew.#{setting}", state.to_s
|
||||
end
|
||||
end
|
||||
|
||||
def read_completions_setting(setting: "linkcompletions")
|
||||
define_method(:read_completions_setting) do |setting: "linkcompletions"|
|
||||
HOMEBREW_REPOSITORY.cd do
|
||||
Utils.popen_read("git", "config", "--get", "homebrew.#{setting}").chomp.presence
|
||||
end
|
||||
end
|
||||
|
||||
def delete_completions_setting(setting: "linkcompletions")
|
||||
define_method(:delete_completions_setting) do |setting: "linkcompletions"|
|
||||
HOMEBREW_REPOSITORY.cd do
|
||||
system "git", "config", "--unset-all", "homebrew.#{setting}"
|
||||
end
|
||||
|
@ -8,7 +8,7 @@ RSpec.describe Dependable do
|
||||
subject(:dependable) do
|
||||
Class.new do
|
||||
include Dependable
|
||||
def initialize
|
||||
define_method(:initialize) do
|
||||
@tags = ["foo", "bar", :build]
|
||||
end
|
||||
end.new
|
||||
|
@ -7,11 +7,11 @@ RSpec.describe DependencyCollector do
|
||||
|
||||
subject(:collector) { described_class.new }
|
||||
|
||||
def find_dependency(name)
|
||||
define_method(:find_dependency) do |name|
|
||||
collector.deps.find { |dep| dep.name == name }
|
||||
end
|
||||
|
||||
def find_requirement(klass)
|
||||
define_method(:find_requirement) do |klass|
|
||||
collector.requirements.find { |req| req.is_a? klass }
|
||||
end
|
||||
|
||||
|
@ -3,7 +3,7 @@
|
||||
require "dependency"
|
||||
|
||||
RSpec.describe Dependency do
|
||||
def build_dep(name, tags = [], deps = [])
|
||||
define_method(:build_dep) do |name, tags = [], deps = []|
|
||||
dep = described_class.new(name.to_s, tags)
|
||||
allow(dep).to receive(:to_formula).and_return \
|
||||
instance_double(Formula, deps:, name:, full_name: name)
|
||||
|
@ -4,7 +4,7 @@ require "cmd/shared_examples/args_parse"
|
||||
require "dev-cmd/bottle"
|
||||
|
||||
RSpec.describe Homebrew::DevCmd::Bottle do
|
||||
def stub_hash(parameters)
|
||||
define_method(:stub_hash) do |parameters|
|
||||
<<~EOS
|
||||
{
|
||||
"#{parameters[:name]}":{
|
||||
|
@ -4,7 +4,7 @@ require "dev-cmd/determine-test-runners"
|
||||
require "cmd/shared_examples/args_parse"
|
||||
|
||||
RSpec.describe Homebrew::DevCmd::DetermineTestRunners do
|
||||
def get_runners(file)
|
||||
define_method(:get_runners) do |file|
|
||||
runner_line = File.open(file).first
|
||||
json_text = runner_line[/runners=(.*)/, 1]
|
||||
runner_hash = JSON.parse(json_text)
|
||||
|
@ -15,7 +15,7 @@ RSpec.describe GitDownloadStrategy do
|
||||
FileUtils.mkpath cached_location
|
||||
end
|
||||
|
||||
def git_commit_all
|
||||
define_method(:git_commit_all) do
|
||||
system "git", "add", "--all"
|
||||
# Allow instance variables here to have nice commit messages.
|
||||
# rubocop:disable RSpec/InstanceVariable
|
||||
@ -24,7 +24,7 @@ RSpec.describe GitDownloadStrategy do
|
||||
# rubocop:enable RSpec/InstanceVariable
|
||||
end
|
||||
|
||||
def setup_git_repo
|
||||
define_method(:setup_git_repo) do
|
||||
system "git", "-c", "init.defaultBranch=master", "init"
|
||||
system "git", "remote", "add", "origin", "https://github.com/Homebrew/homebrew-foo"
|
||||
FileUtils.touch "README"
|
||||
|
@ -5,14 +5,14 @@ require "extend/blank"
|
||||
RSpec.describe Object do
|
||||
let(:empty_true) do
|
||||
Class.new(described_class) do
|
||||
def empty?
|
||||
define_method(:empty?) do
|
||||
0
|
||||
end
|
||||
end
|
||||
end
|
||||
let(:empty_false) do
|
||||
Class.new(described_class) do
|
||||
def empty?
|
||||
define_method(:empty?) do
|
||||
false
|
||||
end
|
||||
end
|
||||
|
@ -3,7 +3,7 @@
|
||||
RSpec.describe Kernel do
|
||||
let(:dir) { mktmpdir }
|
||||
|
||||
def esc(code)
|
||||
define_method(:esc) do |code|
|
||||
/(\e\[\d+m)*\e\[#{code}m/
|
||||
end
|
||||
|
||||
|
@ -16,7 +16,7 @@ RSpec.describe Homebrew::FormulaAuditor do
|
||||
let(:tap_path) { HOMEBREW_TAP_DIRECTORY/"homebrew/homebrew-bar" }
|
||||
let(:formula_path) { tap_path/formula_subpath }
|
||||
|
||||
def formula_auditor(name, text, options = {})
|
||||
define_method(:formula_auditor) do |name, text, options = {}|
|
||||
path = Pathname.new "#{dir}/#{name}.rb"
|
||||
path.open("w") do |f|
|
||||
f.write text
|
||||
@ -34,14 +34,14 @@ RSpec.describe Homebrew::FormulaAuditor do
|
||||
described_class.new(formula, options)
|
||||
end
|
||||
|
||||
def formula_gsub(before, after = "")
|
||||
define_method(:formula_gsub) do |before, after = ""|
|
||||
text = formula_path.read
|
||||
text.gsub! before, after
|
||||
formula_path.unlink
|
||||
formula_path.write text
|
||||
end
|
||||
|
||||
def formula_gsub_origin_commit(before, after = "")
|
||||
define_method(:formula_gsub_origin_commit) do |before, after = ""|
|
||||
text = origin_formula_path.read
|
||||
text.gsub!(before, after)
|
||||
origin_formula_path.unlink
|
||||
|
@ -16,7 +16,7 @@ RSpec.describe FormulaInstaller do
|
||||
match(&:poured_from_bottle)
|
||||
end
|
||||
|
||||
def temporarily_install_bottle(formula)
|
||||
define_method(:temporarily_install_bottle) do |formula|
|
||||
expect(formula).not_to be_latest_version_installed
|
||||
expect(formula).to be_bottled
|
||||
expect(formula).to pour_bottle
|
||||
@ -25,7 +25,7 @@ RSpec.describe FormulaInstaller do
|
||||
stub_formula_loader formula("glibc") { url "glibc-1.0" }
|
||||
stub_formula_loader formula
|
||||
|
||||
fi = FormulaInstaller.new(formula)
|
||||
fi = described_class.new(formula)
|
||||
fi.fetch
|
||||
fi.install
|
||||
|
||||
@ -48,8 +48,7 @@ RSpec.describe FormulaInstaller do
|
||||
expect(formula).not_to be_latest_version_installed
|
||||
end
|
||||
|
||||
def test_basic_formula_setup(formula)
|
||||
# Test that things made it into the Keg
|
||||
define_method(:test_basic_formula_setup) do |formula|
|
||||
expect(formula.bin).to be_a_directory
|
||||
|
||||
expect(formula.libexec).to be_a_directory
|
||||
|
@ -16,7 +16,7 @@ RSpec.describe FormulaInstaller do
|
||||
match(&:poured_from_bottle)
|
||||
end
|
||||
|
||||
def temporary_install(formula, **options)
|
||||
define_method(:temporary_install) do |formula, **options|
|
||||
expect(formula).not_to be_latest_version_installed
|
||||
|
||||
installer = described_class.new(formula, **options)
|
||||
|
@ -676,7 +676,7 @@ RSpec.describe Formula do
|
||||
f1 = formula do
|
||||
url "foo-1.0"
|
||||
|
||||
def post_install
|
||||
define_method(:post_install) do
|
||||
# do nothing
|
||||
end
|
||||
end
|
||||
@ -1146,7 +1146,7 @@ RSpec.describe Formula do
|
||||
f = formula "foo" do
|
||||
url "foo-1.0"
|
||||
|
||||
def pour_bottle?
|
||||
define_method(:pour_bottle?) do
|
||||
false
|
||||
end
|
||||
end
|
||||
@ -1158,7 +1158,7 @@ RSpec.describe Formula do
|
||||
f = formula "foo" do
|
||||
url "foo-1.0"
|
||||
|
||||
def pour_bottle?
|
||||
define_method(:pour_bottle?) do
|
||||
true
|
||||
end
|
||||
end
|
||||
@ -1362,7 +1362,7 @@ RSpec.describe Formula do
|
||||
let(:alias_name) { "bar" }
|
||||
let(:alias_path) { f.tap.alias_dir/alias_name }
|
||||
|
||||
def setup_tab_for_prefix(prefix, options = {})
|
||||
define_method(:setup_tab_for_prefix) do |prefix, options = {}|
|
||||
prefix.mkpath
|
||||
tab = Tab.empty
|
||||
tab.tabfile = prefix/AbstractTab::FILENAME
|
||||
@ -1688,7 +1688,7 @@ RSpec.describe Formula do
|
||||
Class.new(Testball) do
|
||||
attr_reader :test
|
||||
|
||||
def install
|
||||
define_method(:install) do
|
||||
@test = 0
|
||||
on_macos do
|
||||
@test = 1
|
||||
@ -1711,7 +1711,7 @@ RSpec.describe Formula do
|
||||
Class.new(Testball) do
|
||||
attr_reader :test
|
||||
|
||||
def install
|
||||
define_method(:install) do
|
||||
@test = 0
|
||||
on_macos do
|
||||
@test = 1
|
||||
@ -1735,7 +1735,7 @@ RSpec.describe Formula do
|
||||
attr_reader :foo
|
||||
attr_reader :bar
|
||||
|
||||
def install
|
||||
define_method(:install) do
|
||||
@foo = 0
|
||||
@bar = 0
|
||||
on_system :linux, macos: :monterey do
|
||||
@ -1794,7 +1794,7 @@ RSpec.describe Formula do
|
||||
Class.new(Testball) do
|
||||
attr_reader :test
|
||||
|
||||
def install
|
||||
define_method(:install) do
|
||||
@test = 0
|
||||
on_monterey :or_newer do
|
||||
@test = 1
|
||||
@ -1854,7 +1854,7 @@ RSpec.describe Formula do
|
||||
Class.new(Testball) do
|
||||
attr_reader :test
|
||||
|
||||
def install
|
||||
define_method(:install) do
|
||||
@test = 0
|
||||
on_arm do
|
||||
@test = 1
|
||||
@ -1881,7 +1881,7 @@ RSpec.describe Formula do
|
||||
Class.new(Testball) do
|
||||
attr_reader :test
|
||||
|
||||
def install
|
||||
define_method(:install) do
|
||||
@test = 0
|
||||
on_arm do
|
||||
@test = 1
|
||||
@ -1902,7 +1902,7 @@ RSpec.describe Formula do
|
||||
describe "#generate_completions_from_executable" do
|
||||
let(:f) do
|
||||
Class.new(Testball) do
|
||||
def install
|
||||
define_method(:install) do
|
||||
bin.mkpath
|
||||
(bin/"foo").write <<-EOF
|
||||
echo completion
|
||||
|
@ -14,7 +14,7 @@ RSpec.describe Formula do
|
||||
end.to raise_error(FormulaValidationError)
|
||||
end
|
||||
|
||||
def supports_block_expectations?
|
||||
define_method(:supports_block_expectations?) do
|
||||
true
|
||||
end
|
||||
end
|
||||
@ -22,7 +22,8 @@ RSpec.describe Formula do
|
||||
it "can't override the `brew` method" do
|
||||
expect do
|
||||
formula do
|
||||
def brew; end
|
||||
define_method(:brew) do
|
||||
end
|
||||
end
|
||||
end.to raise_error(RuntimeError, /\AThe method `brew` on #{described_class} was declared as final/)
|
||||
end
|
||||
|
@ -289,7 +289,7 @@ RSpec.describe Formulary do
|
||||
end
|
||||
|
||||
context "with the API" do
|
||||
def formula_json_contents(extra_items = {})
|
||||
define_method(:formula_json_contents) do |extra_items = {}|
|
||||
{
|
||||
formula_name => {
|
||||
"desc" => "testball",
|
||||
|
@ -295,13 +295,13 @@ RSpec.describe GitHubRunnerMatrix, :no_api do
|
||||
end
|
||||
end
|
||||
|
||||
def get_runner_names(runner_matrix, predicate = :active)
|
||||
define_method(:get_runner_names) do |runner_matrix, predicate = :active|
|
||||
runner_matrix.runners
|
||||
.select(&predicate)
|
||||
.map { |runner| runner.spec.name }
|
||||
end
|
||||
|
||||
def setup_test_runner_formula(name, dependencies = [], **kwargs)
|
||||
define_method(:setup_test_runner_formula) do |name, dependencies = [], **kwargs|
|
||||
f = formula name do
|
||||
url "https://brew.sh/#{name}-1.0.tar.gz"
|
||||
dependencies.each { |dependency| depends_on dependency }
|
||||
|
@ -5,7 +5,7 @@ require "installed_dependents"
|
||||
RSpec.describe InstalledDependents do
|
||||
include FileUtils
|
||||
|
||||
def stub_formula(name, version = "1.0", &block)
|
||||
define_method(:stub_formula) do |name, version = "1.0", &block|
|
||||
f = formula(name) do
|
||||
url "#{name}-#{version}"
|
||||
|
||||
@ -16,7 +16,7 @@ RSpec.describe InstalledDependents do
|
||||
f
|
||||
end
|
||||
|
||||
def setup_test_keg(name, version, &block)
|
||||
define_method(:setup_test_keg) do |name, version, &block|
|
||||
stub_formula("gcc")
|
||||
stub_formula("glibc")
|
||||
stub_formula(name, version, &block)
|
||||
@ -39,7 +39,7 @@ RSpec.describe InstalledDependents do
|
||||
end
|
||||
|
||||
describe "::find_some_installed_dependents" do
|
||||
def setup_test_keg(name, version, &block)
|
||||
define_method(:setup_test_keg) do |_name, _version|
|
||||
keg = super
|
||||
Tab.create(keg.to_formula, DevelopmentTools.default_compiler, :libcxx).write
|
||||
keg
|
||||
@ -50,7 +50,7 @@ RSpec.describe InstalledDependents do
|
||||
keg_only_keg.optlink
|
||||
end
|
||||
|
||||
def alter_tab(keg)
|
||||
define_method(:alter_tab) do |keg|
|
||||
tab = keg.tab
|
||||
yield tab
|
||||
tab.write
|
||||
@ -58,7 +58,7 @@ RSpec.describe InstalledDependents do
|
||||
|
||||
# 1.1.6 is the earliest version of Homebrew that generates correct runtime
|
||||
# dependency lists in {Tab}s.
|
||||
def tab_dependencies(keg, deps, homebrew_version: "1.1.6")
|
||||
define_method(:tab_dependencies) do |keg, deps, homebrew_version: "1.1.6"|
|
||||
alter_tab(keg) do |tab|
|
||||
tab.homebrew_version = homebrew_version
|
||||
tab.tabfile = keg/AbstractTab::FILENAME
|
||||
@ -66,7 +66,7 @@ RSpec.describe InstalledDependents do
|
||||
end
|
||||
end
|
||||
|
||||
def unreliable_tab_dependencies(keg, deps)
|
||||
define_method(:unreliable_tab_dependencies) do |keg, deps|
|
||||
# 1.1.5 is (hopefully!) the last version of Homebrew that generates
|
||||
# incorrect runtime dependency lists in {Tab}s.
|
||||
tab_dependencies(keg, deps, homebrew_version: "1.1.5")
|
||||
@ -174,7 +174,7 @@ RSpec.describe InstalledDependents do
|
||||
expect(described_class.find_some_installed_dependents([keg_only_keg])).to eq([[keg_only_keg], ["bar"]])
|
||||
end
|
||||
|
||||
def stub_cask_name(name, version, dependency)
|
||||
define_method(:stub_cask_name) do |name, version, dependency|
|
||||
c = Cask::CaskLoader.load(<<-RUBY)
|
||||
cask "#{name}" do
|
||||
version "#{version}"
|
||||
@ -188,7 +188,7 @@ RSpec.describe InstalledDependents do
|
||||
c
|
||||
end
|
||||
|
||||
def setup_test_cask(name, version, dependency)
|
||||
define_method(:setup_test_cask) do |name, version, dependency|
|
||||
c = stub_cask_name(name, version, dependency)
|
||||
Cask::Caskroom.path.join(name, c.version).mkpath
|
||||
c
|
||||
|
@ -13,7 +13,7 @@ RSpec.describe Keg do
|
||||
dir.mkpath
|
||||
end
|
||||
|
||||
def setup_binary_file
|
||||
define_method(:setup_binary_file) do
|
||||
binary_file.atomic_write <<~EOS
|
||||
\x00#{dir}\x00
|
||||
EOS
|
||||
|
@ -13,7 +13,7 @@ RSpec.describe Keg do
|
||||
dir.mkpath
|
||||
end
|
||||
|
||||
def setup_text_file
|
||||
define_method(:setup_text_file) do
|
||||
text_file.atomic_write <<~EOS
|
||||
#{dir}/file.txt
|
||||
/foo#{dir}/file.txt
|
||||
@ -23,7 +23,7 @@ RSpec.describe Keg do
|
||||
EOS
|
||||
end
|
||||
|
||||
def setup_binary_file
|
||||
define_method(:setup_binary_file) do
|
||||
binary_file.atomic_write <<~EOS
|
||||
\x00
|
||||
EOS
|
||||
|
@ -14,7 +14,7 @@ RSpec.describe Keg::Relocation do
|
||||
let(:escaped_prefix) { /(?:(?<=-F|-I|-L|-isystem)|(?<![a-zA-Z0-9]))#{Regexp.escape(HOMEBREW_PREFIX)}/o }
|
||||
let(:escaped_cellar) { /(?:(?<=-F|-I|-L|-isystem)|(?<![a-zA-Z0-9]))#{HOMEBREW_CELLAR}/o }
|
||||
|
||||
def setup_relocation
|
||||
define_method(:setup_relocation) do
|
||||
relocation = described_class.new
|
||||
relocation.add_replacement_pair :prefix, prefix, prefix_placeholder, path: true
|
||||
relocation.add_replacement_pair :cellar, /#{cellar}/o, cellar_placeholder, path: true
|
||||
|
@ -13,7 +13,7 @@ RSpec.describe Keg do
|
||||
(HOMEBREW_CELLAR/"foo/1.0.0").mkpath
|
||||
end
|
||||
|
||||
def setup_file(placeholders: false)
|
||||
define_method(:setup_file) do |placeholders: false|
|
||||
path = placeholders ? placeholder : dir
|
||||
file.atomic_write <<~EOS
|
||||
#{path}/file.txt
|
||||
@ -24,7 +24,7 @@ RSpec.describe Keg do
|
||||
EOS
|
||||
end
|
||||
|
||||
def setup_relocation(placeholders: false)
|
||||
define_method(:setup_relocation) do |placeholders: false|
|
||||
relocation = described_class::Relocation.new
|
||||
|
||||
if placeholders
|
||||
|
@ -6,7 +6,7 @@ require "stringio"
|
||||
RSpec.describe Keg do
|
||||
include FileUtils
|
||||
|
||||
def setup_test_keg(name, version)
|
||||
define_method(:setup_test_keg) do |name, version|
|
||||
path = HOMEBREW_CELLAR/name/version
|
||||
(path/"bin").mkpath
|
||||
|
||||
|
@ -6,7 +6,7 @@ require "bundle_version"
|
||||
RSpec.describe Homebrew::Livecheck::Strategy::Sparkle do
|
||||
subject(:sparkle) { described_class }
|
||||
|
||||
def create_appcast_xml(items_str = "")
|
||||
define_method(:create_appcast_xml) do |items_str = ""|
|
||||
<<~EOS
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:sparkle="http://www.andymatuschak.org/xml-namespaces/sparkle">
|
||||
|
@ -8,7 +8,7 @@ RSpec.describe Pathname do
|
||||
let(:sho_without_runpath_rpath) { elf_dir/"libhello.so.0" }
|
||||
let(:exec) { elf_dir/"hello_with_rpath" }
|
||||
|
||||
def patch_elfs
|
||||
define_method(:patch_elfs) do
|
||||
mktmpdir do |tmp_dir|
|
||||
%w[c.elf].each do |elf|
|
||||
FileUtils.cp(elf_dir/elf, tmp_dir/elf)
|
||||
|
@ -13,7 +13,7 @@
|
||||
#
|
||||
# For indeterminable cases, consult https://opensource.apple.com for the version used.
|
||||
RSpec.describe "pkg-config", :needs_ci, type: :system do
|
||||
def pc_version(library)
|
||||
define_method(:pc_version) do |library|
|
||||
path = HOMEBREW_LIBRARY_PATH/"os/mac/pkgconfig/#{MacOS.version}/#{library}.pc"
|
||||
version = File.foreach(path)
|
||||
.lazy
|
||||
|
@ -25,7 +25,7 @@ RSpec.describe "patching", type: :system do
|
||||
end
|
||||
end
|
||||
|
||||
def formula(name = "formula_name", path: Formulary.core_path(name), spec: :stable, alias_path: nil, &block)
|
||||
define_method(:formula) do |name = "formula_name", path: Formulary.core_path(name), spec: :stable, alias_path: nil, &block|
|
||||
formula_subclass.class_eval(&block)
|
||||
formula_subclass.new(name, path, spec, alias_path:)
|
||||
end
|
||||
|
@ -5,7 +5,7 @@ require "rubocops/patches"
|
||||
RSpec.describe RuboCop::Cop::FormulaAudit::Patches do
|
||||
subject(:cop) { described_class.new }
|
||||
|
||||
def expect_offense_hash(message:, severity:, line:, column:, source:)
|
||||
define_method(:expect_offense_hash) do |message:, severity:, line:, column:, source:|
|
||||
[{ message:, severity:, line:, column:, source: }]
|
||||
end
|
||||
|
||||
|
@ -12,7 +12,7 @@ RSpec.describe RuboCop::Cop::FormulaAuditStrict::MakeCheck do
|
||||
(path/"style_exceptions").mkpath
|
||||
end
|
||||
|
||||
def setup_style_exceptions
|
||||
define_method(:setup_style_exceptions) do
|
||||
(path/"style_exceptions/make_check_allowlist.json").write <<~JSON
|
||||
[ "bar" ]
|
||||
JSON
|
||||
|
@ -37,7 +37,7 @@ RSpec.describe Sandbox, :needs_macos do
|
||||
url "https://brew.sh/foo-1.0.tar.gz"
|
||||
version "1.0"
|
||||
|
||||
def initialize(*, **)
|
||||
define_method(:initialize) do |*, **|
|
||||
super
|
||||
@name = "foo)bar"
|
||||
end
|
||||
@ -53,7 +53,7 @@ RSpec.describe Sandbox, :needs_macos do
|
||||
url "https://brew.sh/foo-1.0.tar.gz"
|
||||
version "1.0"
|
||||
|
||||
def initialize(*, **)
|
||||
define_method(:initialize) do |*, **|
|
||||
super
|
||||
@name = "foo\"bar"
|
||||
end
|
||||
|
@ -6,7 +6,7 @@ require "service"
|
||||
RSpec.describe Homebrew::Service do
|
||||
let(:name) { "formula_name" }
|
||||
|
||||
def stub_formula(&block)
|
||||
define_method(:stub_formula) do |&block|
|
||||
formula(name) do
|
||||
url "https://brew.sh/test-1.0.tbz"
|
||||
|
||||
@ -14,7 +14,7 @@ RSpec.describe Homebrew::Service do
|
||||
end
|
||||
end
|
||||
|
||||
def stub_formula_with_service_sockets(sockets_var)
|
||||
define_method(:stub_formula_with_service_sockets) do |sockets_var|
|
||||
stub_formula do
|
||||
service do
|
||||
run opt_bin/"beanstalkd"
|
||||
|
@ -9,7 +9,7 @@ RSpec.describe Homebrew::Settings do
|
||||
end
|
||||
end
|
||||
|
||||
def setup_setting
|
||||
define_method(:setup_setting) do
|
||||
HOMEBREW_REPOSITORY.cd do
|
||||
system "git", "config", "--replace-all", "homebrew.foo", "true"
|
||||
end
|
||||
|
@ -17,7 +17,7 @@ RSpec.shared_context "integration test" do # rubocop:disable RSpec/ContextWordin
|
||||
status.success?
|
||||
end
|
||||
|
||||
def supports_block_expectations?
|
||||
define_method(:supports_block_expectations?) do
|
||||
true
|
||||
end
|
||||
|
||||
@ -37,7 +37,7 @@ RSpec.shared_context "integration test" do # rubocop:disable RSpec/ContextWordin
|
||||
# }.to output(something).to_stdout
|
||||
# }.to be_a_success
|
||||
#
|
||||
def expects_call_stack_jump?
|
||||
define_method(:expects_call_stack_jump?) do
|
||||
true
|
||||
end
|
||||
end
|
||||
@ -55,14 +55,14 @@ RSpec.shared_context "integration test" do # rubocop:disable RSpec/ContextWordin
|
||||
|
||||
# Generate unique ID to be able to
|
||||
# properly merge coverage results.
|
||||
def command_id
|
||||
define_method(:command_id) do
|
||||
Thread.current[:brew_integration_test_number] ||= 0
|
||||
"#{ENV.fetch("TEST_ENV_NUMBER", "")}:#{Thread.current[:brew_integration_test_number] += 1}"
|
||||
end
|
||||
|
||||
# Runs a `brew` command with the test configuration
|
||||
# and with coverage reporting enabled.
|
||||
def brew(*args)
|
||||
define_method(:brew) do |*args|
|
||||
env = args.last.is_a?(Hash) ? args.pop : {}
|
||||
|
||||
# Avoid warnings when HOMEBREW_PREFIX/bin is not in PATH.
|
||||
@ -119,7 +119,7 @@ RSpec.shared_context "integration test" do # rubocop:disable RSpec/ContextWordin
|
||||
end
|
||||
end
|
||||
|
||||
def brew_sh(*args)
|
||||
define_method(:brew_sh) do |*args|
|
||||
env = {
|
||||
"HOMEBREW_USE_RUBY_FROM_PATH" => ENV.fetch("HOMEBREW_USE_RUBY_FROM_PATH", nil),
|
||||
}
|
||||
@ -131,8 +131,7 @@ RSpec.shared_context "integration test" do # rubocop:disable RSpec/ContextWordin
|
||||
end
|
||||
end
|
||||
|
||||
def setup_test_formula(name, content = nil, tap: CoreTap.instance,
|
||||
bottle_block: nil, tab_attributes: nil)
|
||||
define_method(:setup_test_formula) do |name, content = nil, tap: CoreTap.instance, bottle_block: nil, tab_attributes: nil|
|
||||
case name
|
||||
when /^testball/
|
||||
# Use a different tarball for testball2 to avoid lock errors when writing concurrency tests
|
||||
@ -205,7 +204,7 @@ RSpec.shared_context "integration test" do # rubocop:disable RSpec/ContextWordin
|
||||
formula_path
|
||||
end
|
||||
|
||||
def install_test_formula(name, content = nil, build_bottle: false)
|
||||
define_method(:install_test_formula) do |name, content = nil, build_bottle: false|
|
||||
setup_test_formula(name, content)
|
||||
fi = FormulaInstaller.new(Formula[name], build_bottle:, installed_on_request: true)
|
||||
fi.prelude
|
||||
@ -214,7 +213,7 @@ RSpec.shared_context "integration test" do # rubocop:disable RSpec/ContextWordin
|
||||
fi.finish
|
||||
end
|
||||
|
||||
def setup_test_tap
|
||||
define_method(:setup_test_tap) do
|
||||
path = HOMEBREW_TAP_DIRECTORY/"homebrew/homebrew-foo"
|
||||
path.mkpath
|
||||
path.cd do
|
||||
@ -227,7 +226,7 @@ RSpec.shared_context "integration test" do # rubocop:disable RSpec/ContextWordin
|
||||
path
|
||||
end
|
||||
|
||||
def setup_remote_tap(name)
|
||||
define_method(:setup_remote_tap) do |name|
|
||||
Tap.fetch(name).tap do |tap|
|
||||
next if tap.installed?
|
||||
|
||||
@ -243,7 +242,7 @@ RSpec.shared_context "integration test" do # rubocop:disable RSpec/ContextWordin
|
||||
end
|
||||
end
|
||||
|
||||
def install_and_rename_coretap_formula(old_name, new_name)
|
||||
define_method(:install_and_rename_coretap_formula) do |old_name, new_name|
|
||||
CoreTap.instance.path.cd do |tap_path|
|
||||
system "git", "init"
|
||||
system "git", "add", "--all"
|
||||
@ -261,7 +260,7 @@ RSpec.shared_context "integration test" do # rubocop:disable RSpec/ContextWordin
|
||||
end
|
||||
end
|
||||
|
||||
def testball
|
||||
define_method(:testball) do
|
||||
"#{TEST_FIXTURE_DIR}/testball.rb"
|
||||
end
|
||||
end
|
||||
|
@ -24,7 +24,7 @@ RSpec.describe Tap do
|
||||
(path/"style_exceptions").mkpath
|
||||
end
|
||||
|
||||
def setup_tap_files
|
||||
define_method(:setup_tap_files) do
|
||||
formula_file.dirname.mkpath
|
||||
formula_file.write <<~RUBY
|
||||
class Foo < Formula
|
||||
@ -80,7 +80,7 @@ RSpec.describe Tap do
|
||||
chmod 0755, cmd_file
|
||||
end
|
||||
|
||||
def setup_git_repo
|
||||
define_method(:setup_git_repo) do
|
||||
path.cd do
|
||||
system "git", "init"
|
||||
system "git", "remote", "add", "origin", "https://github.com/Homebrew/homebrew-foo"
|
||||
@ -89,7 +89,7 @@ RSpec.describe Tap do
|
||||
end
|
||||
end
|
||||
|
||||
def setup_completion(link:)
|
||||
define_method(:setup_completion) do |link:|
|
||||
HOMEBREW_REPOSITORY.cd do
|
||||
system "git", "init"
|
||||
system "git", "config", "--replace-all", "homebrew.linkcompletions", link.to_s
|
||||
|
@ -403,7 +403,7 @@ RSpec.describe TestRunnerFormula do
|
||||
end
|
||||
end
|
||||
|
||||
def setup_test_formula(name, dependencies = [], **kwargs)
|
||||
define_method(:setup_test_formula) do |name, dependencies = [], **kwargs|
|
||||
formula name do
|
||||
url "https://brew.sh/#{name}-1.0.tar.gz"
|
||||
dependencies.each { |dependency| depends_on dependency }
|
||||
|
@ -50,7 +50,7 @@ RSpec.describe Utils::Backtrace do
|
||||
backtrace_with_sorbet_paths.drop(1)
|
||||
end
|
||||
|
||||
def exception_with(backtrace:)
|
||||
define_method(:exception_with) do |backtrace:|
|
||||
exception = StandardError.new
|
||||
exception.set_backtrace(backtrace) if backtrace
|
||||
exception
|
||||
|
@ -29,7 +29,7 @@ RSpec.describe SharedAudits do
|
||||
JSON
|
||||
end
|
||||
|
||||
def mock_curl_output(stdout: "", success: true)
|
||||
define_method(:mock_curl_output) do |stdout: "", success: true|
|
||||
status = instance_double(Process::Status, success?: success)
|
||||
curl_output = instance_double(SystemCommand::Result, stdout:, status:)
|
||||
allow(Utils::Curl).to receive(:curl_output).and_return curl_output
|
||||
|
@ -48,7 +48,7 @@ module Homebrew
|
||||
if rack.directory?
|
||||
versions = rack.subdirs.map(&:basename)
|
||||
puts <<~EOS
|
||||
#{keg.name} #{versions.to_sentence} #{(versions.one?) ? "is" : "are"} still installed.
|
||||
#{keg.name} #{versions.to_sentence} #{versions.one? ? "is" : "are"} still installed.
|
||||
To remove all versions, run:
|
||||
brew uninstall --force #{keg.name}
|
||||
EOS
|
||||
@ -133,7 +133,7 @@ module Homebrew
|
||||
def output
|
||||
ofail <<~EOS
|
||||
Refusing to uninstall #{reqs.to_sentence}
|
||||
because #{(reqs.one?) ? "it" : "they"} #{are_required_by_deps}.
|
||||
because #{reqs.one? ? "it" : "they"} #{are_required_by_deps}.
|
||||
You can override this and force removal with:
|
||||
#{sample_command}
|
||||
EOS
|
||||
@ -146,8 +146,8 @@ module Homebrew
|
||||
end
|
||||
|
||||
def are_required_by_deps
|
||||
"#{(reqs.one?) ? "is" : "are"} required by #{deps.to_sentence}, " \
|
||||
"which #{(deps.one?) ? "is" : "are"} currently installed"
|
||||
"#{reqs.one? ? "is" : "are"} required by #{deps.to_sentence}, " \
|
||||
"which #{deps.one? ? "is" : "are"} currently installed"
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -445,7 +445,7 @@ module Utils
|
||||
format "%#{index_width}s", index_header
|
||||
formatted_name_with_options_header =
|
||||
format "%-#{name_with_options_width}s",
|
||||
name_with_options_header[0..name_with_options_width-1]
|
||||
name_with_options_header[0..(name_with_options_width-1)]
|
||||
formatted_count_header =
|
||||
format "%#{count_width}s", count_header
|
||||
formatted_percent_header =
|
||||
@ -464,7 +464,7 @@ module Utils
|
||||
formatted_index = format "%-#{index_width}s", formatted_index
|
||||
formatted_name_with_options =
|
||||
format "%-#{name_with_options_width}s",
|
||||
name_with_options[0..name_with_options_width-1]
|
||||
name_with_options[0..(name_with_options_width-1)]
|
||||
formatted_count = format "%#{count_width}s", format_count(count)
|
||||
formatted_percent = if total_count.zero?
|
||||
format "%#{percent_width}s", format_percent(0)
|
||||
|
@ -776,6 +776,6 @@ class Version
|
||||
|
||||
sig { params(first: Integer, second: Integer).returns(Integer) }
|
||||
def max(first, second)
|
||||
(first > second) ? first : second
|
||||
[first, second].max
|
||||
end
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user