2013-04-13 17:40:13 -05:00
|
|
|
require 'testing_env'
|
|
|
|
require 'formula'
|
|
|
|
|
2014-06-18 20:32:51 -05:00
|
|
|
class FormulaSpecSelectionTests < Homebrew::TestCase
|
2013-04-13 17:40:13 -05:00
|
|
|
def test_selects_stable_by_default
|
2014-10-29 23:32:38 -05:00
|
|
|
f = formula {
|
|
|
|
url "foo-1.0"
|
|
|
|
devel { url "foo-1.1a" }
|
|
|
|
head "foo"
|
|
|
|
}
|
2013-04-13 17:40:13 -05:00
|
|
|
|
2014-10-29 23:32:38 -05:00
|
|
|
assert_predicate f, :stable?
|
2013-04-13 17:40:13 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
def test_selects_stable_when_exclusive
|
2014-10-29 23:32:38 -05:00
|
|
|
f = formula { url "foo-1.0" }
|
|
|
|
assert_predicate f, :stable?
|
2013-04-13 17:40:13 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
def test_selects_devel_before_head
|
2014-10-29 23:32:38 -05:00
|
|
|
f = formula {
|
|
|
|
devel { url "foo-1.1a" }
|
|
|
|
head "foo"
|
|
|
|
}
|
2013-04-13 17:40:13 -05:00
|
|
|
|
2014-10-29 23:32:38 -05:00
|
|
|
assert_predicate f, :devel?
|
2013-04-13 17:40:13 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
def test_selects_devel_when_exclusive
|
2014-10-29 23:32:38 -05:00
|
|
|
f = formula { devel { url "foo-1.1a" } }
|
|
|
|
assert_predicate f, :devel?
|
2013-04-13 17:40:13 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
def test_selects_head_when_exclusive
|
2014-10-29 23:32:38 -05:00
|
|
|
f = formula { head "foo" }
|
|
|
|
assert_predicate f, :head?
|
2013-04-13 17:40:13 -05:00
|
|
|
end
|
2013-04-13 17:46:11 -05:00
|
|
|
|
|
|
|
def test_incomplete_spec_not_selected
|
2014-10-29 23:32:38 -05:00
|
|
|
f = formula {
|
2013-12-09 15:57:50 -06:00
|
|
|
sha1 TEST_SHA1
|
2014-10-29 23:32:38 -05:00
|
|
|
version "1.0"
|
|
|
|
head "foo"
|
|
|
|
}
|
2013-04-13 17:46:11 -05:00
|
|
|
|
2014-10-29 23:32:38 -05:00
|
|
|
assert_predicate f, :head?
|
2013-04-13 17:46:11 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
def test_incomplete_stable_not_set
|
2014-10-29 23:32:38 -05:00
|
|
|
f = formula {
|
2013-12-09 15:57:50 -06:00
|
|
|
sha1 TEST_SHA1
|
2014-10-29 23:32:38 -05:00
|
|
|
devel { url "foo-1.1a" }
|
|
|
|
head "foo"
|
|
|
|
}
|
2013-04-13 17:46:11 -05:00
|
|
|
|
2014-10-29 23:32:38 -05:00
|
|
|
assert_nil f.stable
|
|
|
|
assert_predicate f, :devel?
|
2013-04-13 17:46:11 -05:00
|
|
|
end
|
|
|
|
|
2014-06-19 21:35:47 -05:00
|
|
|
def test_selects_head_when_requested
|
2014-10-29 23:32:38 -05:00
|
|
|
f = formula("test", Pathname.new(__FILE__).expand_path, :head) {
|
|
|
|
url "foo-1.0"
|
|
|
|
devel { url "foo-1.1a" }
|
|
|
|
head "foo"
|
|
|
|
}
|
2014-06-19 21:35:47 -05:00
|
|
|
|
2014-10-29 23:32:38 -05:00
|
|
|
assert_predicate f, :head?
|
2014-06-19 21:35:47 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
def test_selects_devel_when_requested
|
2014-10-29 23:32:38 -05:00
|
|
|
f = formula("test", Pathname.new(__FILE__).expand_path, :devel) {
|
|
|
|
url "foo-1.0"
|
|
|
|
devel { url "foo-1.1a" }
|
|
|
|
head "foo"
|
|
|
|
}
|
2014-06-19 21:35:47 -05:00
|
|
|
|
2014-10-29 23:32:38 -05:00
|
|
|
assert_predicate f, :devel?
|
2014-06-19 21:35:47 -05:00
|
|
|
end
|
|
|
|
|
2013-04-13 17:46:11 -05:00
|
|
|
def test_incomplete_devel_not_set
|
2014-10-29 23:32:38 -05:00
|
|
|
f = formula {
|
|
|
|
url "foo-1.0"
|
|
|
|
devel { version "1.1a" }
|
|
|
|
head "foo"
|
|
|
|
}
|
|
|
|
|
|
|
|
assert_nil f.devel
|
|
|
|
assert_predicate f, :stable?
|
2013-04-13 17:46:11 -05:00
|
|
|
end
|
2014-06-19 21:35:47 -05:00
|
|
|
|
|
|
|
def test_does_not_raise_for_missing_spec
|
2014-10-29 23:32:38 -05:00
|
|
|
f = formula("test", Pathname.new(__FILE__).expand_path, :devel) {
|
|
|
|
url "foo-1.0"
|
|
|
|
head "foo"
|
|
|
|
}
|
2014-06-19 21:35:47 -05:00
|
|
|
|
2014-10-29 23:32:38 -05:00
|
|
|
assert_predicate f, :stable?
|
2014-06-19 21:35:47 -05:00
|
|
|
end
|
2013-04-13 17:40:13 -05:00
|
|
|
end
|