prepend instead of alias hacks for deprecations
This commit is contained in:
parent
02e4cae3d0
commit
8874d1fb13
@ -1,80 +1,82 @@
|
|||||||
require "dependency_collector"
|
require "dependency_collector"
|
||||||
|
|
||||||
class DependencyCollector
|
class DependencyCollector
|
||||||
alias _parse_string_spec parse_string_spec
|
module Compat
|
||||||
|
# Define the languages that we can handle as external dependencies.
|
||||||
|
LANGUAGE_MODULES = Set[
|
||||||
|
:lua, :lua51, :perl, :python, :python3, :ruby
|
||||||
|
].freeze
|
||||||
|
|
||||||
# Define the languages that we can handle as external dependencies.
|
def parse_string_spec(spec, tags)
|
||||||
LANGUAGE_MODULES = Set[
|
if (tag = tags.first) && LANGUAGE_MODULES.include?(tag)
|
||||||
:lua, :lua51, :perl, :python, :python3, :ruby
|
odeprecated "'depends_on :#{tag}'"
|
||||||
].freeze
|
LanguageModuleRequirement.new(tag, spec, tags[1])
|
||||||
|
else
|
||||||
|
super
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def parse_string_spec(spec, tags)
|
def parse_symbol_spec(spec, tags)
|
||||||
if (tag = tags.first) && LANGUAGE_MODULES.include?(tag)
|
case spec
|
||||||
odeprecated "'depends_on :#{tag}'"
|
when :clt
|
||||||
LanguageModuleRequirement.new(tag, spec, tags[1])
|
odeprecated "'depends_on :clt'"
|
||||||
else
|
when :tex
|
||||||
_parse_string_spec(spec, tags)
|
odeprecated "'depends_on :tex'"
|
||||||
|
TeXRequirement.new(tags)
|
||||||
|
when :autoconf, :automake, :bsdmake, :libtool
|
||||||
|
output_deprecation(spec)
|
||||||
|
autotools_dep(spec, tags)
|
||||||
|
when :cairo, :fontconfig, :freetype, :libpng, :pixman
|
||||||
|
output_deprecation(spec)
|
||||||
|
Dependency.new(spec.to_s, tags)
|
||||||
|
when :ant, :expat
|
||||||
|
output_deprecation(spec)
|
||||||
|
Dependency.new(spec.to_s, tags)
|
||||||
|
when :libltdl
|
||||||
|
tags << :run
|
||||||
|
output_deprecation("libtool")
|
||||||
|
Dependency.new("libtool", tags)
|
||||||
|
when :apr
|
||||||
|
output_deprecation(spec, "apr-util")
|
||||||
|
Dependency.new("apr-util", tags)
|
||||||
|
when :fortran
|
||||||
|
output_deprecation(spec, "gcc")
|
||||||
|
Dependency.new("gcc", tags)
|
||||||
|
when :gpg
|
||||||
|
output_deprecation(spec, "gnupg")
|
||||||
|
Dependency.new("gnupg", tags)
|
||||||
|
when :hg
|
||||||
|
output_deprecation(spec, "mercurial")
|
||||||
|
Dependency.new("mercurial", tags)
|
||||||
|
when :mpi
|
||||||
|
output_deprecation(spec, "open-mpi")
|
||||||
|
Dependency.new("open-mpi", tags)
|
||||||
|
when :python, :python2
|
||||||
|
output_deprecation(spec, "python")
|
||||||
|
Dependency.new("python", tags)
|
||||||
|
when :python3
|
||||||
|
output_deprecation(spec, "python3")
|
||||||
|
Dependency.new("python3", tags)
|
||||||
|
when :emacs, :mysql, :perl, :postgresql, :rbenv, :ruby
|
||||||
|
output_deprecation(spec)
|
||||||
|
Dependency.new(spec, tags)
|
||||||
|
else
|
||||||
|
super
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def autotools_dep(spec, tags)
|
||||||
|
tags << :build unless tags.include? :run
|
||||||
|
Dependency.new(spec.to_s, tags)
|
||||||
|
end
|
||||||
|
|
||||||
|
def output_deprecation(dependency, new_dependency = dependency)
|
||||||
|
odeprecated "'depends_on :#{dependency}'",
|
||||||
|
"'depends_on \"#{new_dependency}\"'"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
alias _parse_symbol_spec parse_symbol_spec
|
prepend Compat
|
||||||
|
|
||||||
def parse_symbol_spec(spec, tags)
|
|
||||||
case spec
|
|
||||||
when :clt
|
|
||||||
odeprecated "'depends_on :clt'"
|
|
||||||
when :tex
|
|
||||||
odeprecated "'depends_on :tex'"
|
|
||||||
TeXRequirement.new(tags)
|
|
||||||
when :autoconf, :automake, :bsdmake, :libtool
|
|
||||||
output_deprecation(spec)
|
|
||||||
autotools_dep(spec, tags)
|
|
||||||
when :cairo, :fontconfig, :freetype, :libpng, :pixman
|
|
||||||
output_deprecation(spec)
|
|
||||||
Dependency.new(spec.to_s, tags)
|
|
||||||
when :ant, :expat
|
|
||||||
output_deprecation(spec)
|
|
||||||
Dependency.new(spec.to_s, tags)
|
|
||||||
when :libltdl
|
|
||||||
tags << :run
|
|
||||||
output_deprecation("libtool")
|
|
||||||
Dependency.new("libtool", tags)
|
|
||||||
when :apr
|
|
||||||
output_deprecation(spec, "apr-util")
|
|
||||||
Dependency.new("apr-util", tags)
|
|
||||||
when :fortran
|
|
||||||
output_deprecation(spec, "gcc")
|
|
||||||
Dependency.new("gcc", tags)
|
|
||||||
when :gpg
|
|
||||||
output_deprecation(spec, "gnupg")
|
|
||||||
Dependency.new("gnupg", tags)
|
|
||||||
when :hg
|
|
||||||
output_deprecation(spec, "mercurial")
|
|
||||||
Dependency.new("mercurial", tags)
|
|
||||||
when :mpi
|
|
||||||
output_deprecation(spec, "open-mpi")
|
|
||||||
Dependency.new("open-mpi", tags)
|
|
||||||
when :python, :python2
|
|
||||||
output_deprecation(spec, "python")
|
|
||||||
Dependency.new("python", tags)
|
|
||||||
when :python3
|
|
||||||
output_deprecation(spec, "python3")
|
|
||||||
Dependency.new("python3", tags)
|
|
||||||
when :emacs, :mysql, :perl, :postgresql, :rbenv, :ruby
|
|
||||||
output_deprecation(spec)
|
|
||||||
Dependency.new(spec, tags)
|
|
||||||
else
|
|
||||||
_parse_symbol_spec(spec, tags)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def autotools_dep(spec, tags)
|
|
||||||
tags << :build unless tags.include? :run
|
|
||||||
Dependency.new(spec.to_s, tags)
|
|
||||||
end
|
|
||||||
|
|
||||||
def output_deprecation(dependency, new_dependency = dependency)
|
|
||||||
odeprecated "'depends_on :#{dependency}'",
|
|
||||||
"'depends_on \"#{new_dependency}\"'"
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|||||||
@ -1,18 +1,20 @@
|
|||||||
require "formula_support"
|
require "formula_support"
|
||||||
|
|
||||||
class KegOnlyReason
|
class KegOnlyReason
|
||||||
alias _to_s to_s
|
module Compat
|
||||||
|
def to_s
|
||||||
|
case @reason
|
||||||
|
when :provided_by_osx
|
||||||
|
odeprecated "keg_only :provided_by_osx", "keg_only :provided_by_macos"
|
||||||
|
@reason = :provided_by_macos
|
||||||
|
when :shadowed_by_osx
|
||||||
|
odeprecated "keg_only :shadowed_by_osx", "keg_only :shadowed_by_macos"
|
||||||
|
@reason = :shadowed_by_macos
|
||||||
|
end
|
||||||
|
|
||||||
def to_s
|
super
|
||||||
case @reason
|
|
||||||
when :provided_by_osx
|
|
||||||
odeprecated "keg_only :provided_by_osx", "keg_only :provided_by_macos"
|
|
||||||
@reason = :provided_by_macos
|
|
||||||
when :shadowed_by_osx
|
|
||||||
odeprecated "keg_only :shadowed_by_osx", "keg_only :shadowed_by_macos"
|
|
||||||
@reason = :shadowed_by_macos
|
|
||||||
end
|
end
|
||||||
|
|
||||||
_to_s
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
prepend Compat
|
||||||
end
|
end
|
||||||
|
|||||||
@ -128,5 +128,15 @@ describe DependencyCollector do
|
|||||||
resource.download_strategy = Class.new
|
resource.download_strategy = Class.new
|
||||||
expect { subject.add(resource) }.to raise_error(TypeError)
|
expect { subject.add(resource) }.to raise_error(TypeError)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "is deprecated when called with a language module", :needs_compat do
|
||||||
|
expect(subject).to receive(:odeprecated)
|
||||||
|
subject.add("lpeg" => :lua)
|
||||||
|
end
|
||||||
|
|
||||||
|
it "is deprecated when called with deprecated requirements", :needs_compat do
|
||||||
|
expect(subject).to receive(:odeprecated)
|
||||||
|
subject.add(:python)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -3,7 +3,7 @@ require "formula_support"
|
|||||||
describe KegOnlyReason do
|
describe KegOnlyReason do
|
||||||
describe "#to_s" do
|
describe "#to_s" do
|
||||||
it "returns the reason provided" do
|
it "returns the reason provided" do
|
||||||
r = KegOnlyReason.new :provided_by_osx, "test"
|
r = KegOnlyReason.new :provided_by_macos, "test"
|
||||||
expect(r.to_s).to eq("test")
|
expect(r.to_s).to eq("test")
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -11,6 +11,12 @@ describe KegOnlyReason do
|
|||||||
r = KegOnlyReason.new :provided_by_macos, ""
|
r = KegOnlyReason.new :provided_by_macos, ""
|
||||||
expect(r.to_s).to match(/^macOS already provides/)
|
expect(r.to_s).to match(/^macOS already provides/)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "is deprecated when reason mentions 'osx'", :needs_compat do
|
||||||
|
r = KegOnlyReason.new :provided_by_osx, "test"
|
||||||
|
expect(r).to receive(:odeprecated)
|
||||||
|
r.to_s
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user