sorbet: Use T.bind(self, T.class_of(Formula)) a bunch more in tests

- So that Formula class methods like `keg_only` and `url` can be used in
  more typechecked tests.
- Set the `RSpec/DescribedClass` RuboCop rule to have config `SkipBlocks`
  because Sorbet errors on `T.bind(self, T.class_of(described_class))`,
  because it should be a full class name reference.
This commit is contained in:
Issy Long
2026-06-09 10:33:38 +01:00
parent c74bbec51c
commit af837abb59
40 changed files with 516 additions and 40 deletions
+3
View File
@@ -16,6 +16,9 @@ RSpec/ContextWording:
- which
- to
RSpec/DescribedClass:
SkipBlocks: true
# RSpec helper methods typecheck better as regular methods.
Sorbet/BlockMethodDefinition:
Enabled: false
+13 -3
View File
@@ -285,7 +285,10 @@ RSpec.describe Homebrew::Bundle::Brew do
# don't try to load gcc/glibc
allow(DevelopmentTools).to receive_messages(needs_libc_formula?: false, needs_compiler_formula?: false)
stub_formula_loader formula(formula_name) { url "mysql-1.0" }
stub_formula_loader formula(formula_name) {
T.bind(self, T.class_of(Formula))
url "mysql-1.0"
}
end
context "when the formula is installed" do
@@ -455,6 +458,7 @@ RSpec.describe Homebrew::Bundle::Brew do
context "when the conflicts_with option is provided" do
before do
stub_formula_loader formula(formula_name) {
T.bind(self, T.class_of(Formula))
url "mysql-1.0"
conflicts_with "mysql55"
}
@@ -660,8 +664,14 @@ RSpec.describe Homebrew::Bundle::Brew do
requirements: [],
},
])
stub_formula_loader formula("foo") { url "foo-1.0" }
stub_formula_loader formula("bar") { url "bar-1.0" }
stub_formula_loader formula("foo") {
T.bind(self, T.class_of(Formula))
url "foo-1.0"
}
stub_formula_loader formula("bar") {
T.bind(self, T.class_of(Formula))
url "bar-1.0"
}
end
it "returns result" do
+6 -1
View File
@@ -28,7 +28,12 @@ RSpec.describe Cask::Tab, :cask do
end
let(:time) { Time.now.to_i }
let(:f) { formula { url "foo-1.0" } }
let(:f) do
formula do
T.bind(self, T.class_of(Formula))
url "foo-1.0"
end
end
matcher :be_installed_on_request do
match do |actual|
+30 -2
View File
@@ -7,7 +7,12 @@ require "caveats"
RSpec.describe Caveats do
subject(:caveats) { described_class.new(f) }
let(:f) { formula { url "foo-1.0" } }
let(:f) do
formula do
T.bind(self, T.class_of(Formula))
url "foo-1.0"
end
end
specify "#f" do
expect(caveats.formula).to eq(f)
@@ -20,6 +25,7 @@ RSpec.describe Caveats do
it "returns false if the Formula has caveats" do
f = formula do
T.bind(self, T.class_of(Formula))
url "foo-1.0"
def caveats
@@ -39,6 +45,7 @@ RSpec.describe Caveats do
it "gives information about service" do
f = formula do
T.bind(self, T.class_of(Formula))
url "foo-1.0"
service do
run [bin/"php", "test"]
@@ -53,6 +60,7 @@ RSpec.describe Caveats do
it "prints warning when no service daemon is found" do
f = formula do
T.bind(self, T.class_of(Formula))
url "foo-1.0"
service do
run [bin/"cmd"]
@@ -65,6 +73,7 @@ RSpec.describe Caveats do
it "prints service startup information when service.require_root is true" do
f = formula do
T.bind(self, T.class_of(Formula))
url "foo-1.0"
service do
run [bin/"cmd"]
@@ -77,6 +86,7 @@ RSpec.describe Caveats do
it "prints service login information" do
f = formula do
T.bind(self, T.class_of(Formula))
url "foo-1.0"
service do
run [bin/"cmd"]
@@ -88,6 +98,7 @@ RSpec.describe Caveats do
it "gives information about require_root restarting services after upgrade" do
f = formula do
T.bind(self, T.class_of(Formula))
url "foo-1.0"
service do
run [bin/"cmd"]
@@ -101,6 +112,7 @@ RSpec.describe Caveats do
it "gives information about user restarting services after upgrade" do
f = formula do
T.bind(self, T.class_of(Formula))
url "foo-1.0"
service do
run [bin/"cmd"]
@@ -113,6 +125,7 @@ RSpec.describe Caveats do
it "gives information about require_root starting services after upgrade" do
f = formula do
T.bind(self, T.class_of(Formula))
url "foo-1.0"
service do
run [bin/"cmd"]
@@ -126,6 +139,7 @@ RSpec.describe Caveats do
it "gives information about user starting services after upgrade" do
f = formula do
T.bind(self, T.class_of(Formula))
url "foo-1.0"
service do
run [bin/"cmd"]
@@ -138,6 +152,7 @@ RSpec.describe Caveats do
it "gives information about service manual command" do
f = formula do
T.bind(self, T.class_of(Formula))
url "foo-1.0"
service do
run [bin/"cmd", "start"]
@@ -153,6 +168,7 @@ RSpec.describe Caveats do
it "prints info when there are custom service files" do
f = formula do
T.bind(self, T.class_of(Formula))
url "foo-1.0"
service do
name macos: "custom.mxcl.foo", linux: "custom.foo"
@@ -167,6 +183,7 @@ RSpec.describe Caveats do
context "when f.keg_only is not nil" do
let(:f) do
formula do
T.bind(self, T.class_of(Formula))
url "foo-1.0"
keg_only "some reason"
end
@@ -218,6 +235,7 @@ RSpec.describe Caveats do
context "when joining different caveat types together" do
let(:f) do
formula do
T.bind(self, T.class_of(Formula))
url "foo-1.0"
keg_only "some reason"
@@ -244,7 +262,12 @@ RSpec.describe Caveats do
end
describe "PATH shadowing" do
let(:f) { formula { url "foo-1.0" } }
let(:f) do
formula do
T.bind(self, T.class_of(Formula))
url "foo-1.0"
end
end
before do
Pathname.new(f.opt_bin).mkpath
@@ -280,6 +303,7 @@ RSpec.describe Caveats do
it "does not warn for keg-only formulae" do
keg_only_f = formula do
T.bind(self, T.class_of(Formula))
url "foo-1.0"
keg_only "some reason"
end
@@ -294,6 +318,7 @@ RSpec.describe Caveats do
it "does not warn when the queried formula itself is not installed" do
uninstalled_f = formula("foo@old") do
T.bind(self, T.class_of(Formula))
url "foo-1.0"
keg_only :versioned_formula
end
@@ -317,6 +342,7 @@ RSpec.describe Caveats do
it "warns for a keg-only formula when a sibling keg is linked over it" do
keg_only_f = formula("foo@1.0") do
T.bind(self, T.class_of(Formula))
url "foo-1.0"
keg_only :versioned_formula
end
@@ -342,6 +368,7 @@ RSpec.describe Caveats do
it "warns when a keg-only formula has been linked" do
keg_only_f = formula do
T.bind(self, T.class_of(Formula))
url "foo-1.0"
keg_only "some reason"
end
@@ -426,6 +453,7 @@ RSpec.describe Caveats do
describe "shell completions" do
let(:f) do
formula do
T.bind(self, T.class_of(Formula))
url "foo-1.0"
end
end
@@ -6,6 +6,7 @@ require "formula"
RSpec.describe Formula do
def formula(&block)
super do
T.bind(self, T.class_of(Formula))
url "file://#{TEST_FIXTURE_DIR}/tarballs/testball-0.1.tbz"
instance_eval(&block)
end
@@ -26,7 +26,12 @@ RSpec.describe Homebrew::Cmd::Bundle::AddSubcommand do
let(:file) { "/tmp/some_random_brewfile#{Random.rand(2 ** 16)}" }
before do
stub_formula_loader formula("hello") { url "hello-1.0" }
stub_formula_loader(
formula("hello") do
T.bind(self, T.class_of(Formula))
url "hello-1.0"
end,
)
end
it "adds entries to the given Brewfile" do
@@ -128,7 +128,10 @@ RSpec.describe Homebrew::Cmd::Bundle::CleanupSubcommand do
tap_name = Utils.tap_from_full_name(full_name)
name = Utils.name_from_full_name(full_name)
tap = (Tap.fetch(tap_name) if tap_name.present?)
f = formula(name, tap:) { url "#{name}-1.0" }
f = formula(name, tap:) do
T.bind(self, T.class_of(Formula))
url "#{name}-1.0"
end
stub_formula_loader f, full_name
end
end
@@ -175,7 +178,10 @@ RSpec.describe Homebrew::Cmd::Bundle::CleanupSubcommand do
full_name = hash_formula[:full_name]
tap_name = Utils.tap_from_full_name(full_name) || "homebrew/core"
tap = Tap.fetch(tap_name)
f = formula(name, tap:) { url "#{name}-1.0" }
f = formula(name, tap:) do
T.bind(self, T.class_of(Formula))
url "#{name}-1.0"
end
stub_formula_loader f, full_name
end
@@ -203,7 +209,10 @@ RSpec.describe Homebrew::Cmd::Bundle::CleanupSubcommand do
allow(Homebrew::Bundle::Brew).to receive(:formulae).and_return([
{ name: "foo", full_name: "homebrew/tap/foo", dependencies: [], build_dependencies: [] },
])
stub_formula_loader formula("foo", tap: Tap.fetch("homebrew/tap")) { url "foo-1.0" }, "homebrew/tap/foo"
stub_formula_loader formula("foo", tap: Tap.fetch("homebrew/tap")) {
T.bind(self, T.class_of(Formula))
url "foo-1.0"
}, "homebrew/tap/foo"
allow(Homebrew::Bundle::Tap).to \
receive(:tap_names).and_return(%w[homebrew/core homebrew/tap])
@@ -244,7 +253,10 @@ RSpec.describe Homebrew::Cmd::Bundle::CleanupSubcommand do
it "ignores formulae with .keepme references when computing which formulae to uninstall" do
name = full_name ="c"
allow(Homebrew::Bundle::Brew).to receive(:formulae).and_return([{ name:, full_name: }])
f = formula(name) { url "#{name}-1.0" }
f = formula(name) do
T.bind(self, T.class_of(Formula))
url "#{name}-1.0"
end
stub_formula_loader f, name
keg = instance_double(Keg)
@@ -23,8 +23,14 @@ RSpec.describe Homebrew::Cmd::Bundle::ExecSubcommand do
# don't try to load gcc/glibc
allow(DevelopmentTools).to receive_messages(needs_libc_formula?: false, needs_compiler_formula?: false)
stub_formula_loader formula("openssl") { url "openssl-1.0" }
stub_formula_loader formula("pkgconf") { url "pkgconf-1.0" }
stub_formula_loader formula("openssl") {
T.bind(self, T.class_of(Formula))
url "openssl-1.0"
}
stub_formula_loader formula("pkgconf") {
T.bind(self, T.class_of(Formula))
url "pkgconf-1.0"
}
ENV.extend(Superenv)
allow(ENV).to receive(:setup_build_environment)
end
@@ -123,7 +129,10 @@ RSpec.describe Homebrew::Cmd::Bundle::ExecSubcommand do
let(:brewfile_contents) { "brew 'zlib'" }
before do
stub_formula_loader formula("zlib") { url "zlib-1.0" }
stub_formula_loader formula("zlib") {
T.bind(self, T.class_of(Formula))
url "zlib-1.0"
}
end
shared_examples "allows command execution" do |command|
@@ -144,7 +153,10 @@ RSpec.describe Homebrew::Cmd::Bundle::ExecSubcommand do
let(:brewfile_contents) { "brew 'rbenv'" }
before do
stub_formula_loader formula("rbenv") { url "rbenv-1.0" }
stub_formula_loader formula("rbenv") {
T.bind(self, T.class_of(Formula))
url "rbenv-1.0"
}
ENV["HOMEBREW_RBENV_ROOT"] = rbenv_root.to_s
end
@@ -212,7 +224,10 @@ RSpec.describe Homebrew::Cmd::Bundle::ExecSubcommand do
stub_formula_loader(nginx_formula, "nginx")
stub_formula_loader(redis_formula, "redis")
pkgconf = formula("pkgconf") { url "pkgconf-1.0" }
pkgconf = formula("pkgconf") do
T.bind(self, T.class_of(Formula))
url "pkgconf-1.0"
end
stub_formula_loader(pkgconf)
allow(pkgconf).to receive(:any_version_installed?).and_return(false)
+51
View File
@@ -16,6 +16,7 @@ RSpec.describe Homebrew::Cmd::Info do
def installed_info_formula
test_formula = formula("testball") do
T.bind(self, T.class_of(Formula))
url "https://brew.sh/testball-0.1.tar.gz"
desc "Some test"
end
@@ -38,6 +39,7 @@ RSpec.describe Homebrew::Cmd::Info do
it "prints as json with the --json=v1 flag" do
test_formula = formula("testball") do
T.bind(self, T.class_of(Formula))
url "https://brew.sh/testball-0.1.tar.gz"
desc "Some test"
end
@@ -200,6 +202,7 @@ RSpec.describe Homebrew::Cmd::Info do
it "prints quiet formula information in the slim inventory format" do
info = described_class.new([])
formula = formula("testball") do
T.bind(self, T.class_of(Formula))
url "https://brew.sh/testball-0.1.tar.gz"
desc "Some test"
end
@@ -217,6 +220,7 @@ RSpec.describe Homebrew::Cmd::Info do
it "uses slim formula information when quiet is passed" do
test_formula = formula("testball") do
T.bind(self, T.class_of(Formula))
url "https://brew.sh/testball-0.1.tar.gz"
desc "Some test"
end
@@ -233,6 +237,7 @@ RSpec.describe Homebrew::Cmd::Info do
info = described_class.new([])
formula = formula("testball") do
T.bind(self, T.class_of(Formula))
url "https://brew.sh/testball-0.1.tar.gz"
homepage "https://brew.sh/testball"
desc "Some test"
@@ -282,6 +287,7 @@ RSpec.describe Homebrew::Cmd::Info do
info = described_class.new([])
formula = formula("testball") do
T.bind(self, T.class_of(Formula))
url "https://brew.sh/testball-0.1.tar.gz"
desc "Some test"
deprecate! date: "2024-01-01", because: :versioned_formula
@@ -299,6 +305,7 @@ RSpec.describe Homebrew::Cmd::Info do
info = described_class.new([])
formula = formula("testball") do
T.bind(self, T.class_of(Formula))
url "https://brew.sh/testball-0.1.tar.gz"
desc "Some test"
disable! date: "2024-01-01", because: :unmaintained
@@ -376,6 +383,7 @@ RSpec.describe Homebrew::Cmd::Info do
shadowing_tap = Tap.fetch("homebrew/core")
allow(formula).to receive(:tap).and_return(shadowing_tap)
keg_formula = formula("testball") do
T.bind(self, T.class_of(Formula))
url "https://brew.sh/testball-0.1.tar.gz"
end
allow(Formulary).to receive(:factory).with("ataraxy-labs/tap/testball").and_return(keg_formula)
@@ -424,6 +432,7 @@ RSpec.describe Homebrew::Cmd::Info do
it "warns about a shadowing tap when info_formula is given one" do
info = described_class.new([])
formula = formula("testball") do
T.bind(self, T.class_of(Formula))
url "https://brew.sh/testball-0.1.tar.gz"
end
allow(info).to receive(:github_info).with(formula).and_return("https://example.com/testball.rb")
@@ -437,6 +446,7 @@ RSpec.describe Homebrew::Cmd::Info do
it "treats a `tap/name` input as user-qualified" do
info = described_class.new([])
formula = formula("testball") do
T.bind(self, T.class_of(Formula))
url "https://brew.sh/testball-0.1.tar.gz"
end
allow(formula).to receive(:tap).and_return(Tap.fetch("homebrew/core"))
@@ -448,6 +458,7 @@ RSpec.describe Homebrew::Cmd::Info do
it "treats a bare unqualified input as not user-qualified" do
info = described_class.new([])
formula = formula("testball") do
T.bind(self, T.class_of(Formula))
url "https://brew.sh/testball-0.1.tar.gz"
end
@@ -466,6 +477,7 @@ RSpec.describe Homebrew::Cmd::Info do
allow(shadowed_formula).to receive(:tap).and_return(Tap.fetch("homebrew/core"))
installed_formula = formula("testball") do
T.bind(self, T.class_of(Formula))
url "https://brew.sh/testball-0.1.tar.gz"
end
allow(installed_formula).to receive(:tap).and_return(Tap.fetch("ataraxy-labs/tap"))
@@ -506,6 +518,7 @@ RSpec.describe Homebrew::Cmd::Info do
info = described_class.new([])
formula = formula("testball") do
T.bind(self, T.class_of(Formula))
url "https://brew.sh/testball-0.1.tar.gz"
homepage "https://brew.sh/testball"
desc "Some test"
@@ -561,6 +574,7 @@ RSpec.describe Homebrew::Cmd::Info do
info = described_class.new(["--verbose"])
formula = formula("testball") do
T.bind(self, T.class_of(Formula))
url "https://brew.sh/testball-0.1.tar.gz"
homepage "https://brew.sh/testball"
desc "Some test"
@@ -597,6 +611,7 @@ RSpec.describe Homebrew::Cmd::Info do
info = described_class.new([])
formula = formula("testball") do
T.bind(self, T.class_of(Formula))
url "https://brew.sh/testball-0.1.tar.gz"
homepage "https://brew.sh/testball"
desc "Some test"
@@ -633,6 +648,7 @@ RSpec.describe Homebrew::Cmd::Info do
info = described_class.new([])
formula = formula("testball") do
T.bind(self, T.class_of(Formula))
url "https://brew.sh/testball-0.1.tar.gz"
desc "Some test"
@@ -659,6 +675,7 @@ RSpec.describe Homebrew::Cmd::Info do
info = described_class.new([])
formula = formula("testball") do
T.bind(self, T.class_of(Formula))
url "https://brew.sh/testball-0.1.tar.gz"
desc "Some test"
@@ -695,6 +712,7 @@ RSpec.describe Homebrew::Cmd::Info do
info = described_class.new([])
formula = formula("testball") do
T.bind(self, T.class_of(Formula))
url "https://brew.sh/testball-0.1.tar.gz"
desc "Some test"
@@ -731,6 +749,7 @@ RSpec.describe Homebrew::Cmd::Info do
info = described_class.new([])
formula = formula("testball") do
T.bind(self, T.class_of(Formula))
url "https://brew.sh/testball-0.1.tar.gz"
desc "Some test"
@@ -760,6 +779,7 @@ RSpec.describe Homebrew::Cmd::Info do
info = described_class.new([])
formula = formula("testball") do
T.bind(self, T.class_of(Formula))
url "https://brew.sh/testball-0.1.tar.gz"
desc "Some test"
@@ -789,6 +809,7 @@ RSpec.describe Homebrew::Cmd::Info do
info = described_class.new([])
formula = formula("testball") do
T.bind(self, T.class_of(Formula))
url "https://brew.sh/testball-0.1.tar.gz"
desc "Some test"
@@ -818,6 +839,7 @@ RSpec.describe Homebrew::Cmd::Info do
info = described_class.new([])
formula = formula("testball") do
T.bind(self, T.class_of(Formula))
url "https://brew.sh/testball-0.1.tar.gz"
desc "Some test"
@@ -837,6 +859,7 @@ RSpec.describe Homebrew::Cmd::Info do
info = described_class.new([])
formula = formula("testball") do
T.bind(self, T.class_of(Formula))
url "https://brew.sh/testball-0.1.tar.gz"
desc "Some test"
@@ -863,6 +886,7 @@ RSpec.describe Homebrew::Cmd::Info do
info = described_class.new([])
formula = formula("testball") do
T.bind(self, T.class_of(Formula))
url "https://brew.sh/testball-0.1.tar.gz"
desc "Some test"
@@ -895,6 +919,7 @@ RSpec.describe Homebrew::Cmd::Info do
info = described_class.new([])
formula = formula("testball") do
T.bind(self, T.class_of(Formula))
url "https://brew.sh/testball-0.1.tar.gz"
homepage "https://brew.sh/testball"
desc "Some test"
@@ -922,6 +947,7 @@ RSpec.describe Homebrew::Cmd::Info do
it "shows the installed and stable versions in the headline when outdated" do
info = described_class.new([])
formula = formula("testball") do
T.bind(self, T.class_of(Formula))
url "https://brew.sh/testball-0.1.tar.gz"
homepage "https://brew.sh/testball"
desc "Some test"
@@ -945,6 +971,7 @@ RSpec.describe Homebrew::Cmd::Info do
info = described_class.new([])
formula = formula("testball") do
T.bind(self, T.class_of(Formula))
url "https://brew.sh/testball-0.1.tar.gz"
homepage "https://brew.sh/testball"
desc "Some test"
@@ -966,6 +993,7 @@ RSpec.describe Homebrew::Cmd::Info do
info = described_class.new([])
formula = formula("testball") do
T.bind(self, T.class_of(Formula))
url "https://brew.sh/testball-0.1.tar.gz"
homepage "https://brew.sh/testball"
desc "Some test"
@@ -985,6 +1013,7 @@ RSpec.describe Homebrew::Cmd::Info do
it "prints a Binaries section listing executables in bin and sbin with --verbose" do
info = described_class.new(["--verbose"])
formula = formula("testball") do
T.bind(self, T.class_of(Formula))
url "https://brew.sh/testball-0.1.tar.gz"
homepage "https://brew.sh/testball"
desc "Some test"
@@ -1013,6 +1042,7 @@ RSpec.describe Homebrew::Cmd::Info do
it "prints a Binaries section from the bottle manifest when the formula is not installed with --verbose" do
info = described_class.new(["--verbose"])
formula = formula("testball") do
T.bind(self, T.class_of(Formula))
url "https://brew.sh/testball-0.1.tar.gz"
homepage "https://brew.sh/testball"
desc "Some test"
@@ -1036,6 +1066,7 @@ RSpec.describe Homebrew::Cmd::Info do
it "omits the Binaries section without --verbose" do
info = described_class.new([])
formula = formula("testball") do
T.bind(self, T.class_of(Formula))
url "https://brew.sh/testball-0.1.tar.gz"
homepage "https://brew.sh/testball"
desc "Some test"
@@ -1061,6 +1092,7 @@ RSpec.describe Homebrew::Cmd::Info do
it "omits the Binaries section when no executables are installed" do
info = described_class.new(["--verbose"])
formula = formula("testball") do
T.bind(self, T.class_of(Formula))
url "https://brew.sh/testball-0.1.tar.gz"
homepage "https://brew.sh/testball"
desc "Some test"
@@ -1097,6 +1129,7 @@ RSpec.describe Homebrew::Cmd::Info do
it "returns summary lines for pinned formulae" do
test_formula = formula("testball") do
T.bind(self, T.class_of(Formula))
url "https://brew.sh/testball-1.0"
end
allow(test_formula).to receive_messages(any_version_installed?: true, pinned?: true, pinned_version: "1.0")
@@ -1157,6 +1190,7 @@ RSpec.describe Homebrew::Cmd::Info do
it "lists aliases on their own row when the formula has any" do
info = described_class.new([])
main_formula = formula("testball") do
T.bind(self, T.class_of(Formula))
url "https://brew.sh/testball-1.0.tar.gz"
end
allow(main_formula).to receive_messages(aliases: ["testball@1.0", "tball", "googleball"], oldnames: [])
@@ -1171,6 +1205,7 @@ RSpec.describe Homebrew::Cmd::Info do
it "renders aliases and old names on separate rows when both exist" do
info = described_class.new([])
main_formula = formula("testball") do
T.bind(self, T.class_of(Formula))
url "https://brew.sh/testball-1.0.tar.gz"
end
allow(main_formula).to receive_messages(aliases: ["testball@1.0", "tball"], oldnames: ["foo", "bar"])
@@ -1184,6 +1219,7 @@ RSpec.describe Homebrew::Cmd::Info do
it "renders only an Old Names row when there are no aliases" do
info = described_class.new([])
main_formula = formula("testball") do
T.bind(self, T.class_of(Formula))
url "https://brew.sh/testball-1.0.tar.gz"
end
allow(main_formula).to receive_messages(aliases: [], oldnames: ["foo"])
@@ -1198,6 +1234,7 @@ RSpec.describe Homebrew::Cmd::Info do
it "omits both rows when there are none" do
info = described_class.new([])
main_formula = formula("testball") do
T.bind(self, T.class_of(Formula))
url "https://brew.sh/testball-1.0.tar.gz"
end
allow(main_formula).to receive_messages(aliases: [], oldnames: [])
@@ -1214,9 +1251,11 @@ RSpec.describe Homebrew::Cmd::Info do
it "lists this formula alongside installed sibling versioned formulae" do
info = described_class.new([])
main_formula = formula("testball") do
T.bind(self, T.class_of(Formula))
url "https://brew.sh/testball-1.0.tar.gz"
end
versioned = formula("testball@0.9") do
T.bind(self, T.class_of(Formula))
url "https://brew.sh/testball-0.9.tar.gz"
keg_only :versioned_formula
end
@@ -1248,6 +1287,7 @@ RSpec.describe Homebrew::Cmd::Info do
it "shows installed → latest only on the newest installed keg of an outdated formula" do
info = described_class.new([])
main_formula = formula("testball") do
T.bind(self, T.class_of(Formula))
url "https://brew.sh/testball-2.0.tar.gz"
version "2.0"
end
@@ -1276,9 +1316,11 @@ RSpec.describe Homebrew::Cmd::Info do
it "marks the currently linked version with `*`" do
info = described_class.new([])
main_formula = formula("testball") do
T.bind(self, T.class_of(Formula))
url "https://brew.sh/testball-1.0.tar.gz"
end
versioned = formula("testball@0.9") do
T.bind(self, T.class_of(Formula))
url "https://brew.sh/testball-0.9.tar.gz"
keg_only :versioned_formula
end
@@ -1309,10 +1351,12 @@ RSpec.describe Homebrew::Cmd::Info do
it "includes the unversioned parent when run on a versioned formula" do
info = described_class.new([])
versioned = formula("testball@0.9") do
T.bind(self, T.class_of(Formula))
url "https://brew.sh/testball-0.9.tar.gz"
keg_only :versioned_formula
end
parent = formula("testball") do
T.bind(self, T.class_of(Formula))
url "https://brew.sh/testball-1.0.tar.gz"
end
@@ -1344,6 +1388,7 @@ RSpec.describe Homebrew::Cmd::Info do
it "renders the section even when only the current formula is installed" do
info = described_class.new([])
main_formula = formula("testball") do
T.bind(self, T.class_of(Formula))
url "https://brew.sh/testball-1.0.tar.gz"
end
@@ -1364,10 +1409,12 @@ RSpec.describe Homebrew::Cmd::Info do
it "renders the section when the queried formula is uninstalled but a sibling is installed" do
info = described_class.new([])
versioned = formula("testball@0.9") do
T.bind(self, T.class_of(Formula))
url "https://brew.sh/testball-0.9.tar.gz"
keg_only :versioned_formula
end
parent = formula("testball") do
T.bind(self, T.class_of(Formula))
url "https://brew.sh/testball-1.0.tar.gz"
end
@@ -1390,6 +1437,7 @@ RSpec.describe Homebrew::Cmd::Info do
it "lists every installed keg of a formula, newest first" do
info = described_class.new([])
main_formula = formula("testball") do
T.bind(self, T.class_of(Formula))
url "https://brew.sh/testball-1.0.tar.gz"
end
@@ -1417,6 +1465,7 @@ RSpec.describe Homebrew::Cmd::Info do
it "omits the section when nothing in the family is installed" do
info = described_class.new([])
main_formula = formula("testball") do
T.bind(self, T.class_of(Formula))
url "https://brew.sh/testball-1.0.tar.gz"
end
allow(main_formula).to receive(:versioned_formulae).and_return([])
@@ -1436,6 +1485,7 @@ RSpec.describe Homebrew::Cmd::Info do
# so it gets loaded from the keg's `.brew/` directory by `FromKegLoader`.
keg_formula_path = HOMEBREW_CELLAR/"testball/0.1/.brew/testball.rb"
formula_instance = formula("testball", path: keg_formula_path, tap:) do
T.bind(self, T.class_of(Formula))
url "https://brew.sh/testball-0.1.tar.gz"
end
@@ -1446,6 +1496,7 @@ RSpec.describe Homebrew::Cmd::Info do
it "returns a GitHub URL for a formula whose file lives inside its tap" do
formula_path = tap.new_formula_path("testball")
formula_instance = formula("testball", path: formula_path, tap:) do
T.bind(self, T.class_of(Formula))
url "https://brew.sh/testball-0.1.tar.gz"
end
+2
View File
@@ -9,6 +9,7 @@ RSpec.describe Homebrew::Cmd::Link do
it "uses formula-aware conflict handling when linking a Formula" do
formula = formula "testball" do
T.bind(self, T.class_of(Formula))
url "foo-1.0"
end
keg = instance_double(Keg, rack: HOMEBREW_CELLAR/"testball", linked?: false, name: "testball")
@@ -43,6 +44,7 @@ RSpec.describe Homebrew::Cmd::Link do
}.each do |formula_type, formula_name|
it "does not print keg-only output when linking a #{formula_type} formula" do
test_formula = formula(formula_name) do
T.bind(self, T.class_of(Formula))
url "https://brew.sh/#{formula_name}-1.0"
keg_only :versioned_formula
+1
View File
@@ -39,6 +39,7 @@ RSpec.describe Homebrew::Cmd::Untap do
Formulary.factory(path)
else
formula(name, tap:) do
T.bind(self, T.class_of(Formula))
url "https://brew.sh/#{name}-1.0.tgz"
end
end
+16
View File
@@ -332,6 +332,7 @@ RSpec.describe Homebrew::Cmd::UpgradeCmd do
it "asks before upgrading formulae that resolve from a different name" do
formula = formula("testball") do
T.bind(self, T.class_of(Formula))
url "https://brew.sh/testball-0.2"
end
cmd = described_class.new(["--ask", "oldtestball"])
@@ -362,6 +363,7 @@ RSpec.describe Homebrew::Cmd::UpgradeCmd do
it "prints formula download sizes in dry-run upgrade summaries" do
cmd = described_class.new(["--dry-run"])
formula = formula("testball") do
T.bind(self, T.class_of(Formula))
url "https://brew.sh/testball-0.2"
end
bottle = instance_double(Bottle, fetch_tab: nil, bottle_size: 500)
@@ -376,9 +378,11 @@ RSpec.describe Homebrew::Cmd::UpgradeCmd do
it "prints dry-run cleanup output from one formula cleanup run" do
formula = formula("testball") do
T.bind(self, T.class_of(Formula))
url "https://brew.sh/testball-0.2"
end
other_formula = formula("otherball") do
T.bind(self, T.class_of(Formula))
url "https://brew.sh/otherball-0.2"
end
@@ -404,9 +408,11 @@ RSpec.describe Homebrew::Cmd::UpgradeCmd do
it "omits dry-run dependencies already listed in the final summary" do
formula = formula("yt-dlp") do
T.bind(self, T.class_of(Formula))
url "https://brew.sh/yt-dlp-2026.3.17_2.tar.gz"
end
dependency_formula = formula("python@3.14") do
T.bind(self, T.class_of(Formula))
url "https://brew.sh/python@3.14-3.14.5.tar.gz"
end
formula_installer = FormulaInstaller.new(formula)
@@ -426,9 +432,11 @@ RSpec.describe Homebrew::Cmd::UpgradeCmd do
it "omits dry-run dependents already listed in the final summary" do
formula = formula("sqlite") do
T.bind(self, T.class_of(Formula))
url "https://brew.sh/sqlite-3.53.1.tar.gz"
end
dependent = formula("python@3.14") do
T.bind(self, T.class_of(Formula))
url "https://brew.sh/python@3.14-3.14.5.tar.gz"
end
dependants = Homebrew::Upgrade::Dependents.new(upgradeable: [dependent], pinned: [], skipped: [])
@@ -669,6 +677,7 @@ RSpec.describe Homebrew::Cmd::UpgradeCmd do
it "prints a bottle manifest heading before formula prefetches" do
cmd = described_class.new([])
formula = formula("deno") do
T.bind(self, T.class_of(Formula))
url "https://brew.sh/deno-2.7.11.tar.gz"
bottle do
@@ -690,6 +699,7 @@ RSpec.describe Homebrew::Cmd::UpgradeCmd do
it "omits the bottle manifest heading for cached formula manifests" do
cmd = described_class.new([])
formula = formula("deno") do
T.bind(self, T.class_of(Formula))
url "https://brew.sh/deno-2.7.11.tar.gz"
bottle do
@@ -811,20 +821,25 @@ RSpec.describe Homebrew::Cmd::UpgradeCmd do
it "records final formula upgrade summary details" do
formula = formula("testball") do
T.bind(self, T.class_of(Formula))
url "https://brew.sh/testball-0.2"
end
pinned = formula("pinnedball") do
T.bind(self, T.class_of(Formula))
url "https://brew.sh/pinnedball-1.0"
end
deprecated = formula("oldball") do
T.bind(self, T.class_of(Formula))
url "https://brew.sh/oldball-1.0"
deprecate! date: "2020-01-01", because: :unmaintained
end
disabled = formula("disabledball") do
T.bind(self, T.class_of(Formula))
url "https://brew.sh/disabledball-1.0"
disable! date: "2020-01-01", because: :unsupported
end
source_build = formula("sourceball") do
T.bind(self, T.class_of(Formula))
url "https://brew.sh/sourceball-1.0"
end
old_keg = HOMEBREW_CELLAR/"testball/0.1"
@@ -856,6 +871,7 @@ RSpec.describe Homebrew::Cmd::UpgradeCmd do
it "records formula upgrade versions before upgrading" do
formula = formula("testball") do
T.bind(self, T.class_of(Formula))
url "https://brew.sh/testball-0.2"
end
old_keg = HOMEBREW_CELLAR/"testball/0.1"
@@ -6,6 +6,7 @@ require "dependencies_helpers"
RSpec.describe DependenciesHelpers do
specify "#dependents" do
foo = formula "foo" do
T.bind(self, T.class_of(Formula))
url "foo"
version "1.0"
end
@@ -16,6 +17,7 @@ RSpec.describe DependenciesHelpers do
RUBY
bar = formula "bar" do
T.bind(self, T.class_of(Formula))
url "bar-url"
version "1.0"
end
@@ -10,6 +10,7 @@ RSpec.describe Homebrew::DevCmd::BumpFormulaPr do
let(:f) do
formula("test") do
T.bind(self, T.class_of(Formula))
url "https://brew.sh/test-1.2.3.tgz"
end
end
@@ -66,6 +67,7 @@ RSpec.describe Homebrew::DevCmd::BumpFormulaPr do
let(:f_throttle) do
formula("throttle-test") do
T.bind(self, T.class_of(Formula))
url "https://brew.sh/test-1.2.3.tgz"
livecheck do
@@ -76,6 +78,7 @@ RSpec.describe Homebrew::DevCmd::BumpFormulaPr do
let(:f_throttle_days) do
formula("throttle-days-test") do
T.bind(self, T.class_of(Formula))
url "https://brew.sh/test-1.2.3.tgz"
livecheck do
@@ -86,6 +89,7 @@ RSpec.describe Homebrew::DevCmd::BumpFormulaPr do
let(:f_throttle_rate_and_days) do
formula("throttle-rate-and-days-test") do
T.bind(self, T.class_of(Formula))
url "https://brew.sh/test-1.2.3.tgz"
livecheck do
@@ -16,6 +16,7 @@ RSpec.describe Homebrew::DevCmd::Linkage do
it "accepts no_linkage dependency tag" do
expect(formula("testball") do
T.bind(self, T.class_of(Formula))
url "file://#{TEST_FIXTURE_DIR}/tarballs/testball-0.1.tbz"
sha256 TESTBALL_SHA256
+20 -2
View File
@@ -1039,6 +1039,7 @@ RSpec.describe Homebrew::FormulaAuditor do
let(:f_openssl) do
formula do
T.bind(self, T.class_of(Formula))
url "https://brew.sh/openssl-1.0.tgz"
homepage "https://brew.sh"
@@ -1071,6 +1072,7 @@ RSpec.describe Homebrew::FormulaAuditor do
let(:f_bc) do
formula do
T.bind(self, T.class_of(Formula))
url "https://brew.sh/bc-1.0.tgz"
homepage "https://brew.sh"
@@ -1107,6 +1109,7 @@ RSpec.describe Homebrew::FormulaAuditor do
end
let(:f_bar) do
formula do
T.bind(self, T.class_of(Formula))
url "https://brew.sh/bar-1.0.tgz"
homepage "https://brew.sh"
end
@@ -1173,6 +1176,7 @@ RSpec.describe Homebrew::FormulaAuditor do
let(:tag) { "with-debug" }
let(:f_bar) do
formula do
T.bind(self, T.class_of(Formula))
url "https://brew.sh/bar-1.0.tgz"
homepage "https://brew.sh"
option "with-debug"
@@ -1837,6 +1841,7 @@ RSpec.describe Homebrew::FormulaAuditor do
specify "it warns when conflicting with non-existing formula", :no_api do
foo = formula("foo") do
T.bind(self, T.class_of(Formula))
url "https://brew.sh/bar-1.0.tgz"
conflicts_with "bar"
@@ -1851,6 +1856,7 @@ RSpec.describe Homebrew::FormulaAuditor do
specify "it warns when conflicting with itself", :no_api do
foo = formula("foo") do
T.bind(self, T.class_of(Formula))
url "https://brew.sh/bar-1.0.tgz"
conflicts_with "foo"
@@ -1865,15 +1871,27 @@ RSpec.describe Homebrew::FormulaAuditor do
end
specify "it warns when another formula does not have a symmetric conflict", :no_api do
stub_formula_loader formula("gcc") { url "gcc-1.0" }
stub_formula_loader formula("glibc") { url "glibc-1.0" }
stub_formula_loader(
formula("gcc") do
T.bind(self, T.class_of(Formula))
url "gcc-1.0"
end,
)
stub_formula_loader(
formula("glibc") do
T.bind(self, T.class_of(Formula))
url "glibc-1.0"
end,
)
foo = formula("foo") do
T.bind(self, T.class_of(Formula))
url "https://brew.sh/foo-1.0.tgz"
end
stub_formula_loader foo
bar = formula("bar") do
T.bind(self, T.class_of(Formula))
url "https://brew.sh/bar-1.0.tgz"
conflicts_with "foo"
@@ -22,8 +22,18 @@ RSpec.describe FormulaInstaller do
expect(formula).to be_bottled
expect(formula).to pour_bottle
stub_formula_loader formula("gcc") { url "gcc-1.0" }
stub_formula_loader formula("glibc") { url "glibc-1.0" }
stub_formula_loader(
formula("gcc") do
T.bind(self, T.class_of(Formula))
url "gcc-1.0"
end,
)
stub_formula_loader(
formula("glibc") do
T.bind(self, T.class_of(Formula))
url "glibc-1.0"
end,
)
stub_formula_loader formula
fi = FormulaInstaller.new(formula)
@@ -89,6 +89,7 @@ RSpec.describe FormulaInstaller do
describe "#build_bottle_postinstall" do
let(:f) do
formula "bottle-config" do
T.bind(self, T.class_of(Formula))
url "foo-1.0"
end
end
@@ -138,6 +139,7 @@ RSpec.describe FormulaInstaller do
describe "#fetch_bottle_tab" do
it "does not enqueue cached bottle manifests" do
formula = formula("deno") do
T.bind(self, T.class_of(Formula))
url "https://brew.sh/deno-2.7.11.tar.gz"
bottle do
@@ -163,6 +165,7 @@ RSpec.describe FormulaInstaller do
it "enqueues invalid cached bottle manifests" do
formula = formula("deno") do
T.bind(self, T.class_of(Formula))
url "https://brew.sh/deno-2.7.11.tar.gz"
bottle do
@@ -192,6 +195,7 @@ RSpec.describe FormulaInstaller do
describe "linking defaults" do
it "links non-keg-only formulae when link_keg is false" do
ordinary_formula = formula "homebrew-link-default" do
T.bind(self, T.class_of(Formula))
url "foo-1.0"
end
@@ -200,6 +204,7 @@ RSpec.describe FormulaInstaller do
it "links non-keg-only dependencies even when they were not previously linked" do
dependency_formula = formula "homebrew-link-default-dependency" do
T.bind(self, T.class_of(Formula))
url "foo-1.0"
end
dependency = instance_double(Dependency, to_formula: dependency_formula, name: dependency_formula.name,
@@ -231,6 +236,7 @@ RSpec.describe FormulaInstaller do
it "disables Bubblewrap auto-install until the implicit Bubblewrap dependency is installed" do
formula = formula "homebrew-bubblewrap-bootstrap-target" do
T.bind(self, T.class_of(Formula))
url "foo-1.0"
end
installer = described_class.new(formula)
@@ -260,6 +266,7 @@ RSpec.describe FormulaInstaller do
let(:formula_name) { "#{base_name}@1.0" }
let(:keg_only_formula) do
formula formula_name do
T.bind(self, T.class_of(Formula))
url "foo-1.0"
keg_only :versioned_formula
end
@@ -300,6 +307,7 @@ RSpec.describe FormulaInstaller do
it "does not link by default when another @-versioned formula is installed" do
other_version = formula "#{base_name}@2.0" do
T.bind(self, T.class_of(Formula))
url "foo-2.0"
keg_only :versioned_formula
end
@@ -313,6 +321,7 @@ RSpec.describe FormulaInstaller do
it "does not link by default when the unversioned sibling is installed" do
unversioned_formula = formula base_name do
T.bind(self, T.class_of(Formula))
url "foo-1.0"
end
allow(unversioned_formula).to receive(:any_version_installed?).and_return(true)
@@ -325,6 +334,7 @@ RSpec.describe FormulaInstaller do
it "does not link by default when the unversioned sibling is keg-only" do
unversioned_formula = formula base_name do
T.bind(self, T.class_of(Formula))
url "foo-1.0"
keg_only "some reason"
end
@@ -337,6 +347,7 @@ RSpec.describe FormulaInstaller do
it "does not link by default when the -full variant is installed" do
full_variant = formula "#{base_name}-full" do
T.bind(self, T.class_of(Formula))
url "foo-full-1.0"
keg_only :versioned_formula
end
@@ -350,10 +361,12 @@ RSpec.describe FormulaInstaller do
it "does not link by default when the non-full variant is installed" do
full_formula = formula "#{base_name}-full" do
T.bind(self, T.class_of(Formula))
url "foo-full-1.0"
keg_only :versioned_formula
end
non_full_variant = formula base_name do
T.bind(self, T.class_of(Formula))
url "foo-1.0"
keg_only :versioned_formula
end
@@ -370,12 +383,14 @@ RSpec.describe FormulaInstaller do
describe "#link" do
let(:versioned_formula) do
formula "homebrew-versioned-formula@1.0" do
T.bind(self, T.class_of(Formula))
url "foo-1.0"
keg_only :versioned_formula
end
end
let(:other_version) do
formula "homebrew-versioned-formula" do
T.bind(self, T.class_of(Formula))
url "foo-2.0"
keg_only :versioned_formula
end
@@ -420,6 +435,7 @@ RSpec.describe FormulaInstaller do
let(:formula_name) { "#{base_name}@1.0" }
let(:keg_only_formula) do
formula formula_name do
T.bind(self, T.class_of(Formula))
url "foo-1.0"
keg_only :versioned_formula
end
@@ -427,6 +443,7 @@ RSpec.describe FormulaInstaller do
it "explains why a versioned formula was installed but not linked" do
unversioned_formula = formula base_name do
T.bind(self, T.class_of(Formula))
url "foo-1.0"
end
allow(unversioned_formula).to receive_messages(any_version_installed?: true, linked?: true)
@@ -513,6 +530,7 @@ RSpec.describe FormulaInstaller do
dependency = Formulary.factory(dep_name)
dependent = formula do
T.bind(self, T.class_of(Formula))
url "foo"
version "0.5"
depends_on dependency.name.to_s
@@ -1001,6 +1019,7 @@ RSpec.describe FormulaInstaller do
formula_path = mktmpdir/"homebrew-local-formula.rb"
FileUtils.touch formula_path
formula = formula("homebrew-local-formula", path: formula_path) do
T.bind(self, T.class_of(Formula))
url "foo"
version "1.0"
end
+149 -5
View File
@@ -106,6 +106,7 @@ RSpec.describe Formula do
describe "#follow_installed_alias?" do
let(:f) do
formula do
T.bind(self, T.class_of(Formula))
url "foo-1.0"
end
end
@@ -128,12 +129,14 @@ RSpec.describe Formula do
describe "#versioned_formula?" do
let(:f) do
formula "foo" do
T.bind(self, T.class_of(Formula))
url "foo-1.0"
end
end
let(:f2) do
formula "foo@2.0" do
T.bind(self, T.class_of(Formula))
url "foo-2.0"
end
end
@@ -147,24 +150,28 @@ RSpec.describe Formula do
describe "#versioned_formulae" do
let(:f) do
formula "foo" do
T.bind(self, T.class_of(Formula))
url "foo-1.0"
end
end
let(:f2) do
formula "foo@2.0" do
T.bind(self, T.class_of(Formula))
url "foo-2.0"
end
end
let(:f_full) do
formula "foo-full" do
T.bind(self, T.class_of(Formula))
url "foo-full-1.0"
end
end
let(:f_full2) do
formula "foo@2.0-full" do
T.bind(self, T.class_of(Formula))
url "foo-full-2.0"
end
end
@@ -203,24 +210,28 @@ RSpec.describe Formula do
describe "#full_formulae_names" do
let(:f) do
formula "foo" do
T.bind(self, T.class_of(Formula))
url "foo-1.0"
end
end
let(:f_full) do
formula "foo-full" do
T.bind(self, T.class_of(Formula))
url "foo-full-1.0"
end
end
let(:f_versioned) do
formula "foo@2.0" do
T.bind(self, T.class_of(Formula))
url "foo-2.0"
end
end
let(:f_versioned_full) do
formula "foo@2.0-full" do
T.bind(self, T.class_of(Formula))
url "foo-full-2.0"
end
end
@@ -240,6 +251,7 @@ RSpec.describe Formula do
allow(f_versioned_full).to receive(:tap).and_return(nil)
FileUtils.touch f_versioned_full.path
f_versioned_with_full = formula "foo@2.0" do
T.bind(self, T.class_of(Formula))
url "foo-2.0"
end
allow(f_versioned_with_full).to receive(:tap).and_return(nil)
@@ -252,12 +264,14 @@ RSpec.describe Formula do
describe "#full_formulae" do
let(:f) do
formula "foo" do
T.bind(self, T.class_of(Formula))
url "foo-1.0"
end
end
let(:f_full) do
formula "foo-full" do
T.bind(self, T.class_of(Formula))
url "foo-full-1.0"
end
end
@@ -278,18 +292,21 @@ RSpec.describe Formula do
describe "#unversioned_formula_name" do
let(:f) do
formula "foo" do
T.bind(self, T.class_of(Formula))
url "foo-1.0"
end
end
let(:f_full) do
formula "foo@2.0-full" do
T.bind(self, T.class_of(Formula))
url "foo-full-2.0"
end
end
let(:f_versioned) do
formula "foo@2.0" do
T.bind(self, T.class_of(Formula))
url "foo-2.0"
end
end
@@ -304,9 +321,11 @@ RSpec.describe Formula do
describe "#link_overwrite_reason" do
it "explains why a formula was not linked" do
f = formula "foo@2.0" do
T.bind(self, T.class_of(Formula))
url "foo-2.0"
end
other_formula = formula "foo" do
T.bind(self, T.class_of(Formula))
url "foo-1.0"
end
allow(other_formula).to receive_messages(any_version_installed?: true, linked?: true)
@@ -319,9 +338,11 @@ RSpec.describe Formula do
describe "#link_overwrite_formulae" do
it "deduplicates formulae shared by an alias and canonical name" do
f = formula "foo@2.0" do
T.bind(self, T.class_of(Formula))
url "foo-2.0"
end
other_formula = formula "foo@1.0" do
T.bind(self, T.class_of(Formula))
url "foo-1.0"
end
allow(f).to receive(:link_overwrite_formulae_names).and_return(["foo", "foo@1.0"])
@@ -335,24 +356,28 @@ RSpec.describe Formula do
describe "#link_overwrite_formulae_names" do
let(:f) do
formula "foo" do
T.bind(self, T.class_of(Formula))
url "foo-1.0"
end
end
let(:f_full) do
formula "foo-full" do
T.bind(self, T.class_of(Formula))
url "foo-full-1.0"
end
end
let(:f_versioned) do
formula "foo@2.0" do
T.bind(self, T.class_of(Formula))
url "foo-2.0"
end
end
let(:f_versioned_full) do
formula "foo@2.0-full" do
T.bind(self, T.class_of(Formula))
url "foo-full-2.0"
end
end
@@ -381,12 +406,14 @@ RSpec.describe Formula do
describe "#link_overwrite?" do
let(:versioned_formula) do
formula "foo@22" do
T.bind(self, T.class_of(Formula))
url "foo-22.0"
end
end
let(:related_formula) do
formula "foo" do
T.bind(self, T.class_of(Formula))
url "foo-1.0"
end
end
@@ -430,6 +457,7 @@ RSpec.describe Formula do
it "returns false for unrelated keg names" do
unrelated_formula = formula "bar" do
T.bind(self, T.class_of(Formula))
url "bar-1.0"
end
allow(versioned_formula).to receive(:link_overwrite_keg_name).and_return("bar")
@@ -441,6 +469,7 @@ RSpec.describe Formula do
it "allows explicit link_overwrite paths" do
formula_with_explicit_overwrite = formula "baz" do
T.bind(self, T.class_of(Formula))
url "baz-1.0"
link_overwrite "bin/baz"
end
@@ -467,6 +496,7 @@ RSpec.describe Formula do
it "returns false for missing conflicts without explicit or implied overwrites" do
formula_without_overwrites = formula "qux" do
T.bind(self, T.class_of(Formula))
url "qux-1.0"
end
allow(formula_without_overwrites).to receive_messages(link_overwrite_keg_name: :missing,
@@ -479,12 +509,14 @@ RSpec.describe Formula do
describe "#implied_link_overwrite?" do
let(:versioned_formula) do
formula "foo@22" do
T.bind(self, T.class_of(Formula))
url "foo-22.0"
end
end
let(:related_formula) do
formula "foo" do
T.bind(self, T.class_of(Formula))
url "foo-1.0"
end
end
@@ -520,6 +552,7 @@ RSpec.describe Formula do
example "installed alias with core" do
f = formula do
T.bind(self, T.class_of(Formula))
url "foo-1.0"
end
@@ -555,6 +588,7 @@ RSpec.describe Formula do
name = "foo"
path = tap.path/"Formula/#{name}.rb"
f = formula(name, path:) do
T.bind(self, T.class_of(Formula))
url "foo-1.0"
end
@@ -606,6 +640,7 @@ RSpec.describe Formula do
specify "#any_version_installed?" do
f = formula do
T.bind(self, T.class_of(Formula))
url "foo"
version "1.0"
end
@@ -669,6 +704,7 @@ RSpec.describe Formula do
describe "#latest_installed_prefix" do
let(:f) do
formula do
T.bind(self, T.class_of(Formula))
url "foo"
version "1.9"
head "foo"
@@ -770,6 +806,7 @@ RSpec.describe Formula do
alias_path = (CoreTap.instance.alias_dir/"another_name")
f = formula(alias_path:) do
T.bind(self, T.class_of(Formula))
url "foo-1.0"
end
f.build = BuildOptions.new(Options.new, f.options)
@@ -783,6 +820,7 @@ RSpec.describe Formula do
source_path = CoreTap.instance.new_formula_path("another_other_name")
f = formula(alias_path:) do
T.bind(self, T.class_of(Formula))
url "foo-1.0"
end
f.build = Tab.new(source: { "path" => source_path.to_s })
@@ -796,6 +834,7 @@ RSpec.describe Formula do
source_path = (CoreTap.instance.alias_dir/"another_other_name")
f = formula(alias_path:) do
T.bind(self, T.class_of(Formula))
url "foo-1.0"
end
f.build = Tab.new(source: { "path" => source_path.to_s })
@@ -810,6 +849,7 @@ RSpec.describe Formula do
describe "::inreplace" do
specify "raises build error on failure" do
f = formula do
T.bind(self, T.class_of(Formula))
url "https://brew.sh/test-1.0.tbz"
end
@@ -824,6 +864,7 @@ RSpec.describe Formula do
cd
EOS
f = formula do
T.bind(self, T.class_of(Formula))
url "https://brew.sh/test-1.0.tbz"
end
f.inreplace(file.path) do |s|
@@ -847,18 +888,21 @@ RSpec.describe Formula do
different_alias_path = CoreTap.instance.alias_dir/"another_alias"
formula_with_alias = formula "foo" do
T.bind(self, T.class_of(Formula))
url "foo-1.0"
end
formula_with_alias.build = Tab.empty
formula_with_alias.build.source["path"] = alias_path.to_s
formula_without_alias = formula "bar" do
T.bind(self, T.class_of(Formula))
url "bar-1.0"
end
formula_without_alias.build = Tab.empty
formula_without_alias.build.source["path"] = formula_without_alias.path.to_s
formula_with_different_alias = formula "baz" do
T.bind(self, T.class_of(Formula))
url "baz-1.0"
end
formula_with_different_alias.build = Tab.empty
@@ -882,6 +926,7 @@ RSpec.describe Formula do
specify ".url" do
f = formula do
T.bind(self, T.class_of(Formula))
url "foo-1.0"
end
@@ -890,6 +935,7 @@ RSpec.describe Formula do
specify "spec integration" do
f = formula do
T.bind(self, T.class_of(Formula))
homepage "https://brew.sh"
url "https://brew.sh/test-0.1.tbz"
@@ -909,6 +955,7 @@ RSpec.describe Formula do
specify "#active_spec=" do
f = formula do
T.bind(self, T.class_of(Formula))
url "foo"
version "1.0"
revision 1
@@ -923,6 +970,7 @@ RSpec.describe Formula do
specify "class specs are always initialized" do
f = formula do
T.bind(self, T.class_of(Formula))
url "foo-1.0"
end
@@ -940,6 +988,7 @@ RSpec.describe Formula do
specify "incomplete instance specs are not accessible" do
f = formula do
T.bind(self, T.class_of(Formula))
url "foo-1.0"
end
@@ -949,6 +998,7 @@ RSpec.describe Formula do
describe "#ensure_installed!" do
let(:f) do
formula do
T.bind(self, T.class_of(Formula))
url "foo-1.2.3"
end
end
@@ -996,6 +1046,7 @@ RSpec.describe Formula do
it "honors attributes declared before specs" do
f = formula do
T.bind(self, T.class_of(Formula))
url "foo-1.0"
depends_on "foo"
@@ -1008,6 +1059,7 @@ RSpec.describe Formula do
describe "#pkg_version" do
specify "simple version" do
f = formula do
T.bind(self, T.class_of(Formula))
url "foo-1.0.bar"
end
@@ -1016,6 +1068,7 @@ RSpec.describe Formula do
specify "version with revision" do
f = formula do
T.bind(self, T.class_of(Formula))
url "foo-1.0.bar"
revision 1
end
@@ -1025,6 +1078,7 @@ RSpec.describe Formula do
specify "head uses revisions" do
f = formula "test", spec: :head do
T.bind(self, T.class_of(Formula))
url "foo-1.0.bar"
revision 1
@@ -1037,6 +1091,7 @@ RSpec.describe Formula do
specify "#update_head_version" do
f = formula do
T.bind(self, T.class_of(Formula))
head "foo", using: :git
end
@@ -1057,6 +1112,7 @@ RSpec.describe Formula do
specify "#desc" do
f = formula do
T.bind(self, T.class_of(Formula))
desc "a formula"
url "foo-1.0"
@@ -1067,6 +1123,7 @@ RSpec.describe Formula do
specify "#post_install_defined?" do
f1 = formula do
T.bind(self, T.class_of(Formula))
url "foo-1.0"
def post_install
@@ -1075,6 +1132,7 @@ RSpec.describe Formula do
end
f2 = formula do
T.bind(self, T.class_of(Formula))
url "foo-1.0"
end
@@ -1084,6 +1142,7 @@ RSpec.describe Formula do
specify "#post_install_steps" do
f = formula do
T.bind(self, T.class_of(Formula))
url "foo-1.0"
post_install_steps do
@@ -1121,6 +1180,7 @@ RSpec.describe Formula do
specify "#post_install_steps_defined? with an empty block" do
f = formula do
T.bind(self, T.class_of(Formula))
url "foo-1.0"
# This intentionally declares no steps to test definition tracking.
@@ -1136,6 +1196,7 @@ RSpec.describe Formula do
specify "#post_install_steps_conflict?" do
f = formula do
T.bind(self, T.class_of(Formula))
url "foo-1.0"
# This intentionally declares no steps to test conflict tracking.
@@ -1152,6 +1213,7 @@ RSpec.describe Formula do
specify "#run_post_install_steps uses the versioned prefix" do
f = formula "post-install-steps-prefix" do
T.bind(self, T.class_of(Formula))
url "foo-1.0"
post_install_steps do
@@ -1176,6 +1238,7 @@ RSpec.describe Formula do
describe "#install_etc_var" do
let(:f) do
formula "config-upgrade" do
T.bind(self, T.class_of(Formula))
url "foo-2.0"
version "2.0"
end
@@ -1225,6 +1288,7 @@ RSpec.describe Formula do
specify "test fixtures" do
f1 = formula do
T.bind(self, T.class_of(Formula))
url "foo-1.0"
end
@@ -1233,6 +1297,7 @@ RSpec.describe Formula do
specify "#livecheck" do
f = formula do
T.bind(self, T.class_of(Formula))
url "https://brew.sh/test-1.0.tbz"
livecheck do
skip "foo"
@@ -1250,6 +1315,7 @@ RSpec.describe Formula do
describe "#livecheck_defined?" do
specify "no `livecheck` block defined" do
f = formula do
T.bind(self, T.class_of(Formula))
url "https://brew.sh/test-1.0.tbz"
end
@@ -1258,6 +1324,7 @@ RSpec.describe Formula do
specify "`livecheck` block defined" do
f = formula do
T.bind(self, T.class_of(Formula))
url "https://brew.sh/test-1.0.tbz"
livecheck do
regex(/test-v?(\d+(?:\.\d+)+)\.t/i)
@@ -1269,6 +1336,7 @@ RSpec.describe Formula do
specify "livecheck references Formula URL" do
f = formula do
T.bind(self, T.class_of(Formula))
homepage "https://brew.sh/test"
url "https://brew.sh/test-1.0.tbz"
@@ -1285,6 +1353,7 @@ RSpec.describe Formula do
describe "#service" do
specify "no service defined" do
f = formula do
T.bind(self, T.class_of(Formula))
url "https://brew.sh/test-1.0.tbz"
end
@@ -1293,6 +1362,7 @@ RSpec.describe Formula do
specify "service complicated" do
f = formula do
T.bind(self, T.class_of(Formula))
url "https://brew.sh/test-1.0.tbz"
service do
@@ -1310,6 +1380,7 @@ RSpec.describe Formula do
specify "service uses simple run" do
f = formula do
T.bind(self, T.class_of(Formula))
url "https://brew.sh/test-1.0.tbz"
service do
run opt_bin/"beanstalkd"
@@ -1321,6 +1392,7 @@ RSpec.describe Formula do
specify "service with only custom names" do
f = formula do
T.bind(self, T.class_of(Formula))
url "https://brew.sh/test-1.0.tbz"
service do
name macos: "custom.macos.beanstalkd", linux: "custom.linux.beanstalkd"
@@ -1334,6 +1406,7 @@ RSpec.describe Formula do
specify "service helpers return data" do
f = formula do
T.bind(self, T.class_of(Formula))
url "https://brew.sh/test-1.0.tbz"
end
@@ -1350,14 +1423,17 @@ RSpec.describe Formula do
allow(DevelopmentTools).to receive_messages(needs_libc_formula?: false, needs_compiler_formula?: false)
f1 = formula "f1" do
T.bind(self, T.class_of(Formula))
url "f1-1.0"
end
f2 = formula "f2" do
T.bind(self, T.class_of(Formula))
url "f2-1.0"
end
f3 = formula "f3" do
T.bind(self, T.class_of(Formula))
url "f3-1.0"
depends_on "f1" => :build
@@ -1365,6 +1441,7 @@ RSpec.describe Formula do
end
f4 = formula "f4" do
T.bind(self, T.class_of(Formula))
url "f4-1.0"
depends_on "f1"
@@ -1376,6 +1453,7 @@ RSpec.describe Formula do
stub_formula_loader(f4)
f5 = formula "f5" do
T.bind(self, T.class_of(Formula))
url "f5-1.0"
depends_on "f3" => :build
@@ -1398,9 +1476,16 @@ RSpec.describe Formula do
allow(Formulary).to receive(:loader_for).with("foo/bar/f1", from: nil).and_return(tap_loader)
f2_path = Tap.fetch("baz", "qux").path/"Formula/f2.rb"
stub_formula_loader(formula("f2", path: f2_path) { url("f2-1.0") }, "baz/qux/f2")
stub_formula_loader(
formula("f2", path: f2_path) do
T.bind(self, T.class_of(Formula))
url("f2-1.0")
end,
"baz/qux/f2",
)
f3 = formula "f3" do
T.bind(self, T.class_of(Formula))
url "f3-1.0"
depends_on "foo/bar/f1" => :optional
@@ -1412,7 +1497,13 @@ RSpec.describe Formula do
described_class.clear_cache
f1_path = Tap.fetch("foo", "bar").path/"Formula/f1.rb"
stub_formula_loader(formula("f1", path: f1_path) { url("f1-1.0") }, "foo/bar/f1")
stub_formula_loader(
formula("f1", path: f1_path) do
T.bind(self, T.class_of(Formula))
url("f1-1.0")
end,
"foo/bar/f1",
)
f3.build = BuildOptions.new(Options.create(["--with-f1"]), f3.options)
@@ -1421,7 +1512,10 @@ RSpec.describe Formula do
it "includes non-declared direct dependencies" do
formula = Class.new(Testball).new
dependency = formula("dependency") { url "f-1.0" }
dependency = formula("dependency") do
T.bind(self, T.class_of(Formula))
url "f-1.0"
end
formula.brew { formula.install }
keg = Keg.for(formula.latest_installed_prefix)
@@ -1449,7 +1543,12 @@ RSpec.describe Formula do
end
describe "#missing_dependencies" do
let(:f) { formula("foo") { url "foo-1.0" } }
let(:f) do
formula("foo") do
T.bind(self, T.class_of(Formula))
url "foo-1.0"
end
end
let(:keg) { instance_double(Keg) }
before do
@@ -1490,6 +1589,7 @@ RSpec.describe Formula do
allow(DevelopmentTools).to receive_messages(needs_libc_formula?: false, needs_compiler_formula?: false)
f1 = formula "f1" do
T.bind(self, T.class_of(Formula))
url "f1-1"
depends_on xcode: ["1.0", :optional]
@@ -1506,6 +1606,7 @@ RSpec.describe Formula do
f1.build = f1.stable.build
f2 = formula "f2" do
T.bind(self, T.class_of(Formula))
url "f2-1"
depends_on "f1"
@@ -1527,6 +1628,7 @@ RSpec.describe Formula do
specify "#to_hash" do
f1 = formula "foo" do
T.bind(self, T.class_of(Formula))
url "foo-1.0"
bottle do
@@ -1549,6 +1651,7 @@ RSpec.describe Formula do
describe "#to_hash patches" do
it "serialises an external patch" do
f = formula "foo" do
T.bind(self, T.class_of(Formula))
url "foo-1.0"
patch do
url "https://example.com/foo.diff"
@@ -1563,6 +1666,7 @@ RSpec.describe Formula do
it "serialises an external patch with apply and directory" do
f = formula "foo" do
T.bind(self, T.class_of(Formula))
url "foo-1.0"
patch :p0 do
url "https://example.com/patches.tar.gz"
@@ -1585,6 +1689,7 @@ RSpec.describe Formula do
it "serialises an embedded DATA patch" do
f = formula "foo" do
T.bind(self, T.class_of(Formula))
url "foo-1.0"
patch :p1, :DATA
end
@@ -1594,6 +1699,7 @@ RSpec.describe Formula do
it "serialises a string patch" do
f = formula "foo" do
T.bind(self, T.class_of(Formula))
url "foo-1.0"
patch :p2, "--- a\n+++ b\n"
end
@@ -1603,6 +1709,7 @@ RSpec.describe Formula do
it "serialises a local file patch" do
f = formula "foo" do
T.bind(self, T.class_of(Formula))
url "foo-1.0"
patch do
file "Patches/foo.diff"
@@ -1768,6 +1875,7 @@ RSpec.describe Formula do
specify "with HEAD installed" do
f = formula do
T.bind(self, T.class_of(Formula))
version("0.1")
head("foo")
end
@@ -1789,6 +1897,7 @@ RSpec.describe Formula do
describe "#pour_bottle?" do
it "returns false if set to false" do
f = formula "foo" do
T.bind(self, T.class_of(Formula))
url "foo-1.0"
def pour_bottle?
@@ -1801,6 +1910,7 @@ RSpec.describe Formula do
it "returns true if set to true" do
f = formula "foo" do
T.bind(self, T.class_of(Formula))
url "foo-1.0"
def pour_bottle?
@@ -1813,6 +1923,7 @@ RSpec.describe Formula do
it "returns false if set to false via DSL" do
f = formula "foo" do
T.bind(self, T.class_of(Formula))
url "foo-1.0"
pour_bottle? do
@@ -1826,6 +1937,7 @@ RSpec.describe Formula do
it "returns true if set to true via DSL" do
f = formula "foo" do
T.bind(self, T.class_of(Formula))
url "foo-1.0"
pour_bottle? do
@@ -1842,6 +1954,7 @@ RSpec.describe Formula do
allow(MacOS::CLT).to receive(:installed?).and_return(false)
f = formula "foo" do
T.bind(self, T.class_of(Formula))
url "foo-1.0"
pour_bottle? only_if: :clt_installed
@@ -1855,6 +1968,7 @@ RSpec.describe Formula do
allow(MacOS::CLT).to receive(:installed?).and_return(true)
f = formula "foo" do
T.bind(self, T.class_of(Formula))
url "foo-1.0"
pour_bottle? only_if: :clt_installed
@@ -1865,6 +1979,7 @@ RSpec.describe Formula do
it "returns true with `only_if: :clt_installed` on Linux", :needs_linux do
f = formula "foo" do
T.bind(self, T.class_of(Formula))
url "foo-1.0"
pour_bottle? only_if: :clt_installed
@@ -1876,6 +1991,7 @@ RSpec.describe Formula do
it "throws an error if passed both a symbol and a block" do
expect do
formula "foo" do
T.bind(self, T.class_of(Formula))
url "foo-1.0"
pour_bottle? only_if: :clt_installed do
@@ -1889,6 +2005,7 @@ RSpec.describe Formula do
it "throws an error if passed an invalid symbol" do
expect do
formula "foo" do
T.bind(self, T.class_of(Formula))
url "foo-1.0"
pour_bottle? only_if: :foo
@@ -1900,12 +2017,14 @@ RSpec.describe Formula do
describe "alias changes" do
let(:f) do
formula("formula_name", alias_path:) do
T.bind(self, T.class_of(Formula))
url "foo-1.0"
end
end
let(:new_formula) do
formula("new_formula_name", alias_path:) do
T.bind(self, T.class_of(Formula))
url "foo-1.1"
end
end
@@ -1989,6 +2108,7 @@ RSpec.describe Formula do
let(:f) do
formula do
T.bind(self, T.class_of(Formula))
url "foo"
version "1.20"
end
@@ -1996,12 +2116,14 @@ RSpec.describe Formula do
let(:old_formula) do
formula "foo@1" do
T.bind(self, T.class_of(Formula))
url "foo-1.0"
end
end
let(:new_formula) do
formula "foo@2" do
T.bind(self, T.class_of(Formula))
url "foo-2.0"
end
end
@@ -2097,6 +2219,7 @@ RSpec.describe Formula do
f.build = setup_tab_for_prefix(same_prefix, path: alias_path)
f2 = formula "foo@2" do
T.bind(self, T.class_of(Formula))
url "foo-2.0"
end
@@ -2106,6 +2229,7 @@ RSpec.describe Formula do
example "outdated old alias targets installed" do
f = formula(alias_path:) do
T.bind(self, T.class_of(Formula))
url "foo-1.0"
end
@@ -2121,6 +2245,7 @@ RSpec.describe Formula do
example "outdated old alias targets not installed" do
f = formula(alias_path:) do
T.bind(self, T.class_of(Formula))
url "foo-1.0"
end
@@ -2200,6 +2325,7 @@ RSpec.describe Formula do
let(:f) do
repo = testball_repo
formula "testball" do
T.bind(self, T.class_of(Formula))
url "foo"
version "2.10"
head "file://#{repo}", using: :git
@@ -2259,6 +2385,7 @@ RSpec.describe Formula do
describe "with changed version scheme" do
let(:f) do
formula "testball" do
T.bind(self, T.class_of(Formula))
url "foo"
version "20141010"
version_scheme 1
@@ -2276,6 +2403,7 @@ RSpec.describe Formula do
describe "with mixed version schemes" do
let(:f) do
formula "testball" do
T.bind(self, T.class_of(Formula))
url "foo"
version "20141010"
version_scheme 3
@@ -2307,6 +2435,7 @@ RSpec.describe Formula do
describe "with version scheme" do
let(:f) do
formula "testball" do
T.bind(self, T.class_of(Formula))
url "foo"
version "1.0"
version_scheme 2
@@ -2349,6 +2478,7 @@ RSpec.describe Formula do
describe "OS support" do
it "returns false for Linux when macOS is required at the top level" do
f = formula do
T.bind(self, T.class_of(Formula))
url "foo"
version "1.0"
depends_on macos: :catalina
@@ -2359,6 +2489,7 @@ RSpec.describe Formula do
it "returns true for Linux when macOS is required in an on_macos block" do
f = formula do
T.bind(self, T.class_of(Formula))
url "foo"
version "1.0"
on_macos do
@@ -2371,6 +2502,7 @@ RSpec.describe Formula do
it "returns false for macOS when Linux is required at the top level" do
f = formula do
T.bind(self, T.class_of(Formula))
url "foo"
version "1.0"
depends_on :linux
@@ -2383,6 +2515,7 @@ RSpec.describe Formula do
it "deprecates bare and versioned macOS requirements" do
expect do
formula do
T.bind(self, T.class_of(Formula))
url "foo"
version "1.0"
depends_on :macos
@@ -2395,6 +2528,7 @@ RSpec.describe Formula do
it "does not allow duplicate bare macOS requirements" do
expect do
formula do
T.bind(self, T.class_of(Formula))
url "foo"
version "1.0"
depends_on :macos
@@ -2405,6 +2539,7 @@ RSpec.describe Formula do
it "returns false for Linux when maximum macOS is required at the top level" do
f = formula do
T.bind(self, T.class_of(Formula))
url "foo"
version "1.0"
depends_on maximum_macos: :tahoe
@@ -2416,6 +2551,7 @@ RSpec.describe Formula do
it "does not allow Linux then macOS requirements" do
expect do
formula do
T.bind(self, T.class_of(Formula))
url "foo"
version "1.0"
depends_on :linux
@@ -2427,6 +2563,7 @@ RSpec.describe Formula do
it "does not allow macOS then Linux requirements" do
expect do
formula do
T.bind(self, T.class_of(Formula))
url "foo"
version "1.0"
depends_on macos: :catalina
@@ -2761,6 +2898,7 @@ RSpec.describe Formula do
describe "#preserve_rpath" do
it "defaults to false" do
f = formula do
T.bind(self, T.class_of(Formula))
url "foo-1.0"
end
@@ -2769,6 +2907,7 @@ RSpec.describe Formula do
it "can be enabled" do
f = formula do
T.bind(self, T.class_of(Formula))
url "foo-1.0"
preserve_rpath
end
@@ -2778,6 +2917,7 @@ RSpec.describe Formula do
it "can be explicitly disabled" do
f = formula do
T.bind(self, T.class_of(Formula))
url "foo-1.0"
preserve_rpath value: false
end
@@ -2795,6 +2935,7 @@ RSpec.describe Formula do
deprecation_date_ = deprecation_date
disable_date_ = disable_date
formula "foo" do
T.bind(self, T.class_of(Formula))
url "foo-1.0"
deprecate! date: deprecation_date_.to_s, because: :unmaintained
disable! date: disable_date_.to_s, because: :unsupported
@@ -2831,6 +2972,7 @@ RSpec.describe Formula do
deprecation_date_ = deprecation_date
disable_date_ = disable_date
formula "foo" do
T.bind(self, T.class_of(Formula))
url "foo-1.0"
disable! date: disable_date_.to_s, because: :unsupported
deprecate! date: deprecation_date_.to_s, because: :unmaintained
@@ -2865,7 +3007,8 @@ RSpec.describe Formula do
context "with only disable date" do
let(:f) do
disable_date_ = disable_date
formula "foo" do
formula("foo") do
T.bind(self, T.class_of(Formula))
url "foo-1.0"
disable! date: disable_date_.to_s, because: :unsupported
end
@@ -2929,6 +3072,7 @@ RSpec.describe Formula do
describe "#std_pip_args" do
let(:f) do
formula do
T.bind(self, T.class_of(Formula))
url "foo-1.0"
end
end
@@ -7,6 +7,7 @@ RSpec.describe Formula do
describe "::new" do
it "selects stable by default" do
f = formula do
T.bind(self, T.class_of(Formula))
url "foo-1.0"
head "foo"
end
@@ -15,17 +16,24 @@ RSpec.describe Formula do
end
it "selects stable when exclusive" do
f = formula { url "foo-1.0" }
f = formula do
T.bind(self, T.class_of(Formula))
url "foo-1.0"
end
expect(f).to be_stable
end
it "selects HEAD when exclusive" do
f = formula { head "foo" }
f = formula do
T.bind(self, T.class_of(Formula))
head "foo"
end
expect(f).to be_head
end
it "does not select an incomplete spec" do
f = formula do
T.bind(self, T.class_of(Formula))
sha256 TEST_SHA256
version "1.0"
head "foo"
@@ -36,6 +44,7 @@ RSpec.describe Formula do
it "does not set an incomplete stable spec" do
f = formula do
T.bind(self, T.class_of(Formula))
sha256 TEST_SHA256
head "foo"
end
@@ -46,6 +55,7 @@ RSpec.describe Formula do
it "selects HEAD when requested" do
f = formula("test", spec: :head) do
T.bind(self, T.class_of(Formula))
url "foo-1.0"
head "foo"
end
@@ -55,6 +65,7 @@ RSpec.describe Formula do
it "does not raise an error for a missing spec" do
f = formula("test", spec: :head) do
T.bind(self, T.class_of(Formula))
url "foo-1.0"
end
@@ -31,6 +31,7 @@ RSpec.describe Formula do
it "validates the `name`" do
expect do
formula "name with spaces" do
T.bind(self, T.class_of(Formula))
url "foo"
version "1.0"
end
@@ -40,6 +41,7 @@ RSpec.describe Formula do
it "validates the `url`" do
expect do
formula do
T.bind(self, T.class_of(Formula))
url ""
version "1"
end
@@ -49,6 +51,7 @@ RSpec.describe Formula do
it "validates the `version`" do
expect do
formula do
T.bind(self, T.class_of(Formula))
url "foo"
version "version with spaces"
end
@@ -56,6 +59,7 @@ RSpec.describe Formula do
expect do
formula do
T.bind(self, T.class_of(Formula))
url "foo"
version ""
end
@@ -63,6 +67,7 @@ RSpec.describe Formula do
expect do
formula do
T.bind(self, T.class_of(Formula))
url "foo"
version nil
end
@@ -71,6 +76,7 @@ RSpec.describe Formula do
specify "HEAD-only is valid" do
f = formula do
T.bind(self, T.class_of(Formula))
head "foo"
end
@@ -319,6 +319,7 @@ RSpec.describe GitHubRunnerMatrix, :no_api do
def setup_test_runner_formula(name, dependencies = [], **kwargs)
f = formula name do
T.bind(self, T.class_of(Formula))
url "https://brew.sh/#{name}-1.0.tar.gz"
dependencies.each { |dependency| depends_on dependency }
@@ -15,6 +15,7 @@ RSpec.describe InstalledDependents do
def stub_formula(name, version = "1.0", &block)
f = formula(name) do
T.bind(self, T.class_of(Formula))
url "#{name}-#{version}"
instance_eval(&block) if block
@@ -11,20 +11,24 @@ RSpec.describe Language::Node::Shebang do
f = {}
f[:node18] = formula "node@18" do
T.bind(self, T.class_of(Formula))
url "https://brew.sh/node-18.0.0.tgz"
end
f[:versioned_node_dep] = formula "foo" do
T.bind(self, T.class_of(Formula))
url "https://brew.sh/foo-1.0.tgz"
depends_on "node@18"
end
f[:no_deps] = formula "foo" do
T.bind(self, T.class_of(Formula))
url "https://brew.sh/foo-1.0.tgz"
end
f[:multiple_deps] = formula "foo" do
T.bind(self, T.class_of(Formula))
url "https://brew.sh/foo-1.0.tgz"
depends_on "node"
@@ -11,22 +11,26 @@ RSpec.describe Language::Perl::Shebang do
f = {}
f[:perl] = formula "perl" do
T.bind(self, T.class_of(Formula))
url "https://brew.sh/perl-1.0.tgz"
end
f[:depends_on] = formula "foo" do
T.bind(self, T.class_of(Formula))
url "https://brew.sh/foo-1.0.tgz"
depends_on "perl"
end
f[:uses_from_macos] = formula "foo" do
T.bind(self, T.class_of(Formula))
url "https://brew.sh/foo-1.0.tgz"
uses_from_macos "perl"
end
f[:no_deps] = formula "foo" do
T.bind(self, T.class_of(Formula))
url "https://brew.sh/foo-1.0.tgz"
end
@@ -11,20 +11,24 @@ RSpec.describe Language::PHP::Shebang do
f = {}
f[:php81] = formula "php@8.1" do
T.bind(self, T.class_of(Formula))
url "https://brew.sh/node-18.0.0.tgz"
end
f[:versioned_php_dep] = formula "foo" do
T.bind(self, T.class_of(Formula))
url "https://brew.sh/foo-1.0.tgz"
depends_on "php@8.1"
end
f[:no_deps] = formula "foo" do
T.bind(self, T.class_of(Formula))
url "https://brew.sh/foo-1.0.tgz"
end
f[:multiple_deps] = formula "foo" do
T.bind(self, T.class_of(Formula))
url "https://brew.sh/foo-1.0.tgz"
depends_on "php"
@@ -11,20 +11,24 @@ RSpec.describe Language::Python::Shebang do
f = {}
f[:python311] = formula "python@3.11" do
T.bind(self, T.class_of(Formula))
url "https://brew.sh/python-1.0.tgz"
end
f[:versioned_python_dep] = formula "foo" do
T.bind(self, T.class_of(Formula))
url "https://brew.sh/foo-1.0.tgz"
depends_on "python@3.11"
end
f[:no_deps] = formula "foo" do
T.bind(self, T.class_of(Formula))
url "https://brew.sh/foo-1.0.tgz"
end
f[:multiple_deps] = formula "foo" do
T.bind(self, T.class_of(Formula))
url "https://brew.sh/foo-1.0.tgz"
depends_on "python"
@@ -12,6 +12,7 @@ RSpec.describe Language::Python::Virtualenv, :needs_python do
formula "foo" do
include virtualenv_module
T.bind(self, T.class_of(Formula))
url "https://brew.sh/foo-1.0.tgz"
resource "resource-a" do
@@ -14,6 +14,7 @@ RSpec.describe Homebrew::Livecheck do
let(:resource_url) { "https://brew.sh/foo-1.0.tar.gz" }
let(:f) do
formula("test") do
T.bind(self, T.class_of(Formula))
desc "Test formula"
homepage "https://brew.sh"
url "https://brew.sh/test-0.0.1.tgz"
@@ -39,6 +40,7 @@ RSpec.describe Homebrew::Livecheck do
stable_url_s = stable_url
formula("test_stable_url_only") do
T.bind(self, T.class_of(Formula))
desc "Test formula with only a stable URL"
url stable_url_s
end
@@ -159,6 +161,7 @@ RSpec.describe Homebrew::Livecheck do
resource_url_s = resource_url
formula("test_livecheck_url") do
T.bind(self, T.class_of(Formula))
desc "Test Livecheck URL formula"
homepage homepage_url_s
url stable_url_s
@@ -245,6 +248,7 @@ RSpec.describe Homebrew::Livecheck do
let(:resource_url) { "https://brew.sh/foo-1.0.tar.gz" }
let(:f_duplicate_urls) do
formula("test_duplicate_urls") do
T.bind(self, T.class_of(Formula))
desc "Test formula with a duplicate URL"
homepage "https://github.com/Homebrew/brew.git"
url "https://brew.sh/test-0.0.1.tgz"
@@ -267,6 +271,7 @@ RSpec.describe Homebrew::Livecheck do
let(:f_homebrew_curl) do
formula("test") do
T.bind(self, T.class_of(Formula))
desc "Test formula"
homepage "https://brew.sh"
url "https://brew.sh/test-0.0.1.tgz", using: :homebrew_curl
@@ -330,6 +335,7 @@ RSpec.describe Homebrew::Livecheck do
describe "::latest_version" do
let(:f_throttle_rate) do
formula("test_throttle_rate") do
T.bind(self, T.class_of(Formula))
desc "Test formula"
homepage "https://brew.sh"
url "https://brew.sh/test-0.0.1.tgz"
@@ -344,6 +350,7 @@ RSpec.describe Homebrew::Livecheck do
let(:f_throttle_days) do
formula("test_throttle_days") do
T.bind(self, T.class_of(Formula))
desc "Test formula"
homepage "https://brew.sh"
url "https://brew.sh/test-0.0.1.tgz"
@@ -358,6 +365,7 @@ RSpec.describe Homebrew::Livecheck do
let(:f_throttle_rate_and_days) do
formula("test_throttle_rate_and_days") do
T.bind(self, T.class_of(Formula))
desc "Test formula"
homepage "https://brew.sh"
url "https://brew.sh/test-0.0.1.tgz"
@@ -10,6 +10,7 @@ RSpec.describe Homebrew::Livecheck::SkipConditions do
let(:formulae) do
{
basic: formula("test") do
T.bind(self, T.class_of(Formula))
desc "Test formula"
homepage "https://brew.sh"
url "https://brew.sh/test-0.0.1.tgz"
@@ -21,38 +22,45 @@ RSpec.describe Homebrew::Livecheck::SkipConditions do
end
end,
deprecated: formula("test_deprecated") do
T.bind(self, T.class_of(Formula))
desc "Deprecated test formula"
homepage "https://brew.sh"
url "https://brew.sh/test-0.0.1.tgz"
deprecate! date: "2020-06-25", because: :unmaintained
end,
disabled: formula("test_disabled") do
T.bind(self, T.class_of(Formula))
desc "Disabled test formula"
homepage "https://brew.sh"
url "https://brew.sh/test-0.0.1.tgz"
disable! date: "2020-06-25", because: :unmaintained
end,
head_only: formula("test_head_only") do
T.bind(self, T.class_of(Formula))
desc "HEAD-only test formula"
homepage "https://brew.sh"
head "https://github.com/Homebrew/brew.git", branch: "main"
end,
gist: formula("test_gist") do
T.bind(self, T.class_of(Formula))
desc "Gist test formula"
homepage "https://brew.sh"
url "https://gist.github.com/Homebrew/0000000000"
end,
google_code_archive: formula("test_google_code_archive") do
T.bind(self, T.class_of(Formula))
desc "Google Code Archive test formula"
homepage "https://brew.sh"
url "https://storage.googleapis.com/google-code-archive-downloads/v2/code.google.com/brew/brew-1.0.0.tar.gz"
end,
internet_archive: formula("test_internet_archive") do
T.bind(self, T.class_of(Formula))
desc "Internet Archive test formula"
homepage "https://brew.sh"
url "https://web.archive.org/web/20200101000000/https://brew.sh/test-0.0.1.tgz"
end,
skip: formula("test_skip") do
T.bind(self, T.class_of(Formula))
desc "Skipped test formula"
homepage "https://brew.sh"
url "https://brew.sh/test-0.0.1.tgz"
@@ -62,6 +70,7 @@ RSpec.describe Homebrew::Livecheck::SkipConditions do
end
end,
skip_with_message: formula("test_skip_with_message") do
T.bind(self, T.class_of(Formula))
desc "Skipped test formula"
homepage "https://brew.sh"
url "https://brew.sh/test-0.0.1.tgz"
@@ -71,6 +80,7 @@ RSpec.describe Homebrew::Livecheck::SkipConditions do
end
end,
versioned: formula("test@0.0.1") do
T.bind(self, T.class_of(Formula))
desc "Versioned test formula"
homepage "https://brew.sh"
url "https://brew.sh/test-0.0.1.tgz"
+2
View File
@@ -7,6 +7,7 @@ require "livecheck"
RSpec.describe Livecheck do
let(:f) do
formula do
T.bind(self, T.class_of(Formula))
homepage "https://brew.sh"
url "https://brew.sh/test-0.0.1.tgz"
head "https://github.com/Homebrew/brew.git", branch: "main"
@@ -269,6 +270,7 @@ RSpec.describe Livecheck do
let(:f_version) do
formula do
T.bind(self, T.class_of(Formula))
homepage "https://brew.sh"
url "https://brew.sh/test-0.0.1.tgz"
@@ -274,6 +274,7 @@ RSpec.describe Sandbox do
describe "#allow_write_cellar" do
it "fails when the formula has a name including )" do
f = formula do
T.bind(self, T.class_of(Formula))
url "https://brew.sh/foo-1.0.tar.gz"
version "1.0"
@@ -290,6 +291,7 @@ RSpec.describe Sandbox do
it "fails when the formula has a name including \"" do
f = formula do
T.bind(self, T.class_of(Formula))
url "https://brew.sh/foo-1.0.tar.gz"
version "1.0"
+9 -1
View File
@@ -9,7 +9,12 @@ RSpec.describe SBOM do
before { ENV.delete("HOMEBREW_ENFORCE_SBOM") }
let(:f) { formula { url "foo-1.0" } }
let(:f) do
formula do
T.bind(self, T.class_of(Formula))
url "foo-1.0"
end
end
let(:tab) { Tab.new }
it "returns true if valid" do
@@ -23,6 +28,7 @@ RSpec.describe SBOM do
context "with a maximal SBOM" do
let(:f) do
formula do
T.bind(self, T.class_of(Formula))
homepage "https://brew.sh"
url "https://brew.sh/test-0.1.tbz"
@@ -47,6 +53,7 @@ RSpec.describe SBOM do
end
let(:tab) do
beanstalkd = formula "beanstalkd" do
T.bind(self, T.class_of(Formula))
url "one-1.1"
bottle do
@@ -55,6 +62,7 @@ RSpec.describe SBOM do
end
zlib = formula "zlib" do
T.bind(self, T.class_of(Formula))
url "two-1.1"
bottle do
+1
View File
@@ -9,6 +9,7 @@ RSpec.describe Homebrew::Service do
def stub_formula(&block)
formula(name) do
T.bind(self, T.class_of(Formula))
url "https://brew.sh/test-1.0.tbz"
instance_eval(&block) if block
+54 -11
View File
@@ -38,7 +38,12 @@ RSpec.describe Tab do
let(:unused_options) { Options.create(%w[--with-baz --without-qux]) }
let(:used_options) { Options.create(%w[--with-foo --without-bar]) }
let(:git_repo) { HOMEBREW_CACHE/"tab-spec-git-repo" }
let(:f) { formula { url "foo-1.0" } }
let(:f) do
formula do
T.bind(self, T.class_of(Formula))
url "foo-1.0"
end
end
let(:f_tab_path) { f.prefix/"INSTALL_RECEIPT.json" }
let(:f_tab_content) { (TEST_FIXTURE_DIR/"receipt.json").read }
@@ -184,7 +189,10 @@ RSpec.describe Tab do
describe "::runtime_deps_hash" do
it "handles older Homebrew versions correctly" do
runtime_deps = [Dependency.new("foo")]
foo = formula("foo") { url "foo-1.0" }
foo = formula("foo") do
T.bind(self, T.class_of(Formula))
url "foo-1.0"
end
stub_formula_loader foo
runtime_deps_hash = described_class.runtime_deps_hash(foo, runtime_deps)
tab = described_class.new
@@ -197,7 +205,10 @@ RSpec.describe Tab do
end
it "include declared dependencies" do
foo = formula("foo") { url "foo-1.0" }
foo = formula("foo") do
T.bind(self, T.class_of(Formula))
url "foo-1.0"
end
stub_formula_loader foo
runtime_deps = [Dependency.new("foo")]
@@ -216,8 +227,14 @@ RSpec.describe Tab do
end
it "includes recursive dependencies" do
foo = formula("foo") { url "foo-1.0" }
bar = formula("bar") { url "bar-2.0" }
foo = formula("foo") do
T.bind(self, T.class_of(Formula))
url "foo-1.0"
end
bar = formula("bar") do
T.bind(self, T.class_of(Formula))
url "bar-2.0"
end
stub_formula_loader foo
stub_formula_loader bar
@@ -247,6 +264,7 @@ RSpec.describe Tab do
it "includes compatibility_version when set" do
foo = formula("foo") do
T.bind(self, T.class_of(Formula))
url "foo-1.0"
compatibility_version 1
end
@@ -367,6 +385,7 @@ RSpec.describe Tab do
allow(DevelopmentTools).to receive_messages(needs_libc_formula?: false, needs_compiler_formula?: false)
f = formula do
T.bind(self, T.class_of(Formula))
url "foo-1.0"
depends_on "bar"
depends_on "user/repo/from_tap"
@@ -375,13 +394,24 @@ RSpec.describe Tab do
tap = Tap.fetch("user", "repo")
from_tap = formula("from_tap", path: tap.path/"Formula/from_tap.rb") do
T.bind(self, T.class_of(Formula))
url "from_tap-1.0"
revision 1
end
stub_formula_loader from_tap
stub_formula_loader formula("bar") { url "bar-2.0" }
stub_formula_loader formula("baz") { url "baz-3.0" }
stub_formula_loader(
formula("bar") do
T.bind(self, T.class_of(Formula))
url "bar-2.0"
end,
)
stub_formula_loader(
formula("baz") do
T.bind(self, T.class_of(Formula))
url "baz-3.0"
end,
)
compiler = DevelopmentTools.default_compiler
stdlib = :libcxx
@@ -401,7 +431,10 @@ RSpec.describe Tab do
it "can create a formula Tab from an alias" do
alias_path = CoreTap.instance.alias_dir/"bar"
f = formula(alias_path:) { url "foo-1.0" }
f = formula(alias_path:) do
T.bind(self, T.class_of(Formula))
url "foo-1.0"
end
compiler = DevelopmentTools.default_compiler
stdlib = :libcxx
tab = described_class.create(f, compiler, stdlib)
@@ -415,6 +448,7 @@ RSpec.describe Tab do
commit = git_repo.cd { Utils.popen_read("git", "rev-parse", "HEAD").chomp }
repo = git_repo
f = formula("tab-spec-git") do
T.bind(self, T.class_of(Formula))
url "file://#{repo}", using: :git, branch: "master"
version "1.0"
end
@@ -451,7 +485,10 @@ RSpec.describe Tab do
it "can create a Tab for for a Formula from an alias" do
alias_path = CoreTap.instance.alias_dir/"bar"
f = formula(alias_path:) { url "foo-1.0" }
f = formula(alias_path:) do
T.bind(self, T.class_of(Formula))
url "foo-1.0"
end
tab = described_class.for_formula(f)
expect(tab.source["path"]).to eq(alias_path.to_s)
@@ -476,7 +513,10 @@ RSpec.describe Tab do
f.prefix.mkpath
f_tab_path.write f_tab_content
f2 = formula { url "foo-2.0" }
f2 = formula do
T.bind(self, T.class_of(Formula))
url "foo-2.0"
end
f2.prefix.mkpath
expect(f2.rack).to eq(f.rack)
@@ -490,7 +530,10 @@ RSpec.describe Tab do
f.prefix.mkpath
f_tab_path.write f_tab_content
f2 = formula { url "foo-2.0" }
f2 = formula do
T.bind(self, T.class_of(Formula))
url "foo-2.0"
end
expect(f2.rack).to eq(f.rack)
expect(f.installed_prefixes.length).to eq(1)
@@ -11,13 +11,16 @@ RSpec.describe Homebrew::TestBot::FormulaeDependents do
describe "#dependents_for_shard" do
it "keeps dependent formulae that depend on each other in the same shard" do
dependency = formula "dependent-a" do
T.bind(self, T.class_of(Formula))
url "https://brew.sh/dependent-a-1.0.tar.gz"
end
dependent = formula "dependent-b" do
T.bind(self, T.class_of(Formula))
url "https://brew.sh/dependent-b-1.0.tar.gz"
depends_on "dependent-a"
end
independent = formula "dependent-c" do
T.bind(self, T.class_of(Formula))
url "https://brew.sh/dependent-c-1.0.tar.gz"
end
@@ -45,6 +48,7 @@ RSpec.describe Homebrew::TestBot::FormulaeDependents do
it "returns no formulae for an empty shard" do
dependent = formula "dependent-a" do
T.bind(self, T.class_of(Formula))
url "https://brew.sh/dependent-a-1.0.tar.gz"
end
@@ -398,6 +398,7 @@ RSpec.describe TestRunnerFormula do
def setup_test_runner_formula(name, dependencies = [], **kwargs)
formula name do
T.bind(self, T.class_of(Formula))
url "https://brew.sh/#{name}-1.0.tar.gz"
dependencies.each { |dependency| depends_on dependency }
+7 -1
View File
@@ -4,10 +4,16 @@
require "uninstall"
RSpec.describe Homebrew::Uninstall do
let(:dependency) { formula("dependency") { url "f-1" } }
let(:dependency) do
formula("dependency") do
T.bind(self, T.class_of(Formula))
url "f-1"
end
end
let(:dependent_formula) do
formula("dependent_formula") do
T.bind(self, T.class_of(Formula))
url "f-1"
depends_on "dependency"
end
@@ -7,6 +7,7 @@ RSpec.describe Utils::Autoremove do
shared_context "with formulae for dependency testing" do
let(:formula_with_deps) do
formula "zero" do
T.bind(self, T.class_of(Formula))
url "zero-1.0"
depends_on "three" => :build
@@ -15,18 +16,21 @@ RSpec.describe Utils::Autoremove do
let(:first_formula_dep) do
formula "one" do
T.bind(self, T.class_of(Formula))
url "one-1.1"
end
end
let(:second_formula_dep) do
formula "two" do
T.bind(self, T.class_of(Formula))
url "two-1.1"
end
end
let(:formula_is_build_dep) do
formula "three" do
T.bind(self, T.class_of(Formula))
url "three-1.1"
end
end
@@ -29,23 +29,27 @@ RSpec.describe Utils::TopologicalHash do
describe "::graph_package_dependencies" do
it "returns a topological hash" do
formula1 = formula "homebrew-test-formula1" do
T.bind(self, T.class_of(Formula))
url "foo"
version "0.5"
end
formula2 = formula "homebrew-test-formula2" do
T.bind(self, T.class_of(Formula))
url "foo"
version "0.5"
depends_on "homebrew-test-formula1"
end
formula3 = formula "homebrew-test-formula3" do
T.bind(self, T.class_of(Formula))
url "foo"
version "0.5"
depends_on "homebrew-test-formula4"
end
formula4 = formula "homebrew-test-formula4" do
T.bind(self, T.class_of(Formula))
url "foo"
version "0.5"
depends_on "homebrew-test-formula3"