Commit 9d9e4a53 authored by Fabio Pelosin's avatar Fabio Pelosin

[FileReferencesInstaller] Fix crash on #header_mappings

parent 748ea86f
...@@ -113,12 +113,11 @@ module Pod ...@@ -113,12 +113,11 @@ module Pod
sandbox.build_headers.add_search_path(headers_sandbox) sandbox.build_headers.add_search_path(headers_sandbox)
sandbox.public_headers.add_search_path(headers_sandbox) sandbox.public_headers.add_search_path(headers_sandbox)
consumer = file_accessor.spec_consumer header_mappings(headers_sandbox, file_accessor, file_accessor.headers).each do |namespaced_path, files|
header_mappings(headers_sandbox, consumer, file_accessor.headers).each do |namespaced_path, files|
sandbox.build_headers.add_files(namespaced_path, files) sandbox.build_headers.add_files(namespaced_path, files)
end end
header_mappings(headers_sandbox, consumer, file_accessor.public_headers).each do |namespaced_path, files| header_mappings(headers_sandbox, file_accessor, file_accessor.public_headers).each do |namespaced_path, files|
sandbox.public_headers.add_files(namespaced_path, files) sandbox.public_headers.add_files(namespaced_path, files)
end end
end end
...@@ -154,7 +153,8 @@ module Pod ...@@ -154,7 +153,8 @@ module Pod
# headers folders as the keys and the absolute paths of the # headers folders as the keys and the absolute paths of the
# header files as the values. # header files as the values.
# #
def header_mappings(headers_sandbox, consumer, headers) def header_mappings(headers_sandbox, file_accessor, headers)
consumer = file_accessor.spec_consumer
dir = headers_sandbox dir = headers_sandbox
dir = dir + consumer.header_dir if consumer.header_dir dir = dir + consumer.header_dir if consumer.header_dir
...@@ -162,7 +162,7 @@ module Pod ...@@ -162,7 +162,7 @@ module Pod
headers.each do |header| headers.each do |header|
sub_dir = dir sub_dir = dir
if consumer.header_mappings_dir if consumer.header_mappings_dir
header_mappings_dir = Pathname.new(consumer.header_mappings_dir) header_mappings_dir = file_accessor.path_list.root + consumer.header_mappings_dir
relative_path = header.relative_path_from(header_mappings_dir) relative_path = header.relative_path_from(header_mappings_dir)
sub_dir = sub_dir + relative_path.dirname sub_dir = sub_dir + relative_path.dirname
end end
......
...@@ -91,9 +91,8 @@ module Pod ...@@ -91,9 +91,8 @@ module Pod
it "returns the header mappings" do it "returns the header mappings" do
headers_sandbox = Pathname.new('BananaLib') headers_sandbox = Pathname.new('BananaLib')
consumer = @file_accessor.spec_consumer
headers = [Pathname.new('BananaLib/Banana.h')] headers = [Pathname.new('BananaLib/Banana.h')]
mappings = @installer.send(:header_mappings, headers_sandbox, consumer, headers) mappings = @installer.send(:header_mappings, headers_sandbox, @file_accessor, headers)
mappings.should == { mappings.should == {
headers_sandbox => [Pathname.new('BananaLib/Banana.h')] headers_sandbox => [Pathname.new('BananaLib/Banana.h')]
} }
...@@ -101,10 +100,9 @@ module Pod ...@@ -101,10 +100,9 @@ module Pod
it "takes into account the header dir specified in the spec" do it "takes into account the header dir specified in the spec" do
headers_sandbox = Pathname.new('BananaLib') headers_sandbox = Pathname.new('BananaLib')
consumer = @file_accessor.spec_consumer
headers = [Pathname.new('BananaLib/Banana.h')] headers = [Pathname.new('BananaLib/Banana.h')]
consumer.stubs(:header_dir).returns('Sub_dir') @file_accessor.spec_consumer.stubs(:header_dir).returns('Sub_dir')
mappings = @installer.send(:header_mappings, headers_sandbox, consumer, headers) mappings = @installer.send(:header_mappings, headers_sandbox, @file_accessor, headers)
mappings.should == { mappings.should == {
(headers_sandbox + 'Sub_dir') => [Pathname.new('BananaLib/Banana.h')] (headers_sandbox + 'Sub_dir') => [Pathname.new('BananaLib/Banana.h')]
} }
...@@ -112,16 +110,14 @@ module Pod ...@@ -112,16 +110,14 @@ module Pod
it "takes into account the header mappings dir specified in the spec" do it "takes into account the header mappings dir specified in the spec" do
headers_sandbox = Pathname.new('BananaLib') headers_sandbox = Pathname.new('BananaLib')
consumer = @file_accessor.spec_consumer header_1 = @file_accessor.root + 'BananaLib/sub_dir/dir_1/banana_1.h'
headers = [ header_2 = @file_accessor.root + 'BananaLib/sub_dir/dir_2/banana_2.h'
Pathname.new('BananaLib/sub_dir/dir_1/banana_1.h'), headers = [ header_1, header_2 ]
Pathname.new('BananaLib/sub_dir/dir_2/banana_2.h'), @file_accessor.spec_consumer.stubs(:header_mappings_dir).returns('BananaLib/sub_dir')
] mappings = @installer.send(:header_mappings, headers_sandbox, @file_accessor, headers)
consumer.stubs(:header_mappings_dir).returns('BananaLib/sub_dir')
mappings = @installer.send(:header_mappings, headers_sandbox, consumer, headers)
mappings.should == { mappings.should == {
(headers_sandbox + 'dir_1') => [Pathname.new('BananaLib/sub_dir/dir_1/banana_1.h')], (headers_sandbox + 'dir_1') => [header_1],
(headers_sandbox + 'dir_2') => [Pathname.new('BananaLib/sub_dir/dir_2/banana_2.h')], (headers_sandbox + 'dir_2') => [header_2],
} }
end end
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment