From e70e7f4ad38abb305342dd4d5a392782597d1f98 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Rodr=C3=ADguez?= Date: Sat, 16 Apr 2022 13:53:11 +0200 Subject: [rubygems/rubygems] Fix test issues surfaced using a stricter behavior of `FileUtils` We were trying to remove directories using `FileUtils.rm_f` which is unexpected and does not remove anything. Changing to `FileUtils.rm_rf` actually removes the directories properly. That itself showed other issues: * One test was actually removing the gem package it was about to install, since it was living in the cache folder. To fix that, avoid removing the cache folder, and only make sure the other directories are created automatically, which seems enough. * Another test was actually removing an incorrect directory. Change it to remove the right one (the one that's asserted later to have been created). https://github.com/rubygems/rubygems/commit/5538e7ff20 --- test/rubygems/test_gem_installer.rb | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'test') diff --git a/test/rubygems/test_gem_installer.rb b/test/rubygems/test_gem_installer.rb index c90fdab283..46bb6965c7 100644 --- a/test/rubygems/test_gem_installer.rb +++ b/test/rubygems/test_gem_installer.rb @@ -1221,15 +1221,13 @@ gem 'other', version def test_install_missing_dirs installer = setup_base_installer - FileUtils.rm_f File.join(Gem.dir, 'cache') - FileUtils.rm_f File.join(Gem.dir, 'doc') - FileUtils.rm_f File.join(Gem.dir, 'specifications') + FileUtils.rm_rf File.join(Gem.dir, 'doc') + FileUtils.rm_rf File.join(Gem.dir, 'specifications') use_ui @ui do installer.install end - assert_directory_exists File.join(Gem.dir, 'cache') assert_directory_exists File.join(Gem.dir, 'doc') assert_directory_exists File.join(Gem.dir, 'specifications') @@ -2237,7 +2235,7 @@ gem 'other', version def test_default_gem_without_wrappers installer = setup_base_installer - FileUtils.rm_f File.join(Gem.dir, 'specifications') + FileUtils.rm_rf File.join(Gem.default_dir, 'specifications') installer.wrappers = false installer.options[:install_as_default] = true -- cgit v1.2.3