summaryrefslogtreecommitdiff
path: root/test/rubygems
diff options
context:
space:
mode:
authordrbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-08-05 01:00:01 +0000
committerdrbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-08-05 01:00:01 +0000
commit3434676e9e3c87c39fe4a8c411a041449efc7446 (patch)
tree1dabd9705561ef803bb9f62e6d8e3eaf0618a1cb /test/rubygems
parentd24997cce12d27cec767ca7091a076df1b2319db (diff)
* lib/rubygems: Import RubyGems 1.8.7:
Added missing require for `gem uninstall --format-executable`. The correct name of the executable being uninstalled is now displayed with --format-executable. Fixed `gem unpack uninstalled_gem` default version picker. RubyGems no longer claims a nonexistent gem can be uninstalled. `gem which` no longer claims directories are requirable files. `gem cleanup` continues cleaning up gems if one can't be uninstalled due to permissions. Issue #82. Gem repository directories are no longer created world-writable. Patch by Sakuro OZAWA. [Ruby 1.9 - Bug #4930] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32852 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/rubygems')
-rw-r--r--test/rubygems/test_gem.rb14
-rw-r--r--test/rubygems/test_gem_commands_cleanup_command.rb38
-rw-r--r--test/rubygems/test_gem_commands_sources_command.rb2
-rw-r--r--test/rubygems/test_gem_remote_fetcher.rb22
4 files changed, 76 insertions, 0 deletions
diff --git a/test/rubygems/test_gem.rb b/test/rubygems/test_gem.rb
index 20f2a93c04..273ba8f640 100644
--- a/test/rubygems/test_gem.rb
+++ b/test/rubygems/test_gem.rb
@@ -598,6 +598,20 @@ class TestGem < Gem::TestCase
assert File.directory? File.join(@gemhome, "cache")
end
+ def test_self_ensure_gem_directories_safe_permissions
+ FileUtils.rm_r @gemhome
+ Gem.use_paths @gemhome
+
+ old_umask = File.umask
+ File.umask 0
+ Gem.ensure_gem_subdirectories @gemhome
+
+ assert_equal 0, File::Stat.new(@gemhome).mode & 022
+ assert_equal 0, File::Stat.new(File.join(@gemhome, "cache")).mode & 022
+ ensure
+ File.umask old_umask
+ end unless win_platform?
+
def test_self_ensure_gem_directories_missing_parents
gemdir = File.join @tempdir, 'a/b/c/gemdir'
FileUtils.rm_rf File.join(@tempdir, 'a') rescue nil
diff --git a/test/rubygems/test_gem_commands_cleanup_command.rb b/test/rubygems/test_gem_commands_cleanup_command.rb
index 22bbfb7a2f..40c7b30539 100644
--- a/test/rubygems/test_gem_commands_cleanup_command.rb
+++ b/test/rubygems/test_gem_commands_cleanup_command.rb
@@ -38,6 +38,44 @@ class TestGemCommandsCleanupCommand < Gem::TestCase
refute_path_exists @b_1.gem_dir
end
+ def test_execute_all_user
+ @a_1_1 = quick_spec 'a', '1.1'
+ @a_1_1 = install_gem_user @a_1_1 # pick up user install path
+
+ Gem::Specification.dirs = [Gem.dir, Gem.user_dir]
+
+ assert_path_exists @a_1.gem_dir
+ assert_path_exists @a_1_1.gem_dir
+
+ @cmd.options[:args] = %w[a]
+
+ @cmd.execute
+
+ refute_path_exists @a_1.gem_dir
+ refute_path_exists @a_1_1.gem_dir
+ end
+
+ def test_execute_all_user_no_sudo
+ FileUtils.chmod 0555, @gemhome
+
+ @a_1_1 = quick_spec 'a', '1.1'
+ @a_1_1 = install_gem_user @a_1_1 # pick up user install path
+
+ Gem::Specification.dirs = [Gem.dir, Gem.user_dir]
+
+ assert_path_exists @a_1.gem_dir
+ assert_path_exists @a_1_1.gem_dir
+
+ @cmd.options[:args] = %w[a]
+
+ @cmd.execute
+
+ assert_path_exists @a_1.gem_dir
+ refute_path_exists @a_1_1.gem_dir
+ ensure
+ FileUtils.chmod 0755, @gemhome
+ end unless win_platform?
+
def test_execute_dry_run
@cmd.options[:args] = %w[a]
@cmd.options[:dryrun] = true
diff --git a/test/rubygems/test_gem_commands_sources_command.rb b/test/rubygems/test_gem_commands_sources_command.rb
index 3d06940232..8b439025ed 100644
--- a/test/rubygems/test_gem_commands_sources_command.rb
+++ b/test/rubygems/test_gem_commands_sources_command.rb
@@ -6,6 +6,8 @@ class TestGemCommandsSourcesCommand < Gem::TestCase
def setup
super
+ util_setup_fake_fetcher
+
@cmd = Gem::Commands::SourcesCommand.new
@new_repo = "http://beta-gems.example.com"
diff --git a/test/rubygems/test_gem_remote_fetcher.rb b/test/rubygems/test_gem_remote_fetcher.rb
index 2ccb8ce37a..3bdba5e072 100644
--- a/test/rubygems/test_gem_remote_fetcher.rb
+++ b/test/rubygems/test_gem_remote_fetcher.rb
@@ -346,6 +346,28 @@ gems:
assert_equal 'unsupported URI scheme ftp', e.message
end
+ def test_download_to_cache
+ @a2, @a2_gem = util_gem 'a', '2'
+
+ util_setup_spec_fetcher @a1, @a2
+ @fetcher.instance_variable_set :@a1, @a1
+ @fetcher.instance_variable_set :@a2, @a2
+ def @fetcher.fetch_path uri, mtime = nil, head = false
+ case uri.request_uri
+ when /#{@a1.spec_name}/ then
+ Gem.deflate Marshal.dump @a1
+ when /#{@a2.spec_name}/ then
+ Gem.deflate Marshal.dump @a2
+ else
+ uri.to_s
+ end
+ end
+
+ gem = Gem::RemoteFetcher.fetcher.download_to_cache dep 'a'
+
+ assert_equal @a2.file_name, File.basename(gem)
+ end
+
def test_explicit_proxy
use_ui @ui do
fetcher = Gem::RemoteFetcher.new @proxy_uri