diff options
author | ko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-08-04 14:57:31 +0000 |
---|---|---|
committer | ko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-08-04 14:57:31 +0000 |
commit | 41e1670a64405133e3d25b73e5cab9456ccb364e (patch) | |
tree | b8035897325cace1e35d99068123a500ef71d422 /lib/rubygems | |
parent | 92c52f08322bae4f8f1094fe8135532a0f4d5bcc (diff) |
use stable sort.
* lib/rubygems/resolver.rb (sort_dependencies): use stable sort.
TestGemRequestSetLockfile#test_to_s_gem_dependency_non_default
fails because this method return unstable results.
Note that Enumerable#sort_by is unstable.
I'm not sure the "stable" nature is required for RubyGems.
The fact is that using stable sort, the test passed on
mswin64+VS2017 where the sort results was reverse (unstable) order.
Also using `-i` instead of `i` (it means forcing unstable sort)
this test fails on other platform where the test successed before.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59502 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/rubygems')
-rw-r--r-- | lib/rubygems/resolver.rb | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/lib/rubygems/resolver.rb b/lib/rubygems/resolver.rb index a7b11179c8..8f0db512a2 100644 --- a/lib/rubygems/resolver.rb +++ b/lib/rubygems/resolver.rb @@ -254,13 +254,14 @@ class Gem::Resolver end def sort_dependencies(dependencies, activated, conflicts) - dependencies.sort_by do |dependency| + dependencies.sort_by.with_index do |dependency, i| name = name_for(dependency) [ activated.vertex_named(name).payload ? 0 : 1, amount_constrained(dependency), conflicts[name] ? 0 : 1, activated.vertex_named(name).payload ? 0 : search_for(dependency).count, + i # for stable sort ] end end |