linkage_checker.rb: meld allowed_missing_lib? into unexpected_broken_dylibs

This commit is contained in:
Maxim Belkin 2020-07-22 14:39:29 +00:00
parent 1b8c32c716
commit 77a38aed0d

View File

@ -75,28 +75,19 @@ class LinkageChecker
[issues, unexpected_broken_dylibs].flatten.any?(&:present?)
end
def allowed_missing_lib?(lib)
raise TypeError, "Library must be a string; got a #{lib.class} (#{lib})" unless lib.is_a? String
# lib: Full path to the missing library
# Ex.: /home/linuxbrew/.linuxbrew/lib/libsomething.so.1
# x - Name of or a pattern for a library, linkage to which is allowed to be missing.
# Ex. 1: "libONE.so.1"
# Ex. 2: %r{(libONE|libTWO)\.so}
@formula.class.allowed_missing_libraries.any? do |x|
case x
when Regexp
x.match? lib
when String
lib.include? x
end
end
end
def unexpected_broken_dylibs
return @unexpected_broken_dylibs if @unexpected_broken_dylibs
@unexpected_broken_dylibs = @broken_dylibs.reject { |lib| allowed_missing_lib? lib }
@unexpected_broken_dylibs = @broken_dylibs.reject do |broken_lib|
@formula.class.allowed_missing_libraries.any? do |allowed_missing_lib|
case allowed_missing_lib
when Regexp
allowed_missing_lib.match? broken_lib
when String
broken_lib.include? allowed_missing_lib
end
end
end
end
def broken_dylibs_with_expectations