aboutsummaryrefslogtreecommitdiffstats
path: root/Library
diff options
context:
space:
mode:
Diffstat (limited to 'Library')
-rw-r--r--Library/Homebrew/formula.rb13
-rw-r--r--Library/Homebrew/formula_installer.rb2
-rw-r--r--Library/Homebrew/formulary.rb5
-rw-r--r--Library/Homebrew/tab.rb4
-rw-r--r--Library/Homebrew/test/fixtures/receipt.json1
-rw-r--r--Library/Homebrew/test/test_formula.rb4
-rw-r--r--Library/Homebrew/test/test_formulary.rb7
-rw-r--r--Library/Homebrew/test/test_tab.rb38
-rw-r--r--Library/Homebrew/test/testball.rb2
-rw-r--r--Library/Homebrew/test/testball_bottle.rb2
-rw-r--r--Library/Homebrew/test/testing_env.rb4
11 files changed, 70 insertions, 12 deletions
diff --git a/Library/Homebrew/formula.rb b/Library/Homebrew/formula.rb
index 7e25fedd1..db59fccc9 100644
--- a/Library/Homebrew/formula.rb
+++ b/Library/Homebrew/formula.rb
@@ -60,6 +60,11 @@ class Formula
# e.g. `this-formula`
attr_reader :name
+ # The name specified when installing this {Formula}.
+ # Could be the name of the {Formula}, or an alias.
+ # e.g. `another-name-for-this-formula`
+ attr_reader :alias_path
+
# The fully-qualified name of this {Formula}.
# For core formula it's the same as {#name}.
# e.g. `homebrew/tap-name/this-formula`
@@ -145,9 +150,10 @@ class Formula
attr_accessor :build
# @private
- def initialize(name, path, spec)
+ def initialize(name, path, spec, alias_path: nil)
@name = name
@path = path
+ @alias_path = alias_path
@revision = self.class.revision || 0
@version_scheme = self.class.version_scheme || 0
@@ -222,6 +228,11 @@ class Formula
public
+ # The path that was specified to find/install this formula.
+ def specified_path
+ alias_path || path
+ end
+
# Is the currently active {SoftwareSpec} a {#stable} build?
# @private
def stable?
diff --git a/Library/Homebrew/formula_installer.rb b/Library/Homebrew/formula_installer.rb
index 1e2e8e978..68c02aee3 100644
--- a/Library/Homebrew/formula_installer.rb
+++ b/Library/Homebrew/formula_installer.rb
@@ -599,7 +599,7 @@ class FormulaInstaller
-I #{HOMEBREW_LOAD_PATH}
--
#{HOMEBREW_LIBRARY_PATH}/build.rb
- #{formula.path}
+ #{formula.specified_path}
].concat(build_argv)
Sandbox.print_sandbox_message if Sandbox.formula?(formula)
diff --git a/Library/Homebrew/formulary.rb b/Library/Homebrew/formulary.rb
index 261a54fef..cbad28fc7 100644
--- a/Library/Homebrew/formulary.rb
+++ b/Library/Homebrew/formulary.rb
@@ -68,6 +68,8 @@ class Formulary
attr_reader :name
# The formula's ruby file's path or filename
attr_reader :path
+ # The name used to install the formula
+ attr_reader :alias_path
def initialize(name, path)
@name = name
@@ -76,7 +78,7 @@ class Formulary
# Gets the formula instance.
def get_formula(spec)
- klass.new(name, path, spec)
+ klass.new(name, path, spec, :alias_path => alias_path)
end
def klass
@@ -118,6 +120,7 @@ class Formulary
path = alias_path.resolved_path
name = path.basename(".rb").to_s
super name, path
+ @alias_path = alias_path
end
end
diff --git a/Library/Homebrew/tab.rb b/Library/Homebrew/tab.rb
index 5adf66194..69e44d9dd 100644
--- a/Library/Homebrew/tab.rb
+++ b/Library/Homebrew/tab.rb
@@ -31,7 +31,7 @@ class Tab < OpenStruct
"compiler" => compiler,
"stdlib" => stdlib,
"source" => {
- "path" => formula.path.to_s,
+ "path" => formula.specified_path.to_s,
"tap" => formula.tap ? formula.tap.name : nil,
"spec" => formula.active_spec_sym.to_s,
"versions" => {
@@ -146,7 +146,7 @@ class Tab < OpenStruct
tab = empty
tab.unused_options = f.options.as_flags
tab.source = {
- "path" => f.path.to_s,
+ "path" => f.specified_path.to_s,
"tap" => f.tap ? f.tap.name : f.tap,
"spec" => f.active_spec_sym.to_s,
"versions" => {
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)