molinillo 0.5.0 → 0.5.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1b84ed4e59212748f00d03e6af1c8efa14a50312
4
- data.tar.gz: c23774f7ef7ceb3641ae3f34357fbc4894c9afb5
3
+ metadata.gz: e941ca9751ad429184a78dbb929fba03428d5630
4
+ data.tar.gz: a60bb544a0c227c078e49249848e7a93dcc654b5
5
5
  SHA512:
6
- metadata.gz: 748d0fcec60150be7b9b33b0585ee1bd52e08ba19bf1ac7d2be6889ad2b4669a29d15a5d4de21e22823f9900f8e2f1b364b1ac40406cff35d4261a8a7c783103
7
- data.tar.gz: 1a09bbe11d5b9c1d27e26e5f7b0dfc4848f28a87729d999fea11e784b6ba788a98146108572c6c8b340774360815bc0e3c44ae2f478c9373a85a85be1bbec8c8
6
+ metadata.gz: 7cfb3cbe6a1c524938933f30ad4cce2384b5ddca16632c99609721e841fb70557be98df82fa2feb0980a127dd009d026f9bd5b34edca1d7fa2e39ba6ecae0307
7
+ data.tar.gz: 952805cd2f2fc302b2ea5c11181442c3019755cd22dab63afe37e97121ba270e9b3ddebdf2443c83604578dac2f16f8d9252164c490e1dc7cb02a2694421bbe2
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
  module Molinillo
3
3
  # The version of Molinillo.
4
- VERSION = '0.5.0'.freeze
4
+ VERSION = '0.5.1'.freeze
5
5
  end
@@ -184,6 +184,8 @@ module Molinillo
184
184
  raise VersionConflict.new(c) unless state
185
185
  activated.rewind_to(sliced_states.first || :initial_state) if sliced_states
186
186
  state.conflicts = c
187
+ index = states.size - 1
188
+ @parent_of.reject! { |_, i| i >= index }
187
189
  end
188
190
  end
189
191
 
@@ -209,7 +211,10 @@ module Molinillo
209
211
  # @return [Object] the requirement that led to `requirement` being added
210
212
  # to the list of requirements.
211
213
  def parent_of(requirement)
212
- @parent_of[requirement]
214
+ return unless requirement
215
+ return unless index = @parent_of[requirement]
216
+ return unless parent_state = @states[index]
217
+ parent_state.requirement
213
218
  end
214
219
 
215
220
  # @return [Object] the requirement that led to a version of a possibility
@@ -418,7 +423,8 @@ module Molinillo
418
423
  debug(depth) { "Requiring nested dependencies (#{nested_dependencies.join(', ')})" }
419
424
  nested_dependencies.each do |d|
420
425
  activated.add_child_vertex(name_for(d), nil, [name_for(activated_spec)], d)
421
- @parent_of[d] = requirement
426
+ parent_index = states.size - 1
427
+ @parent_of[d] ||= parent_index
422
428
  end
423
429
 
424
430
  push_state_for_requirements(requirements + nested_dependencies, !nested_dependencies.empty?)
@@ -4,7 +4,7 @@ require 'json'
4
4
  require 'open-uri'
5
5
  require 'set'
6
6
 
7
- GEMS = %w(rails capybara bundler github-linguist).freeze
7
+ GEMS = %w(chef).freeze
8
8
 
9
9
  VERSION_PATTERN = /\A
10
10
  [0-9]+\.[0-9]+\.[0-9]+ (?# Number component)
@@ -28,7 +28,7 @@ def coerce_to_semver(version)
28
28
  semver = parts[0..2].join('.')
29
29
  semver.sub!(/([a-zA-Z])/, '-\1')
30
30
  semver += '-' + parts[-1] if parts.size > 3
31
- semver
31
+ semver.chomp(".")
32
32
  end
33
33
 
34
34
  def coerce_dependencies_to_semver(deps)
@@ -121,6 +121,81 @@ module Molinillo
121
121
  expect(resolved.map(&:payload).map(&:to_s)).to eq(['actionpack (1.2.3)'])
122
122
  end
123
123
 
124
+ it 'can resolve when two specs have the same dependencies' do
125
+ bundler_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
+ def sort_dependencies(dependencies, activated, conflicts)
130
+ dependencies.sort_by do |dependency|
131
+ name = name_for(dependency)
132
+ [
133
+ activated.vertex_named(name).payload ? 0 : 1,
134
+ conflicts[name] ? 0 : 1,
135
+ activated.vertex_named(name).payload ? 0 : search_for(dependency).count,
136
+ ]
137
+ end
138
+ end
139
+ end
140
+
141
+ index = bundler_index.new('rubygems-2016-09-11')
142
+ @resolver = described_class.new(index, TestUI.new)
143
+ demands = [
144
+ VersionKit::Dependency.new('chef', '~> 12.1.2'),
145
+ ]
146
+
147
+ resolved = @resolver.resolve(demands, DependencyGraph.new)
148
+
149
+ expected = [
150
+ 'rake (10.5.0)',
151
+ 'builder (3.2.2)',
152
+ 'ffi (1.9.14)',
153
+ 'libyajl2 (1.2.0)',
154
+ 'hashie (2.1.2)',
155
+ 'mixlib-log (1.7.1)',
156
+ 'rack (2.0.1)',
157
+ 'uuidtools (2.1.5)',
158
+ 'diff-lcs (1.2.5)',
159
+ 'erubis (2.7.0)',
160
+ 'highline (1.7.8)',
161
+ 'mixlib-cli (1.7.0)',
162
+ 'mixlib-config (2.2.4)',
163
+ 'mixlib-shellout (2.2.7)',
164
+ 'net-ssh (2.9.4)',
165
+ 'ipaddress (0.8.3)',
166
+ 'mime-types (2.99.3)',
167
+ 'systemu (2.6.5)',
168
+ 'wmi-lite (1.0.0)',
169
+ 'plist (3.1.0)',
170
+ 'coderay (1.1.1)',
171
+ 'method_source (0.8.2)',
172
+ 'slop (3.6.0)',
173
+ 'rspec-support (3.5.0)',
174
+ 'multi_json (1.12.1)',
175
+ 'net-telnet (0.1.1)',
176
+ 'sfl (2.2.0)',
177
+ 'ffi-yajl (1.4.0)',
178
+ 'mixlib-authentication (1.4.1)',
179
+ 'net-ssh-gateway (1.2.0)',
180
+ 'net-scp (1.2.1)',
181
+ 'pry (0.10.4)',
182
+ 'rspec-core (3.5.3)',
183
+ 'rspec-expectations (3.5.0)',
184
+ 'rspec-mocks (3.5.0)',
185
+ 'chef-zero (4.2.3)',
186
+ 'ohai (8.4.0)',
187
+ 'net-ssh-multi (1.2.1)',
188
+ 'specinfra (2.61.3)',
189
+ 'rspec_junit_formatter (0.2.3)',
190
+ 'rspec-its (1.2.0)',
191
+ 'rspec (3.5.0)',
192
+ 'serverspec (2.36.1)',
193
+ 'chef (12.1.2)',
194
+ ]
195
+
196
+ expect(resolved.map(&:payload).map(&:to_s)).to match_array(expected)
197
+ end
198
+
124
199
  # Regression test. See: https://github.com/CocoaPods/Molinillo/pull/38
125
200
  it 'can resolve when swapping children with successors' do
126
201
  swap_child_with_successors_index = Class.new(TestIndex) do
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.5.0
4
+ version: 0.5.1
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-06-14 00:00:00.000000000 Z
11
+ date: 2016-09-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -96,7 +96,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
96
96
  version: '0'
97
97
  requirements: []
98
98
  rubyforge_project:
99
- rubygems_version: 2.6.4
99
+ rubygems_version: 2.6.6
100
100
  signing_key:
101
101
  specification_version: 4
102
102
  summary: Provides support for dependency resolution