mirror of
				https://github.com/ruby/ruby.git
				synced 2022-11-09 12:17:21 -05:00 
			
		
		
		
	* lib/rubygems/uninstaller.rb: Add missing require and update
messaging to avoid confusion with uninstall --format-executable. [Ruby 1.9 - Bug #4062] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32697 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
		
							parent
							
								
									3550766601
								
							
						
					
					
						commit
						55b81eb9e6
					
				
					 4 changed files with 30 additions and 21 deletions
				
			
		| 
						 | 
				
			
			@ -1,3 +1,9 @@
 | 
			
		|||
Wed Jul 27 12:24:17 2011  Eric Hodel  <drbrain@segment7.net>
 | 
			
		||||
 | 
			
		||||
	* lib/rubygems/uninstaller.rb:  Add missing require and update
 | 
			
		||||
	  messaging to avoid confusion with uninstall --format-executable.
 | 
			
		||||
	  [Ruby 1.9 - Bug #4062]
 | 
			
		||||
 | 
			
		||||
Wed Jul 27 09:34:24 2011  Eric Hodel  <drbrain@segment7.net>
 | 
			
		||||
 | 
			
		||||
	* lib/rubygems:  Update to RubyGems 1.8.6.1.
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -70,7 +70,7 @@ class Gem::Uninstaller
 | 
			
		|||
    list = Gem::Specification.find_all_by_name(@gem, @version)
 | 
			
		||||
 | 
			
		||||
    if list.empty? then
 | 
			
		||||
      raise Gem::InstallError, "cannot uninstall, check `gem list -d #{@gem}`"
 | 
			
		||||
      raise Gem::InstallError, "gem #{@gem.inspect} is not installed"
 | 
			
		||||
 | 
			
		||||
    elsif list.size > 1 and @force_all then
 | 
			
		||||
      remove_all list
 | 
			
		||||
| 
						 | 
				
			
			@ -141,9 +141,11 @@ class Gem::Uninstaller
 | 
			
		|||
 | 
			
		||||
    return if executables.empty?
 | 
			
		||||
 | 
			
		||||
    executables = executables.map { |exec| formatted_program_filename exec }
 | 
			
		||||
 | 
			
		||||
    remove = if @force_executables.nil? then
 | 
			
		||||
               ask_yes_no("Remove executables:\n" \
 | 
			
		||||
                          "\t#{spec.executables.join ', '}\n\n" \
 | 
			
		||||
                          "\t#{executables.join ', '}\n\n" \
 | 
			
		||||
                          "in addition to the gem?",
 | 
			
		||||
                          true)
 | 
			
		||||
             else
 | 
			
		||||
| 
						 | 
				
			
			@ -153,14 +155,17 @@ class Gem::Uninstaller
 | 
			
		|||
    unless remove then
 | 
			
		||||
      say "Executables and scripts will remain installed."
 | 
			
		||||
    else
 | 
			
		||||
      bindir = @bin_dir || Gem.bindir(spec.base_dir)
 | 
			
		||||
      bin_dir = @bin_dir || Gem.bindir(spec.base_dir)
 | 
			
		||||
 | 
			
		||||
      raise Gem::FilePermissionError, bindir unless File.writable? bindir
 | 
			
		||||
      raise Gem::FilePermissionError, bin_dir unless File.writable? bin_dir
 | 
			
		||||
 | 
			
		||||
      spec.executables.each do |exe_name|
 | 
			
		||||
      executables.each do |exe_name|
 | 
			
		||||
        say "Removing #{exe_name}"
 | 
			
		||||
        FileUtils.rm_f File.join(bindir, formatted_program_filename(exe_name))
 | 
			
		||||
        FileUtils.rm_f File.join(bindir, "#{formatted_program_filename(exe_name)}.bat")
 | 
			
		||||
 | 
			
		||||
        exe_file = File.join bin_dir, exe_name
 | 
			
		||||
 | 
			
		||||
        FileUtils.rm_f exe_file
 | 
			
		||||
        FileUtils.rm_f "#{exe_file}.bat"
 | 
			
		||||
      end
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
| 
						 | 
				
			
			@ -257,6 +262,7 @@ class Gem::Uninstaller
 | 
			
		|||
 | 
			
		||||
  def formatted_program_filename(filename)
 | 
			
		||||
    if @format_executable then
 | 
			
		||||
      require 'rubygems/installer'
 | 
			
		||||
      Gem::Installer.exec_format % File.basename(filename)
 | 
			
		||||
    else
 | 
			
		||||
      filename
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -69,19 +69,6 @@ class TestGemCommandsUninstallCommand < Gem::InstallerTestCase
 | 
			
		|||
    Gem::Installer.exec_format = nil
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def test_execute_not_installed
 | 
			
		||||
    @cmd.options[:args] = ["foo"]
 | 
			
		||||
    e = assert_raises Gem::InstallError do
 | 
			
		||||
      use_ui @ui do
 | 
			
		||||
        @cmd.execute
 | 
			
		||||
      end
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    assert_match(/\Acannot uninstall, check `gem list -d foo`$/, e.message)
 | 
			
		||||
    output = @ui.output.split "\n"
 | 
			
		||||
    assert_empty output, "UI output should be empty after an uninstall error"
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def test_execute_prerelease
 | 
			
		||||
    @spec = quick_spec "pre", "2.b"
 | 
			
		||||
    @gem = File.join @tempdir, @spec.file_name
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -94,7 +94,7 @@ class TestGemUninstaller < Gem::InstallerTestCase
 | 
			
		|||
    exec_path = File.join Gem.user_dir, 'bin', 'foo-executable-bar'
 | 
			
		||||
    assert_equal false, File.exist?(exec_path), 'removed exec from bin dir'
 | 
			
		||||
 | 
			
		||||
    assert_equal "Removing executable\n", @ui.output
 | 
			
		||||
    assert_equal "Removing foo-executable-bar\n", @ui.output
 | 
			
		||||
  ensure
 | 
			
		||||
    Gem::Installer.exec_format = nil
 | 
			
		||||
  end
 | 
			
		||||
| 
						 | 
				
			
			@ -158,6 +158,16 @@ class TestGemUninstaller < Gem::InstallerTestCase
 | 
			
		|||
    assert_same uninstaller, @post_uninstall_hook_arg
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def test_uninstall_nonexistent
 | 
			
		||||
    uninstaller = Gem::Uninstaller.new 'bogus', :executables => true
 | 
			
		||||
 | 
			
		||||
    e = assert_raises Gem::InstallError do
 | 
			
		||||
      uninstaller.uninstall
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    assert_equal 'gem "bogus" is not installed', e.message
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def test_uninstall_not_ok
 | 
			
		||||
    quick_gem 'z' do |s|
 | 
			
		||||
      s.add_runtime_dependency @spec.name
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue