summaryrefslogtreecommitdiff
path: root/test/rubygems/test_require.rb
AgeCommit message (Collapse)Author
42 hours[ruby/rubygems] Fix RubyGems not able to require the right gem:Edouard CHIN
- Fix https://github.com/ruby/rubygems/issues/9238 - ### Problem This is an issue that bites gem maintainers from time to time, with the most recent one in https://github.com/minitest/minitest/issues/1040#issuecomment-3679370619 The issue is summarized as follow: 1) A gem "X" has a feature in "lib/feature.rb" 2) Maintainer wants to extract this feature into its own gem "Y" 3) Maintainer cut a release of X without that new feature. 4) Users install the new version of X and also install the new gem "Y" since the feature is now extracted. 5) When a call to "require 'feature'" is encountered, RG will fail to load the right gem, resulting in a `LoadError`. ### Details Now that we have two gems (old version of X and new gem Y) with the same path, RubyGems will detect that `feature.rb` can be loaded from the old version of X, but if the new version of X had already been loaded, then RubyGems will raise due to versions conflicting. ```ruby require 'x' # Loads the new version of X without the feature which was extracted. require 'feature' # Rubygems see that the old version of X include that file and tries to activate the spec. ``` ### Solution I propose that RubyGems fallback to a spec that's not yet loaded. We try to find a spec by its path and filter it out in case a spec with the same name has already been loaded. Its worth to note that RubyGems already has a `find_inactive_by_path` but we can't use it. This method only checks if the spec object is active and doesn't look if other spec with the same name have been loaded. The new method we are introducing verifies this. https://github.com/ruby/rubygems/commit/f298e2c68e
2024-10-10[rubygems/rubygems] Run specs that now pass on JRubyDavid Rodríguez
https://github.com/rubygems/rubygems/commit/2af077ee38
2024-10-03Update default gem test for colon-style hash inspecttompng
Notes: Merged: https://github.com/ruby/ruby/pull/10924
2024-09-30[rubygems/rubygems] Don't add duplicated specs to unresolved specsDavid Rodríguez
This could happen when a regular gem shadows a default gem. https://github.com/rubygems/rubygems/commit/9ef70dd1f7
2024-08-29Don't use benchmark for test_activate_via_require_respects_loaded_filesHiroshi SHIBATA
benchmark.rb may extract as bundled gems in the future release Notes: Merged: https://github.com/ruby/ruby/pull/11490
2024-06-13[rubygems/rubygems] Fix default gem priority when sorting specsDavid Rodríguez
https://github.com/rubygems/rubygems/commit/8dbe1dbdc7 Co-authored-by: MSP-Greg <Greg.mpls@gmail.com>
2024-01-22Make tests play with upstream Ruby testsStan Hu
CI broke in https://github.com/ruby/ruby/pull/9604 because if any Ruby tests run `require 'net/http'`, they will pollute the `$LOADED_FEATURES` for the RubyGems tests. We can fix this by renaming the test default gem from `net-http` to `my-http`. See https://github.com/rubygems/rubygems/pull/7379#issuecomment-1901241299 for more details.
2024-01-22Reapply "[rubygems/rubygems] Fix activation conflicts when circularly ↵Hiroshi SHIBATA
requiring a gem" This reverts commit 04cf66765a8a9d48baea6d9aee266dc9aa21df27.
2024-01-22Reapply "[rubygems/rubygems] Fix `require` of a default gem when unresolved ↵Hiroshi SHIBATA
gems depend on it" This reverts commit 54552b89e73fc616ba47c1c87d33625af99cbce9.
2024-01-19Revert "[rubygems/rubygems] Fix `require` of a default gem when unresolved ↵Hiroshi SHIBATA
gems depend on it" This reverts commit f1f5f22d22a149f20e019728b1ab35593d29d81a.
2024-01-19Revert "[rubygems/rubygems] Fix activation conflicts when circularly ↵Hiroshi SHIBATA
requiring a gem" This reverts commit db44088c2a92040879386aa5f268db4c858e4e5b. https://github.com/ruby/ruby/actions/runs/7578672002/job/20641640821 https://github.com/ruby/ruby/actions/runs/7578672002/job/20641641212 https://github.com/ruby/ruby/actions/runs/7578672002/job/20641642031
2024-01-19[rubygems/rubygems] Fix activation conflicts when circularly requiring a gemDavid Rodríguez
If a gem is required circular, and there are unresolved specs depending on it, we may end up in an activation conflict. The solution is to not try to activate unresolved gems when requiring a default gem, regardless of it having already been activated or not. https://github.com/rubygems/rubygems/commit/3b2b8f4e3e
2024-01-19[rubygems/rubygems] Fix `require` of a default gem when unresolved gems ↵David Rodríguez
depend on it The following conditions must be met: * A default gem is required. * A previous require left some gems unresolved, and those dependencies themselves depend on the default gem. In this case, rubygems require will first activate the default version of the gem, then try to activate another unresolved version of the default gem that conflicts with the first activation. The solution is, if we are in the middle of requiring a default gem, skip this step, because we have already activated it successfully. https://github.com/rubygems/rubygems/commit/8cd5608db5 Co-authored-by: Stan Hu <stanhu@gmail.com>
2024-01-19[rubygems/rubygems] Test that regular gems don't shadow default gemsDavid Rodríguez
https://github.com/rubygems/rubygems/commit/b8ca5950a6
2023-11-13[rubygems/rubygems] Provide more insightful test error outputVít Ondruch
Original output: ~~~ Failure: test_realworld_upgraded_default_gem(TestGemRequire): <false> is not true. /mnt/test/rubygems/test_require.rb:474:in `test_realworld_upgraded_default_gem' 471: File.write(path, code) 472: 473: output = Gem::Util.popen({ "GEM_HOME" => @gemhome }, *ruby_with_rubygems_in_load_path, path).strip => 474: assert $?.success? 475: refute_empty output 476: assert_equal "999.99.9", output.lines[0].chomp 477: # Make sure only files from the newer json gem are loaded, and no files from the default json gem ~~~ New output: ~~~ Failure: test_realworld_upgraded_default_gem(TestGemRequire) /mnt/test/rubygems/test_require.rb:475:in `test_realworld_upgraded_default_gem' 472: 473: output = Gem::Util.popen({ "GEM_HOME" => @gemhome }, *ruby_with_rubygems_in_load_path, path).strip 474: refute_empty output => 475: assert_equal "999.99.9", output.lines[0].chomp 476: # Make sure only files from the newer json gem are loaded, and no files from the default json gem 477: assert_equal ["#{@gemhome}/gems/json-999.99.9/lib/json.rb"], output.lines.grep(%r{/gems/json-}).map(&:chomp) 478: assert $?.success? <"999.99.9"> expected but was <"/mnt/tmp/test_rubygems_20231110-36663-of405r/test_realworld_upgraded_default_gem.rb:3:in `<main>': undefined method `version' for nil:NilClass (NoMethodError)"> diff: ? 999 .99.9 ? /mnt/tmp/test_rubygems_20231110-36663-of405r/test_realworld_upgraded_default_gem rb:3:in `<main>': undefined method `version' for nil:NilClass (NoMethodError) ? ??? ???? ~~~ It is more valuable to check the command output then the error code. If the command fails for some reason, the output probably contains some detail, while checking the return code tells not much. https://github.com/rubygems/rubygems/commit/b76062e852
2023-04-05[rubygems/rubygems] Unify java_platform? to Gem.java_platform?Hiroshi SHIBATA
https://github.com/rubygems/rubygems/commit/7f27ab32b8
2023-03-23util/rubocop -A --only Layout/EmptyLineAfterMagicCommentHiroshi SHIBATA
Notes: Merged: https://github.com/ruby/ruby/pull/7582
2023-03-17[rubygems/rubygems] util/rubocop -A --only Style/RedundantBeginHiroshi SHIBATA
https://github.com/rubygems/rubygems/commit/b595d3cf0f
2023-03-17[rubygems/rubygems] util/rubocop -A --only Style/SingleLineMethodsHiroshi SHIBATA
https://github.com/rubygems/rubygems/commit/fa2e835ed2
2023-03-17[rubygems/rubygems] util/rubocop -A --only Style/RedundantInterpolationHiroshi SHIBATA
https://github.com/rubygems/rubygems/commit/add44e56eb
2023-03-17[rubygems/rubygems] util/rubocop -A --only Style/NestedParenthesizedCallsHiroshi SHIBATA
https://github.com/rubygems/rubygems/commit/a875fdb535
2023-03-17[rubygems/rubygems] util/rubocop -A --only Style/AliasHiroshi SHIBATA
https://github.com/rubygems/rubygems/commit/fba6e94de9
2023-03-17[rubygems/rubygems] util/rubocop -A --only Lint/UnusedBlockArgumentHiroshi SHIBATA
https://github.com/rubygems/rubygems/commit/d8efd919db
2023-01-20[rubygems/rubygems] Clean test outputNobuyoshi Nakada
The output from the command is mixed in this test, even when successful. Use the output as a part of the message on failure instead. https://github.com/rubygems/rubygems/commit/960509a133
2022-12-24Merge RubyGems-3.4.0 and Bundler-2.4.0Hiroshi SHIBATA
Notes: Merged: https://github.com/ruby/ruby/pull/6987
2022-12-20[rubygems/rubygems] Use better name for variableDavid Rodríguez
The installed file not always have the `.so` extension. https://github.com/rubygems/rubygems/commit/6f6681bcb9 Co-authored-by: Eloy Espinaco <eloyesp@gmail.com> Notes: Merged: https://github.com/ruby/ruby/pull/6966
2022-12-20[rubygems/rubygems] Fix tests checking intermediate filesEloy Espinaco
Some tests check that the shared objects are actually installed, but checking an intermediate build file instead of the installed one. https://github.com/rubygems/rubygems/commit/ad526073b0 Notes: Merged: https://github.com/ruby/ruby/pull/6966
2022-12-12Merge RubyGems/Bundler masterHiroshi SHIBATA
from https://github.com/rubygems/rubygems/commit/bfb0ae69776069155d2092702bfbb5a12617d85a Notes: Merged: https://github.com/ruby/ruby/pull/6906
2022-09-29[rubygems/rubygems] Test a pure RubyGems methodDavid Rodríguez
`Gem::Specification#load_paths` is actually a Bundler thing. https://github.com/rubygems/rubygems/commit/d20b4d1950
2022-08-09Merge rubygems/bundler HEAD.Hiroshi SHIBATA
Pick from https://github.com/rubygems/rubygems/commit/dfbb5a38114640e0d8d616861607f3de73ee0199 Notes: Merged: https://github.com/ruby/ruby/pull/6224
2022-07-22RubyGems: Enable Style/StringLiterals copTakuya Noguchi
Signed-off-by: Takuya Noguchi <takninnovationresearch@gmail.com>
2022-06-24Sync RubyGems & Bundler with upstream repoDavid Rodríguez
Notes: Merged: https://github.com/ruby/ruby/pull/6054
2022-05-20Merge RubyGems and Bundler HEADHiroshi SHIBATA
https://github.com/rubygems/rubygems/commit/125415593ead9ab69a9f0bb5392c9d7ec61b1f51
2022-04-28Move testing_ruby_repo into test helperHiroshi SHIBATA
Notes: Merged: https://github.com/ruby/ruby/pull/5669
2022-04-28Merge rubygems master 1e4eda741d732ca1bd7031aef0a16c7348adf7a5Hiroshi SHIBATA
Notes: Merged: https://github.com/ruby/ruby/pull/5669
2021-12-23Merge RubyGems-3.3.1 and Bundler-2.3.1Hiroshi SHIBATA
Notes: Merged: https://github.com/ruby/ruby/pull/5325
2021-12-15[rubygems/rubygems] Unify duplicated helperDavid Rodríguez
https://github.com/rubygems/rubygems/commit/c6ef75424d
2021-12-06[rubygems/rubygems] LOAD_PATH is already reset globallyDavid Rodríguez
https://github.com/rubygems/rubygems/commit/b0bbb27115
2021-12-06[rubygems/rubygems] Remove unneded setupDavid Rodríguez
https://github.com/rubygems/rubygems/commit/9815a04e31
2021-12-01Merge rubygems master fd676ac464491afaa0baf5435cb11b3f86229cbdHiroshi SHIBATA
2021-07-07Sync latest bundler & rubygems development versionDavid Rodríguez
Notes: Merged: https://github.com/ruby/ruby/pull/4533
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] Use pend instead of skipHiroshi SHIBATA
2021-05-28[rubygems/rubygems] Require the new files in `test/` relativelyDavid Rodríguez
https://github.com/rubygems/rubygems/commit/c77868a555
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
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-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