2017-02-21 04:52:53 +01:00
|
|
|
require "keg"
|
|
|
|
|
|
|
|
|
|
describe Keg do
|
|
|
|
|
include FileUtils
|
|
|
|
|
|
|
|
|
|
subject { described_class.new(keg_path) }
|
|
|
|
|
|
2017-08-22 17:03:22 +05:30
|
|
|
let(:keg_path) { HOMEBREW_CELLAR/"a/1.0" }
|
|
|
|
|
let(:file) { keg_path/"lib/i386.dylib" }
|
2017-02-21 04:52:53 +01:00
|
|
|
|
2017-08-22 17:03:22 +05:30
|
|
|
before(:each) do
|
|
|
|
|
(keg_path/"lib").mkpath
|
|
|
|
|
cp dylib_path("i386"), file
|
|
|
|
|
subject.link
|
|
|
|
|
end
|
2017-02-21 04:52:53 +01:00
|
|
|
|
2017-08-22 17:03:22 +05:30
|
|
|
after(:each) { subject.unlink }
|
2017-02-21 04:52:53 +01:00
|
|
|
|
2017-08-22 17:03:22 +05:30
|
|
|
describe "#change_dylib_id" do
|
|
|
|
|
it "does nothing if given id is same as file's dylib id" do
|
|
|
|
|
id = file.dylib_id
|
|
|
|
|
file.change_dylib_id(id)
|
|
|
|
|
expect(file.dylib_id).to eq(id)
|
|
|
|
|
end
|
|
|
|
|
end
|
2017-02-21 04:52:53 +01:00
|
|
|
|
2017-08-22 17:03:22 +05:30
|
|
|
describe "#change_install_name" do
|
|
|
|
|
it "does nothing if given name is same as file's install name" do
|
|
|
|
|
file.ensure_writable do
|
|
|
|
|
subject.each_install_name_for(file) do |name|
|
|
|
|
|
file.change_install_name(name, name)
|
|
|
|
|
expect(name).to eq(name)
|
|
|
|
|
end
|
|
|
|
|
end
|
2017-02-21 04:52:53 +01:00
|
|
|
end
|
|
|
|
|
|
2017-08-22 17:03:22 +05:30
|
|
|
it "does nothing when install name start with '/'" do
|
|
|
|
|
file.ensure_writable do
|
|
|
|
|
subject.each_install_name_for(file) do |name|
|
|
|
|
|
new_name = subject.fixed_name(file, name)
|
|
|
|
|
file.change_install_name(name, new_name)
|
|
|
|
|
expect(name).not_to eq(new_name)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
describe "#require_relocation?" do
|
|
|
|
|
it "is set to false at initialization" do
|
|
|
|
|
expect(subject.require_relocation?).to be false
|
|
|
|
|
end
|
2017-02-21 04:52:53 +01:00
|
|
|
|
2017-08-22 17:03:22 +05:30
|
|
|
it "is set to true after linkage is fixed" do
|
|
|
|
|
subject.fix_dynamic_linkage
|
|
|
|
|
expect(subject.require_relocation?).to be true
|
2017-02-21 04:52:53 +01:00
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|