Use SimulateSystem for ignore_missing_libraries
This commit is contained in:
parent
fa384b03fa
commit
34a1bc6618
@ -23,17 +23,4 @@ class Formula
|
||||
|
||||
sig { params(targets: T.nilable(T.any(Pathname, String))).void }
|
||||
def deuniversalize_machos(*targets); end
|
||||
|
||||
class << self
|
||||
undef ignore_missing_libraries
|
||||
|
||||
def ignore_missing_libraries(*libs)
|
||||
libraries = libs.flatten
|
||||
if libraries.any? { |x| !x.is_a?(String) && !x.is_a?(Regexp) }
|
||||
raise FormulaSpecificationError, "#{__method__} can handle Strings and Regular Expressions only"
|
||||
end
|
||||
|
||||
allowed_missing_libraries.merge(libraries)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@ -3214,10 +3214,17 @@ class Formula
|
||||
end
|
||||
|
||||
# Permit links to certain libraries that don't exist. Available on Linux only.
|
||||
def ignore_missing_libraries(*)
|
||||
return if Homebrew::SimulateSystem.linux?
|
||||
def ignore_missing_libraries(*libs)
|
||||
unless Homebrew::SimulateSystem.treat_as_linux?
|
||||
raise FormulaSpecificationError, "#{__method__} is available on Linux only"
|
||||
end
|
||||
|
||||
raise FormulaSpecificationError, "#{__method__} is available on Linux only"
|
||||
libraries = libs.flatten
|
||||
if libraries.any? { |x| !x.is_a?(String) && !x.is_a?(Regexp) }
|
||||
raise FormulaSpecificationError, "#{__method__} can handle Strings and Regular Expressions only"
|
||||
end
|
||||
|
||||
allowed_missing_libraries.merge(libraries)
|
||||
end
|
||||
|
||||
# @private
|
||||
|
||||
@ -1845,4 +1845,52 @@ describe Formula do
|
||||
expect(f.test).to eq(2)
|
||||
end
|
||||
end
|
||||
|
||||
describe "#ignore_missing_libraries" do
|
||||
after do
|
||||
Homebrew::SimulateSystem.clear
|
||||
end
|
||||
|
||||
it "adds library to allowed_missing_libraries on Linux", :needs_linux do
|
||||
Homebrew::SimulateSystem.clear
|
||||
f = formula do
|
||||
url "foo-1.0"
|
||||
|
||||
ignore_missing_libraries "bar.so"
|
||||
end
|
||||
expect(f.class.allowed_missing_libraries.to_a).to eq(["bar.so"])
|
||||
end
|
||||
|
||||
it "adds library to allowed_missing_libraries on macOS when simulating Linux", :needs_macos do
|
||||
Homebrew::SimulateSystem.os = :linux
|
||||
f = formula do
|
||||
url "foo-1.0"
|
||||
|
||||
ignore_missing_libraries "bar.so"
|
||||
end
|
||||
expect(f.class.allowed_missing_libraries.to_a).to eq(["bar.so"])
|
||||
end
|
||||
|
||||
it "raises an error on macOS", :needs_macos do
|
||||
Homebrew::SimulateSystem.clear
|
||||
expect {
|
||||
formula do
|
||||
url "foo-1.0"
|
||||
|
||||
ignore_missing_libraries "bar.so"
|
||||
end
|
||||
}.to raise_error("ignore_missing_libraries is available on Linux only")
|
||||
end
|
||||
|
||||
it "raises an error on Linux when simulating macOS", :needs_linux do
|
||||
Homebrew::SimulateSystem.os = :macos
|
||||
expect {
|
||||
formula do
|
||||
url "foo-1.0"
|
||||
|
||||
ignore_missing_libraries "bar.so"
|
||||
end
|
||||
}.to raise_error("ignore_missing_libraries is available on Linux only")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user