rubygems-update 0.9.4 → 0.9.5

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of rubygems-update might be problematic. Click here for more details.

Files changed (225) hide show
  1. data/ChangeLog +587 -0
  2. data/README +0 -1
  3. data/Rakefile +39 -12
  4. data/TODO +0 -5
  5. data/bin/gem +7 -7
  6. data/bin/update_rubygems +1 -1
  7. data/examples/application/an-app.gemspec +1 -1
  8. data/gemspecs/cgikit-1.1.0.gemspec +1 -2
  9. data/gemspecs/jabber4r.gemspec +1 -1
  10. data/gemspecs/linguistics.gemspec +1 -1
  11. data/gemspecs/ook.gemspec +1 -1
  12. data/gemspecs/progressbar.gemspec +1 -1
  13. data/gemspecs/redcloth.gemspec +1 -1
  14. data/gemspecs/rublog.gemspec +1 -1
  15. data/gemspecs/ruby-doom.gemspec +1 -1
  16. data/gemspecs/rubyjdwp.gemspec +1 -1
  17. data/gemspecs/statistics.gemspec +1 -1
  18. data/lib/rubygems.rb +167 -105
  19. data/lib/rubygems/builder.rb +12 -10
  20. data/lib/rubygems/command.rb +177 -60
  21. data/lib/rubygems/command_manager.rb +30 -38
  22. data/lib/rubygems/commands/build_command.rb +42 -46
  23. data/lib/rubygems/commands/cert_command.rb +72 -69
  24. data/lib/rubygems/commands/check_command.rb +63 -63
  25. data/lib/rubygems/commands/cleanup_command.rb +25 -7
  26. data/lib/rubygems/commands/contents_command.rb +70 -62
  27. data/lib/rubygems/commands/dependency_command.rb +131 -86
  28. data/lib/rubygems/commands/environment_command.rb +67 -46
  29. data/lib/rubygems/commands/fetch_command.rb +62 -0
  30. data/lib/rubygems/commands/generate_index_command.rb +57 -0
  31. data/lib/rubygems/commands/help_command.rb +163 -73
  32. data/lib/rubygems/commands/install_command.rb +114 -128
  33. data/lib/rubygems/commands/list_command.rb +10 -8
  34. data/lib/rubygems/commands/lock_command.rb +101 -0
  35. data/lib/rubygems/commands/mirror_command.rb +105 -0
  36. data/lib/rubygems/commands/outdated_command.rb +24 -15
  37. data/lib/rubygems/commands/pristine_command.rb +118 -88
  38. data/lib/rubygems/commands/query_command.rb +109 -77
  39. data/lib/rubygems/commands/rdoc_command.rb +13 -10
  40. data/lib/rubygems/commands/search_command.rb +10 -8
  41. data/lib/rubygems/commands/server_command.rb +48 -0
  42. data/lib/rubygems/commands/sources_command.rb +104 -83
  43. data/lib/rubygems/commands/specification_command.rb +65 -51
  44. data/lib/rubygems/commands/uninstall_command.rb +17 -12
  45. data/lib/rubygems/commands/unpack_command.rb +68 -68
  46. data/lib/rubygems/commands/update_command.rb +72 -25
  47. data/lib/rubygems/commands/which_command.rb +86 -0
  48. data/lib/rubygems/config_file.rb +202 -78
  49. data/lib/rubygems/custom_require.rb +7 -88
  50. data/lib/rubygems/dependency.rb +65 -0
  51. data/lib/rubygems/dependency_installer.rb +232 -0
  52. data/lib/rubygems/dependency_list.rb +133 -105
  53. data/lib/rubygems/digest/md5.rb +4 -1
  54. data/lib/rubygems/digest/sha2.rb +1 -1
  55. data/lib/rubygems/doc_manager.rb +41 -19
  56. data/lib/rubygems/exceptions.rb +63 -0
  57. data/lib/rubygems/ext.rb +18 -0
  58. data/lib/rubygems/ext/builder.rb +56 -0
  59. data/lib/rubygems/ext/configure_builder.rb +24 -0
  60. data/lib/rubygems/ext/ext_conf_builder.rb +23 -0
  61. data/lib/rubygems/ext/rake_builder.rb +27 -0
  62. data/lib/rubygems/format.rb +16 -6
  63. data/lib/rubygems/gem_openssl.rb +43 -6
  64. data/lib/rubygems/gem_path_searcher.rb +84 -0
  65. data/lib/rubygems/gem_runner.rb +20 -5
  66. data/lib/rubygems/indexer.rb +163 -0
  67. data/lib/rubygems/indexer/abstract_index_builder.rb +80 -0
  68. data/lib/rubygems/indexer/marshal_index_builder.rb +17 -0
  69. data/lib/rubygems/indexer/master_index_builder.rb +53 -0
  70. data/lib/rubygems/indexer/quick_index_builder.rb +48 -0
  71. data/lib/rubygems/install_update_options.rb +87 -0
  72. data/lib/rubygems/installer.rb +316 -562
  73. data/lib/rubygems/local_remote_options.rb +106 -0
  74. data/lib/rubygems/old_format.rb +5 -13
  75. data/lib/rubygems/open-uri.rb +2 -0
  76. data/lib/rubygems/package.rb +28 -32
  77. data/lib/rubygems/platform.rb +187 -0
  78. data/lib/rubygems/remote_fetcher.rb +46 -29
  79. data/lib/rubygems/remote_installer.rb +11 -18
  80. data/lib/rubygems/requirement.rb +157 -0
  81. data/lib/rubygems/rubygems_version.rb +1 -1
  82. data/lib/rubygems/security.rb +715 -457
  83. data/lib/rubygems/server.rb +77 -59
  84. data/lib/rubygems/source_index.rb +154 -83
  85. data/lib/rubygems/source_info_cache.rb +73 -30
  86. data/lib/rubygems/source_info_cache_entry.rb +12 -3
  87. data/lib/rubygems/specification.rb +378 -145
  88. data/lib/rubygems/uninstaller.rb +183 -0
  89. data/lib/rubygems/user_interaction.rb +38 -9
  90. data/lib/rubygems/validator.rb +53 -24
  91. data/lib/rubygems/version.rb +126 -289
  92. data/lib/rubygems/version_option.rb +49 -0
  93. data/pkgs/sources/lib/sources.rb +1 -4
  94. data/pkgs/sources/sources.gemspec +3 -3
  95. data/scripts/gemdoc.rb +0 -1
  96. data/setup.rb +166 -1505
  97. data/test/bogussources.rb +0 -1
  98. data/test/data/gem-private_key.pem +27 -0
  99. data/test/data/gem-public_cert.pem +20 -0
  100. data/test/functional.rb +3 -105
  101. data/test/gemutilities.rb +145 -24
  102. data/test/insure_session.rb +0 -1
  103. data/test/{test_datadir.rb → test_config.rb} +7 -13
  104. data/test/test_gem.rb +360 -9
  105. data/test/test_gem_builder.rb +34 -0
  106. data/test/{test_command.rb → test_gem_command.rb} +119 -62
  107. data/test/{test_parse_commands.rb → test_gem_command_manager.rb} +64 -40
  108. data/test/test_gem_commands_build_command.rb +75 -0
  109. data/test/test_gem_commands_cert_command.rb +122 -0
  110. data/test/test_gem_commands_check_command.rb +25 -0
  111. data/test/test_gem_commands_contents_command.rb +92 -0
  112. data/test/test_gem_commands_dependency_command.rb +108 -0
  113. data/test/test_gem_commands_environment_command.rb +117 -0
  114. data/test/test_gem_commands_fetch_command.rb +34 -0
  115. data/test/test_gem_commands_generate_index_command.rb +32 -0
  116. data/test/test_gem_commands_install_command.rb +160 -0
  117. data/test/test_gem_commands_mirror_command.rb +56 -0
  118. data/test/test_gem_commands_pristine_command.rb +100 -0
  119. data/test/test_gem_commands_query_command.rb +82 -0
  120. data/test/test_gem_commands_sources_command.rb +147 -0
  121. data/test/test_gem_commands_specification_command.rb +93 -0
  122. data/test/test_gem_commands_unpack_command.rb +55 -0
  123. data/test/test_gem_config_file.rb +210 -0
  124. data/test/test_gem_dependency.rb +89 -0
  125. data/test/test_gem_dependency_installer.rb +542 -0
  126. data/test/test_gem_dependency_list.rb +212 -0
  127. data/test/test_gem_doc_manager.rb +32 -0
  128. data/test/test_gem_ext_configure_builder.rb +13 -17
  129. data/test/test_gem_ext_ext_conf_builder.rb +9 -9
  130. data/test/test_gem_ext_rake_builder.rb +23 -11
  131. data/test/test_gem_format.rb +69 -0
  132. data/test/test_gem_gem_path_searcher.rb +57 -0
  133. data/test/test_gem_gem_runner.rb +35 -0
  134. data/test/test_gem_indexer.rb +119 -0
  135. data/test/test_gem_install_update_options.rb +40 -0
  136. data/test/test_gem_installer.rb +796 -0
  137. data/test/test_gem_local_remote_options.rb +84 -0
  138. data/test/test_gem_outdated_command.rb +11 -9
  139. data/test/test_gem_platform.rb +240 -0
  140. data/test/{test_remote_fetcher.rb → test_gem_remote_fetcher.rb} +124 -55
  141. data/test/{test_remote_installer.rb → test_gem_remote_installer.rb} +3 -4
  142. data/test/test_gem_requirement.rb +223 -0
  143. data/test/test_gem_server.rb +71 -0
  144. data/test/test_gem_source_index.rb +429 -0
  145. data/test/test_gem_source_info_cache.rb +79 -17
  146. data/test/test_gem_source_info_cache_entry.rb +11 -9
  147. data/test/test_gem_specification.rb +738 -0
  148. data/test/test_gem_stream_ui.rb +117 -0
  149. data/test/test_gem_validator.rb +70 -0
  150. data/test/test_gem_version.rb +191 -0
  151. data/test/test_gem_version_option.rb +77 -0
  152. data/test/{test_require_gem.rb → test_kernel.rb} +19 -12
  153. data/test/test_open_uri.rb +1 -2
  154. data/test/test_package.rb +45 -34
  155. metadata +116 -141
  156. data/Releases +0 -127
  157. data/bin/gem_mirror +0 -73
  158. data/bin/gem_server +0 -6
  159. data/bin/gemlock +0 -127
  160. data/bin/gemri +0 -24
  161. data/bin/gemwhich +0 -89
  162. data/bin/index_gem_repository.rb +0 -302
  163. data/lib/gemconfigure.rb +0 -24
  164. data/lib/rubygems/gem_commands.rb +0 -273
  165. data/pkgs/sources/sources-0.0.1.gem +0 -0
  166. data/post-install.rb +0 -121
  167. data/test/brokenbuildgem.rb +0 -35
  168. data/test/data/PostMessage-0.0.1.gem +0 -0
  169. data/test/data/a-0.0.1.gem +0 -0
  170. data/test/data/a-0.0.2.gem +0 -0
  171. data/test/data/b-0.0.2.gem +0 -0
  172. data/test/data/broken-1.0.0.gem +0 -0
  173. data/test/data/broken_build/broken-build.gemspec +0 -20
  174. data/test/data/broken_build/ext/extconf.rb +0 -3
  175. data/test/data/broken_build/ext/foo.c +0 -1
  176. data/test/data/c-1.2.gem +0 -0
  177. data/test/data/gemhome/cache/a-0.0.1.gem +0 -0
  178. data/test/data/gemhome/cache/a-0.0.2.gem +0 -0
  179. data/test/data/gemhome/cache/b-0.0.2.gem +0 -0
  180. data/test/data/gemhome/cache/c-1.2.gem +0 -0
  181. data/test/data/gemhome/gems/a-0.0.1/lib/code.rb +0 -1
  182. data/test/data/gemhome/gems/a-0.0.2/lib/code.rb +0 -1
  183. data/test/data/gemhome/gems/b-0.0.2/lib/code.rb +0 -1
  184. data/test/data/gemhome/gems/c-1.2/lib/code.rb +0 -1
  185. data/test/data/gemhome/specifications/a-0.0.1.gemspec +0 -8
  186. data/test/data/gemhome/specifications/a-0.0.2.gemspec +0 -8
  187. data/test/data/gemhome/specifications/b-0.0.2.gemspec +0 -8
  188. data/test/data/gemhome/specifications/c-1.2.gemspec +0 -8
  189. data/test/data/legacy/keyedlist-0.4.0.ruby +0 -11
  190. data/test/data/legacy/keyedlist-0.4.0.yaml +0 -16
  191. data/test/data/lib/code.rb +0 -1
  192. data/test/data/one/README.one +0 -1
  193. data/test/data/one/lib/one.rb +0 -9
  194. data/test/data/one/one-0.0.1.gem +0 -0
  195. data/test/data/one/one.gemspec +0 -17
  196. data/test/data/one/one.yaml +0 -40
  197. data/test/data/post_install.gemspec +0 -19
  198. data/test/functional_extension_gems.rb +0 -48
  199. data/test/functional_generate_yaml_index.rb +0 -104
  200. data/test/gemenvironment.rb +0 -59
  201. data/test/io_capture.rb +0 -33
  202. data/test/mock/gems/gems/sources-0.0.1/lib/sources.rb +0 -11
  203. data/test/mock/gems/specifications/sources-0.0.1.gemspec +0 -8
  204. data/test/onegem.rb +0 -35
  205. data/test/test_builder.rb +0 -34
  206. data/test/test_check_command.rb +0 -34
  207. data/test/test_configfile.rb +0 -42
  208. data/test/test_dependency_list.rb +0 -169
  209. data/test/test_file_list.rb +0 -101
  210. data/test/test_format.rb +0 -49
  211. data/test/test_gem_sources_command.rb +0 -135
  212. data/test/test_gemloadpaths.rb +0 -51
  213. data/test/test_gempaths.rb +0 -170
  214. data/test/test_installer.rb +0 -369
  215. data/test/test_loadmanager.rb +0 -48
  216. data/test/test_process_commands.rb +0 -52
  217. data/test/test_source_index.rb +0 -231
  218. data/test/test_specific_extras.rb +0 -46
  219. data/test/test_specification.rb +0 -565
  220. data/test/test_user_interaction.rb +0 -48
  221. data/test/test_validator.rb +0 -59
  222. data/test/test_version_comparison.rb +0 -321
  223. data/test/testgem.rc +0 -7
  224. data/test/user_capture.rb +0 -7
  225. data/test/yaml_data.rb +0 -63
@@ -0,0 +1,84 @@
1
+ require 'test/unit'
2
+ require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
3
+ require 'rubygems/local_remote_options'
4
+ require 'rubygems/command'
5
+
6
+ class TestGemLocalRemoteOptions < RubyGemTestCase
7
+
8
+ def setup
9
+ super
10
+
11
+ @cmd = Gem::Command.new 'dummy', 'dummy'
12
+ @cmd.extend Gem::LocalRemoteOptions
13
+ end
14
+
15
+ def test_add_local_remote_options
16
+ @cmd.add_local_remote_options
17
+
18
+ args = %w[-l -r -b -B 10 --source http://gems.example.com -p --update-sources]
19
+ assert @cmd.handles?(args)
20
+ end
21
+
22
+ def test_local_eh
23
+ assert_equal false, @cmd.local?
24
+
25
+ @cmd.options[:domain] = :local
26
+
27
+ assert_equal true, @cmd.local?
28
+
29
+ @cmd.options[:domain] = :both
30
+
31
+ assert_equal true, @cmd.local?
32
+ end
33
+
34
+ def test_remote_eh
35
+ assert_equal false, @cmd.remote?
36
+
37
+ @cmd.options[:domain] = :remote
38
+
39
+ assert_equal true, @cmd.remote?
40
+
41
+ @cmd.options[:domain] = :both
42
+
43
+ assert_equal true, @cmd.remote?
44
+ end
45
+
46
+ def test_source_option
47
+ @cmd.add_source_option
48
+
49
+ s1 = URI.parse 'http://more-gems.example.com'
50
+ s2 = URI.parse 'http://even-more-gems.example.com'
51
+
52
+ @cmd.handle_options %W[--source #{s1} --source #{s2}]
53
+
54
+ assert_equal [s1, s2], Gem.sources
55
+ end
56
+
57
+ def test_update_sources_option
58
+ @cmd.add_update_sources_option
59
+
60
+ Gem.configuration.update_sources = false
61
+
62
+ @cmd.handle_options %W[--update-sources]
63
+
64
+ assert_equal true, Gem.configuration.update_sources
65
+
66
+ @cmd.handle_options %W[--no-update-sources]
67
+
68
+ assert_equal false, Gem.configuration.update_sources
69
+ end
70
+
71
+ def test_source_option_bad
72
+ @cmd.add_source_option
73
+
74
+ s1 = 'htp://more-gems.example.com'
75
+
76
+ assert_raise OptionParser::InvalidArgument do
77
+ @cmd.handle_options %W[--source #{s1}]
78
+ end
79
+
80
+ assert_equal %w[http://gems.example.com], Gem.sources
81
+ end
82
+
83
+ end
84
+
@@ -1,12 +1,17 @@
1
1
  require 'test/unit'
2
- require 'test/gemutilities'
3
- require 'rubygems/gem_commands'
2
+ require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
3
+ require 'rubygems/commands/outdated_command'
4
4
 
5
5
  class TestGemOutdatedCommand < RubyGemTestCase
6
6
 
7
7
  def setup
8
- Gem::CommandManager.instance
9
8
  super
9
+
10
+ @cmd = Gem::Commands::OutdatedCommand.new
11
+ end
12
+
13
+ def test_initialize
14
+ assert @cmd.handles?(%W[--platform #{Gem::Platform.local}])
10
15
  end
11
16
 
12
17
  def test_execute
@@ -23,15 +28,12 @@ class TestGemOutdatedCommand < RubyGemTestCase
23
28
  remote_20.full_name + ".gemspec"
24
29
  FileUtils.rm remote_spec_file
25
30
 
26
- oc = Gem::Commands::OutdatedCommand.new
27
-
28
31
  util_setup_source_info_cache remote_10, remote_20
29
32
 
30
- ui = MockGemUi.new
31
- use_ui ui do oc.execute end
33
+ use_ui @ui do @cmd.execute end
32
34
 
33
- assert_equal "foo (0.2 < 2.0)\n", ui.output
34
- assert_equal "", ui.error
35
+ assert_equal "foo (0.2 < 2.0)\n", @ui.output
36
+ assert_equal "", @ui.error
35
37
  end
36
38
 
37
39
  end
@@ -0,0 +1,240 @@
1
+ require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
2
+ require 'test/unit'
3
+ require 'rubygems/platform'
4
+ require 'rbconfig'
5
+
6
+ class TestGemPlatform < RubyGemTestCase
7
+
8
+ def test_self_local
9
+ util_set_arch 'i686-darwin8.10.1'
10
+
11
+ assert_equal Gem::Platform.new(%w[x86 darwin 8]), Gem::Platform.local
12
+ end
13
+
14
+ def test_self_match
15
+ assert Gem::Platform.match(nil), 'nil == ruby'
16
+ assert Gem::Platform.match(Gem::Platform.local), 'exact match'
17
+ assert Gem::Platform.match(Gem::Platform.local.to_s), '=~ match'
18
+ assert Gem::Platform.match(Gem::Platform::RUBY), 'ruby'
19
+ end
20
+
21
+ def test_self_new
22
+ assert_equal Gem::Platform::RUBY, Gem::Platform.new(Gem::Platform::RUBY)
23
+ assert_equal Gem::Platform::RUBY, Gem::Platform.new(nil)
24
+ assert_equal Gem::Platform::RUBY, Gem::Platform.new('')
25
+ end
26
+
27
+ def test_initialize
28
+ test_cases = {
29
+ 'amd64-freebsd6' => ['amd64', 'freebsd', '6'],
30
+ 'hppa2.0w-hpux11.31' => ['hppa2.0w', 'hpux', '11'],
31
+ 'java' => [nil, 'java', nil],
32
+ 'jruby' => [nil, 'java', nil],
33
+ 'powerpc-aix5.3.0.0' => ['powerpc', 'aix', '5'],
34
+ 'powerpc-darwin7' => ['powerpc', 'darwin', '7'],
35
+ 'powerpc-darwin8' => ['powerpc', 'darwin', '8'],
36
+ 'powerpc-linux' => ['powerpc', 'linux', nil],
37
+ 'powerpc64-linux' => ['powerpc64', 'linux', nil],
38
+ 'sparc-solaris2.10' => ['sparc', 'solaris', '2.10'],
39
+ 'sparc-solaris2.8' => ['sparc', 'solaris', '2.8'],
40
+ 'sparc-solaris2.9' => ['sparc', 'solaris', '2.9'],
41
+ 'universal-darwin8' => ['universal', 'darwin', '8'],
42
+ 'universal-darwin9' => ['universal', 'darwin', '9'],
43
+ 'i386-cygwin' => ['x86', 'cygwin', nil],
44
+ 'i686-darwin' => ['x86', 'darwin', nil],
45
+ 'i686-darwin8.4.1' => ['x86', 'darwin', '8'],
46
+ 'i386-freebsd4.11' => ['x86', 'freebsd', '4'],
47
+ 'i386-freebsd5' => ['x86', 'freebsd', '5'],
48
+ 'i386-freebsd6' => ['x86', 'freebsd', '6'],
49
+ 'i386-freebsd7' => ['x86', 'freebsd', '7'],
50
+ 'i386-java1.5' => ['x86', 'java', '1.5'],
51
+ 'x86-java1.6' => ['x86', 'java', '1.6'],
52
+ 'i386-java1.6' => ['x86', 'java', '1.6'],
53
+ 'i686-linux' => ['x86', 'linux', nil],
54
+ 'i586-linux' => ['x86', 'linux', nil],
55
+ 'i486-linux' => ['x86', 'linux', nil],
56
+ 'i386-linux' => ['x86', 'linux', nil],
57
+ 'i586-linux-gnu' => ['x86', 'linux', nil],
58
+ 'i386-linux-gnu' => ['x86', 'linux', nil],
59
+ 'i386-mingw32' => ['x86', 'mingw32', nil],
60
+ 'i386-mswin32' => ['x86', 'mswin32', nil],
61
+ 'i386-mswin32_80' => ['x86', 'mswin32', '80'],
62
+ 'i386-netbsdelf' => ['x86', 'netbsdelf', nil],
63
+ 'i386-openbsd4.0' => ['x86', 'openbsd', '4.0'],
64
+ 'i386-solaris2.10' => ['x86', 'solaris', '2.10'],
65
+ 'i386-solaris2.8' => ['x86', 'solaris', '2.8'],
66
+ 'x86_64-linux' => ['x86_64', 'linux', nil],
67
+ 'x86_64-openbsd3.9' => ['x86_64', 'openbsd', '3.9'],
68
+ 'x86_64-openbsd4.0' => ['x86_64', 'openbsd', '4.0'],
69
+ }
70
+
71
+ test_cases.each do |arch, expected|
72
+ platform = Gem::Platform.new arch
73
+ assert_equal expected, platform.to_a, arch.inspect
74
+ end
75
+ end
76
+
77
+ def test_initialize_command_line
78
+ expected = ['x86', 'mswin32', nil]
79
+
80
+ platform = Gem::Platform.new 'i386-mswin32'
81
+
82
+ assert_equal expected, platform.to_a, 'i386-mswin32'
83
+
84
+ expected = ['x86', 'mswin32', '80']
85
+
86
+ platform = Gem::Platform.new 'i386-mswin32-80'
87
+
88
+ assert_equal expected, platform.to_a, 'i386-mswin32-80'
89
+ end
90
+
91
+ def test_initialize_mswin32_vc6
92
+ orig_RUBY_SO_NAME = Config::CONFIG['RUBY_SO_NAME']
93
+ Config::CONFIG['RUBY_SO_NAME'] = 'msvcrt-ruby18'
94
+
95
+ expected = ['x86', 'mswin32', nil]
96
+
97
+ platform = Gem::Platform.new 'i386-mswin32'
98
+
99
+ assert_equal expected, platform.to_a, 'i386-mswin32 VC6'
100
+ ensure
101
+ Config::CONFIG['RUBY_SO_NAME'] = orig_RUBY_SO_NAME
102
+ end
103
+
104
+ def test_initialize_platform
105
+ platform = Gem::Platform.new 'cpu-my_platform1'
106
+ expected = Gem::Platform.new platform
107
+
108
+ assert_equal 'cpu', platform.cpu
109
+ assert_equal 'my_platform', platform.os
110
+ assert_equal '1', platform.version
111
+ end
112
+
113
+ def test_initialize_test
114
+ platform = Gem::Platform.new 'cpu-my_platform1'
115
+ assert_equal 'cpu', platform.cpu
116
+ assert_equal 'my_platform', platform.os
117
+ assert_equal '1', platform.version
118
+
119
+ platform = Gem::Platform.new 'cpu-other_platform1'
120
+ assert_equal 'cpu', platform.cpu
121
+ assert_equal 'other_platform', platform.os
122
+ assert_equal '1', platform.version
123
+ end
124
+
125
+ def test_to_s
126
+ if win_platform? then
127
+ assert_equal 'x86-mswin32-60', Gem::Platform.local.to_s
128
+ else
129
+ assert_equal 'x86-darwin-8', Gem::Platform.local.to_s
130
+ end
131
+ end
132
+
133
+ def test_equals2
134
+ my = Gem::Platform.new %w[cpu my_platform 1]
135
+ other = Gem::Platform.new %w[cpu other_platform 1]
136
+
137
+ assert_equal my, my
138
+ assert_not_equal my, other
139
+ assert_not_equal other, my
140
+ end
141
+
142
+ def test_equals3
143
+ my = Gem::Platform.new %w[cpu my_platform 1]
144
+ other = Gem::Platform.new %w[cpu other_platform 1]
145
+
146
+ assert(my === my)
147
+ assert !(other === my)
148
+ assert !(my === other)
149
+ end
150
+
151
+ def test_equals3_cpu
152
+ ppc_darwin8 = Gem::Platform.new 'powerpc-darwin8.0'
153
+ uni_darwin8 = Gem::Platform.new 'universal-darwin8.0'
154
+ x86_darwin8 = Gem::Platform.new 'i686-darwin8.0'
155
+
156
+ util_set_arch 'powerpc-darwin8'
157
+ assert((ppc_darwin8 === Gem::Platform.local), 'powerpc =~ universal')
158
+ assert((uni_darwin8 === Gem::Platform.local), 'powerpc =~ universal')
159
+ assert !(x86_darwin8 === Gem::Platform.local), 'powerpc =~ universal'
160
+
161
+ util_set_arch 'i686-darwin8'
162
+ assert !(ppc_darwin8 === Gem::Platform.local), 'powerpc =~ universal'
163
+ assert((uni_darwin8 === Gem::Platform.local), 'x86 =~ universal')
164
+ assert((x86_darwin8 === Gem::Platform.local), 'powerpc =~ universal')
165
+
166
+ util_set_arch 'universal-darwin8'
167
+ assert((ppc_darwin8 === Gem::Platform.local), 'universal =~ ppc')
168
+ assert((uni_darwin8 === Gem::Platform.local), 'universal =~ universal')
169
+ assert((x86_darwin8 === Gem::Platform.local), 'universal =~ x86')
170
+ end
171
+
172
+ def test_equals3_version
173
+ util_set_arch 'i686-darwin8'
174
+
175
+ x86_darwin = Gem::Platform.new ['x86', 'darwin', nil]
176
+ x86_darwin7 = Gem::Platform.new ['x86', 'darwin', '7']
177
+ x86_darwin8 = Gem::Platform.new ['x86', 'darwin', '8']
178
+ x86_darwin9 = Gem::Platform.new ['x86', 'darwin', '9']
179
+
180
+ assert((x86_darwin === Gem::Platform.local), 'x86_darwin === x86_darwin8')
181
+ assert((x86_darwin8 === Gem::Platform.local), 'x86_darwin8 === x86_darwin8')
182
+
183
+ assert !(x86_darwin7 === Gem::Platform.local), 'x86_darwin7 === x86_darwin8'
184
+ assert !(x86_darwin9 === Gem::Platform.local), 'x86_darwin9 === x86_darwin8'
185
+ end
186
+
187
+ def test_equals_tilde
188
+ util_set_arch 'i386-mswin32'
189
+
190
+ assert_match 'mswin32', Gem::Platform.local
191
+ assert_match 'i386-mswin32', Gem::Platform.local
192
+
193
+ # oddballs
194
+ assert_match 'i386-mswin32-mq5.3', Gem::Platform.local
195
+ assert_match 'i386-mswin32-mq6', Gem::Platform.local
196
+ deny_match 'win32-1.8.2-VC7', Gem::Platform.local
197
+ deny_match 'win32-1.8.4-VC6', Gem::Platform.local
198
+ deny_match 'win32-source', Gem::Platform.local
199
+ deny_match 'windows', Gem::Platform.local
200
+
201
+ util_set_arch 'i686-linux'
202
+ assert_match 'i486-linux', Gem::Platform.local
203
+ assert_match 'i586-linux', Gem::Platform.local
204
+ assert_match 'i686-linux', Gem::Platform.local
205
+
206
+ util_set_arch 'i686-darwin8'
207
+ assert_match 'i686-darwin8.4.1', Gem::Platform.local
208
+ assert_match 'i686-darwin8.8.2', Gem::Platform.local
209
+
210
+ util_set_arch 'java'
211
+ assert_match 'java', Gem::Platform.local
212
+ assert_match 'jruby', Gem::Platform.local
213
+
214
+ util_set_arch 'powerpc-darwin'
215
+ assert_match 'powerpc-darwin', Gem::Platform.local
216
+
217
+ util_set_arch 'powerpc-darwin7'
218
+ assert_match 'powerpc-darwin7.9.0', Gem::Platform.local
219
+
220
+ util_set_arch 'powerpc-darwin8'
221
+ assert_match 'powerpc-darwin8.10.0', Gem::Platform.local
222
+
223
+ util_set_arch 'sparc-solaris2.8'
224
+ assert_match 'sparc-solaris2.8-mq5.3', Gem::Platform.local
225
+ end
226
+
227
+ def assert_match(pattern, platform, message = '')
228
+ full_message = build_message message, "<?> expected to be =~\n<?>.",
229
+ platform, pattern
230
+ assert_block(full_message) { platform =~ pattern }
231
+ end
232
+
233
+ def deny_match(pattern, platform, message = '')
234
+ full_message = build_message message, "<?> expected to be !~\n<?>.",
235
+ platform, pattern
236
+ assert_block(full_message) { platform !~ pattern }
237
+ end
238
+
239
+ end
240
+
@@ -5,19 +5,12 @@
5
5
  # See LICENSE.txt for permissions.
6
6
  #++
7
7
 
8
-
9
8
  require 'test/unit'
10
- require 'zlib'
9
+ require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
11
10
  require 'webrick'
11
+ require 'zlib'
12
12
  require 'rubygems/remote_fetcher'
13
13
 
14
- require 'test/gemutilities'
15
- require 'test/mockgemui'
16
- require 'test/yaml_data'
17
-
18
- Gem.manage_gems
19
- include WEBrick
20
-
21
14
  # = Testing Proxy Settings
22
15
  #
23
16
  # These tests check the proper proxy server settings by running two
@@ -32,26 +25,71 @@ include WEBrick
32
25
  # software doesn't really care, as long as we hit the proxy URL when a
33
26
  # proxy is configured.
34
27
  #
35
- class TestRemoteFetcher < RubyGemTestCase
28
+ class TestGemRemoteFetcher < RubyGemTestCase
36
29
 
37
30
  include Gem::DefaultUserInteraction
38
31
 
39
- SERVER_DATA = YAML_DATA
40
-
41
- PROXY_PORT = 12344
42
- SERVER_PORT = 12345
32
+ SERVER_DATA = <<-EOY
33
+ --- !ruby/object:Gem::Cache
34
+ gems:
35
+ rake-0.4.11: !ruby/object:Gem::Specification
36
+ rubygems_version: "0.7"
37
+ specification_version: 1
38
+ name: rake
39
+ version: !ruby/object:Gem::Version
40
+ version: 0.4.11
41
+ date: 2004-11-12
42
+ summary: Ruby based make-like utility.
43
+ require_paths:
44
+ - lib
45
+ author: Jim Weirich
46
+ email: jim@weirichhouse.org
47
+ homepage: http://rake.rubyforge.org
48
+ rubyforge_project: rake
49
+ description: Rake is a Make-like program implemented in Ruby. Tasks and dependencies are specified in standard Ruby syntax.
50
+ autorequire:
51
+ default_executable: rake
52
+ bindir: bin
53
+ has_rdoc: true
54
+ required_ruby_version: !ruby/object:Gem::Version::Requirement
55
+ requirements:
56
+ -
57
+ - ">"
58
+ - !ruby/object:Gem::Version
59
+ version: 0.0.0
60
+ version:
61
+ platform: ruby
62
+ files:
63
+ - README
64
+ test_files: []
65
+ library_stubs:
66
+ rdoc_options:
67
+ extra_rdoc_files:
68
+ executables:
69
+ - rake
70
+ extensions: []
71
+ requirements: []
72
+ dependencies: []
73
+ EOY
74
+
75
+ PROXY_DATA = SERVER_DATA.gsub(/0.4.11/, '0.4.2')
76
+
77
+ # don't let 1.8 and 1.9 autotest collide
78
+ RUBY_VERSION =~ /(\d+)\.(\d+)\.(\d+)/
79
+ PROXY_PORT = 12345 + $1.to_i * 100 + $2.to_i * 10 + $3.to_i
80
+ SERVER_PORT = 23456 + $1.to_i * 100 + $2.to_i * 10 + $3.to_i
43
81
 
44
82
  def setup
45
83
  super
46
84
  self.class.start_servers
47
85
  self.class.enable_yaml = true
48
86
  self.class.enable_zip = false
49
- ENV['http_proxy'] = nil
50
- ENV['HTTP_PROXY'] = nil
51
- ENV['http_proxy_user'] = nil
52
- ENV['HTTP_PROXY_USER'] = nil
53
- ENV['http_proxy_pass'] = nil
54
- ENV['HTTP_PROXY_PASS'] = nil
87
+ ENV.delete 'http_proxy'
88
+ ENV.delete 'HTTP_PROXY'
89
+ ENV.delete 'http_proxy_user'
90
+ ENV.delete 'HTTP_PROXY_USER'
91
+ ENV.delete 'http_proxy_pass'
92
+ ENV.delete 'HTTP_PROXY_PASS'
55
93
 
56
94
  base_server_uri = "http://localhost:#{SERVER_PORT}"
57
95
  @proxy_uri = "http://localhost:#{PROXY_PORT}"
@@ -77,6 +115,15 @@ class TestRemoteFetcher < RubyGemTestCase
77
115
  assert_equal proxy_uri, fetcher.instance_variable_get(:@proxy_uri).to_s
78
116
  end
79
117
 
118
+ def test_self_fetcher_with_proxy_URI
119
+ proxy_uri = URI.parse 'http://proxy.example.com'
120
+ Gem.configuration[:http_proxy] = proxy_uri
121
+ fetcher = Gem::RemoteFetcher.fetcher
122
+ assert_not_nil fetcher
123
+ assert_kind_of Gem::RemoteFetcher, fetcher
124
+ assert_equal proxy_uri, fetcher.instance_variable_get(:@proxy_uri)
125
+ end
126
+
80
127
  def test_fetch_size_bad_uri
81
128
  fetcher = Gem::RemoteFetcher.new nil
82
129
 
@@ -97,27 +144,27 @@ class TestRemoteFetcher < RubyGemTestCase
97
144
  fetcher.fetch_size 'http://gems.example.com/yaml'
98
145
  end
99
146
 
100
- assert_equal 'SocketError(SocketError)', e.message
147
+ assert_equal 'SocketError (SocketError)', e.message
101
148
  end
102
149
 
103
150
  def test_no_proxy
104
- use_ui(MockGemUi.new) do
151
+ use_ui @ui do
105
152
  fetcher = Gem::RemoteFetcher.new nil
106
153
  assert_data_from_server fetcher.fetch_path(@server_uri)
107
154
  assert_equal SERVER_DATA.size, fetcher.fetch_size(@server_uri)
108
155
  end
109
156
  end
110
-
157
+
111
158
  def test_explicit_proxy
112
- use_ui(MockGemUi.new) do
159
+ use_ui @ui do
113
160
  fetcher = Gem::RemoteFetcher.new @proxy_uri
114
161
  assert_equal PROXY_DATA.size, fetcher.fetch_size(@server_uri)
115
162
  assert_data_from_proxy fetcher.fetch_path(@server_uri)
116
163
  end
117
164
  end
118
-
165
+
119
166
  def test_explicit_proxy_with_user_auth
120
- use_ui(MockGemUi.new) do
167
+ use_ui @ui do
121
168
  uri = URI.parse @proxy_uri
122
169
  uri.user, uri.password = 'foo', 'bar'
123
170
  fetcher = Gem::RemoteFetcher.new uri.to_s
@@ -127,7 +174,7 @@ class TestRemoteFetcher < RubyGemTestCase
127
174
  assert_data_from_proxy fetcher.fetch_path(@server_uri)
128
175
  end
129
176
 
130
- use_ui(MockGemUi.new) do
177
+ use_ui @ui do
131
178
  uri = URI.parse @proxy_uri
132
179
  uri.user, uri.password = 'domain%5Cuser', 'bar'
133
180
  fetcher = Gem::RemoteFetcher.new uri.to_s
@@ -137,7 +184,7 @@ class TestRemoteFetcher < RubyGemTestCase
137
184
  assert_data_from_proxy fetcher.fetch_path(@server_uri)
138
185
  end
139
186
 
140
- use_ui(MockGemUi.new) do
187
+ use_ui @ui do
141
188
  uri = URI.parse @proxy_uri
142
189
  uri.user, uri.password = 'user', 'my%20pass'
143
190
  fetcher = Gem::RemoteFetcher.new uri.to_s
@@ -149,7 +196,7 @@ class TestRemoteFetcher < RubyGemTestCase
149
196
  end
150
197
 
151
198
  def test_explicit_proxy_with_user_auth_in_env
152
- use_ui(MockGemUi.new) do
199
+ use_ui @ui do
153
200
  ENV['http_proxy'] = @proxy_uri
154
201
  ENV['http_proxy_user'] = 'foo'
155
202
  ENV['http_proxy_pass'] = 'bar'
@@ -160,7 +207,7 @@ class TestRemoteFetcher < RubyGemTestCase
160
207
  assert_data_from_proxy fetcher.fetch_path(@server_uri)
161
208
  end
162
209
 
163
- use_ui(MockGemUi.new) do
210
+ use_ui @ui do
164
211
  ENV['http_proxy'] = @proxy_uri
165
212
  ENV['http_proxy_user'] = 'foo\user'
166
213
  ENV['http_proxy_pass'] = 'my bar'
@@ -181,7 +228,7 @@ class TestRemoteFetcher < RubyGemTestCase
181
228
  fetcher.fetch_path 'uri'
182
229
  end
183
230
 
184
- assert_equal 'EOFError reading uri', e.message
231
+ assert_equal 'EOFError: EOFError reading uri', e.message
185
232
  end
186
233
 
187
234
  def test_fetch_path_socket_error
@@ -193,7 +240,7 @@ class TestRemoteFetcher < RubyGemTestCase
193
240
  fetcher.fetch_path 'uri'
194
241
  end
195
242
 
196
- assert_equal 'SocketError reading uri', e.message
243
+ assert_equal 'SocketError: SocketError reading uri', e.message
197
244
  end
198
245
 
199
246
  def test_fetch_path_system_call_error
@@ -207,11 +254,30 @@ class TestRemoteFetcher < RubyGemTestCase
207
254
  fetcher.fetch_path 'uri'
208
255
  end
209
256
 
210
- assert_equal 'Errno::ECONNREFUSED reading uri', e.message
257
+ assert_match %r|\AErrno::ECONNREFUSED: .* - connect\(2\) reading uri\z|,
258
+ e.message
259
+ end
260
+
261
+ def test_get_proxy_from_env_empty
262
+ orig_env_HTTP_PROXY = ENV['HTTP_PROXY']
263
+ orig_env_http_proxy = ENV['http_proxy']
264
+
265
+ ENV['HTTP_PROXY'] = ''
266
+ ENV.delete 'http_proxy'
267
+
268
+ fetcher = Gem::RemoteFetcher.new nil
269
+
270
+ assert_equal nil, fetcher.send(:get_proxy_from_env)
271
+
272
+ ensure
273
+ orig_env_HTTP_PROXY.nil? ? ENV.delete('HTTP_PROXY') :
274
+ ENV['HTTP_PROXY'] = orig_env_HTTP_PROXY
275
+ orig_env_http_proxy.nil? ? ENV.delete('http_proxy') :
276
+ ENV['http_proxy'] = orig_env_http_proxy
211
277
  end
212
278
 
213
279
  def test_implicit_no_proxy
214
- use_ui(MockGemUi.new) do
280
+ use_ui @ui do
215
281
  ENV['http_proxy'] = 'http://fakeurl:12345'
216
282
  fetcher = Gem::RemoteFetcher.new :no_proxy
217
283
  assert_data_from_server fetcher.fetch_path(@server_uri)
@@ -219,30 +285,30 @@ class TestRemoteFetcher < RubyGemTestCase
219
285
  end
220
286
 
221
287
  def test_implicit_proxy
222
- use_ui(MockGemUi.new) do
288
+ use_ui @ui do
223
289
  ENV['http_proxy'] = @proxy_uri
224
290
  fetcher = Gem::RemoteFetcher.new nil
225
291
  assert_data_from_proxy fetcher.fetch_path(@server_uri)
226
292
  end
227
293
  end
228
-
294
+
229
295
  def test_implicit_upper_case_proxy
230
- use_ui(MockGemUi.new) do
296
+ use_ui @ui do
231
297
  ENV['HTTP_PROXY'] = @proxy_uri
232
298
  fetcher = Gem::RemoteFetcher.new nil
233
299
  assert_data_from_proxy fetcher.fetch_path(@server_uri)
234
300
  end
235
301
  end
236
-
302
+
237
303
  def test_implicit_proxy_no_env
238
- use_ui(MockGemUi.new) do
304
+ use_ui @ui do
239
305
  fetcher = Gem::RemoteFetcher.new nil
240
306
  assert_data_from_server fetcher.fetch_path(@server_uri)
241
307
  end
242
308
  end
243
-
309
+
244
310
  def test_zip
245
- use_ui(MockGemUi.new) do
311
+ use_ui @ui do
246
312
  self.class.enable_zip = true
247
313
  fetcher = Gem::RemoteFetcher.new nil
248
314
  assert_equal SERVER_DATA.size, fetcher.fetch_size(@server_uri), "probably not from proxy"
@@ -252,14 +318,15 @@ class TestRemoteFetcher < RubyGemTestCase
252
318
  end
253
319
 
254
320
  def test_no_zip
255
- use_ui(MockGemUi.new) do
321
+ use_ui @ui do
322
+ self.class.enable_zip = false
256
323
  fetcher = Gem::RemoteFetcher.new nil
257
324
  assert_error { fetcher.fetch_path(@server_z_uri) }
258
325
  end
259
326
  end
260
327
 
261
328
  def test_yaml_error_on_size
262
- use_ui(MockGemUi.new) do
329
+ use_ui @ui do
263
330
  self.class.enable_yaml = false
264
331
  fetcher = Gem::RemoteFetcher.new nil
265
332
  assert_error { fetcher.size }
@@ -275,40 +342,40 @@ class TestRemoteFetcher < RubyGemTestCase
275
342
  rescue exception_class => ex
276
343
  got_exception = true
277
344
  end
278
- assert got_exception, "Expected exception conforming to #{exception_class}"
345
+ assert got_exception, "Expected exception conforming to #{exception_class}"
279
346
  end
280
347
 
281
348
  def assert_data_from_server(data)
282
349
  assert_block("Data is not from server") { data =~ /0\.4\.11/ }
283
350
  end
284
-
351
+
285
352
  def assert_data_from_proxy(data)
286
353
  assert_block("Data is not from proxy") { data =~ /0\.4\.2/ }
287
354
  end
288
-
289
- class NilLog < Log
355
+
356
+ class NilLog < WEBrick::Log
290
357
  def log(level, data) #Do nothing
291
358
  end
292
359
  end
293
-
360
+
294
361
  class << self
295
362
  attr_reader :normal_server, :proxy_server
296
363
  attr_accessor :enable_zip, :enable_yaml
297
-
364
+
298
365
  def start_servers
299
366
  @normal_server ||= start_server(SERVER_PORT, SERVER_DATA)
300
367
  @proxy_server ||= start_server(PROXY_PORT, PROXY_DATA)
301
368
  @enable_yaml = true
302
369
  @enable_zip = false
303
370
  end
304
-
371
+
305
372
  private
306
-
373
+
307
374
  def start_server(port, data)
308
375
  Thread.new do
309
376
  begin
310
377
  null_logger = NilLog.new
311
- s = HTTPServer.new(
378
+ s = WEBrick::HTTPServer.new(
312
379
  :Port => port,
313
380
  :DocumentRoot => nil,
314
381
  :Logger => null_logger,
@@ -321,7 +388,7 @@ class TestRemoteFetcher < RubyGemTestCase
321
388
  res['Content-Type'] = 'text/plain'
322
389
  res['content-length'] = data.size
323
390
  else
324
- res.code = "404"
391
+ res.status = "404"
325
392
  res.body = "<h1>NOT FOUND</h1>"
326
393
  res['Content-Type'] = 'text/html'
327
394
  end
@@ -331,18 +398,20 @@ class TestRemoteFetcher < RubyGemTestCase
331
398
  res.body = Zlib::Deflate.deflate(data)
332
399
  res['Content-Type'] = 'text/plain'
333
400
  else
334
- res.code = "404"
401
+ res.status = "404"
335
402
  res.body = "<h1>NOT FOUND</h1>"
336
403
  res['Content-Type'] = 'text/html'
337
404
  end
338
405
  }
339
406
  s.start
340
407
  rescue Exception => ex
408
+ abort ex.message
341
409
  puts "ERROR during server thread: #{ex.message}"
342
410
  end
343
411
  end
344
412
  sleep 0.2 # Give the servers time to startup
345
413
  end
346
414
  end
347
-
415
+
348
416
  end
417
+