formula: deprecate devel blocks.

As we haven't released 2.3.1 I think we can get away with sneaking this
in. I'm also prepared to back this out if it's too widely used and
there's too much backlash.
This commit is contained in:
Mike McQuaid 2020-06-05 09:22:49 +01:00
parent 0af7a28fb8
commit 22857b56b9
No known key found for this signature in database
GPG Key ID: 48A898132FD8EE70
4 changed files with 3 additions and 104 deletions

View File

@ -2387,6 +2387,7 @@ class Formula
@devel ||= SoftwareSpec.new @devel ||= SoftwareSpec.new
return @devel unless block_given? return @devel unless block_given?
odeprecated "'devel' blocks in formulae", "'head' blocks or @-versioned formulae"
@devel.instance_eval(&block) @devel.instance_eval(&block)
end end

View File

@ -303,18 +303,11 @@ describe Formula do
formula do formula do
url "foo" url "foo"
version "1.9" version "1.9"
head "foo" head "foo"
devel do
url "foo"
version "2.1-devel"
end
end end
end end
let(:stable_prefix) { HOMEBREW_CELLAR/f.name/f.version } let(:stable_prefix) { HOMEBREW_CELLAR/f.name/f.version }
let(:devel_prefix) { HOMEBREW_CELLAR/f.name/f.devel.version }
let(:head_prefix) { HOMEBREW_CELLAR/f.name/f.head.version } let(:head_prefix) { HOMEBREW_CELLAR/f.name/f.head.version }
it "is the same as #prefix by default" do it "is the same as #prefix by default" do
@ -326,11 +319,6 @@ describe Formula do
expect(f.installed_prefix).to eq(stable_prefix) expect(f.installed_prefix).to eq(stable_prefix)
end end
it "returns the devel prefix if it is installed" do
devel_prefix.mkpath
expect(f.installed_prefix).to eq(devel_prefix)
end
it "returns the head prefix if it is installed" do it "returns the head prefix if it is installed" do
head_prefix.mkpath head_prefix.mkpath
expect(f.installed_prefix).to eq(head_prefix) expect(f.installed_prefix).to eq(head_prefix)
@ -347,22 +335,6 @@ describe Formula do
expect(f.installed_prefix).to eq(stable_prefix) expect(f.installed_prefix).to eq(stable_prefix)
end end
it "returns the stable prefix if head and devel are outdated" do
head_prefix.mkpath
tab = Tab.empty
tab.tabfile = head_prefix/Tab::FILENAME
tab.source["versions"] = { "stable" => "1.9", "devel" => "2.0" }
tab.write
expect(f.installed_prefix).to eq(stable_prefix)
end
it "returns the devel prefix if the active specification is :devel" do
f.active_spec = :devel
expect(f.installed_prefix).to eq(devel_prefix)
end
it "returns the head prefix if the active specification is :head" do it "returns the head prefix if the active specification is :head" do
f.active_spec = :head f.active_spec = :head
expect(f.installed_prefix).to eq(head_prefix) expect(f.installed_prefix).to eq(head_prefix)
@ -519,19 +491,12 @@ describe Formula do
sha256 TEST_SHA256 sha256 TEST_SHA256
head "https://brew.sh/test.git", tag: "foo" head "https://brew.sh/test.git", tag: "foo"
devel do
url "https://brew.sh/test-0.2.tbz"
mirror "https://example.org/test-0.2.tbz"
sha256 TEST_SHA256
end
end end
expect(f.homepage).to eq("https://brew.sh") expect(f.homepage).to eq("https://brew.sh")
expect(f.version).to eq(Version.create("0.1")) expect(f.version).to eq(Version.create("0.1"))
expect(f).to be_stable expect(f).to be_stable
expect(f.stable.version).to eq(Version.create("0.1")) expect(f.stable.version).to eq(Version.create("0.1"))
expect(f.devel.version).to eq(Version.create("0.2"))
expect(f.head.version).to eq(Version.create("HEAD")) expect(f.head.version).to eq(Version.create("HEAD"))
end end
@ -540,22 +505,12 @@ describe Formula do
url "foo" url "foo"
version "1.0" version "1.0"
revision 1 revision 1
devel do
url "foo"
version "1.0beta"
end
end end
expect(f.active_spec_sym).to eq(:stable) expect(f.active_spec_sym).to eq(:stable)
expect(f.send(:active_spec)).to eq(f.stable) expect(f.send(:active_spec)).to eq(f.stable)
expect(f.pkg_version.to_s).to eq("1.0_1") expect(f.pkg_version.to_s).to eq("1.0_1")
f.active_spec = :devel
expect(f.active_spec_sym).to eq(:devel)
expect(f.send(:active_spec)).to eq(f.devel)
expect(f.pkg_version.to_s).to eq("1.0beta_1")
expect { f.active_spec = :head }.to raise_error(FormulaSpecificationError) expect { f.active_spec = :head }.to raise_error(FormulaSpecificationError)
end end
@ -565,7 +520,6 @@ describe Formula do
end end
expect(f.class.stable).to be_kind_of(SoftwareSpec) expect(f.class.stable).to be_kind_of(SoftwareSpec)
expect(f.class.devel).to be_kind_of(SoftwareSpec)
expect(f.class.head).to be_kind_of(SoftwareSpec) expect(f.class.head).to be_kind_of(SoftwareSpec)
end end
@ -574,7 +528,6 @@ describe Formula do
url "foo-1.0" url "foo-1.0"
end end
expect(f.devel).to be nil
expect(f.head).to be nil expect(f.head).to be nil
end end
@ -583,14 +536,9 @@ describe Formula do
url "foo-1.0" url "foo-1.0"
depends_on "foo" depends_on "foo"
devel do
url "foo-1.1"
end
end end
expect(f.class.stable.deps.first.name).to eq("foo") expect(f.class.stable.deps.first.name).to eq("foo")
expect(f.class.devel.deps.first.name).to eq("foo")
expect(f.class.head.deps.first.name).to eq("foo") expect(f.class.head.deps.first.name).to eq("foo")
end end

View File

@ -7,7 +7,6 @@ describe Formula do
it "selects stable by default" do it "selects stable by default" do
f = formula do f = formula do
url "foo-1.0" url "foo-1.0"
devel { url "foo-1.1a" }
head "foo" head "foo"
end end
@ -19,20 +18,6 @@ describe Formula do
expect(f).to be_stable expect(f).to be_stable
end end
it "selects devel before HEAD" do
f = formula do
devel { url "foo-1.1a" }
head "foo"
end
expect(f).to be_devel
end
it "selects devel when exclusive" do
f = formula { devel { url "foo-1.1a" } }
expect(f).to be_devel
end
it "selects HEAD when exclusive" do it "selects HEAD when exclusive" do
f = formula { head "foo" } f = formula { head "foo" }
expect(f).to be_head expect(f).to be_head
@ -51,49 +36,25 @@ describe Formula do
it "does not set an incomplete stable spec" do it "does not set an incomplete stable spec" do
f = formula do f = formula do
sha256 TEST_SHA256 sha256 TEST_SHA256
devel { url "foo-1.1a" }
head "foo" head "foo"
end end
expect(f.stable).to be nil expect(f.stable).to be nil
expect(f).to be_devel expect(f).to be_head
end end
it "selects HEAD when requested" do it "selects HEAD when requested" do
f = formula("test", spec: :head) do f = formula("test", spec: :head) do
url "foo-1.0" url "foo-1.0"
devel { url "foo-1.1a" }
head "foo" head "foo"
end end
expect(f).to be_head expect(f).to be_head
end end
it "selects devel when requested" do
f = formula("test", spec: :devel) do
url "foo-1.0"
devel { url "foo-1.1a" }
head "foo"
end
expect(f).to be_devel
end
it "does not set an incomplete devel spec" do
f = formula do
url "foo-1.0"
devel { version "1.1a" }
head "foo"
end
expect(f.devel).to be nil
expect(f).to be_stable
end
it "does not raise an error for a missing spec" do it "does not raise an error for a missing spec" do
f = formula("test", spec: :devel) do f = formula("test", spec: :head) do
url "foo-1.0" url "foo-1.0"
head "foo"
end end
expect(f).to be_stable expect(f).to be_stable

View File

@ -70,17 +70,6 @@ describe Formula do
}.to fail_with_invalid :version }.to fail_with_invalid :version
end end
specify "devel-only is valid" do
f = formula do
devel do
url "foo"
version "1.0"
end
end
expect(f).to be_devel
end
specify "head-only is valid" do specify "head-only is valid" do
f = formula do f = formula do
head "foo" head "foo"