diff options
| author | David RodrÃguez <deivid.rodriguez@riseup.net> | 2024-06-13 17:56:17 +0200 |
|---|---|---|
| committer | git <svn-admin@ruby-lang.org> | 2024-06-14 08:02:38 +0000 |
| commit | 62fc473224eb8da96206badbc2496dd5ec38935d (patch) | |
| tree | dbe39a0cee8507e91dfc9d601de8e92ef0737a65 /test | |
| parent | 7767b60ff2f02a600f0b1fe5f438639fea6ac7b7 (diff) | |
[rubygems/rubygems] Never remove executables that may belong to a default gem
https://github.com/rubygems/rubygems/commit/ed585f2fca
Diffstat (limited to 'test')
| -rw-r--r-- | test/rubygems/helper.rb | 8 | ||||
| -rw-r--r-- | test/rubygems/test_gem_commands_uninstall_command.rb | 29 |
2 files changed, 36 insertions, 1 deletions
diff --git a/test/rubygems/helper.rb b/test/rubygems/helper.rb index e47f2fa837..5b6ba999a4 100644 --- a/test/rubygems/helper.rb +++ b/test/rubygems/helper.rb @@ -816,9 +816,15 @@ class Gem::TestCase < Test::Unit::TestCase Gem::Specification.unresolved_deps.values.map(&:to_s).sort end - def new_default_spec(name, version, deps = nil, *files) + def new_default_spec(name, version, deps = nil, *files, executable: false) spec = util_spec name, version, deps + if executable + spec.executables = %w[executable] + + write_file File.join(@tempdir, "bin", "executable") + end + spec.loaded_from = File.join(@gemhome, "specifications", "default", spec.spec_name) spec.files = files diff --git a/test/rubygems/test_gem_commands_uninstall_command.rb b/test/rubygems/test_gem_commands_uninstall_command.rb index 66885395d8..81fadfcb99 100644 --- a/test/rubygems/test_gem_commands_uninstall_command.rb +++ b/test/rubygems/test_gem_commands_uninstall_command.rb @@ -81,6 +81,35 @@ class TestGemCommandsUninstallCommand < Gem::InstallerTestCase assert_equal "Successfully uninstalled z-2", output.shift end + def test_execute_does_not_remove_default_gem_executables + z_1_default = new_default_spec "z", "1", executable: true + install_default_gems z_1_default + + z_1, = util_gem "z", "1" do |spec| + util_make_exec spec + end + install_gem z_1, force: true + + Gem::Specification.reset + + @cmd.options[:all] = true + @cmd.options[:force] = true + @cmd.options[:executables] = true + @cmd.options[:args] = %w[z] + + use_ui @ui do + @cmd.execute + end + + assert File.exist? File.join(@gemhome, "bin", "executable") + + output = @ui.output.split "\n" + + refute_includes output, "Removing executable" + assert_equal "Successfully uninstalled z-1", output.shift + assert_equal "There was both a regular copy and a default copy of z-1. The regular copy was successfully uninstalled, but the default copy was left around because default gems can't be removed.", output.shift + end + def test_execute_dependency_order initial_install |
