diff options
author | Ellen Marie Dash <me@duckie.co> | 2022-06-30 20:28:33 -0400 |
---|---|---|
committer | git <svn-admin@ruby-lang.org> | 2022-12-02 19:21:08 +0000 |
commit | 82b86b4c97963d25c4e8ba12aab327d47c1f5861 (patch) | |
tree | 5d3b0be16a728681b61f42958753cd5981ed8ae5 /test/rubygems | |
parent | 5fafff15c606dd4ad323cc9a9c75776ab9536d54 (diff) | |
download | ruby-82b86b4c97963d25c4e8ba12aab327d47c1f5861.tar.gz |
[rubygems/rubygems] Delete partial file and re-raise on Errno::ENOSPC.
Add test for not leaving empty files if ENOSPC is raised during 'gem install'
https://github.com/rubygems/rubygems/commit/8e0e20f079
Diffstat (limited to 'test/rubygems')
-rw-r--r-- | test/rubygems/test_gem_installer.rb | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/test/rubygems/test_gem_installer.rb b/test/rubygems/test_gem_installer.rb index 0d0746ec84..f9209350fb 100644 --- a/test/rubygems/test_gem_installer.rb +++ b/test/rubygems/test_gem_installer.rb @@ -2222,6 +2222,37 @@ gem 'other', version assert_equal @spec, eval(File.read(@spec.spec_file)) end + def test_leaves_no_empty_cached_spec_when_no_more_disk_space + @spec = setup_base_spec + FileUtils.rm @spec.spec_file + assert_path_not_exist @spec.spec_file + + @spec.files = %w[a.rb b.rb c.rb] + + installer = Gem::Installer.for_spec @spec + installer.gem_home = @gemhome + + File.class_eval do + alias_method :original_write, :write + + def write(data) + raise Errno::ENOSPC + end + end + + assert_raise Errno::ENOSPC do + installer.write_spec + end + + assert_path_not_exist @spec.spec_file + ensure + File.class_eval do + remove_method :write + alias_method :write, :original_write # rubocop:disable Lint/DuplicateMethods + remove_method :original_write + end + end + def test_dir installer = setup_base_installer |