Expand stub-out scope of Fiddle.dlopen
This commit is contained in:
parent
ec2bd6f74e
commit
470784cbd9
Notes:
git
2025-02-04 22:37:22 +00:00
@ -2,7 +2,6 @@
|
||||
|
||||
require "rbconfig"
|
||||
require "shellwords"
|
||||
require "fiddle"
|
||||
|
||||
module Bundler
|
||||
class CLI::Doctor
|
||||
@ -57,6 +56,14 @@ module Bundler
|
||||
Dir.glob("#{spec.full_gem_path}/**/*.bundle")
|
||||
end
|
||||
|
||||
def lookup_with_fiddle(path)
|
||||
require "fiddle"
|
||||
Fiddle.dlopen(path)
|
||||
false
|
||||
rescue Fiddle::DLError
|
||||
true
|
||||
end
|
||||
|
||||
def check!
|
||||
require_relative "check"
|
||||
Bundler::CLI::Check.new({}).run
|
||||
@ -73,10 +80,7 @@ module Bundler
|
||||
definition.specs.each do |spec|
|
||||
bundles_for_gem(spec).each do |bundle|
|
||||
bad_paths = dylibs(bundle).select do |f|
|
||||
Fiddle.dlopen(f)
|
||||
false
|
||||
rescue Fiddle::DLError
|
||||
true
|
||||
lookup_with_fiddle(f)
|
||||
end
|
||||
if bad_paths.any?
|
||||
broken_links[spec] ||= []
|
||||
|
@ -54,16 +54,20 @@ RSpec.describe "bundle doctor" do
|
||||
doctor = Bundler::CLI::Doctor.new({})
|
||||
expect(doctor).to receive(:bundles_for_gem).exactly(2).times.and_return ["/path/to/myrack/myrack.bundle"]
|
||||
expect(doctor).to receive(:dylibs).exactly(2).times.and_return ["/usr/lib/libSystem.dylib"]
|
||||
allow(Fiddle).to receive(:dlopen).with("/usr/lib/libSystem.dylib").and_return(true)
|
||||
allow(doctor).to receive(:lookup_with_fiddle).with("/usr/lib/libSystem.dylib").and_return(false)
|
||||
expect { doctor.run }.not_to raise_error
|
||||
expect(@stdout.string).to be_empty
|
||||
end
|
||||
|
||||
class Fiddle
|
||||
class DLError < StandardError; end
|
||||
end unless defined?(Fiddle)
|
||||
|
||||
it "exits with a message if one of the linked libraries is missing" do
|
||||
doctor = Bundler::CLI::Doctor.new({})
|
||||
expect(doctor).to receive(:bundles_for_gem).exactly(2).times.and_return ["/path/to/myrack/myrack.bundle"]
|
||||
expect(doctor).to receive(:dylibs).exactly(2).times.and_return ["/usr/local/opt/icu4c/lib/libicui18n.57.1.dylib"]
|
||||
allow(Fiddle).to receive(:dlopen).with("/usr/local/opt/icu4c/lib/libicui18n.57.1.dylib").and_raise(Fiddle::DLError)
|
||||
allow(doctor).to receive(:lookup_with_fiddle).with("/usr/local/opt/icu4c/lib/libicui18n.57.1.dylib").and_return(true)
|
||||
expect { doctor.run }.to raise_error(Bundler::ProductionError, <<~E.strip), @stdout.string
|
||||
The following gems are missing OS dependencies:
|
||||
* bundler: /usr/local/opt/icu4c/lib/libicui18n.57.1.dylib
|
||||
|
Loading…
x
Reference in New Issue
Block a user