mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
ef481c120c
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. |
||
---|---|---|
.. | ||
benchmark | ||
bundler | ||
cgi | ||
csv | ||
delegate | ||
did_you_mean | ||
drb | ||
forwardable | ||
getoptlong | ||
irb | ||
logger | ||
matrix | ||
net | ||
observer | ||
open3 | ||
optparse | ||
ostruct | ||
pstore | ||
racc | ||
rdoc | ||
reline | ||
rinda | ||
rubygems | ||
singleton | ||
timeout | ||
tracer | ||
unicode_normalize | ||
uri | ||
weakref | ||
webrick | ||
yaml | ||
.document | ||
abbrev.rb | ||
base64.rb | ||
benchmark.rb | ||
bundler.rb | ||
cgi.rb | ||
csv.rb | ||
debug.rb | ||
delegate.rb | ||
did_you_mean.rb | ||
drb.rb | ||
English.gemspec | ||
English.rb | ||
erb.rb | ||
fileutils.gemspec | ||
fileutils.rb | ||
find.rb | ||
forwardable.rb | ||
getoptlong.rb | ||
ipaddr.gemspec | ||
ipaddr.rb | ||
irb.rb | ||
logger.rb | ||
matrix.rb | ||
mkmf.rb | ||
mutex_m.gemspec | ||
mutex_m.rb | ||
observer.rb | ||
open-uri.rb | ||
open3.rb | ||
optionparser.rb | ||
optparse.rb | ||
ostruct.rb | ||
pp.rb | ||
prettyprint.rb | ||
prime.gemspec | ||
prime.rb | ||
pstore.rb | ||
racc.rb | ||
rdoc.rb | ||
readline.gemspec | ||
readline.rb | ||
reline.rb | ||
resolv-replace.rb | ||
resolv.rb | ||
rubygems.rb | ||
securerandom.rb | ||
set.rb | ||
shellwords.rb | ||
singleton.rb | ||
tempfile.gemspec | ||
tempfile.rb | ||
time.rb | ||
timeout.rb | ||
tmpdir.gemspec | ||
tmpdir.rb | ||
tracer.rb | ||
tsort.rb | ||
un.rb | ||
uri.rb | ||
weakref.rb | ||
webrick.rb | ||
yaml.rb |