From 44d0a6dcd7563526a8b05ccdfa21d9425b94e62b Mon Sep 17 00:00:00 2001 From: drbrain Date: Tue, 12 Nov 2013 00:16:41 +0000 Subject: * lib/rubygems: Update to RubyGems master b9213d7. Changes include: Fixed tests on Windows (I hope) by forcing platform for platform-dependent tests. Fixed File.exists? warnings. Improved testing infrastructure. * test/rubygems: ditto. * test/rdoc/test_rdoc_rubygems_hook.rb: Switch to util_spec like RubyGems. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43651 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/rubygems/test_gem_commands_query_command.rb | 172 ++++++++++++++++------- 1 file changed, 123 insertions(+), 49 deletions(-) (limited to 'test/rubygems/test_gem_commands_query_command.rb') diff --git a/test/rubygems/test_gem_commands_query_command.rb b/test/rubygems/test_gem_commands_query_command.rb index ccd64810fb..43fa82571d 100644 --- a/test/rubygems/test_gem_commands_query_command.rb +++ b/test/rubygems/test_gem_commands_query_command.rb @@ -8,9 +8,11 @@ class TestGemCommandsQueryCommand < Gem::TestCase @cmd = Gem::Commands::QueryCommand.new - util_setup_fake_fetcher - util_clear_gems - util_setup_spec_fetcher @a1, @a2, @pl1, @a3a + @specs = spec_fetcher do |fetcher| + fetcher.spec 'a', 1 + fetcher.spec 'a', 2 + fetcher.spec 'a', '3.a' + end @fetcher.data["#{@gem_repo}Marshal.#{Gem.marshal_version}"] = proc do raise Gem::RemoteFetcher::FetchError @@ -18,6 +20,10 @@ class TestGemCommandsQueryCommand < Gem::TestCase end def test_execute + spec_fetcher do |fetcher| + fetcher.legacy_platform + end + @cmd.handle_options %w[-r] use_ui @ui do @@ -37,13 +43,18 @@ pl (1 i386-linux) end def test_execute_platform - @a1r = @a1.dup + spec_fetcher do |fetcher| + fetcher.clear - @a1.platform = 'x86-linux' - @a2.platform = 'universal-darwin' + fetcher.spec 'a', 1 + fetcher.spec 'a', 1 do |s| + s.platform = 'x86-linux' + end - util_clear_gems - util_setup_spec_fetcher @a1, @a1r, @a2, @b2, @pl1 + fetcher.spec 'a', 2 do |s| + s.platform = 'universal-darwin' + end + end @cmd.handle_options %w[-r -a] @@ -56,8 +67,6 @@ pl (1 i386-linux) *** REMOTE GEMS *** a (2 universal-darwin, 1 ruby x86-linux) -b (2) -pl (1 i386-linux) EOF assert_equal expected, @ui.output @@ -65,6 +74,10 @@ pl (1 i386-linux) end def test_execute_all + spec_fetcher do |fetcher| + fetcher.legacy_platform + end + @cmd.handle_options %w[-r --all] use_ui @ui do @@ -84,6 +97,10 @@ pl (1 i386-linux) end def test_execute_all_prerelease + spec_fetcher do |fetcher| + fetcher.legacy_platform + end + @cmd.handle_options %w[-r --all --prerelease] use_ui @ui do @@ -103,12 +120,15 @@ pl (1 i386-linux) end def test_execute_details - @a2.summary = 'This is a lot of text. ' * 4 - @a2.authors = ['Abraham Lincoln', 'Hirohito'] - @a2.homepage = 'http://a.example.com/' + spec_fetcher do |fetcher| + fetcher.spec 'a', 2 do |s| + s.summary = 'This is a lot of text. ' * 4 + s.authors = ['Abraham Lincoln', 'Hirohito'] + s.homepage = 'http://a.example.com/' + end - util_clear_gems - util_setup_spec_fetcher @a1, @a2, @pl1 + fetcher.legacy_platform + end @cmd.handle_options %w[-r -d] @@ -140,15 +160,22 @@ pl (1) end def test_execute_details_platform - @a1.platform = 'x86-linux' + spec_fetcher do |fetcher| + fetcher.clear + + fetcher.spec 'a', 1 do |s| + s.platform = 'x86-linux' + end - @a2.summary = 'This is a lot of text. ' * 4 - @a2.authors = ['Abraham Lincoln', 'Hirohito'] - @a2.homepage = 'http://a.example.com/' - @a2.platform = 'universal-darwin' + fetcher.spec 'a', 2 do |s| + s.summary = 'This is a lot of text. ' * 4 + s.authors = ['Abraham Lincoln', 'Hirohito'] + s.homepage = 'http://a.example.com/' + s.platform = 'universal-darwin' + end - util_clear_gems - util_setup_spec_fetcher @a1, @a2, @pl1 + fetcher.legacy_platform + end @cmd.handle_options %w[-r -d] @@ -282,6 +309,10 @@ pl (1) end def test_execute_local + spec_fetcher do |fetcher| + fetcher.legacy_platform + end + @cmd.options[:domain] = :local use_ui @ui do @@ -301,6 +332,10 @@ pl (1 i386-linux) end def test_execute_local_notty + spec_fetcher do |fetcher| + fetcher.legacy_platform + end + @cmd.handle_options %w[] @ui.outs.tty = false @@ -319,6 +354,10 @@ pl (1 i386-linux) end def test_execute_local_quiet + spec_fetcher do |fetcher| + fetcher.legacy_platform + end + @cmd.options[:domain] = :local Gem.configuration.verbose = false @@ -336,6 +375,10 @@ pl (1 i386-linux) end def test_execute_no_versions + spec_fetcher do |fetcher| + fetcher.legacy_platform + end + @cmd.handle_options %w[-r --no-versions] use_ui @ui do @@ -355,6 +398,10 @@ pl end def test_execute_notty + spec_fetcher do |fetcher| + fetcher.legacy_platform + end + @cmd.handle_options %w[-r] @ui.outs.tty = false @@ -391,6 +438,10 @@ a (3.a) end def test_execute_prerelease_local + spec_fetcher do |fetcher| + fetcher.legacy_platform + end + @cmd.handle_options %w[-l --prerelease] use_ui @ui do @@ -410,6 +461,10 @@ pl (1 i386-linux) end def test_execute_remote + spec_fetcher do |fetcher| + fetcher.legacy_platform + end + @cmd.options[:domain] = :remote use_ui @ui do @@ -429,6 +484,10 @@ pl (1 i386-linux) end def test_execute_remote_notty + spec_fetcher do |fetcher| + fetcher.legacy_platform + end + @cmd.handle_options %w[] @ui.outs.tty = false @@ -447,6 +506,10 @@ pl (1 i386-linux) end def test_execute_remote_quiet + spec_fetcher do |fetcher| + fetcher.legacy_platform + end + @cmd.options[:domain] = :remote Gem.configuration.verbose = false @@ -464,15 +527,22 @@ pl (1 i386-linux) end def test_execute_local_details - @a1.platform = 'x86-linux' + spec_fetcher do |fetcher| + fetcher.clear - @a2.summary = 'This is a lot of text. ' * 4 - @a2.authors = ['Abraham Lincoln', 'Hirohito'] - @a2.homepage = 'http://a.example.com/' - @a2.platform = 'universal-darwin' + fetcher.spec 'a', 1 do |s| + s.platform = 'x86-linux' + end + + fetcher.spec 'a', 2 do |s| + s.summary = 'This is a lot of text. ' * 4 + s.authors = ['Abraham Lincoln', 'Hirohito'] + s.homepage = 'http://a.example.com/' + s.platform = 'universal-darwin' + end - util_clear_gems - util_setup_spec_fetcher @a1, @a2, @pl1 + fetcher.legacy_platform + end @cmd.handle_options %w[-l -d] @@ -486,6 +556,7 @@ pl (1 i386-linux) str.gsub!(/at: [^\n]*/, "at: -") expected = <<-EOF + *** LOCAL GEMS *** a (2, 1) @@ -500,7 +571,7 @@ a (2, 1) This is a lot of text. This is a lot of text. This is a lot of text. This is a lot of text. -pl \(1\) +pl (1) Platform: i386-linux Author: A User Homepage: http://example.com @@ -509,13 +580,18 @@ pl \(1\) this is a summary EOF - assert_match expected, @ui.output + assert_equal expected, @ui.output end def test_execute_default_details - default_gem_dir = Gem::Specification.default_specifications_dir - @a1.loaded_from = - File.join default_gem_dir, @a1.spec_name + spec_fetcher do |fetcher| + fetcher.clear + + fetcher.spec 'a', 2 + end + + a1 = new_default_spec 'a', 1 + install_default_specs a1 @cmd.handle_options %w[-l -d] @@ -527,20 +603,11 @@ pl \(1\) *** LOCAL GEMS *** -a (3.a, 2, 1) - Author: A User - Homepage: http://example.com - Installed at (3.a): #{@gemhome} - (2): #{@gemhome} - (1, default): #{@a1.base_dir} - - this is a summary - -pl \(1\) - Platform: i386-linux +a (2, 1) Author: A User Homepage: http://example.com - Installed at: #{@gemhome} + Installed at (2): #{@gemhome} + (1, default): #{a1.base_dir} this is a summary EOF @@ -549,15 +616,18 @@ pl \(1\) end def test_make_entry + a_2_name = @specs['a-2'].original_name + @fetcher.data.delete \ - "#{@gem_repo}quick/Marshal.#{Gem.marshal_version}/#{@a2.original_name}.gemspec.rz" + "#{@gem_repo}quick/Marshal.#{Gem.marshal_version}/#{a_2_name}.gemspec.rz" + a2 = @specs['a-2'] entry_tuples = [ - [Gem::NameTuple.new(@a2.name, @a2.version, @a2.platform), + [Gem::NameTuple.new(a2.name, a2.version, a2.platform), Gem.sources.first], ] - platforms = { @a2.version => [@a2.platform] } + platforms = { a2.version => [a2.platform] } entry = @cmd.send :make_entry, entry_tuples, platforms @@ -566,6 +636,10 @@ pl \(1\) # Test for multiple args handling! def test_execute_multiple_args + spec_fetcher do |fetcher| + fetcher.legacy_platform + end + @cmd.handle_options %w[a pl] use_ui @ui do -- cgit v1.2.3