From 0ef3e1e0dcbcd5aa55408fe81d23613e1c2c5e79 Mon Sep 17 00:00:00 2001 From: Alyssa Ross Date: Sat, 3 Sep 2016 21:10:44 +0100 Subject: Preserve alias when installing formulae Part of #567 --- Library/Homebrew/test/fixtures/receipt.json | 1 + Library/Homebrew/test/test_formula.rb | 19 ++++++++++++++++++- Library/Homebrew/test/test_formulary.rb | 4 +++- Library/Homebrew/test/test_tab.rb | 3 +++ Library/Homebrew/test/testball.rb | 2 +- Library/Homebrew/test/testball_bottle.rb | 2 +- 6 files changed, 27 insertions(+), 4 deletions(-) (limited to 'Library/Homebrew/test') diff --git a/Library/Homebrew/test/fixtures/receipt.json b/Library/Homebrew/test/fixtures/receipt.json index 4a829788e..cf93f932d 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", + "install_name": "test-formula", "stdlib": "libcxx", "compiler": "clang", "source": { diff --git a/Library/Homebrew/test/test_formula.rb b/Library/Homebrew/test/test_formula.rb index 7ebb17884..1ea1ff185 100644 --- a/Library/Homebrew/test/test_formula.rb +++ b/Library/Homebrew/test/test_formula.rb @@ -8,13 +8,30 @@ class FormulaTests < Homebrew::TestCase name = "formula_name" path = Formulary.core_path(name) spec = :stable + install_name = "formula_alias" - f = klass.new(name, path, spec) + f = klass.new(name, path, spec, install_name: install_name) assert_equal name, f.name assert_equal path, f.path + assert_equal install_name, f.install_name assert_raises(ArgumentError) { klass.new } end + def test_install_ref_with_alias + name = "formula_name" + path = Formulary.core_path(name) + spec = :stable + install_name = "formula_alias" + + f = Testball.new(name, path, spec, install_name: install_name) + assert_equal f.install_name, f.install_ref + end + + def test_install_ref_with_non_alias + f = Testball.new + assert_equal f.path, f.install_ref + end + def test_prefix f = Testball.new assert_equal HOMEBREW_CELLAR/f.name/"0.1", f.prefix diff --git a/Library/Homebrew/test/test_formulary.rb b/Library/Homebrew/test/test_formulary.rb index abc034e14..0d34132ec 100644 --- a/Library/Homebrew/test/test_formulary.rb +++ b/Library/Homebrew/test/test_formulary.rb @@ -86,7 +86,9 @@ class FormularyFactoryTest < Homebrew::TestCase alias_dir = CoreTap.instance.alias_dir alias_dir.mkpath FileUtils.ln_s @path, alias_dir/"foo" - assert_kind_of Formula, Formulary.factory("foo") + result = Formulary.factory("foo") + assert_kind_of Formula, result + assert_equal "foo", result.install_name ensure alias_dir.rmtree end diff --git a/Library/Homebrew/test/test_tab.rb b/Library/Homebrew/test/test_tab.rb index 8a261a46a..dd61fd57b 100644 --- a/Library/Homebrew/test/test_tab.rb +++ b/Library/Homebrew/test/test_tab.rb @@ -43,6 +43,7 @@ class TabTests < Homebrew::TestCase assert_nil tab.stable_version assert_nil tab.devel_version assert_nil tab.head_version + assert_nil tab.install_name assert_equal DevelopmentTools.default_compiler, tab.cxxstdlib.compiler assert_nil tab.cxxstdlib.type end @@ -116,6 +117,7 @@ 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 "test-formula", tab.install_name end def test_to_json @@ -133,6 +135,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.install_name, tab.install_name end def test_remap_deprecated_options diff --git a/Library/Homebrew/test/testball.rb b/Library/Homebrew/test/testball.rb index c1b09111b..c13c73adb 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, install_name: name) 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..584478afd 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, install_name: name) self.class.instance_eval do stable.url "file://#{File.expand_path("..", __FILE__)}/tarballs/testball-0.1.tbz" stable.sha256 TESTBALL_SHA256 -- cgit v1.2.3 From c17664b124a84c7b6f8373337b3623003ca30772 Mon Sep 17 00:00:00 2001 From: Alyssa Ross Date: Sun, 4 Sep 2016 20:48:15 +0100 Subject: Switch to hash rockets --- Library/Homebrew/test/test_formula.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'Library/Homebrew/test') diff --git a/Library/Homebrew/test/test_formula.rb b/Library/Homebrew/test/test_formula.rb index 1ea1ff185..b70ecbb6f 100644 --- a/Library/Homebrew/test/test_formula.rb +++ b/Library/Homebrew/test/test_formula.rb @@ -10,7 +10,7 @@ class FormulaTests < Homebrew::TestCase spec = :stable install_name = "formula_alias" - f = klass.new(name, path, spec, install_name: install_name) + f = klass.new(name, path, spec, :install_name => install_name) assert_equal name, f.name assert_equal path, f.path assert_equal install_name, f.install_name @@ -23,7 +23,7 @@ class FormulaTests < Homebrew::TestCase spec = :stable install_name = "formula_alias" - f = Testball.new(name, path, spec, install_name: install_name) + f = Testball.new(name, path, spec, :install_name => install_name) assert_equal f.install_name, f.install_ref end -- cgit v1.2.3 From 65ee5408c3d000393c1b73bfe8fb731a651ee281 Mon Sep 17 00:00:00 2001 From: Alyssa Ross Date: Mon, 5 Sep 2016 01:11:36 +0100 Subject: Replace install_name/install_ref with alias_path --- Library/Homebrew/test/fixtures/receipt.json | 2 +- Library/Homebrew/test/test_formula.rb | 21 +++------------------ Library/Homebrew/test/test_formulary.rb | 5 +++-- Library/Homebrew/test/test_tab.rb | 6 +++--- Library/Homebrew/test/testball.rb | 2 +- Library/Homebrew/test/testball_bottle.rb | 2 +- 6 files changed, 12 insertions(+), 26 deletions(-) (limited to 'Library/Homebrew/test') diff --git a/Library/Homebrew/test/fixtures/receipt.json b/Library/Homebrew/test/fixtures/receipt.json index cf93f932d..39dcaea07 100644 --- a/Library/Homebrew/test/fixtures/receipt.json +++ b/Library/Homebrew/test/fixtures/receipt.json @@ -11,7 +11,7 @@ "poured_from_bottle": true, "time": 1403827774, "HEAD": "deadbeefdeadbeefdeadbeefdeadbeefdeadbeef", - "install_name": "test-formula", + "alias_path": "test-formula", "stdlib": "libcxx", "compiler": "clang", "source": { diff --git a/Library/Homebrew/test/test_formula.rb b/Library/Homebrew/test/test_formula.rb index b70ecbb6f..ce1ac28b1 100644 --- a/Library/Homebrew/test/test_formula.rb +++ b/Library/Homebrew/test/test_formula.rb @@ -8,30 +8,15 @@ class FormulaTests < Homebrew::TestCase name = "formula_name" path = Formulary.core_path(name) spec = :stable - install_name = "formula_alias" + alias_path = "formula_alias" - f = klass.new(name, path, spec, :install_name => install_name) + f = klass.new(name, path, spec, :alias_path => alias_path) assert_equal name, f.name assert_equal path, f.path - assert_equal install_name, f.install_name + assert_equal alias_path, f.alias_path assert_raises(ArgumentError) { klass.new } end - def test_install_ref_with_alias - name = "formula_name" - path = Formulary.core_path(name) - spec = :stable - install_name = "formula_alias" - - f = Testball.new(name, path, spec, :install_name => install_name) - assert_equal f.install_name, f.install_ref - end - - def test_install_ref_with_non_alias - f = Testball.new - assert_equal f.path, f.install_ref - end - def test_prefix f = Testball.new assert_equal HOMEBREW_CELLAR/f.name/"0.1", f.prefix diff --git a/Library/Homebrew/test/test_formulary.rb b/Library/Homebrew/test/test_formulary.rb index 0d34132ec..8b3417dad 100644 --- a/Library/Homebrew/test/test_formulary.rb +++ b/Library/Homebrew/test/test_formulary.rb @@ -85,10 +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" + alias_path = alias_dir/"foo" + FileUtils.ln_s @path, alias_path result = Formulary.factory("foo") assert_kind_of Formula, result - assert_equal "foo", result.install_name + 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 dd61fd57b..85fcf4d16 100644 --- a/Library/Homebrew/test/test_tab.rb +++ b/Library/Homebrew/test/test_tab.rb @@ -43,7 +43,7 @@ class TabTests < Homebrew::TestCase assert_nil tab.stable_version assert_nil tab.devel_version assert_nil tab.head_version - assert_nil tab.install_name + assert_nil tab.alias_path assert_equal DevelopmentTools.default_compiler, tab.cxxstdlib.compiler assert_nil tab.cxxstdlib.type end @@ -117,7 +117,7 @@ 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 "test-formula", tab.install_name + assert_equal "test-formula", tab.alias_path end def test_to_json @@ -135,7 +135,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.install_name, tab.install_name + assert_equal @tab.alias_path, tab.alias_path end def test_remap_deprecated_options diff --git a/Library/Homebrew/test/testball.rb b/Library/Homebrew/test/testball.rb index c13c73adb..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, install_name: name) + 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 584478afd..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, install_name: name) + 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 -- cgit v1.2.3 From b90eba8ffd9549879bf4c911377d8d4cf9aa7b39 Mon Sep 17 00:00:00 2001 From: Alyssa Ross Date: Mon, 5 Sep 2016 14:21:00 +0100 Subject: Update Tap for alias_path --- Library/Homebrew/test/fixtures/receipt.json | 2 +- Library/Homebrew/test/test_tab.rb | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) (limited to 'Library/Homebrew/test') diff --git a/Library/Homebrew/test/fixtures/receipt.json b/Library/Homebrew/test/fixtures/receipt.json index 39dcaea07..585a4e27d 100644 --- a/Library/Homebrew/test/fixtures/receipt.json +++ b/Library/Homebrew/test/fixtures/receipt.json @@ -11,7 +11,7 @@ "poured_from_bottle": true, "time": 1403827774, "HEAD": "deadbeefdeadbeefdeadbeefdeadbeefdeadbeef", - "alias_path": "test-formula", + "alias_path": "/usr/local/Library/Taps/homebrew/homebrew-core/Aliases/test-formula", "stdlib": "libcxx", "compiler": "clang", "source": { diff --git a/Library/Homebrew/test/test_tab.rb b/Library/Homebrew/test/test_tab.rb index 85fcf4d16..be528390a 100644 --- a/Library/Homebrew/test/test_tab.rb +++ b/Library/Homebrew/test/test_tab.rb @@ -100,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) + alias_path = Pathname.new("/usr/local/Library/Taps/homebrew/homebrew-core/Aliases/test-formula") assert_equal @used.sort, tab.used_options.sort assert_equal @unused.sort, tab.unused_options.sort @@ -117,7 +118,7 @@ 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 "test-formula", tab.alias_path + assert_equal alias_path, tab.alias_path end def test_to_json -- cgit v1.2.3 From 8bbcbfc0203cde999a0a6e10053ffc173ee73b06 Mon Sep 17 00:00:00 2001 From: Alyssa Ross Date: Wed, 7 Sep 2016 21:47:53 +0100 Subject: More realistic alias_path test --- Library/Homebrew/test/test_formula.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Library/Homebrew/test') diff --git a/Library/Homebrew/test/test_formula.rb b/Library/Homebrew/test/test_formula.rb index ce1ac28b1..63cefe9fa 100644 --- a/Library/Homebrew/test/test_formula.rb +++ b/Library/Homebrew/test/test_formula.rb @@ -8,7 +8,7 @@ class FormulaTests < Homebrew::TestCase name = "formula_name" path = Formulary.core_path(name) spec = :stable - alias_path = "formula_alias" + alias_path = CoreTap.instance.alias_dir/"formula_alias" f = klass.new(name, path, spec, :alias_path => alias_path) assert_equal name, f.name -- cgit v1.2.3 From f9e16ee2e04b7b23b273bfa683ab54a85ed40660 Mon Sep 17 00:00:00 2001 From: Alyssa Ross Date: Wed, 7 Sep 2016 22:48:52 +0100 Subject: Combine Tab alias_path with source.path --- Library/Homebrew/test/test_tab.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'Library/Homebrew/test') diff --git a/Library/Homebrew/test/test_tab.rb b/Library/Homebrew/test/test_tab.rb index be528390a..a5d50d81d 100644 --- a/Library/Homebrew/test/test_tab.rb +++ b/Library/Homebrew/test/test_tab.rb @@ -43,9 +43,9 @@ class TabTests < Homebrew::TestCase assert_nil tab.stable_version assert_nil tab.devel_version assert_nil tab.head_version - assert_nil tab.alias_path assert_equal DevelopmentTools.default_compiler, tab.cxxstdlib.compiler assert_nil tab.cxxstdlib.type + assert_nil tab.source["path"] end def test_include? @@ -100,7 +100,7 @@ class TabTests < Homebrew::TestCase def test_from_file path = Pathname.new(TEST_DIRECTORY).join("fixtures", "receipt.json") tab = Tab.from_file(path) - alias_path = Pathname.new("/usr/local/Library/Taps/homebrew/homebrew-core/Aliases/test-formula") + 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 @@ -118,7 +118,7 @@ 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 alias_path, tab.alias_path + assert_equal source_path, tab.source["path"] end def test_to_json @@ -136,7 +136,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.alias_path, tab.alias_path + assert_equal @tab.source["path"], tab.source["path"] end def test_remap_deprecated_options -- cgit v1.2.3 From 4f1d47bc156253ab0eabf6b7aba1fcfa46d80633 Mon Sep 17 00:00:00 2001 From: Alyssa Ross Date: Wed, 7 Sep 2016 22:52:25 +0100 Subject: Test source.path on Tab.create and .for_formula --- Library/Homebrew/test/test_tab.rb | 34 ++++++++++++++++++++++++++++++++++ Library/Homebrew/test/testing_env.rb | 4 ++-- 2 files changed, 36 insertions(+), 2 deletions(-) (limited to 'Library/Homebrew/test') diff --git a/Library/Homebrew/test/test_tab.rb b/Library/Homebrew/test/test_tab.rb index a5d50d81d..962bfc602 100644 --- a/Library/Homebrew/test/test_tab.rb +++ b/Library/Homebrew/test/test_tab.rb @@ -121,6 +121,40 @@ class TabTests < Homebrew::TestCase 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 tab = Tab.new(Utils::JSON.load(@tab.to_json)) assert_equal @tab.used_options.sort, tab.used_options.sort 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) -- cgit v1.2.3