Add predicate methods for specs and stop testing internals
This commit is contained in:
parent
1753362024
commit
1a487fa2b3
@ -65,6 +65,18 @@ class Formula
|
||||
end
|
||||
end
|
||||
|
||||
def stable?
|
||||
active_spec == stable
|
||||
end
|
||||
|
||||
def devel?
|
||||
active_spec == devel
|
||||
end
|
||||
|
||||
def head?
|
||||
active_spec == head
|
||||
end
|
||||
|
||||
def bottle
|
||||
Bottle.new(self, active_spec.bottle_specification) if active_spec.bottled?
|
||||
end
|
||||
|
@ -437,9 +437,10 @@ class FormulaInstaller
|
||||
args << "--cc=#{ARGV.cc}" if ARGV.cc
|
||||
args << "--env=#{ARGV.env}" if ARGV.env
|
||||
|
||||
case formula.active_spec
|
||||
when formula.head then args << "--HEAD"
|
||||
when formula.devel then args << "--devel"
|
||||
if formula.head?
|
||||
args << "--HEAD"
|
||||
elsif formula.devel?
|
||||
args << "--devel"
|
||||
end
|
||||
|
||||
formula.options.each do |opt|
|
||||
|
@ -91,7 +91,7 @@ class FormulaTests < Homebrew::TestCase
|
||||
f.rack.rmtree
|
||||
end
|
||||
|
||||
def test_installed_prefix_head_active_spec
|
||||
def test_installed_prefix_head
|
||||
f = formula("test", Pathname.new(__FILE__).expand_path, :head) do
|
||||
head 'foo'
|
||||
devel do
|
||||
@ -103,7 +103,7 @@ class FormulaTests < Homebrew::TestCase
|
||||
assert_equal prefix, f.installed_prefix
|
||||
end
|
||||
|
||||
def test_installed_prefix_devel_active_spec
|
||||
def test_installed_prefix_devel
|
||||
f = formula("test", Pathname.new(__FILE__).expand_path, :devel) do
|
||||
head 'foo'
|
||||
devel do
|
||||
@ -171,7 +171,7 @@ class FormulaTests < Homebrew::TestCase
|
||||
|
||||
assert_equal 'http://example.com', f.homepage
|
||||
assert_version_equal '0.1', f.version
|
||||
assert_equal f.stable, f.active_spec
|
||||
assert_predicate f, :stable?
|
||||
|
||||
assert_instance_of SoftwareSpec, f.stable
|
||||
assert_instance_of SoftwareSpec, f.devel
|
||||
|
@ -2,115 +2,98 @@ require 'testing_env'
|
||||
require 'formula'
|
||||
|
||||
class FormulaSpecSelectionTests < Homebrew::TestCase
|
||||
def assert_spec_selected(spec)
|
||||
assert_equal @_f.send(spec), @_f.active_spec
|
||||
end
|
||||
|
||||
def assert_spec_unset(spec)
|
||||
assert_nil @_f.send(spec)
|
||||
end
|
||||
|
||||
def test_selects_stable_by_default
|
||||
formula do
|
||||
url 'foo-1.0'
|
||||
devel { url 'foo-1.1a' }
|
||||
head 'foo'
|
||||
end
|
||||
f = formula {
|
||||
url "foo-1.0"
|
||||
devel { url "foo-1.1a" }
|
||||
head "foo"
|
||||
}
|
||||
|
||||
assert_spec_selected :stable
|
||||
assert_predicate f, :stable?
|
||||
end
|
||||
|
||||
def test_selects_stable_when_exclusive
|
||||
formula do
|
||||
url 'foo-1.0'
|
||||
end
|
||||
|
||||
assert_spec_selected :stable
|
||||
f = formula { url "foo-1.0" }
|
||||
assert_predicate f, :stable?
|
||||
end
|
||||
|
||||
def test_selects_devel_before_head
|
||||
formula do
|
||||
devel { url 'foo-1.1a' }
|
||||
head 'foo'
|
||||
end
|
||||
f = formula {
|
||||
devel { url "foo-1.1a" }
|
||||
head "foo"
|
||||
}
|
||||
|
||||
assert_spec_selected :devel
|
||||
assert_predicate f, :devel?
|
||||
end
|
||||
|
||||
def test_selects_devel_when_exclusive
|
||||
formula do
|
||||
devel { url 'foo-1.1a' }
|
||||
end
|
||||
|
||||
assert_spec_selected :devel
|
||||
f = formula { devel { url "foo-1.1a" } }
|
||||
assert_predicate f, :devel?
|
||||
end
|
||||
|
||||
def test_selects_head_when_exclusive
|
||||
formula do
|
||||
head 'foo'
|
||||
end
|
||||
|
||||
assert_spec_selected :head
|
||||
f = formula { head "foo" }
|
||||
assert_predicate f, :head?
|
||||
end
|
||||
|
||||
def test_incomplete_spec_not_selected
|
||||
formula do
|
||||
f = formula {
|
||||
sha1 TEST_SHA1
|
||||
version '1.0'
|
||||
head 'foo'
|
||||
end
|
||||
version "1.0"
|
||||
head "foo"
|
||||
}
|
||||
|
||||
assert_spec_selected :head
|
||||
assert_predicate f, :head?
|
||||
end
|
||||
|
||||
def test_incomplete_stable_not_set
|
||||
formula do
|
||||
f = formula {
|
||||
sha1 TEST_SHA1
|
||||
devel { url 'foo-1.1a' }
|
||||
head 'foo'
|
||||
end
|
||||
devel { url "foo-1.1a" }
|
||||
head "foo"
|
||||
}
|
||||
|
||||
assert_spec_unset :stable
|
||||
assert_spec_selected :devel
|
||||
assert_nil f.stable
|
||||
assert_predicate f, :devel?
|
||||
end
|
||||
|
||||
def test_selects_head_when_requested
|
||||
formula("test", Pathname.new(__FILE__).expand_path, :head) do
|
||||
url 'foo-1.0'
|
||||
devel { url 'foo-1.1a' }
|
||||
head 'foo'
|
||||
end
|
||||
f = formula("test", Pathname.new(__FILE__).expand_path, :head) {
|
||||
url "foo-1.0"
|
||||
devel { url "foo-1.1a" }
|
||||
head "foo"
|
||||
}
|
||||
|
||||
assert_spec_selected :head
|
||||
assert_predicate f, :head?
|
||||
end
|
||||
|
||||
def test_selects_devel_when_requested
|
||||
formula("test", Pathname.new(__FILE__).expand_path, :devel) do
|
||||
url 'foo-1.0'
|
||||
devel { url 'foo-1.1a' }
|
||||
head 'foo'
|
||||
end
|
||||
f = formula("test", Pathname.new(__FILE__).expand_path, :devel) {
|
||||
url "foo-1.0"
|
||||
devel { url "foo-1.1a" }
|
||||
head "foo"
|
||||
}
|
||||
|
||||
assert_spec_selected :devel
|
||||
assert_predicate f, :devel?
|
||||
end
|
||||
|
||||
def test_incomplete_devel_not_set
|
||||
formula do
|
||||
url 'foo-1.0'
|
||||
devel { version '1.1a' }
|
||||
head 'foo'
|
||||
end
|
||||
f = formula {
|
||||
url "foo-1.0"
|
||||
devel { version "1.1a" }
|
||||
head "foo"
|
||||
}
|
||||
|
||||
assert_spec_unset :devel
|
||||
assert_spec_selected :stable
|
||||
assert_nil f.devel
|
||||
assert_predicate f, :stable?
|
||||
end
|
||||
|
||||
def test_does_not_raise_for_missing_spec
|
||||
formula("test", Pathname.new(__FILE__).expand_path, :devel) do
|
||||
url 'foo-1.0'
|
||||
head 'foo'
|
||||
end
|
||||
f = formula("test", Pathname.new(__FILE__).expand_path, :devel) {
|
||||
url "foo-1.0"
|
||||
head "foo"
|
||||
}
|
||||
|
||||
assert_spec_selected :stable
|
||||
assert_predicate f, :stable?
|
||||
end
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user