aboutsummaryrefslogtreecommitdiffstats
path: root/test/rubygems/test_gem_specification.rb
Commit message (Collapse)AuthorAgeFilesLines
* Revert "Manually merged from https://github.com/rubygems/rubygems/pull/2636"Hiroshi SHIBATA2020-09-231-10/+0
| | | | | 31a6eaabc165d8a222e176f2c809d90622d88ec2 is obsoleted with https://github.com/rubygems/rubygems/pull/3820
* Manually merged from https://github.com/rubygems/rubygems/pull/2636Hiroshi SHIBATA2020-09-231-0/+10
| | | | Enable Style/EmptyLinesAroundClassBody rubocop cop.
* [rubygems/rubygems] Make sure tests at least load without opensslDavid Rodríguez2020-07-311-0/+3
| | | | https://github.com/rubygems/rubygems/commit/054d57f74b
* [rubygems/rubygems] Reword warningbronzdoc2020-07-311-1/+1
| | | | https://github.com/rubygems/rubygems/commit/cbd4abf8cf
* [rubygems/rubygems] Warn on duplicate dependency in a specificationbronzdoc2020-07-311-0/+7
| | | | https://github.com/rubygems/rubygems/commit/af3e5f7883
* Enforce no empty lines around class body in rubygemsDavid Rodríguez2020-07-311-10/+0
| | | | To normalize the code style with `bundler`.
* Use space inside block braces everywhereDavid Rodríguez2020-06-151-16/+16
| | | | To make rubygems code style consistent with bundler.
* [rubygems/rubygems] Only run optional validations in packaging contextsDavid Rodríguez2020-06-051-0/+11
| | | | https://github.com/rubygems/rubygems/commit/f4fe949dfa
* [rubygems/rubygems] Add build warning when rake based extension is present, ↵Josef Šimánek2020-06-051-0/+31
| | | | | | but rake is not specified as dependency. https://github.com/rubygems/rubygems/commit/75fe5475b6
* [rubygems/rubygems] Revert adding loaded specs to `Gem::Specification.stubs` ↵David Rodríguez2020-05-081-42/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | and `Gem::Specification.stubs_for` The rationale is that: * The change has caused realworld issues. See for example https://github.com/ruby/did_you_mean/issues/117 and specifically [this comment](https://github.com/ruby/did_you_mean/issues/117#issuecomment-482733159) for a great explanation of the issue it caused for `did_you_mean`. * The change also causes problems for our development workflows. For example, because of it, our `bundler` specs cannot currently be run with `bin/rake` and we have to use `bin/rspec` or `bin/parallel_spec` directly. The explanation for this is: - Our specs install test dependencies to `tmp` before running specs. - `rake` is one of these test dependencies. - Before installing each test dependency, we check whether it has matching installed specs: https://github.com/rubygems/rubygems/blob/2bbcdcde08b90d4ef03da8fb1f7a8a3313e13bb8/bundler/spec/support/rubygems_ext.rb#L109-L114. - Normally, if `rake` has not yet been installed to `tmp`, this check fails and `rake` is installed, but since the loaded specs are now added to `Gem::Specification.stubs` and `rake`'s specification _is_ loaded because we're running through `bin/rake`, the check incorrectly assumes that `rake` is already installed to `tmp` and skips installation. - At a later point the specs check whether `rake` is actually installed and fail if it's not: https://github.com/rubygems/rubygems/blob/2bbcdcde08b90d4ef03da8fb1f7a8a3313e13bb8/bundler/spec/support/builders.rb#L372-L383 Essentially, both of the issues are the same. If at runtime we change the location of gems, we'll _want_ to not consider loaded specifications when dealing with the new gem location, because the loaded specifications have not been loaded from there. Loaded specifications is something different from installed stub specifications and those should not be mixed. The PR still seemed to have fixed an issue, so I did my archaeology job and investigated the original issue to double check if reverting is ok. The logs for the original error can be found here: https://ci.appveyor.com/project/rubygems/rubygems/build/1172/job/ogubyucpljcv22ux. So I installed ruby 2.4.4, checked out the commit reference before the offending PR, and the exact error reproduced. :tada: ``` $ rake test /home/deivid/Code/rubygems/lib/rubygems/resolver.rb:231:in `search_for': Unable to resolve dependency: user requested 'bundler (= 1.16.2)' (Gem::UnsatisfiableDependencyError) from /home/deivid/Code/rubygems/lib/rubygems/resolver.rb:283:in `block in sort_dependencies' from /home/deivid/Code/rubygems/lib/rubygems/resolver.rb:277:in `each' from /home/deivid/Code/rubygems/lib/rubygems/resolver.rb:277:in `sort_by' from /home/deivid/Code/rubygems/lib/rubygems/resolver.rb:277:in `with_index' from /home/deivid/Code/rubygems/lib/rubygems/resolver.rb:277:in `sort_dependencies' from /home/deivid/Code/rubygems/lib/rubygems/resolver/molinillo/lib/molinillo/delegates/specification_provider.rb:52:in `block in sort_dependencies' from /home/deivid/Code/rubygems/lib/rubygems/resolver/molinillo/lib/molinillo/delegates/specification_provider.rb:69:in `with_no_such_dependency_error_handling' from /home/deivid/Code/rubygems/lib/rubygems/resolver/molinillo/lib/molinillo/delegates/specification_provider.rb:51:in `sort_dependencies' from /home/deivid/Code/rubygems/lib/rubygems/resolver/molinillo/lib/molinillo/resolution.rb:165:in `initial_state' from /home/deivid/Code/rubygems/lib/rubygems/resolver/molinillo/lib/molinillo/resolution.rb:106:in `start_resolution' from /home/deivid/Code/rubygems/lib/rubygems/resolver/molinillo/lib/molinillo/resolution.rb:64:in `resolve' from /home/deivid/Code/rubygems/lib/rubygems/resolver/molinillo/lib/molinillo/resolver.rb:42:in `resolve' from /home/deivid/Code/rubygems/lib/rubygems/resolver.rb:188:in `resolve' from /home/deivid/Code/rubygems/lib/rubygems/request_set.rb:396:in `resolve' from /home/deivid/Code/rubygems/lib/rubygems/request_set.rb:408:in `resolve_current' from /home/deivid/Code/rubygems/lib/rubygems.rb:243:in `finish_resolve' from /home/deivid/Code/rubygems/lib/rubygems/rdoc.rb:13:in `<top (required)>' from /home/deivid/Code/rubygems/lib/rubygems/core_ext/kernel_require.rb:54:in `require' from /home/deivid/Code/rubygems/lib/rubygems/core_ext/kernel_require.rb:54:in `require' from /home/deivid/Code/rubygems/lib/rubygems/test_case.rb:1563:in `<top (required)>' from /home/deivid/Code/rubygems/test/rubygems/test_bundled_ca.rb:2:in `require' from /home/deivid/Code/rubygems/test/rubygems/test_bundled_ca.rb:2:in `<top (required)>' from /home/deivid/.rbenv/versions/2.4.4/lib/ruby/gems/2.4.0/gems/rake-12.0.0/lib/rake/rake_test_loader.rb:15:in `require' from /home/deivid/.rbenv/versions/2.4.4/lib/ruby/gems/2.4.0/gems/rake-12.0.0/lib/rake/rake_test_loader.rb:15:in `block in <main>' from /home/deivid/.rbenv/versions/2.4.4/lib/ruby/gems/2.4.0/gems/rake-12.0.0/lib/rake/rake_test_loader.rb:4:in `select' from /home/deivid/.rbenv/versions/2.4.4/lib/ruby/gems/2.4.0/gems/rake-12.0.0/lib/rake/rake_test_loader.rb:4:in `<main>' rake aborted! Command failed with status (1) Tasks: TOP => test ``` Now the explanation of the error: * Rubygems base `TestCase` class requires `bundler` because some tests use `bundler`: https://github.com/rubygems/rubygems/blob/2bbcdcde08b90d4ef03da8fb1f7a8a3313e13bb8/lib/rubygems/test_case.rb#L26 * That `require` (our custom rubygems require) would activate the default bundler spec (1.16.1 for ruby 2.4.4) but then overwrite it with a 1.16.2 version (the locally provided bundler those days) due to [this old hack](https://github.com/rubygems/bundler/blob/9f7bf0ac3ab8d995e3a274cec3c292a5203f4534/lib/bundler/version.rb#L7-L23). * Rubygems base `TestCase` class requires `rubygems/rdoc`: https://github.com/rubygems/rubygems/blob/2bbcdcde08b90d4ef03da8fb1f7a8a3313e13bb8/lib/rubygems/test_case.rb#L1536 * And that file ends up calling `Gem.finish_resolve`: https://github.com/rubygems/rubygems/blob/2bbcdcde08b90d4ef03da8fb1f7a8a3313e13bb8/lib/rubygems/rdoc.rb#L13 * `Gem.finish_resolve` adds the currently loaded specs to the resolution: https://github.com/rubygems/rubygems/blob/2bbcdcde08b90d4ef03da8fb1f7a8a3313e13bb8/lib/rubygems.rb#L235 * That means it would try to resolve bundler 1.16.2, but no specification for that version was installed since the default was 1.16.1. That explains why upgrading to rubygems 2.7.7 fixed the issue, since it provided bundler 1.16.2 by default so there was not bundler version discrepancy. After understanding the error, I conclude that: * Only this part of the original patch was actually needed to resolve the error, not any of the changes in `Gem::Specification.stubs` and `Gem::Specification.stubs_for`: ```diff diff --git a/lib/rubygems/test_case.rb b/lib/rubygems/test_case.rb index f1cd3d274c..92c848e870 100644 --- a/lib/rubygems/test_case.rb +++ b/lib/rubygems/test_case.rb @@ -13,6 +13,15 @@ else require 'rubygems' end +# If bundler gemspec exists, add to stubs +bundler_gemspec = File.expand_path("../../../bundler/bundler.gemspec", __FILE__) +if File.exist?(bundler_gemspec) + Gem::Specification.dirs.unshift File.dirname(bundler_gemspec) + Gem::Specification.class_variable_set :@@stubs, nil + Gem::Specification.stubs + Gem::Specification.dirs.shift +end + begin gem 'minitest' rescue Gem::LoadError ``` So, I propose to revert adding loaded specification to `Gem::Specification.stubs` and `Gem::Specification.stubs_for` because I think it's safe, it fixes the issues caused by their addition, and it simplifies `Gem::Specification` code, which is already complicated enough. https://github.com/rubygems/rubygems/commit/5269cd617c
* [rubygems/rubygems] Test that two calls to `stub_for` returns the same ↵Vít Ondruch2020-05-081-0/+5
| | | | | | (cached) instance. https://github.com/rubygems/rubygems/commit/00b3f55562
* [rubygems/rubygems] Let `@@stubs_by_name` to be incrementally populated again.Vít Ondruch2020-05-081-0/+19
| | | | | | | | | | | | | | | | | | | Originally, the call to `.stubs_for` allowed to incrementally populate the `@@stubs_by_name` (especially see the `"#{name}-*.gemspec"` pattern in 4fa03bb7aac9f25f44394e818433fdda9962ae8d). Now it looks like it expects that all stubs are loaded, but the `.stubs_for` still matches the .gemspec files by the `name` pattern: https://github.com/rubygems/rubygems/blob/6d45e0f7ac1caca22900e39f703e226c4cfdebf7/lib/rubygems/specification.rb#L845 I think this was done by mistake incrementally by PR #1239 and 4cee8ca9199ac7b3ab8647e0b78615f55d3eb02b. I think the best option is to get back to the original implementation, to let RubyGems incrementally populate the array. Other option would be to replace the logic in `.stub_for` by call to `.stubs`, but the means the performance improvement from the original commit was lost. https://github.com/rubygems/rubygems/commit/4d0e18185a
* Normalize heredoc case in rubygems code baseDavid Rodríguez2020-05-081-12/+12
|
* [rubygems/rubygems] Only run the $SAFE test on MRI < 2.7Benoit Daloze2020-05-081-1/+1
| | | | | | * Other Ruby implementations don't support $SAFE. https://github.com/rubygems/rubygems/commit/9a4ba16efa
* [rubygems/rubygems] Track removed methods calls and warn during build time.Josef Šimánek2020-05-081-10/+5
| | | | | | move rubyforge_project= to removed methods https://github.com/rubygems/rubygems/commit/223f7fd470
* [rubygems/rubygems] Deprecate rubyforge_project attribute only during build ↵Josef Šimánek2020-05-081-0/+20
| | | | | | time. https://github.com/rubygems/rubygems/commit/c44eb21648
* [rubygems/rubygems] Make the test suite pass under `umask 077`Yusuke Endoh2020-04-281-6/+11
| | | | | | | | | | Some tests had failed under `umask 077` mode. As far as I investigated, there is no actual bug. All failures were caused by tests that create a wrong-permission file or expect wrong permission. This changeset fixes the tests. https://github.com/rubygems/rubygems/commit/078213e527
* [rubygems/rubygems] Enable `Style/ExtraSpacing` and auto-correctDavid Rodríguez2020-03-301-5/+5
| | | | https://github.com/rubygems/rubygems/commit/6fa0b1b679
* [rubygems/rubygems] Enable Style/PercentLiteralDelimiters cop in rubygemsDavid Rodríguez2020-03-301-48/+48
| | | | | | So it matches the style used by bundler. https://github.com/rubygems/rubygems/commit/ab0580fd65
* Sync rubygems with current master (#2889)David Rodríguez2020-03-241-0/+5
|
* Merge the current master branch of rubygems/rubygems.Hiroshi SHIBATA2020-02-011-6/+7
| | | | Just started to develop RubyGems 3.2.0.
* Do not load files in build directoryKazuhiro NISHIYAMA2019-12-111-48/+48
| | | | related https://bugs.ruby-lang.org/issues/16177
* Merge RubyGems 3.1.0.pre3Hiroshi SHIBATA2019-11-111-16/+17
| | | | | | | | | | | | | | | | | | | * Fix gem pristine not accounting for user installed gems. Pull request #2914 by Luis Sagastume. * Refactor keyword argument test for Ruby 2.7. Pull request #2947 by SHIBATA Hiroshi. * Fix errors at frozen Gem::Version. Pull request #2949 by Nobuyoshi Nakada. * Remove taint usage on Ruby 2.7+. Pull request #2951 by Jeremy Evans. * Check Manifest.txt is up to date. Pull request #2953 by David Rodríguez. * Clarify symlink conditionals in tests. Pull request #2962 by David Rodríguez. * Update command line parsing to work under ps. Pull request #2966 by David Rodríguez. * Properly test `Gem::Specifications.stub_for`. Pull request #2970 by David Rodríguez. * Fix Gem::LOADED_SPECS_MUTEX handling for recursive locking. Pull request #2985 by MSP-Greg.
* [rubygems/rubygems] Also bump test variableHiroshi SHIBATA2019-10-151-1/+1
| | | | https://github.com/rubygems/rubygems/commit/97e9768612
* [rubygems/rubygems] Do not compare with unreliable Gem::Specification::TODAYNobuyoshi Nakada2019-10-101-15/+18
| | | | | | https://gist.github.com/ko1/a88834d744a0682711dab53fd9015a04#file-brlog-trunk-nopara-20191005-235153-L393-L472 https://github.com/rubygems/rubygems/commit/707408d8e7
* [rubygems/rubygems] Restrict possible date rangeNobuyoshi Nakada2019-10-101-2/+3
| | | | https://github.com/rubygems/rubygems/commit/1bd77f53df
* [rubygems/rubygems] The date might have advanced since TODAY has been setNobuyoshi Nakada2019-10-051-1/+3
| | | | | | https://bugs.ruby-lang.org/issues/16189 https://github.com/rubygems/rubygems/commit/e331222163
* [rubygems/rubygems] Update expectation in test_to_ruby_with_rsa_keybronzdoc2019-09-261-2/+1
| | | | https://github.com/rubygems/rubygems/commit/2e65f7d4ae
* [rubygems/rubygems] Make ruby_code method handle OpenSSL::PKey::RSA objectsbronzdoc2019-09-261-0/+30
| | | | https://github.com/rubygems/rubygems/commit/b1d825ab3a
* [rubygems/rubygems] Revert cadb66037d9b58c80fc795f39384d533229a1f73bronzdoc2019-08-051-0/+18
| | | | https://github.com/rubygems/rubygems/commit/5c3158d975
* [rubygems/rubygems] Move default specifications dir definition out of ↵Vít Ondruch2019-07-311-3/+3
| | | | | | | | | | | | BasicSpecification. This was never the right place. The method got there just by evolution, not by design. Move it within default methods, where it suits better. Since this method is presumably used just internally, it should be safe to deprecate it and remove later. https://github.com/rubygems/rubygems/commit/0c0dd9458a
* [rubygems/rubygems] Autorequire was used by old RubyGems, it is neither ↵bronzdoc2019-07-311-18/+0
| | | | | | supported nor functional. https://github.com/rubygems/rubygems/commit/cadb66037d
* [rubygems/rubygems] Simplify #to_ruby codeNobuyoshi Nakada2019-07-311-19/+11
| | | | | | | | | | Separate #add_runtime_dependency and #add_development_dependency availability condition from #specification_version availability, which is not related to directly. Also check if the former method is available, instead of comparing the version. https://github.com/rubygems/rubygems/commit/5cccc2b836
* Merge rubygems master from upstream.Hiroshi SHIBATA2019-06-011-2/+11
| | | | I picked the commit from 3c469e0da538428a0ddd94f99aa73c32da22e8ba
* Fix fd leakNobuyoshi Nakada2019-05-161-1/+1
| | | | merged https://github.com/rubygems/rubygems/pull/2765
* Renamed duplicate testnobu2019-03-111-1/+1
| | | | | | Import rubygems/rubygems#2678 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67205 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Ignore to handle the different platformhsbt2019-03-071-1/+13
| | | | | | | When `GEM_HOME` was shared with CRuby and JRuby. RubyGems try to handle both platforms. It should be ignored the different platform. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67190 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Merge RubyGems upstream: 56c0bbb69e4506bda7ef7f447dfec5db820df20bhsbt2019-03-051-0/+8
| | | | | | | It fixed the multiple vulnerabilities. https://blog.rubygems.org/2019/03/05/security-advisories-2019-03.html git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67168 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Merge RubyGems master@9be7858f7f17eae3058204f3c03e4b798ba18b9chsbt2019-02-141-14/+23
| | | | | | | | | | | This version contains the some style changes by RuboCop. * https://github.com/rubygems/rubygems/commit/9d810be0ede925fb2e3af535848582c3f8e0e72f * https://github.com/rubygems/rubygems/commit/61ea98a727fb1b76b6fac52d74107ee4b02aaef2 * https://github.com/rubygems/rubygems/commit/795893dce3c5f8540804fc08144cc6a90f086b13 * https://github.com/rubygems/rubygems/commit/9be7858f7f17eae3058204f3c03e4b798ba18b9c git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67074 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Merge rubygems master targeted RubyGems 3.1.0.hsbt2019-01-221-2/+2
| | | | | | https://github.com/rubygems/rubygems/commit/1172320540c8c33c59fc1db5191b021c3b2db487 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66904 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Restore SOURCE_DATE_EPOCHnobu2018-12-251-0/+3
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66554 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Merge rubygems@21f12a8 from upstream.hsbt2018-12-121-6/+4
| | | | | | | * [BudlerVersionFinder] set .filter! and .compatible? to match only on major versions https://github.com/rubygems/rubygems/pull/2515 * Fix broken symlink that points to ../* https://github.com/rubygems/rubygems/pull/2516 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66347 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Merge rubygems master@221bdeahsbt2018-12-041-0/+10
| | | | | | * Fixed https://github.com/rubygems/rubygems/pull/2506 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66188 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Merge rubygems upstream from ↵hsbt2018-11-281-12/+0
| | | | | | | | https://github.com/rubygems/rubygems/commit/2c499655f29070c809dfea9f5fda6fac6850e62e https://github.com/rubygems/rubygems/pull/2493 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66065 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Merge master branch from rubygems/rubygems upstream.hsbt2018-11-211-4/+14
| | | | | | | | | | | | | * Enable Style/MethodDefParentheses in Rubocop https://github.com/rubygems/rubygems/pull/2478 * Enable Style/MultilineIfThen in Rubocop https://github.com/rubygems/rubygems/pull/2479 * Fix required_ruby_version with prereleases and improve error message https://github.com/rubygems/rubygems/pull/2344 * Fix bundler rubygems binstub not properly looking for bundler https://github.com/rubygems/rubygems/pull/2426 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65904 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Merge rubygems master branch from github.com/rubygems/rubygems.hsbt2018-10-221-6/+6
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65294 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * remove trailing spaces.svn2018-08-271-1/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64556 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Merge master branch from rubygems upstream.hsbt2018-08-271-18/+137
| | | | | | | | * It's preparation to release RubyGems 3.0.0.beta2 and Ruby 2.6.0 preview 3. * https://github.com/rubygems/rubygems/compare/v3.0.0.beta1...fad2eb15a282b19dfcb4b48bc95b8b39ebb4511f git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64555 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Merge RubyGems 3.0.0.beta1.hsbt2018-05-301-171/+196
| | | | | | | | | * It drop to support < Ruby 2.2 * Cleanup deprecated methods and classes. * Mark obsoleted methods to deprecate. * and other enhancements. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63528 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Merge RubyGems 2.7.7hsbt2018-05-181-1/+1
| | | | | | see release details here: https://blog.rubygems.org/2018/05/18/2.7.7-released.html git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63461 b2dd03c8-39d4-4d8f-98ff-823fe69b080e