diff options
Diffstat (limited to 'Library/Homebrew/test')
| -rw-r--r-- | Library/Homebrew/test/fixtures/receipt.json | 1 | ||||
| -rw-r--r-- | Library/Homebrew/test/test_formula.rb | 4 | ||||
| -rw-r--r-- | Library/Homebrew/test/test_formulary.rb | 7 | ||||
| -rw-r--r-- | Library/Homebrew/test/test_tab.rb | 38 | ||||
| -rw-r--r-- | Library/Homebrew/test/testball.rb | 2 | ||||
| -rw-r--r-- | Library/Homebrew/test/testball_bottle.rb | 2 | ||||
| -rw-r--r-- | Library/Homebrew/test/testing_env.rb | 4 |
7 files changed, 51 insertions, 7 deletions
diff --git a/Library/Homebrew/test/fixtures/receipt.json b/Library/Homebrew/test/fixtures/receipt.json index 4a829788e..585a4e27d 100644 --- a/Library/Homebrew/test/fixtures/receipt.json +++ b/Library/Homebrew/test/fixtures/receipt.json @@ -11,6 +11,7 @@ "poured_from_bottle": true, "time": 1403827774, "HEAD": "deadbeefdeadbeefdeadbeefdeadbeefdeadbeef", + "alias_path": "/usr/local/Library/Taps/homebrew/homebrew-core/Aliases/test-formula", "stdlib": "libcxx", "compiler": "clang", "source": { diff --git a/Library/Homebrew/test/test_formula.rb b/Library/Homebrew/test/test_formula.rb index 0e6650a95..8dd77e186 100644 --- a/Library/Homebrew/test/test_formula.rb +++ b/Library/Homebrew/test/test_formula.rb @@ -8,10 +8,12 @@ class FormulaTests < Homebrew::TestCase name = "formula_name" path = Formulary.core_path(name) spec = :stable + alias_path = CoreTap.instance.alias_dir/"formula_alias" - f = klass.new(name, path, spec) + f = klass.new(name, path, spec, :alias_path => alias_path) assert_equal name, f.name assert_equal path, f.path + assert_equal alias_path, f.alias_path assert_raises(ArgumentError) { klass.new } end diff --git a/Library/Homebrew/test/test_formulary.rb b/Library/Homebrew/test/test_formulary.rb index abc034e14..8b3417dad 100644 --- a/Library/Homebrew/test/test_formulary.rb +++ b/Library/Homebrew/test/test_formulary.rb @@ -85,8 +85,11 @@ class FormularyFactoryTest < Homebrew::TestCase def test_factory_from_alias alias_dir = CoreTap.instance.alias_dir alias_dir.mkpath - FileUtils.ln_s @path, alias_dir/"foo" - assert_kind_of Formula, Formulary.factory("foo") + alias_path = alias_dir/"foo" + FileUtils.ln_s @path, alias_path + result = Formulary.factory("foo") + assert_kind_of Formula, result + assert_equal alias_path, result.alias_path ensure alias_dir.rmtree end diff --git a/Library/Homebrew/test/test_tab.rb b/Library/Homebrew/test/test_tab.rb index 8a261a46a..962bfc602 100644 --- a/Library/Homebrew/test/test_tab.rb +++ b/Library/Homebrew/test/test_tab.rb @@ -45,6 +45,7 @@ class TabTests < Homebrew::TestCase assert_nil tab.head_version assert_equal DevelopmentTools.default_compiler, tab.cxxstdlib.compiler assert_nil tab.cxxstdlib.type + assert_nil tab.source["path"] end def test_include? @@ -99,6 +100,7 @@ class TabTests < Homebrew::TestCase def test_from_file path = Pathname.new(TEST_DIRECTORY).join("fixtures", "receipt.json") tab = Tab.from_file(path) + source_path = "/usr/local/Library/Taps/hombrew/homebrew-core/Formula/foo.rb" assert_equal @used.sort, tab.used_options.sort assert_equal @unused.sort, tab.unused_options.sort @@ -116,6 +118,41 @@ class TabTests < Homebrew::TestCase assert_equal "2.14", tab.stable_version.to_s assert_equal "2.15", tab.devel_version.to_s assert_equal "HEAD-0000000", tab.head_version.to_s + assert_equal source_path, tab.source["path"] + end + + def test_create + f = formula { url "foo-1.0" } + compiler = DevelopmentTools.default_compiler + stdlib = :libcxx + tab = Tab.create(f, compiler, stdlib) + + assert_equal f.path.to_s, tab.source["path"] + end + + def test_create_from_alias + alias_path = CoreTap.instance.alias_dir/"bar" + f = formula(:alias_path => alias_path) { url "foo-1.0" } + compiler = DevelopmentTools.default_compiler + stdlib = :libcxx + tab = Tab.create(f, compiler, stdlib) + + assert_equal f.alias_path.to_s, tab.source["path"] + end + + def test_for_formula + f = formula { url "foo-1.0" } + tab = Tab.for_formula(f) + + assert_equal f.path.to_s, tab.source["path"] + end + + def test_for_formula_from_alias + alias_path = CoreTap.instance.alias_dir/"bar" + f = formula(:alias_path => alias_path) { url "foo-1.0" } + tab = Tab.for_formula(f) + + assert_equal alias_path.to_s, tab.source["path"] end def test_to_json @@ -133,6 +170,7 @@ class TabTests < Homebrew::TestCase assert_equal @tab.stable_version, tab.stable_version assert_equal @tab.devel_version, tab.devel_version assert_equal @tab.head_version, tab.head_version + assert_equal @tab.source["path"], tab.source["path"] end def test_remap_deprecated_options diff --git a/Library/Homebrew/test/testball.rb b/Library/Homebrew/test/testball.rb index c1b09111b..cce09738d 100644 --- a/Library/Homebrew/test/testball.rb +++ b/Library/Homebrew/test/testball.rb @@ -1,5 +1,5 @@ class Testball < Formula - def initialize(name = "testball", path = Pathname.new(__FILE__).expand_path, spec = :stable) + def initialize(name = "testball", path = Pathname.new(__FILE__).expand_path, spec = :stable, alias_path: nil) self.class.instance_eval do stable.url "file://#{File.expand_path("..", __FILE__)}/tarballs/testball-0.1.tbz" stable.sha256 TESTBALL_SHA256 diff --git a/Library/Homebrew/test/testball_bottle.rb b/Library/Homebrew/test/testball_bottle.rb index 5aa582fa8..769f615aa 100644 --- a/Library/Homebrew/test/testball_bottle.rb +++ b/Library/Homebrew/test/testball_bottle.rb @@ -1,5 +1,5 @@ class TestballBottle < Formula - def initialize(name = "testball_bottle", path = Pathname.new(__FILE__).expand_path, spec = :stable) + def initialize(name = "testball_bottle", path = Pathname.new(__FILE__).expand_path, spec = :stable, alias_path: nil) self.class.instance_eval do stable.url "file://#{File.expand_path("..", __FILE__)}/tarballs/testball-0.1.tbz" stable.sha256 TESTBALL_SHA256 diff --git a/Library/Homebrew/test/testing_env.rb b/Library/Homebrew/test/testing_env.rb index 5d464b8cc..bc25f8ef8 100644 --- a/Library/Homebrew/test/testing_env.rb +++ b/Library/Homebrew/test/testing_env.rb @@ -72,8 +72,8 @@ module Homebrew TEST_SHA1 = "deadbeefdeadbeefdeadbeefdeadbeefdeadbeef".freeze TEST_SHA256 = "deadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef".freeze - def formula(name = "formula_name", path = Formulary.core_path(name), spec = :stable, &block) - @_f = Class.new(Formula, &block).new(name, path, spec) + def formula(name = "formula_name", path = Formulary.core_path(name), spec = :stable, alias_path: nil, &block) + @_f = Class.new(Formula, &block).new(name, path, spec, :alias_path => alias_path) end def mktmpdir(prefix_suffix = nil, &block) |
