utils: tell people to report deprecations to tap.
This should hopefully avoid Homebrew/brew or Homebrew/homebrew-core having these exceptions reported to us.
This commit is contained in:
parent
3e5ccaf3d2
commit
7a00f03c92
@ -223,4 +223,17 @@ class UtilTests < Homebrew::TestCase
|
||||
s = truncate_text_to_approximate_size(long_s, n, :front_weight => 1.0)
|
||||
assert_equal(("x" * (n - glue.length)) + glue, s)
|
||||
end
|
||||
|
||||
def test_odeprecated
|
||||
ARGV.stubs(:homebrew_developer?).returns false
|
||||
e = assert_raises(FormulaMethodDeprecatedError) do
|
||||
odeprecated("method", "replacement",
|
||||
:caller => ["#{HOMEBREW_LIBRARY}/Taps/homebrew/homebrew-core/"],
|
||||
:die => true)
|
||||
end
|
||||
assert_match "method", e.message
|
||||
assert_match "replacement", e.message
|
||||
assert_match "homebrew/homebrew-core", e.message
|
||||
assert_match "homebrew/core", e.message
|
||||
end
|
||||
end
|
||||
|
||||
@ -130,8 +130,13 @@ def odeprecated(method, replacement = nil, options = {})
|
||||
# - Location outside of 'compat/'.
|
||||
# - Location of caller of deprecated method (if all else fails).
|
||||
backtrace = options.fetch(:caller, caller)
|
||||
tap_message = nil
|
||||
caller_message = backtrace.detect do |line|
|
||||
line.start_with?("#{HOMEBREW_LIBRARY}/Taps/")
|
||||
if line =~ %r{^#{Regexp.escape HOMEBREW_LIBRARY}/Taps/([^/]+/[^/]+)/}
|
||||
tap = Tap.fetch $1
|
||||
tap_message = "\nPlease report this to the #{tap} tap!"
|
||||
true
|
||||
end
|
||||
end
|
||||
caller_message ||= backtrace.detect do |line|
|
||||
!line.start_with?("#{HOMEBREW_LIBRARY_PATH}/compat/")
|
||||
@ -141,7 +146,7 @@ def odeprecated(method, replacement = nil, options = {})
|
||||
message = <<-EOS.undent
|
||||
Calling #{method} is #{verb}!
|
||||
#{replacement_message}
|
||||
#{caller_message}
|
||||
#{caller_message}#{tap_message}
|
||||
EOS
|
||||
|
||||
if ARGV.homebrew_developer? || options[:die]
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user