aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Library/Homebrew/test/test_bottles.rb22
-rw-r--r--Library/Homebrew/test/test_formula_spec_selection.rb99
2 files changed, 99 insertions, 22 deletions
diff --git a/Library/Homebrew/test/test_bottles.rb b/Library/Homebrew/test/test_bottles.rb
deleted file mode 100644
index 5c18cc681..000000000
--- a/Library/Homebrew/test/test_bottles.rb
+++ /dev/null
@@ -1,22 +0,0 @@
-require 'testing_env'
-require 'test/testball'
-
-class BottleTests < Test::Unit::TestCase
- def test_bottle_spec_selection
- f = SnowLeopardBottleSpecTestBall.new
-
- assert_equal case MacOS.cat
- when :snow_leopard then f.bottle
- else f.stable
- end, f.active_spec
-
- f = LionBottleSpecTestBall.new
- assert_equal case MacOS.cat
- when :lion then f.bottle
- else f.stable
- end, f.active_spec
-
- f = AllCatsBottleSpecTestBall.new
- assert_equal f.bottle, f.active_spec
- end
-end
diff --git a/Library/Homebrew/test/test_formula_spec_selection.rb b/Library/Homebrew/test/test_formula_spec_selection.rb
new file mode 100644
index 000000000..73cf97ad2
--- /dev/null
+++ b/Library/Homebrew/test/test_formula_spec_selection.rb
@@ -0,0 +1,99 @@
+require 'testing_env'
+require 'formula'
+
+class FormulaSpecSelectionTests < Test::Unit::TestCase
+ def formula(*args, &block)
+ @_f = Class.new(Formula, &block).new(*args)
+ end
+
+ def assert_spec_selected(spec)
+ assert_equal @_f.send(spec), @_f.active_spec
+ end
+
+ def test_selects_head_when_requested
+ ARGV.stubs(:build_head?).returns(true)
+
+ formula do
+ url 'foo-1.0'
+ devel { url 'foo-1.1a' }
+ head 'foo'
+ end
+
+ assert_spec_selected :head
+ end
+
+ def test_selects_devel_when_requested
+ ARGV.stubs(:build_devel?).returns(true)
+
+ formula do
+ url 'foo-1.0'
+ devel { url 'foo-1.1a' }
+ head 'foo'
+ end
+
+ assert_spec_selected :devel
+ end
+
+ def test_selects_bottle_when_available
+ formula do
+ def install_bottle?(*); true; end
+
+ url 'foo-1.0'
+ bottle do
+ {
+ :snow_leopard_32 => 'deadbeef'*5,
+ :snow_leopard => 'faceb00c'*5,
+ :lion => 'baadf00d'*5,
+ :mountain_lion => '8badf00d'*5,
+ }.each_pair do |cat, val|
+ sha1(val => cat)
+ end
+ end
+ end
+
+ assert_spec_selected :bottle
+ end
+
+ def test_selects_stable_by_default
+ formula do
+ url 'foo-1.0'
+ devel { url 'foo-1.1a' }
+ head 'foo'
+ end
+
+ assert_spec_selected :stable
+ end
+
+ def test_selects_stable_when_exclusive
+ formula do
+ url 'foo-1.0'
+ end
+
+ assert_spec_selected :stable
+ end
+
+ def test_selects_devel_before_head
+ formula do
+ devel { url 'foo-1.1a' }
+ head 'foo'
+ end
+
+ assert_spec_selected :devel
+ end
+
+ def test_selects_devel_when_exclusive
+ formula do
+ devel { url 'foo-1.1a' }
+ end
+
+ assert_spec_selected :devel
+ end
+
+ def test_selects_head_when_exclusive
+ formula do
+ head 'foo'
+ end
+
+ assert_spec_selected :head
+ end
+end