diff options
| author | Jack Nagel | 2013-04-13 17:40:13 -0500 | 
|---|---|---|
| committer | Jack Nagel | 2013-04-13 17:40:13 -0500 | 
| commit | d78efa8f02936b9bfc7da344f18351ce00eed936 (patch) | |
| tree | 8854c897dca0541b7f06589342a5b11289e66de4 /Library/Homebrew/test | |
| parent | f0b7f44415b0004cb6bcc909665777307b6d2543 (diff) | |
| download | homebrew-d78efa8f02936b9bfc7da344f18351ce00eed936.tar.bz2 | |
Add tests for formula spec selection
These tests document the relative precedence of the stable, bottle,
devel, and head specifications, and the conditions that can influence
which is selected (e.g. command-line flags).
Diffstat (limited to 'Library/Homebrew/test')
| -rw-r--r-- | Library/Homebrew/test/test_bottles.rb | 22 | ||||
| -rw-r--r-- | Library/Homebrew/test/test_formula_spec_selection.rb | 99 | 
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 | 
