From bcce59fd46b18ea20d7892350e6ad225ba0850c3 Mon Sep 17 00:00:00 2001 From: Adam Jacob Date: Wed, 23 Apr 2014 21:09:58 -0700 Subject: [PATCH] Fixes Github Issue #140 This issue happens when a software is both a transitive dependency at the software level, and a top level project dependency. We were blindly shifting all the project deps to the end of the build order as an optimization, and failed to check for the case where we actually *needed* that software in the right place. This patch ensures that, if the software is a dependency of any other software description, it does not get shifted to the end. --- lib/omnibus/library.rb | 2 +- spec/unit/library_spec.rb | 10 +++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/lib/omnibus/library.rb b/lib/omnibus/library.rb index df48cfb83..fd883748c 100644 --- a/lib/omnibus/library.rb +++ b/lib/omnibus/library.rb @@ -38,7 +38,7 @@ def build_order @components.each do |component| if head.length == 0 head << component - elsif @project.dependencies.include?(component.name) + elsif @project.dependencies.include?(component.name) && @components.none? { |c| c.dependencies.include?(component.name) } tail << component else head << component diff --git a/spec/unit/library_spec.rb b/spec/unit/library_spec.rb index 12e39aa87..3591c114b 100644 --- a/spec/unit/library_spec.rb +++ b/spec/unit/library_spec.rb @@ -31,6 +31,7 @@ homepage 'http://getchef.com' dependency 'preparation' dependency 'erchef' +dependency 'postgresql' dependency 'chef' EOH Omnibus::Project.new(raw_project, 'chef-server.rb') @@ -40,6 +41,7 @@ library = Omnibus::Library.new(project) library.component_added(preparation) library.component_added(erlang) + library.component_added(postgresql) # as a skitch trans dep library.component_added(skitch) library.component_added(erchef) library.component_added(ruby) @@ -47,7 +49,7 @@ library end - project_deps = [:preparation, :erchef, :chef] + project_deps = [:preparation, :erchef, :postgresql, :chef] erchef_deps = [:erlang, :skitch] chef_deps = [:ruby] @@ -55,12 +57,14 @@ let(dep) do software = Omnibus::Software.new('', "#{dep}.rb", 'chef-server') software.name(dep.to_s) + software.dependency('postgresql') if dep == :skitch software end end - it 'returns an array of software descriptions, with all non top level deps first' do - expect(library.build_order).to eql([preparation, erlang, skitch, ruby, erchef, chef]) + it 'returns an array of software descriptions, with all top level deps first, assuming they are not themselves transitive deps' do + library.build_order.map { |m| m.name.to_s } + expect(library.build_order).to eql([preparation, erlang, postgresql, skitch, ruby, erchef, chef]) end end