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
common_specs = all_spec_variants.reduce(all_spec_variants.first, &:&)
result = variants.map do |variant|
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
[variant, subspec_names.empty? ? nil : subspec_names.join('-')]
end
......
......@@ -133,7 +133,7 @@ module Pod
describe '#scope_suffixes_for_variants' do
before do
@analyzer = Pod::Installer::Analyzer.new(config.sandbox, stub('Podfile'), nil)
@root_spec = stub(:name => 'Spec')
@root_spec = stub(:name => 'Spec', :root? => true)
end
PodVariant = Pod::Installer::Analyzer::PodVariant.freeze
......@@ -155,21 +155,29 @@ module Pod
end
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 = [
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/Bar')], 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', :root? => false)], Platform.ios),
]
@analyzer.send(:scope_suffixes_for_variants, variants).values.should == [nil, 'Foo', 'Bar']
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
variants = [
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, 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 == [
'iOS',
......@@ -182,9 +190,9 @@ module Pod
it 'returns scopes by versioned platform names and subspec names if they qualify' do
specs = [
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, 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 == [
'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