diff options
author | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2021-01-24 18:17:28 +0900 |
---|---|---|
committer | git <svn-admin@ruby-lang.org> | 2024-04-16 10:24:49 +0000 |
commit | 54d472d91fe9fc724969a6ed71a3919710e28bfa (patch) | |
tree | 9f94de70e8b1efb6f898bda388355b367e41fe0a /test | |
parent | 29110fe18d8f10f649cbcd43a9726069bfff1c54 (diff) |
[rubygems/rubygems] Honor a specified path as the temporary diretory if given
## The problem
Currently the tests are executed in the fixed name directory "tmp"
under the top source directory. However it makes the tests fail when
the source path contains symlinks. Or unable to even start if the top
source directory is read-only, e.g., remote-mounting in read-only mode
from virtual machines.
Also, with the fixed directory, there is no way to avoid `pend` in
`TestGemPackage#test_extract_symlink_parent_doesnt_delete_user_dir`.
## The fix
Instead of creating the fixed name directory, this PR allows to use a
different path given with the environment variable "GEM_TEST_TMPDIR".
The default path is, as well as the current behavior, "tmp" from the
top source directory.
### Caveat
It is the caller's responsibility to make the directory safe (owned,
world unwritable, or sticky) when setting the environment variable.
https://github.com/rubygems/rubygems/commit/bf00850656
Diffstat (limited to 'test')
-rw-r--r-- | test/rubygems/helper.rb | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/test/rubygems/helper.rb b/test/rubygems/helper.rb index 82fb50b704..f97306717d 100644 --- a/test/rubygems/helper.rb +++ b/test/rubygems/helper.rb @@ -285,9 +285,12 @@ class Gem::TestCase < Test::Unit::TestCase def setup @orig_hooks = {} @orig_env = ENV.to_hash - @tmp = File.expand_path("../../tmp", __dir__) - FileUtils.mkdir_p @tmp + top_srcdir = __dir__ + "/../.." + @tmp = File.expand_path(ENV.fetch("GEM_TEST_TMPDIR", "tmp"), top_srcdir) + + FileUtils.mkdir_p(@tmp, mode: 0o700) # =rwx + @tmp = File.realpath(@tmp) @tempdir = Dir.mktmpdir("test_rubygems_", @tmp) |