зеркало из https://github.com/github/ruby.git
[rubygems/rubygems] Remove the lock file for binstubs
https://github.com/rubygems/rubygems/pull/7806#issuecomment-2241662488 https://github.com/rubygems/rubygems/commit/4f06ee234a
This commit is contained in:
Родитель
6bf519ba81
Коммит
5afee4d795
|
@ -794,7 +794,7 @@ An Array (#{env.inspect}) was passed in from #{caller[3]}
|
|||
File.open(path, flags, &block)
|
||||
end
|
||||
|
||||
MODE_TO_FLOCK = IO::RDONLY | IO::APPEND | IO::CREAT # :nodoc:
|
||||
MODE_TO_FLOCK = IO::RDONLY | IO::APPEND | IO::CREAT | IO::SHARE_DELETE | IO::BINARY # :nodoc:
|
||||
|
||||
##
|
||||
# Open a file with given flags, and protect access with flock
|
||||
|
|
|
@ -538,7 +538,7 @@ class Gem::Installer
|
|||
def generate_bin_script(filename, bindir)
|
||||
bin_script_path = File.join bindir, formatted_program_filename(filename)
|
||||
|
||||
Gem.open_file_with_flock("#{bin_script_path}.lock") do
|
||||
Gem.open_file_with_flock("#{bin_script_path}.lock") do |lock|
|
||||
require "fileutils"
|
||||
FileUtils.rm_f bin_script_path # prior install may have been --no-wrappers
|
||||
|
||||
|
@ -546,6 +546,7 @@ class Gem::Installer
|
|||
file.write app_script_text(filename)
|
||||
file.chmod(options[:prog_mode] || 0o755)
|
||||
end
|
||||
File.unlink(lock.path)
|
||||
end
|
||||
|
||||
verbose bin_script_path
|
||||
|
|
|
@ -1083,6 +1083,8 @@ end
|
|||
end
|
||||
|
||||
assert_match(/ran executable/, e.message)
|
||||
|
||||
assert_path_not_exist(File.join(installer.bin_dir, "executable.lock"))
|
||||
end
|
||||
|
||||
def test_conflicting_binstubs
|
||||
|
@ -1131,6 +1133,8 @@ end
|
|||
# We expect the bin stub to activate the version that actually contains
|
||||
# the binstub.
|
||||
assert_match("I have an executable", e.message)
|
||||
|
||||
assert_path_not_exist(File.join(installer.bin_dir, "executable.lock"))
|
||||
end
|
||||
|
||||
def test_install_creates_binstub_that_understand_version
|
||||
|
@ -1160,6 +1164,8 @@ end
|
|||
end
|
||||
|
||||
assert_includes(e.message, "can't find gem a (= 3.0)")
|
||||
|
||||
assert_path_not_exist(File.join(installer.bin_dir, "executable.lock"))
|
||||
end
|
||||
|
||||
def test_install_creates_binstub_that_prefers_user_installed_gem_to_default
|
||||
|
@ -1192,6 +1198,8 @@ end
|
|||
end
|
||||
|
||||
assert_equal(e.message, "ran executable")
|
||||
|
||||
assert_path_not_exist(File.join(installer.bin_dir, "executable.lock"))
|
||||
end
|
||||
|
||||
def test_install_creates_binstub_that_dont_trust_encoding
|
||||
|
@ -1222,6 +1230,8 @@ end
|
|||
end
|
||||
|
||||
assert_match(/ran executable/, e.message)
|
||||
|
||||
assert_path_not_exist(File.join(installer.bin_dir, "executable.lock"))
|
||||
end
|
||||
|
||||
def test_install_with_no_prior_files
|
||||
|
|
Загрузка…
Ссылка в новой задаче