molinillo 0.4.4 → 0.4.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e9236a5dbc46018bc0f27a22e51d675808034c0f
4
- data.tar.gz: fc9a01753517f46df9ced17dd489b4329d812fa4
3
+ metadata.gz: 5471c5978d4fcbf76eb45959379323cb82e267c5
4
+ data.tar.gz: 7fdf053d634d953fd63625c8954ead0f36d7b9cd
5
5
  SHA512:
6
- metadata.gz: b75238ffd8561de2d08d4965b167193ea40e83305892d35d228a105166740f4f18da1a02d4d844be5f13b20ab0f900d9bdd6c54bc56c238339646365d45f2b8c
7
- data.tar.gz: f39575f18399b6e67fc98ee2efda18e4578f4cfd53c1b29366e17857031812afaaf2e4ff91eb6a1d424e4f0d010f207a311e4404d2c4fc3a118308913c8f54df
6
+ metadata.gz: 7eebcc4b974f45733fbf034330958c5add2ad31b0dfd674f2442d6811761bbbf7a4ae160d3f1c6a98e19483d2d5511d715c724c15e07eff52dbc8da92234a257
7
+ data.tar.gz: ab9a7d6eb33b8f40cf1aa4a9a5495da77c4ee2eeac629d128cffb5e9e54fbf5f1acc06d8a23f2af20960e05dbb7f58c3eebd723f8b58c5623bec9040640adb70
@@ -16,7 +16,7 @@ module Molinillo
16
16
  include TSort
17
17
 
18
18
  # @visibility private
19
- alias_method :tsort_each_node, :each
19
+ alias tsort_each_node each
20
20
 
21
21
  # @visibility private
22
22
  def tsort_each_child(vertex, &block)
@@ -184,7 +184,7 @@ module Molinillo
184
184
 
185
185
  # @return [Boolean] whether the vertex is considered a root vertex
186
186
  attr_accessor :root
187
- alias_method :root?, :root
187
+ alias root? root
188
188
 
189
189
  # Initializes a vertex with the given name and payload.
190
190
  # @param [String] name see {#name}
@@ -262,7 +262,7 @@ module Molinillo
262
262
  payload == other.payload
263
263
  end
264
264
 
265
- alias_method :eql?, :==
265
+ alias eql? ==
266
266
 
267
267
  # @return [Fixnum] a hash for the vertex based upon its {#name}
268
268
  def hash
@@ -276,7 +276,7 @@ module Molinillo
276
276
  equal?(other) || successors.any? { |v| v.path_to?(other) }
277
277
  end
278
278
 
279
- alias_method :descendent?, :path_to?
279
+ alias descendent? path_to?
280
280
 
281
281
  # Is there a path from `other` to `self` following edges in the
282
282
  # dependency graph?
@@ -285,7 +285,7 @@ module Molinillo
285
285
  other.path_to?(self)
286
286
  end
287
287
 
288
- alias_method :is_reachable_from?, :ancestor?
288
+ alias is_reachable_from? ancestor?
289
289
  end
290
290
  end
291
291
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
  module Molinillo
3
3
  # The version of Molinillo.
4
- VERSION = '0.4.4'.freeze
4
+ VERSION = '0.4.5'.freeze
5
5
  end
@@ -131,7 +131,7 @@ module Molinillo
131
131
  specification_provider.send(instance_method, *args, &block)
132
132
  rescue NoSuchDependencyError => error
133
133
  if state
134
- vertex = activated.vertex_named(name_for error.dependency)
134
+ vertex = activated.vertex_named(name_for(error.dependency))
135
135
  error.required_by += vertex.incoming_edges.map { |e| e.origin.name }
136
136
  error.required_by << name_for_explicit_dependency_source unless vertex.explicit_requirements.empty?
137
137
  end
@@ -345,7 +345,7 @@ module Molinillo
345
345
  vertex = swapped.vertex_named(name)
346
346
  vertex.payload = possibility
347
347
  return unless vertex.requirements.
348
- all? { |r| requirement_satisfied_by?(r, swapped, possibility) }
348
+ all? { |r| requirement_satisfied_by?(r, swapped, possibility) }
349
349
  return unless new_spec_satisfied?
350
350
  actual_vertex = activated.vertex_named(name)
351
351
  actual_vertex.payload = possibility
@@ -363,7 +363,13 @@ module Molinillo
363
363
  if !dep_names.include?(succ.name) && !succ.root? && succ.predecessors.to_a == [vertex]
364
364
  debug(depth) { "Removing orphaned spec #{succ.name} after swapping #{name}" }
365
365
  activated.detach_vertex_named(succ.name)
366
- requirements.delete_if { |r| name_for(r) == succ.name }
366
+
367
+ all_successor_names = succ.recursive_successors.map(&:name)
368
+
369
+ requirements.delete_if do |requirement|
370
+ requirement_name = name_for(requirement)
371
+ (requirement_name == succ.name) || all_successor_names.include?(requirement_name)
372
+ end
367
373
  end
368
374
  end
369
375
  end
@@ -420,14 +426,14 @@ module Molinillo
420
426
  debug(depth) { "Requiring nested dependencies (#{nested_dependencies.join(', ')})" }
421
427
  nested_dependencies.each { |d| activated.add_child_vertex(name_for(d), nil, [name_for(activated_spec)], d) }
422
428
 
423
- push_state_for_requirements(requirements + nested_dependencies, nested_dependencies.size > 0)
429
+ push_state_for_requirements(requirements + nested_dependencies, !nested_dependencies.empty?)
424
430
  end
425
431
 
426
432
  # Pushes a new {DependencyState} that encapsulates both existing and new
427
433
  # requirements
428
434
  # @param [Array] new_requirements
429
435
  # @return [void]
430
- def push_state_for_requirements(new_requirements, requires_sort = true, new_activated = activated.dup)
436
+ def push_state_for_requirements(new_requirements, requires_sort = true, new_activated = activated)
431
437
  new_requirements = sort_dependencies(new_requirements.uniq, new_activated, conflicts) if requires_sort
432
438
  new_requirement = new_requirements.shift
433
439
  new_name = new_requirement ? name_for(new_requirement) : ''
@@ -119,6 +119,51 @@ module Molinillo
119
119
  resolved = @resolver.resolve([dep], DependencyGraph.new)
120
120
  expect(resolved.map(&:payload).map(&:to_s)).to eq(['actionpack (1.2.3)'])
121
121
  end
122
+
123
+ # Regression test. See: https://github.com/CocoaPods/Molinillo/pull/38
124
+ it 'can resolve when swapping children with successors' do
125
+ swap_child_with_successors_index = Class.new(TestIndex) do
126
+ # The bug we want to write a regression test for only occurs when
127
+ # Molinillo processes dependencies in a specific order for the given
128
+ # index and demands. This sorting logic ensures we hit the repro case
129
+ # when using the index file "swap_child_with_successors"
130
+ def sort_dependencies(dependencies, activated, conflicts)
131
+ dependencies.sort_by do |dependency|
132
+ name = name_for(dependency)
133
+ [
134
+ activated.vertex_named(name).payload ? 0 : 1,
135
+ conflicts[name] ? 0 : 1,
136
+ activated.vertex_named(name).payload ? 0 : versions_of(name),
137
+ ]
138
+ end
139
+ end
140
+
141
+ def versions_of(dependency_name)
142
+ specs[dependency_name].count
143
+ end
144
+ end
145
+
146
+ index = swap_child_with_successors_index.new('swap_child_with_successors')
147
+ @resolver = described_class.new(index, TestUI.new)
148
+ demands = [
149
+ VersionKit::Dependency.new('build-essential', '>= 0.0.0'),
150
+ VersionKit::Dependency.new('nginx', '>= 0.0.0'),
151
+ ]
152
+
153
+ resolved = @resolver.resolve(demands, DependencyGraph.new)
154
+
155
+ expected = [
156
+ 'build-essential (2.4.0)',
157
+ '7-zip (1.0.0)',
158
+ 'windows (1.39.2)',
159
+ 'chef-handler (1.3.0)',
160
+ 'nginx (2.7.6)',
161
+ 'yum-epel (0.6.6)',
162
+ 'yum (3.10.0)',
163
+ ]
164
+
165
+ expect(resolved.map(&:payload).map(&:to_s)).to match_array(expected)
166
+ end
122
167
  end
123
168
  end
124
169
  end
data/spec/spec_helper.rb CHANGED
@@ -33,4 +33,6 @@ require 'molinillo'
33
33
  RSpec.configure do |config|
34
34
  # Enable flags like --only-failures and --next-failure
35
35
  config.example_status_persistence_file_path = '.rspec_status'
36
+ config.filter_run :focus => true
37
+ config.run_all_when_everything_filtered = true
36
38
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: molinillo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.4
4
+ version: 0.4.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel E. Giddins
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-02-28 00:00:00.000000000 Z
11
+ date: 2016-04-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -85,7 +85,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
85
85
  version: '0'
86
86
  requirements: []
87
87
  rubyforge_project:
88
- rubygems_version: 2.6.0
88
+ rubygems_version: 2.6.3
89
89
  signing_key:
90
90
  specification_version: 4
91
91
  summary: Provides support for dependency resolution