summaryrefslogtreecommitdiff
path: root/test/rubygems/test_gem_specification.rb
AgeCommit message (Collapse)Author
2021-06-03[rubygems/rubygems] Rename test/rubygems/test_{case,utilities}.rb to avoid ↵Yusuke Endoh
"test_" prefix This changes "test/rubygems/test_case.rb" to "test/rubygems/helper.rb", and "test/rubygems/test_utilities.rb" to "test/rubygems/utilities.rb". The two files are a helper for tests, not test files. However, a file starting with "test_" prefix is handled as a test file directly loaded by test-unit because Rakefile specifies: ``` t.test_files = FileList['test/**/test_*.rb'] ``` Directly loading test/rubygems/test_utilities.rb caused "uninitialized constant Gem::TestCase". This issue was fixed by 59c682097197fee4052b47e4b4ab86562f3eaa9b, but the fix caused a "circular require" warning because test_utilities.rb and test_case.rb are now requiring each other. Anyway, adding "test_" prefix to a test helper file is confusing, so this changeset reverts the fix and solve the issue by renaming them. https://github.com/rubygems/rubygems/commit/6460e018df
2021-05-28[rubygems/rubygems] Require the new files in `test/` relativelyDavid Rodríguez
https://github.com/rubygems/rubygems/commit/c77868a555
2021-05-28[rubygems/rubygems] Try fix ruby-core CIHiroshi SHIBATA
* Port https://github.com/ruby/ruby/commit/8e91b969df08b7a2eb27a5d6d38733eea42dc7ad from ruby-core, and make it compatible with psych 3 & 4.
2021-05-17Workaround with fbb4e3f96c10de2240f2d87eac19cf6f62f65feaHiroshi SHIBATA
2021-05-12[rubygems/rubygems] util/rubocop -aHiroshi SHIBATA
https://github.com/rubygems/rubygems/commit/a10ff97830 Notes: Merged: https://github.com/ruby/ruby/pull/4491
2021-05-12[rubygems/rubygems] capture_output will return empty string, not nilHiroshi SHIBATA
https://github.com/rubygems/rubygems/commit/3fa93f6144 Notes: Merged: https://github.com/ruby/ruby/pull/4491
2021-05-12[rubygems/rubygems] Rewrite with capture_outputHiroshi SHIBATA
https://github.com/rubygems/rubygems/commit/a091004ded Notes: Merged: https://github.com/ruby/ruby/pull/4491
2021-05-12[rubygems/rubygems] Use assert_raise instead of assert_raisesHiroshi SHIBATA
https://github.com/rubygems/rubygems/commit/769e87f011 Notes: Merged: https://github.com/ruby/ruby/pull/4491
2021-05-12[rubygems/rubygems] Use assert_path_exist and assert_path_not_exist instead ↵Hiroshi SHIBATA
of assert_path_exists and refute_path_exists https://github.com/rubygems/rubygems/commit/a7c93558c3 Notes: Merged: https://github.com/ruby/ruby/pull/4491
2021-05-12[rubygems/rubygems] Extract assert_output to assert_empty and assert_equal ↵Hiroshi SHIBATA
with capture_output https://github.com/rubygems/rubygems/commit/f6759440a4 Notes: Merged: https://github.com/ruby/ruby/pull/4491
2021-05-12[rubygems/rubygems] Use Regexp with refute_matchHiroshi SHIBATA
https://github.com/rubygems/rubygems/commit/51fdbe53bc Notes: Merged: https://github.com/ruby/ruby/pull/4491
2021-05-12[rubygems/rubygems] Use capture_output instead of capture_io.Hiroshi SHIBATA
https://github.com/rubygems/rubygems/commit/ad9206d4d0 Notes: Merged: https://github.com/ruby/ruby/pull/4491
2021-03-08Sync latest development version of bundler & rubygemsDavid Rodríguez
Notes: Merged: https://github.com/ruby/ruby/pull/4143
2021-01-04Track RubyGems master(3.3.0.dev) branch at ↵Hiroshi SHIBATA
55634a8af18a52df86c4275d70fa1179118bcc20 Notes: Merged: https://github.com/ruby/ruby/pull/4021
2020-12-08Merge prepare version of RubyGems 3.2.0Hiroshi SHIBATA
Notes: Merged: https://github.com/ruby/ruby/pull/3864
2020-09-23Revert "Manually merged from https://github.com/rubygems/rubygems/pull/2636"Hiroshi SHIBATA
31a6eaabc165d8a222e176f2c809d90622d88ec2 is obsoleted with https://github.com/rubygems/rubygems/pull/3820
2020-09-23Manually merged from https://github.com/rubygems/rubygems/pull/2636Hiroshi SHIBATA
Enable Style/EmptyLinesAroundClassBody rubocop cop.
2020-07-31[rubygems/rubygems] Make sure tests at least load without opensslDavid Rodríguez
https://github.com/rubygems/rubygems/commit/054d57f74b Notes: Merged: https://github.com/ruby/ruby/pull/3379
2020-07-31[rubygems/rubygems] Reword warningbronzdoc
https://github.com/rubygems/rubygems/commit/cbd4abf8cf Notes: Merged: https://github.com/ruby/ruby/pull/3379
2020-07-31[rubygems/rubygems] Warn on duplicate dependency in a specificationbronzdoc
https://github.com/rubygems/rubygems/commit/af3e5f7883 Notes: Merged: https://github.com/ruby/ruby/pull/3379
2020-07-31Enforce no empty lines around class body in rubygemsDavid Rodríguez
To normalize the code style with `bundler`. Notes: Merged: https://github.com/ruby/ruby/pull/3379
2020-06-15Use space inside block braces everywhereDavid Rodríguez
To make rubygems code style consistent with bundler. Notes: Merged: https://github.com/ruby/ruby/pull/3229
2020-06-05[rubygems/rubygems] Only run optional validations in packaging contextsDavid Rodríguez
https://github.com/rubygems/rubygems/commit/f4fe949dfa Notes: Merged: https://github.com/ruby/ruby/pull/3184
2020-06-05[rubygems/rubygems] Add build warning when rake based extension is present, ↵Josef Šimánek
but rake is not specified as dependency. https://github.com/rubygems/rubygems/commit/75fe5475b6 Notes: Merged: https://github.com/ruby/ruby/pull/3184
2020-05-08[rubygems/rubygems] Revert adding loaded specs to `Gem::Specification.stubs` ↵David Rodríguez
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 Notes: Merged: https://github.com/ruby/ruby/pull/3092
2020-05-08[rubygems/rubygems] Test that two calls to `stub_for` returns the same ↵Vít Ondruch
(cached) instance. https://github.com/rubygems/rubygems/commit/00b3f55562 Notes: Merged: https://github.com/ruby/ruby/pull/3092
2020-05-08[rubygems/rubygems] Let `@@stubs_by_name` to be incrementally populated again.Vít Ondruch
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 Notes: Merged: https://github.com/ruby/ruby/pull/3092
2020-05-08Normalize heredoc case in rubygems code baseDavid Rodríguez
Notes: Merged: https://github.com/ruby/ruby/pull/3087
2020-05-08[rubygems/rubygems] Only run the $SAFE test on MRI < 2.7Benoit Daloze
* Other Ruby implementations don't support $SAFE. https://github.com/rubygems/rubygems/commit/9a4ba16efa Notes: Merged: https://github.com/ruby/ruby/pull/3087
2020-05-08[rubygems/rubygems] Track removed methods calls and warn during build time.Josef Šimánek
move rubyforge_project= to removed methods https://github.com/rubygems/rubygems/commit/223f7fd470 Notes: Merged: https://github.com/ruby/ruby/pull/3087
2020-05-08[rubygems/rubygems] Deprecate rubyforge_project attribute only during build ↵Josef Šimánek
time. https://github.com/rubygems/rubygems/commit/c44eb21648 Notes: Merged: https://github.com/ruby/ruby/pull/3087
2020-04-28[rubygems/rubygems] Make the test suite pass under `umask 077`Yusuke Endoh
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
2020-03-30[rubygems/rubygems] Enable `Style/ExtraSpacing` and auto-correctDavid Rodríguez
https://github.com/rubygems/rubygems/commit/6fa0b1b679
2020-03-30[rubygems/rubygems] Enable Style/PercentLiteralDelimiters cop in rubygemsDavid Rodríguez
So it matches the style used by bundler. https://github.com/rubygems/rubygems/commit/ab0580fd65
2020-03-24Sync rubygems with current master (#2889)David Rodríguez
Notes: Merged-By: hsbt <hsbt@ruby-lang.org>
2020-02-01Merge the current master branch of rubygems/rubygems.Hiroshi SHIBATA
Just started to develop RubyGems 3.2.0.
2019-12-11Do not load files in build directoryKazuhiro NISHIYAMA
related https://bugs.ruby-lang.org/issues/16177 Notes: Merged: https://github.com/ruby/ruby/pull/2736
2019-11-11Merge RubyGems 3.1.0.pre3Hiroshi SHIBATA
* 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. Notes: Merged: https://github.com/ruby/ruby/pull/2666
2019-10-15[rubygems/rubygems] Also bump test variableHiroshi SHIBATA
https://github.com/rubygems/rubygems/commit/97e9768612
2019-10-10[rubygems/rubygems] Do not compare with unreliable Gem::Specification::TODAYNobuyoshi Nakada
https://gist.github.com/ko1/a88834d744a0682711dab53fd9015a04#file-brlog-trunk-nopara-20191005-235153-L393-L472 https://github.com/rubygems/rubygems/commit/707408d8e7
2019-10-10[rubygems/rubygems] Restrict possible date rangeNobuyoshi Nakada
https://github.com/rubygems/rubygems/commit/1bd77f53df
2019-10-05[rubygems/rubygems] The date might have advanced since TODAY has been setNobuyoshi Nakada
https://bugs.ruby-lang.org/issues/16189 https://github.com/rubygems/rubygems/commit/e331222163
2019-09-26[rubygems/rubygems] Update expectation in test_to_ruby_with_rsa_keybronzdoc
https://github.com/rubygems/rubygems/commit/2e65f7d4ae
2019-09-26[rubygems/rubygems] Make ruby_code method handle OpenSSL::PKey::RSA objectsbronzdoc
https://github.com/rubygems/rubygems/commit/b1d825ab3a
2019-08-05[rubygems/rubygems] Revert cadb66037d9b58c80fc795f39384d533229a1f73bronzdoc
https://github.com/rubygems/rubygems/commit/5c3158d975
2019-07-31[rubygems/rubygems] Move default specifications dir definition out of ↵Vít Ondruch
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
2019-07-31[rubygems/rubygems] Autorequire was used by old RubyGems, it is neither ↵bronzdoc
supported nor functional. https://github.com/rubygems/rubygems/commit/cadb66037d
2019-07-31[rubygems/rubygems] Simplify #to_ruby codeNobuyoshi Nakada
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
2019-06-01Merge rubygems master from upstream.Hiroshi SHIBATA
I picked the commit from 3c469e0da538428a0ddd94f99aa73c32da22e8ba
2019-05-16Fix fd leakNobuyoshi Nakada
merged https://github.com/rubygems/rubygems/pull/2765