mirror of
https://github.com/ruby/ruby.git
synced 2025-08-24 05:25:34 +02:00
[rubygems/rubygems] Never remove executables that may belong to a default gem
ed585f2fca
This commit is contained in:
parent
7767b60ff2
commit
62fc473224
3 changed files with 37 additions and 2 deletions
|
@ -178,7 +178,7 @@ class Gem::Uninstaller
|
||||||
# Removes installed executables and batch files (windows only) for +spec+.
|
# Removes installed executables and batch files (windows only) for +spec+.
|
||||||
|
|
||||||
def remove_executables(spec)
|
def remove_executables(spec)
|
||||||
return if spec.executables.empty?
|
return if spec.executables.empty? || default_spec_matches?(spec)
|
||||||
|
|
||||||
executables = spec.executables.clone
|
executables = spec.executables.clone
|
||||||
|
|
||||||
|
|
|
@ -816,9 +816,15 @@ class Gem::TestCase < Test::Unit::TestCase
|
||||||
Gem::Specification.unresolved_deps.values.map(&:to_s).sort
|
Gem::Specification.unresolved_deps.values.map(&:to_s).sort
|
||||||
end
|
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
|
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.loaded_from = File.join(@gemhome, "specifications", "default", spec.spec_name)
|
||||||
spec.files = files
|
spec.files = files
|
||||||
|
|
||||||
|
|
|
@ -81,6 +81,35 @@ class TestGemCommandsUninstallCommand < Gem::InstallerTestCase
|
||||||
assert_equal "Successfully uninstalled z-2", output.shift
|
assert_equal "Successfully uninstalled z-2", output.shift
|
||||||
end
|
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
|
def test_execute_dependency_order
|
||||||
initial_install
|
initial_install
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue