Permalink
Browse files

Fix filtering of platform gems in always_install

Previously platform was ignored when choosing a gem to always install.
This meant a platform that could not be installed was chosen and nothing
would happen.
  • Loading branch information...
1 parent 0514a3e commit 8a920483953eb2f1d7ec5e6ab0d0ba1cde4e0a0d @drbrain drbrain committed Jan 24, 2014
Showing with 22 additions and 0 deletions.
  1. +6 −0 lib/rubygems/resolver/installer_set.rb
  2. +16 −0 test/rubygems/test_gem_resolver_installer_set.rb
@@ -55,6 +55,12 @@ def add_always_install dependency
found.delete_if { |s| s.version.prerelease? } unless dependency.prerelease?
+ found = found.select do |s|
+ Gem::Source::SpecificFile === s.source or
+ Gem::Platform::RUBY == s.platform or
+ Gem::Platform.local === s.platform
+ end
+
if found.empty? then
exc = Gem::UnsatisfiableDependencyError.new request
exc.errors = errors
@@ -37,6 +37,22 @@ def test_add_always_install_errors
refute_empty e.errors
end
+ def test_add_always_install_platform
+ spec_fetcher do |fetcher|
+ fetcher.spec 'a', 1
+ fetcher.spec 'a', 2 do |s|
+ s.platform = Gem::Platform.new 'x86-freebsd-9'
+ end
+ fetcher.clear
+ end
+
+ set = Gem::Resolver::InstallerSet.new :both
+
+ set.add_always_install dep('a')
+
+ assert_equal %w[a-1], set.always_install.map { |s| s.full_name }
+ end
+
def test_add_always_install_prerelease
spec_fetcher do |fetcher|
fetcher.gem 'a', 1

0 comments on commit 8a92048

Please sign in to comment.