Commit 139c2ea0 authored by Marius Rackwitz's avatar Marius Rackwitz

[Analyzer] Handle when the root spec is not present in all variants

parent 7b6d2edc
...@@ -352,7 +352,9 @@ module Pod ...@@ -352,7 +352,9 @@ module Pod
common_specs = all_spec_variants.reduce(all_spec_variants.first, &:&) common_specs = all_spec_variants.reduce(all_spec_variants.first, &:&)
result = variants.map do |variant| result = variants.map do |variant|
subspecs = variant.specs - common_specs subspecs = variant.specs - common_specs
subspec_names = subspecs.map { |spec| spec.name.split('/')[1..-1].join('_') } subspec_names = subspecs.map do |spec|
spec.root? ? 'root' : spec.name.split('/')[1..-1].join('_')
end.sort
# => Subspecs names without common subspecs # => Subspecs names without common subspecs
[variant, subspec_names.empty? ? nil : subspec_names.join('-')] [variant, subspec_names.empty? ? nil : subspec_names.join('-')]
end end
......
...@@ -133,7 +133,7 @@ module Pod ...@@ -133,7 +133,7 @@ module Pod
describe '#scope_suffixes_for_variants' do describe '#scope_suffixes_for_variants' do
before do before do
@analyzer = Pod::Installer::Analyzer.new(config.sandbox, stub('Podfile'), nil) @analyzer = Pod::Installer::Analyzer.new(config.sandbox, stub('Podfile'), nil)
@root_spec = stub(:name => 'Spec') @root_spec = stub(:name => 'Spec', :root? => true)
end end
PodVariant = Pod::Installer::Analyzer::PodVariant.freeze PodVariant = Pod::Installer::Analyzer::PodVariant.freeze
...@@ -155,21 +155,29 @@ module Pod ...@@ -155,21 +155,29 @@ module Pod
end end
it 'returns scopes by subspec names if they qualify' do it 'returns scopes by subspec names if they qualify' do
shared_subspec = stub(:name => 'Spec/Shared') shared_subspec = stub(:name => 'Spec/Shared', :root? => false)
variants = [ variants = [
PodVariant.new([@root_spec, shared_subspec], Platform.ios), PodVariant.new([@root_spec, shared_subspec], Platform.ios),
PodVariant.new([@root_spec, shared_subspec, stub(:name => 'Spec/Foo')], Platform.ios), PodVariant.new([@root_spec, shared_subspec, stub(:name => 'Spec/Foo', :root? => false)], Platform.ios),
PodVariant.new([@root_spec, shared_subspec, stub(:name => 'Spec/Bar')], Platform.ios), PodVariant.new([@root_spec, shared_subspec, stub(:name => 'Spec/Bar', :root? => false)], Platform.ios),
] ]
@analyzer.send(:scope_suffixes_for_variants, variants).values.should == [nil, 'Foo', 'Bar'] @analyzer.send(:scope_suffixes_for_variants, variants).values.should == [nil, 'Foo', 'Bar']
end end
it 'returns scopes by subspec names if they qualify and handle partial root spec presence well' do
variants = [
PodVariant.new([stub(:name => 'Spec/Foo', :root? => false)], Platform.ios),
PodVariant.new([@root_spec, stub(:name => 'Spec/Bar', :root? => false)], Platform.ios),
]
@analyzer.send(:scope_suffixes_for_variants, variants).values.should == ['Foo', 'Bar-root']
end
it 'returns scopes by platform names and subspec names if they qualify' do it 'returns scopes by platform names and subspec names if they qualify' do
variants = [ variants = [
PodVariant.new([@root_spec], Platform.ios), PodVariant.new([@root_spec], Platform.ios),
PodVariant.new([@root_spec, stub(:name => 'Spec/Foo')], Platform.ios), PodVariant.new([@root_spec, stub(:name => 'Spec/Foo', :root? => false)], Platform.ios),
PodVariant.new([@root_spec], Platform.osx), PodVariant.new([@root_spec], Platform.osx),
PodVariant.new([@root_spec, stub(:name => 'Spec/Bar')], Platform.osx), PodVariant.new([@root_spec, stub(:name => 'Spec/Bar', :root? => false)], Platform.osx),
] ]
@analyzer.send(:scope_suffixes_for_variants, variants).values.should == [ @analyzer.send(:scope_suffixes_for_variants, variants).values.should == [
'iOS', 'iOS',
...@@ -182,9 +190,9 @@ module Pod ...@@ -182,9 +190,9 @@ module Pod
it 'returns scopes by versioned platform names and subspec names if they qualify' do it 'returns scopes by versioned platform names and subspec names if they qualify' do
specs = [ specs = [
PodVariant.new([@root_spec], Platform.new(:ios, '7.0')), PodVariant.new([@root_spec], Platform.new(:ios, '7.0')),
PodVariant.new([@root_spec, stub(:name => 'Spec/Foo')], Platform.ios), PodVariant.new([@root_spec, stub(:name => 'Spec/Foo', :root? => false)], Platform.ios),
PodVariant.new([@root_spec], Platform.osx), PodVariant.new([@root_spec], Platform.osx),
PodVariant.new([@root_spec, stub(:name => 'Spec/Bar')], Platform.osx), PodVariant.new([@root_spec, stub(:name => 'Spec/Bar', :root? => false)], Platform.osx),
] ]
@analyzer.send(:scope_suffixes_for_variants, specs).values.should == [ @analyzer.send(:scope_suffixes_for_variants, specs).values.should == [
'iOS7.0', 'iOS7.0',
......
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