diff options
author | drbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-09-13 01:40:42 +0000 |
---|---|---|
committer | drbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-09-13 01:40:42 +0000 |
commit | fdb6a621b0bde5dec6b4541569a95fb2f16261a3 (patch) | |
tree | c9e5506f6f6cc62d33bb90c9b1b933e374c68d4e /test | |
parent | e6a317bf6c4f988fe005af271c1d40ddc9c1ae59 (diff) | |
download | ruby-fdb6a621b0bde5dec6b4541569a95fb2f16261a3.tar.gz |
* lib/rubygems: Update to RubyGems 2.1.3
Fixed installing platform gems
Restored concurrent requires
Fixed installing gems with extensions with --install-dir
Fixed `gem fetch -v` to install the latest version
Fixed installing gems with "./" in their files entries
* test/rubygems/test_gem_package.rb: Tests for the above.
* NEWS: Updated for RubyGems 2.1.3
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42927 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r-- | test/rubygems/test_gem_commands_fetch_command.rb | 30 | ||||
-rw-r--r-- | test/rubygems/test_gem_dependency_resolver.rb | 31 | ||||
-rw-r--r-- | test/rubygems/test_gem_installer.rb | 127 | ||||
-rw-r--r-- | test/rubygems/test_gem_package.rb | 13 |
4 files changed, 142 insertions, 59 deletions
diff --git a/test/rubygems/test_gem_commands_fetch_command.rb b/test/rubygems/test_gem_commands_fetch_command.rb index 924f4c44e7..364881a132 100644 --- a/test/rubygems/test_gem_commands_fetch_command.rb +++ b/test/rubygems/test_gem_commands_fetch_command.rb @@ -34,6 +34,32 @@ class TestGemCommandsFetchCommand < Gem::TestCase 'gem repository directories must not be created' end + def test_execute_latest + util_setup_fake_fetcher + util_setup_spec_fetcher @a1, @a2 + + @fetcher.data["#{@gem_repo}gems/#{@a1.file_name}"] = + File.read(@a1.cache_file) + @fetcher.data["#{@gem_repo}gems/#{@a2.file_name}"] = + File.read(@a2.cache_file) + + refute_path_exists File.join(@tempdir, 'cache'), 'sanity check' + + @cmd.options[:args] = [@a2.name] + @cmd.options[:version] = req('>= 0.1') + + use_ui @ui do + Dir.chdir @tempdir do + @cmd.execute + end + end + + assert_path_exists(File.join(@tempdir, @a2.file_name), + "#{@a2.full_name} not fetched") + refute_path_exists File.join(@tempdir, 'cache'), + 'gem repository directories must not be created' + end + def test_execute_prerelease util_setup_fake_fetcher true util_clear_gems @@ -53,8 +79,8 @@ class TestGemCommandsFetchCommand < Gem::TestCase end end - assert_path_exists(File.join(@tempdir, @a2_pre.file_name), - "#{@a2_pre.full_name} not fetched") + assert_path_exists(File.join(@tempdir, @a2.file_name), + "#{@a2.full_name} not fetched") end def test_execute_specific_prerelease diff --git a/test/rubygems/test_gem_dependency_resolver.rb b/test/rubygems/test_gem_dependency_resolver.rb index 38f3d868ea..47eef8cc55 100644 --- a/test/rubygems/test_gem_dependency_resolver.rb +++ b/test/rubygems/test_gem_dependency_resolver.rb @@ -68,23 +68,28 @@ class TestGemDependencyResolver < Gem::TestCase def test_picks_best_platform is = Gem::DependencyResolver::IndexSpecification - a2_p = quick_spec 'a' do |s| s.platform = Gem::Platform.local end - version = Gem::Version.new 2 + unknown = Gem::Platform.new 'unknown' + a2_p1 = quick_spec 'a', 2 do |s| s.platform = Gem::Platform.local end + a3_p2 = quick_spec 'a', 3 do |s| s.platform = unknown end + v2 = v(2) + v3 = v(3) source = Gem::Source.new @gem_repo s = set - a2 = is.new s, 'a', version, source, Gem::Platform::RUBY - a2_p = is.new s, 'a', version, source, Gem::Platform.local.to_s + a2 = is.new s, 'a', v2, source, Gem::Platform::RUBY + a2_p1 = is.new s, 'a', v2, source, Gem::Platform.local.to_s + a3_p2 = is.new s, 'a', v3, source, unknown - s.add a2_p + s.add a3_p2 + s.add a2_p1 s.add a2 ad = make_dep "a" res = Gem::DependencyResolver.new([ad], s) - assert_set [a2_p], res.resolve + assert_set [a2_p1], res.resolve end def test_only_returns_spec_once @@ -348,4 +353,18 @@ class TestGemDependencyResolver < Gem::TestCase assert_set [b1, c1, d2], r.resolve end + + def test_select_local_platforms + r = Gem::DependencyResolver.new nil, nil + + a1 = quick_spec 'a', 1 + a1_p1 = quick_spec 'a', 1 do |s| s.platform = Gem::Platform.local end + a1_p2 = quick_spec 'a', 1 do |s| s.platform = 'unknown' end + + selected = r.select_local_platforms [a1, a1_p1, a1_p2] + + assert_equal [a1, a1_p1], selected + end + end + diff --git a/test/rubygems/test_gem_installer.rb b/test/rubygems/test_gem_installer.rb index ba9253b50c..01b151c089 100644 --- a/test/rubygems/test_gem_installer.rb +++ b/test/rubygems/test_gem_installer.rb @@ -73,7 +73,7 @@ load Gem.bin_path('a', 'executable', version) @installer.generate_bin installed_exec = File.join util_inst_bindir, 'executable' - assert File.exist? installed_exec + assert_path_exists installed_exec wrapper = File.read installed_exec assert_match %r|generated by RubyGems|, wrapper @@ -136,7 +136,7 @@ gem 'other', version @installer.generate_bin # should not raise installed_exec = File.join util_inst_bindir, 'foo-executable-bar' - assert File.exist? installed_exec + assert_path_exists installed_exec wrapper = File.read installed_exec assert_match %r|generated by RubyGems|, wrapper @@ -165,7 +165,7 @@ gem 'other', version @installer.generate_bin installed_exec = File.join util_inst_bindir, 'executable' - assert File.exist? installed_exec + assert_path_exists installed_exec wrapper = File.read installed_exec assert_match %r|generated by RubyGems|, wrapper @@ -178,7 +178,7 @@ gem 'other', version @installer.generate_bin installed_exec = File.join util_inst_bindir, 'executable' - assert File.exist? installed_exec + assert_path_exists installed_exec wrapper = File.read installed_exec assert_match %r|generated by RubyGems|, wrapper @@ -252,7 +252,7 @@ gem 'other', version assert_equal true, File.directory?(util_inst_bindir) installed_exec = File.join(util_inst_bindir, 'executable') - assert_equal true, File.exist?(installed_exec) + assert_path_exists installed_exec assert_equal mask, File.stat(installed_exec).mode unless win_platform? wrapper = File.read installed_exec @@ -287,7 +287,7 @@ gem 'other', version @installer.generate_bin assert File.directory? util_inst_bindir installed_exec = File.join util_inst_bindir, 'executable' - assert File.exist? installed_exec + assert_path_exists installed_exec assert_equal mask, File.stat(installed_exec).mode unless win_platform? wrapper = File.read installed_exec @@ -304,7 +304,7 @@ gem 'other', version @installer.generate_bin assert_equal true, File.directory?(util_inst_bindir) installed_exec = File.join util_inst_bindir, 'foo-executable-bar' - assert_equal true, File.exist?(installed_exec) + assert_path_exists installed_exec ensure Gem::Installer.exec_format = nil end @@ -318,7 +318,7 @@ gem 'other', version @installer.generate_bin assert_equal true, File.directory?(util_inst_bindir) installed_exec = File.join util_inst_bindir, 'executable' - assert_equal true, File.exist?(installed_exec) + assert_path_exists installed_exec ensure Gem::Installer.exec_format = nil end @@ -340,7 +340,7 @@ gem 'other', version @installer.generate_bin installed_exec = File.join("#{@gemhome}2", "bin", 'executable') - assert File.exist? installed_exec + assert_path_exists installed_exec assert_equal mask, File.stat(installed_exec).mode unless win_platform? wrapper = File.read installed_exec @@ -353,7 +353,7 @@ gem 'other', version @installer.wrappers = true @installer.generate_bin - refute File.exist?(util_inst_bindir), 'bin dir was created when not needed' + refute_path_exists util_inst_bindir, 'bin dir was created when not needed' end def test_generate_bin_script_no_perms @@ -389,7 +389,7 @@ gem 'other', version @installer.generate_bin installed_exec = File.join @gemhome, 'bin', 'executable' - assert_equal true, File.exist?(installed_exec) + assert_path_exists installed_exec assert_equal mask, File.stat(installed_exec).mode unless win_platform? wrapper = File.read installed_exec @@ -414,7 +414,7 @@ gem 'other', version @installer.generate_bin assert_equal true, File.directory?(util_inst_bindir) - assert_equal true, File.exist?(installed_exec) + assert_path_exists installed_exec assert_equal mask, File.stat(installed_exec).mode unless win_platform? assert_match %r|generated by RubyGems|, File.read(installed_exec) @@ -444,7 +444,7 @@ gem 'other', version @installer.wrappers = false @installer.generate_bin - refute File.exist?(util_inst_bindir) + refute_path_exists util_inst_bindir end def test_generate_bin_symlink_no_perms @@ -543,7 +543,7 @@ gem 'other', version @installer.generate_bin installed_exec = File.join util_inst_bindir, 'executable' - assert File.exist? installed_exec + assert_path_exists installed_exec @spec = Gem::Specification.new do |s| s.files = ['lib/code.rb'] @@ -580,7 +580,7 @@ gem 'other', version assert_equal true, File.directory?(util_inst_bindir) installed_exec = File.join(util_inst_bindir, 'executable') - assert_equal true, File.exist?(installed_exec) + assert_path_exists installed_exec assert_match(/Unable to use symlinks on Windows, installing wrapper/i, @ui.error) @@ -647,19 +647,19 @@ gem 'other', version rakefile = File.join gemdir, 'ext', 'a', 'Rakefile' Gem.pre_install do |installer| - refute File.exist?(cache_file), 'cache file must not exist yet' + refute_path_exists cache_file, 'cache file must not exist yet' true end Gem.post_build do |installer| - assert File.exist?(gemdir), 'gem install dir must exist' - assert File.exist?(rakefile), 'gem executable must exist' - refute File.exist?(stub_exe), 'gem executable must not exist' + assert_path_exists gemdir, 'gem install dir must exist' + assert_path_exists rakefile, 'gem executable must exist' + refute_path_exists stub_exe, 'gem executable must not exist' true end Gem.post_install do |installer| - assert File.exist?(cache_file), 'cache file must exist' + assert_path_exists cache_file, 'cache file must exist' end @newspec = nil @@ -670,23 +670,23 @@ gem 'other', version end assert_equal @spec, @newspec - assert File.exist? gemdir - assert File.exist?(stub_exe), 'gem executable must exist' + assert_path_exists gemdir + assert_path_exists stub_exe, 'gem executable must exist' exe = File.join gemdir, 'bin', 'executable' - assert File.exist? exe + assert_path_exists exe exe_mode = File.stat(exe).mode & 0111 assert_equal 0111, exe_mode, "0%o" % exe_mode unless win_platform? - assert File.exist?(File.join(gemdir, 'lib', 'code.rb')) + assert_path_exists File.join gemdir, 'lib', 'code.rb' - assert File.exist? rakefile + assert_path_exists rakefile spec_file = File.join(@gemhome, 'specifications', @spec.spec_name) assert_equal spec_file, @newspec.loaded_from - assert File.exist?(spec_file) + assert_path_exists spec_file assert_same @installer, @post_build_hook_arg assert_same @installer, @post_install_hook_arg @@ -795,7 +795,7 @@ gem 'other', version end gemdir = File.join(@gemhome, 'gems', @spec.full_name) - assert File.exist?(File.join(gemdir, 'lib', 'code.rb')) + assert_path_exists File.join gemdir, 'lib', 'code.rb' util_setup_gem # Morph spec to have lib/other.rb instead of code.rb and recreate @@ -814,9 +814,9 @@ gem 'other', version end end - assert File.exist?(File.join(gemdir, 'lib', 'other.rb')) - refute(File.exist?(File.join(gemdir, 'lib', 'code.rb')), - "code.rb from prior install of same gem shouldn't remain here") + assert_path_exists File.join gemdir, 'lib', 'other.rb' + refute_path_exists File.join gemdir, 'lib', 'code.rb', + "code.rb from prior install of same gem shouldn't remain here" end def test_install_force @@ -826,7 +826,7 @@ gem 'other', version end gem_dir = File.join(@gemhome, 'gems', 'old_ruby_required-1') - assert File.exist?(gem_dir) + assert_path_exists gem_dir end def test_install_missing_dirs @@ -842,8 +842,8 @@ gem 'other', version File.directory? File.join(Gem.dir, 'docs') File.directory? File.join(Gem.dir, 'specifications') - assert File.exist?(File.join(@gemhome, 'cache', @spec.file_name)) - assert File.exist?(File.join(@gemhome, 'specifications', @spec.spec_name)) + assert_path_exists File.join @gemhome, 'cache', @spec.file_name + assert_path_exists File.join @gemhome, 'specifications', @spec.spec_name end def test_install_post_build_false @@ -864,10 +864,10 @@ gem 'other', version end spec_file = File.join @gemhome, 'specifications', @spec.spec_name - refute File.exist? spec_file + refute_path_exists spec_file gem_dir = File.join @gemhome, 'gems', @spec.full_name - refute File.exist? gem_dir + refute_path_exists gem_dir end def test_install_post_build_nil @@ -882,10 +882,10 @@ gem 'other', version end spec_file = File.join @gemhome, 'specifications', @spec.spec_name - assert File.exist? spec_file + assert_path_exists spec_file gem_dir = File.join @gemhome, 'gems', @spec.full_name - assert File.exist? gem_dir + assert_path_exists gem_dir end def test_install_pre_install_false @@ -906,7 +906,7 @@ gem 'other', version end spec_file = File.join @gemhome, 'specifications', @spec.spec_name - refute File.exist? spec_file + refute_path_exists spec_file end def test_install_pre_install_nil @@ -921,7 +921,7 @@ gem 'other', version end spec_file = File.join @gemhome, 'specifications', @spec.spec_name - assert File.exist? spec_file + assert_path_exists spec_file end def test_install_with_message @@ -937,6 +937,31 @@ gem 'other', version assert_match %r|I am a shiny gem!|, @ui.output end + def test_install_extension_install_dir + gemhome2 = "#{@gemhome}2" + + @spec.extensions << "extconf.rb" + write_file File.join(@tempdir, "extconf.rb") do |io| + io.write <<-RUBY + require "mkmf" + create_makefile("#{@spec.name}") + RUBY + end + + @spec.files += %w[extconf.rb] + + use_ui @ui do + path = Gem::Package.build @spec + + installer = Gem::Installer.new path, :install_dir => gemhome2 + installer.install + end + + expected_makefile = File.join gemhome2, 'gems', @spec.full_name, 'Makefile' + + assert_path_exists expected_makefile + end + def test_install_extension_and_script @spec.extensions << "extconf.rb" write_file File.join(@tempdir, "extconf.rb") do |io| @@ -963,16 +988,16 @@ gem 'other', version RUBY end - assert !File.exist?(File.join(@spec.gem_dir, rb)) - assert !File.exist?(File.join(@spec.gem_dir, rb2)) + refute_path_exists File.join @spec.gem_dir, rb + refute_path_exists File.join @spec.gem_dir, rb2 use_ui @ui do path = Gem::Package.build @spec @installer = Gem::Installer.new path @installer.install end - assert File.exist?(File.join(@spec.gem_dir, rb)) - assert File.exist?(File.join(@spec.gem_dir, rb2)) + assert_path_exists File.join @spec.gem_dir, rb + assert_path_exists File.join @spec.gem_dir, rb2 end def test_install_extension_flat @@ -1001,14 +1026,14 @@ gem 'other', version } so = File.join(@spec.gem_dir, "#{@spec.name}.#{RbConfig::CONFIG["DLEXT"]}") - assert !File.exist?(so) + refute_path_exists so use_ui @ui do path = Gem::Package.build @spec @installer = Gem::Installer.new path @installer.install end - assert File.exist?(so) + assert_path_exists so rescue puts '-' * 78 puts File.read File.join(@gemhome, 'gems', 'a-2', 'Makefile') @@ -1253,8 +1278,8 @@ gem 'other', version @installer.unpack dest - assert File.exist?(File.join(dest, 'lib', 'code.rb')) - assert File.exist?(File.join(dest, 'bin', 'executable')) + assert_path_exists File.join dest, 'lib', 'code.rb' + assert_path_exists File.join dest, 'bin', 'executable' end def test_write_build_info_file @@ -1313,20 +1338,20 @@ gem 'other', version def test_write_spec FileUtils.rm @spec.spec_file - refute File.exist?(@spec.spec_file) + refute_path_exists @spec.spec_file @installer.spec = @spec @installer.gem_home = @gemhome @installer.write_spec - assert File.exist?(@spec.spec_file) + assert_path_exists @spec.spec_file assert_equal @spec, eval(File.read(@spec.spec_file)) end def test_write_spec_writes_cached_spec FileUtils.rm @spec.spec_file - refute File.exist?(@spec.spec_file) + refute_path_exists @spec.spec_file @spec.files = %w[a.rb b.rb c.rb] @@ -1359,7 +1384,7 @@ gem 'other', version assert File.directory? util_inst_bindir installed_exec = File.join util_inst_bindir, 'executable' - assert File.exist? installed_exec + assert_path_exists installed_exec assert File.directory? File.join(Gem.dir, 'specifications') assert File.directory? File.join(Gem.dir, 'specifications', 'default') diff --git a/test/rubygems/test_gem_package.rb b/test/rubygems/test_gem_package.rb index eaa7ff813c..af5319a150 100644 --- a/test/rubygems/test_gem_package.rb +++ b/test/rubygems/test_gem_package.rb @@ -396,6 +396,19 @@ class TestGemPackage < Gem::Package::TarTestCase "#{@destination} is not allowed", e.message) end + def test_extract_tar_gz_dot_slash + package = Gem::Package.new @gem + + tgz_io = util_tar_gz do |tar| + tar.add_file './dot_slash.rb', 0644 do |io| io.write 'hi' end + end + + package.extract_tar_gz tgz_io, @destination + + extracted = File.join @destination, 'dot_slash.rb' + assert_path_exists extracted + end + def test_install_location package = Gem::Package.new @gem |