aboutsummaryrefslogtreecommitdiffstats
path: root/test/rubygems/test_gem_specification.rb
Commit message (Collapse)AuthorAgeFilesLines
* Merge RubyGems and Bundler masterHiroshi SHIBATA2023-01-101-2/+2
| | | | from https://github.com/rubygems/rubygems/commit/0635c1423db5d7c461d53bf0c3329bca75de7609
* Merge RubyGems-3.4.0 and Bundler-2.4.0Hiroshi SHIBATA2022-12-241-0/+33
|
* Resync Bundler & RubyGemsDavid Rodríguez2022-09-081-9/+9
|
* Merge rubygems/bundler HEAD.Hiroshi SHIBATA2022-08-091-2/+2
| | | | Pick from https://github.com/rubygems/rubygems/commit/dfbb5a38114640e0d8d616861607f3de73ee0199
* [rubygems/rubygems] Warn (rather than crash) when setting `nil` ↵David Rodríguez2022-08-031-0/+9
| | | | | | specification versions https://github.com/rubygems/rubygems/commit/a4ba1a4d97
* RubyGems: Enable Style/StringLiterals copTakuya Noguchi2022-07-221-434/+434
| | | | Signed-off-by: Takuya Noguchi <takninnovationresearch@gmail.com>
* [rubygems/rubygems] Drop support for old `Gem::Specification` versionsNobuyoshi Nakada2022-07-161-28/+8
| | | | | | | | `specification_version` method was added before RubyGems 1.0, and `add_runtime_dependency` method was before 1.2. These seem aged enough to remove. https://github.com/rubygems/rubygems/commit/92770c5cd9
* Merge RubyGems and Bundler masterHiroshi SHIBATA2022-07-131-0/+2
|
* Sync RubyGems & Bundler with upstream repoDavid Rodríguez2022-06-241-2/+9
|
* [rubygems/rubygems] Improve null private type testDavid Rodríguez2022-06-011-1/+1
| | | | | | | | | | | | | | | | | | | | | | | This test is making sure that RubyGems is able to load old marshalled gemspecs that include a field loading `YAML::PrivateType` instances in the `rubyforge_project` field instead of `nil` due to a bug in old YAML emitters. At some point, the `rubyforge_project` field was removed and this test was updated to just check another field. However, in the realworld other fields do not have this issue and the marshalled gemspec we use for testing still has this issue in the field reserved for the `rubyforge_project` field. So I think updating the test to check other field was not correct. Instead, since the `rubyforge_project` field is now ignored, we no longer need to worry about any conversion in this field. The only thing we care about is that the marshal loading still works (which requires that the constant is at least defined). So this commit updates the test to make this more clear. https://github.com/rubygems/rubygems/commit/cddfacf6d4
* Merge RubyGems and Bundler HEADHiroshi SHIBATA2022-05-201-11/+11
| | | | https://github.com/rubygems/rubygems/commit/125415593ead9ab69a9f0bb5392c9d7ec61b1f51
* Merge rubygems master 1e4eda741d732ca1bd7031aef0a16c7348adf7a5Hiroshi SHIBATA2022-04-281-1/+1
|
* [rubygems/rubygems] Skip find_in_unresolved_tree test for TruffleRuby due to ↵Brandon Fish2021-12-211-0/+1
| | | | | | longer runtime https://github.com/rubygems/rubygems/commit/36b8fbc508
* [rubygems/rubygems] Extract a helper to temporarily modify internal encodingDavid Rodríguez2021-12-151-15/+12
| | | | https://github.com/rubygems/rubygems/commit/93051fd2aa
* [rubygems/rubygems] Unify duplicated helperDavid Rodríguez2021-12-151-7/+0
| | | | https://github.com/rubygems/rubygems/commit/c6ef75424d
* Merge RubyGems and Bundler masterHiroshi SHIBATA2021-12-151-3/+3
| | | | Merge from https://github.com/rubygems/rubygems/commit/793ad95ecb40e84a1dcb4cb60f2686843ed90de5
* Allow custom LicenseRefCarlos Palhares2021-11-021-0/+11
|
* [rubygems/rubygems] Remove save_loaded_featuresNobuyoshi Nakada2021-10-141-232/+200
| | | | https://github.com/rubygems/rubygems/commit/f5e408f83d
* [rubygems/rubygems] Only disallow FIXME/TODO for first word of gemspec ↵Ellen Marie Dash2021-09-281-0/+14
| | | | | | | | | description 7890c98 matched the start of each line, whereas this matches the start of the entire string. https://github.com/rubygems/rubygems/commit/432de7b819
* [rubygems/rubygems] Only check if descriptions *start with* FIXME/TODOEllen Marie Dash2021-09-221-0/+14
| | | | | | It doesn't make much sense to just forbid certain words in descriptions. https://github.com/rubygems/rubygems/commit/7890c98415
* [rubygems/rubygems] Remove all `syck` traces from `rubygems`David Rodríguez2021-07-271-164/+0
| | | | | | | | | | | | | | | | | | | After reading [this blog post](https://blog.rubygems.org/2011/08/31/shaving-the-yaml-yak.html), published almost 10 years ago already, my understanding is that this problem could come up in two ways: * Rubygems.org serving corrupted gemspecs". As far as I understand this was fixed in rubygems.org a lot time ago, since https://github.com/rubygems/rubygems.org/pull/331. * Clients having a ten years old gemspec cache with some of these bad gemspecs. In this case, there's no easy solution but I think ten years is enough and rebuilding the cache should do the trick. So, I think it's time we remove this. https://github.com/rubygems/rubygems/commit/afcb15d556
* Sync latest bundler & rubygems development versionDavid Rodríguez2021-07-071-3/+3
|
* [rubygems/rubygems] Rename test/rubygems/test_{case,utilities}.rb to avoid ↵Yusuke Endoh2021-06-031-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | "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
* [rubygems/rubygems] Require the new files in `test/` relativelyDavid Rodríguez2021-05-281-1/+1
| | | | https://github.com/rubygems/rubygems/commit/c77868a555
* [rubygems/rubygems] Try fix ruby-core CIHiroshi SHIBATA2021-05-281-21/+21
| | | | | | * Port https://github.com/ruby/ruby/commit/8e91b969df08b7a2eb27a5d6d38733eea42dc7ad from ruby-core, and make it compatible with psych 3 & 4.
* Workaround with fbb4e3f96c10de2240f2d87eac19cf6f62f65feaHiroshi SHIBATA2021-05-171-1/+1
|
* [rubygems/rubygems] util/rubocop -aHiroshi SHIBATA2021-05-121-1/+1
| | | | https://github.com/rubygems/rubygems/commit/a10ff97830
* [rubygems/rubygems] capture_output will return empty string, not nilHiroshi SHIBATA2021-05-121-1/+1
| | | | https://github.com/rubygems/rubygems/commit/3fa93f6144
* [rubygems/rubygems] Rewrite with capture_outputHiroshi SHIBATA2021-05-121-1/+3
| | | | https://github.com/rubygems/rubygems/commit/a091004ded
* [rubygems/rubygems] Use assert_raise instead of assert_raisesHiroshi SHIBATA2021-05-121-40/+40
| | | | https://github.com/rubygems/rubygems/commit/769e87f011
* [rubygems/rubygems] Use assert_path_exist and assert_path_not_exist instead ↵Hiroshi SHIBATA2021-05-121-9/+9
| | | | | | of assert_path_exists and refute_path_exists https://github.com/rubygems/rubygems/commit/a7c93558c3
* [rubygems/rubygems] Extract assert_output to assert_empty and assert_equal ↵Hiroshi SHIBATA2021-05-121-2/+6
| | | | | | with capture_output https://github.com/rubygems/rubygems/commit/f6759440a4
* [rubygems/rubygems] Use Regexp with refute_matchHiroshi SHIBATA2021-05-121-1/+1
| | | | https://github.com/rubygems/rubygems/commit/51fdbe53bc
* [rubygems/rubygems] Use capture_output instead of capture_io.Hiroshi SHIBATA2021-05-121-3/+3
| | | | https://github.com/rubygems/rubygems/commit/ad9206d4d0
* Sync latest development version of bundler & rubygemsDavid Rodríguez2021-03-081-41/+18
|
* Track RubyGems master(3.3.0.dev) branch at ↵Hiroshi SHIBATA2021-01-041-3/+1
| | | | 55634a8af18a52df86c4275d70fa1179118bcc20
* Merge prepare version of RubyGems 3.2.0Hiroshi SHIBATA2020-12-081-4/+5
|
* 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
|