[rubygems/rubygems] Ensure that the lock file will be removed

https://github.com/rubygems/rubygems/commit/2706acb271
This commit is contained in:
Nobuyoshi Nakada 2024-08-16 20:19:22 +09:00 коммит произвёл git
Родитель 6dd917bd01
Коммит 30176e3f23
2 изменённых файлов: 30 добавлений и 1 удалений

Просмотреть файл

@ -546,7 +546,8 @@ class Gem::Installer
file.write app_script_text(filename)
file.chmod(options[:prog_mode] || 0o755)
end
File.unlink(lock.path)
ensure
FileUtils.rm_f lock.path
end
verbose bin_script_path

Просмотреть файл

@ -1234,6 +1234,34 @@ end
assert_path_not_exist(File.join(installer.bin_dir, "executable.lock"))
end
def test_install_does_not_leave_lockfile_for_binstub
installer = util_setup_installer
installer.wrappers = true
File.class_eval do
alias_method :original_chmod, :chmod
define_method(:chmod) do |mode|
original_chmod(mode)
raise Gem::Ext::BuildError if path.end_with?("/executable")
end
end
assert_raise(Gem::Ext::BuildError) do
installer.install
end
assert_path_not_exist(File.join(installer.bin_dir, "executable.lock"))
# TODO: remove already copied files at failures.
# assert_path_not_exist(File.join(installer.bin_dir, "executable"))
ensure
File.class_eval do
remove_method :chmod
alias_method :chmod, :original_chmod
remove_method :original_chmod
end
end
def test_install_with_no_prior_files
installer = util_setup_installer