Skip to content

Commit

Permalink
[rubygems/rubygems] Honor a specified path as the temporary diretory …
Browse files Browse the repository at this point in the history
…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.

rubygems/rubygems@bf00850656
  • Loading branch information
nobu authored and matzbot committed Apr 16, 2024
1 parent 29110fe commit 54d472d
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions test/rubygems/helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -285,9 +285,12 @@ def assert_contains_make_command(target, output, msg = nil)
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)

Expand Down

0 comments on commit 54d472d

Please sign in to comment.