|author||David Rodríguez <firstname.lastname@example.org>||2020-06-07 20:36:53 +0200|
|committer||Hiroshi SHIBATA <email@example.com>||2020-06-15 19:48:25 +0900|
Fix ruby-head failing tests
In `ruby-head` (where system rubygems already has the `XDG` standard implementation), some tests currently depend on the presence of a `~/.gem` folder in the home of the user that runs the tests. If that file is present, tests pass, otherwise they don't. For example, the following passes if you have a `~/.gem` folder but fails otherwise with: ``` $ rake TESTOPTS="--name=/TestGemCommandsGenerateIndexCommand#test_execute$\|TestGemCommandsUpdateCommand#test_execute_user_install/ -v" Run options: "--name=/TestGemCommandsGenerateIndexCommand#test_execute$|TestGemCommandsUpdateCommand#test_execute_user_install/" -v --seed 17318 # Running: TestGemCommandsGenerateIndexCommand#test_execute = 0.02 s = . TestGemCommandsUpdateCommand#test_execute_user_install = /rubygems/test/rubygems/test_gem_commands_update_command.rb:412: warning: instance variable @user_install not initialized 0.04 s = F Finished in 0.095337s, 20.9783 runs/s, 20.9783 assertions/s. 1) Failure: TestGemCommandsUpdateCommand#test_execute_user_install [/rubygems/test/rubygems/test_gem_commands_update_command.rb:414]: user_install must be set on the installer 2 runs, 2 assertions, 1 failures, 0 errors, 0 skips rake aborted! Command failed with status (1) Tasks: TOP => default => test (See full trace by running task with --trace) ``` This is because the very initial `require` of the default `did_you_mean` gem that ruby does on startup runs _before_ the global `setup` hook of our tests run. During this require `Gem.data_home` and its value is memoized to a path in the real users home (not the fake user's home that our tests setup, since that code hasn't run yet). Then that memoized value is used when looking for the default folders to look for gems, and since there's no `~/.gem` folder, its value is actually used as part of the `Gem.user_dir` folder in `Gem::Specification.dirs` (this is how we've approached backwards compatibility for the `XDG` feature). That means dummy test gems with the `--user-install` flag are installed to global, real locations and everything is messed up. This commit fixes the issue by resetting the `Gem.data_home` value in case it has already been memoized.
Notes: Merged: https://github.com/ruby/ruby/pull/3211
Diffstat (limited to 'lib/rubygems/core_ext')
0 files changed, 0 insertions, 0 deletions