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
@@ -1,49 +0,0 @@
1
- #--
2
- # Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
3
- # All rights reserved.
4
- # See LICENSE.txt for permissions.
5
- #++
6
-
7
- require 'test/unit'
8
- require 'stringio'
9
-
10
- require 'rubygems'
11
- require 'rubygems/format'
12
- require "test/simple_gem"
13
-
14
- class TestFormat < Test::Unit::TestCase
15
-
16
- def setup
17
- @simple_gem = SIMPLE_GEM
18
- end
19
-
20
- def test_garbled_gem_throws_format_exception
21
- e = assert_raises Gem::Package::FormatError do
22
- # subtly bogus input
23
- Gem::Format.from_io(StringIO.new(@simple_gem.upcase))
24
- end
25
-
26
- assert_equal 'No metadata found!', e.message
27
-
28
- e = assert_raises Gem::Package::FormatError do
29
- # Totally bogus input
30
- Gem::Format.from_io(StringIO.new(@simple_gem.reverse))
31
- end
32
-
33
- assert_equal 'No metadata found!', e.message
34
-
35
- e = assert_raises Gem::Package::FormatError do
36
- # This was intentionally screws up YAML parsing.
37
- Gem::Format.from_io(StringIO.new(@simple_gem.gsub(/:/, "boom")))
38
- end
39
-
40
- assert_equal 'No metadata found!', e.message
41
- end
42
-
43
- def test_passing_nonexistent_files_throws_sensible_exception
44
- assert_raises(Gem::Exception) {
45
- Gem::Format.from_file_by_path("/this/path/almost/definitely/will/not/exist")
46
- }
47
- end
48
- end
49
-
@@ -1,135 +0,0 @@
1
- require 'test/unit'
2
- require 'test/gemutilities'
3
- require 'rubygems/command_manager'
4
-
5
- class TestGemSourcesCommand < RubyGemTestCase
6
-
7
- def setup
8
- super
9
- Gem::CommandManager.instance # preload command objects
10
- end
11
-
12
- def test_execute
13
- util_setup_source_info_cache
14
- cmd = Gem::Commands::SourcesCommand.new
15
- cmd.send :handle_options, []
16
-
17
- ui = MockGemUi.new
18
- use_ui ui do
19
- cmd.execute
20
- end
21
-
22
- expected = <<-EOF
23
- *** CURRENT SOURCES ***
24
-
25
- http://gems.example.com
26
- EOF
27
-
28
- assert_equal expected, ui.output
29
- assert_equal '', ui.error
30
- end
31
-
32
- def test_execute_add
33
- util_setup_fake_fetcher
34
-
35
- @si = Gem::SourceIndex.new @gem1.full_name => @gem1.name
36
-
37
- @fetcher.data['http://beta-gems.example.com/yaml'] = @si.to_yaml
38
-
39
- cmd = Gem::Commands::SourcesCommand.new
40
- cmd.send :handle_options, %w[--add http://beta-gems.example.com]
41
-
42
- util_setup_source_info_cache
43
-
44
- ui = MockGemUi.new
45
- use_ui ui do
46
- cmd.execute
47
- end
48
-
49
- expected = <<-EOF
50
- Bulk updating Gem source index for: http://beta-gems.example.com
51
- http://beta-gems.example.com added to sources
52
- EOF
53
-
54
- assert_equal expected, ui.output
55
- assert_equal '', ui.error
56
-
57
- Gem::SourceInfoCache.cache.flush
58
- assert_equal %w[http://beta-gems.example.com http://gems.example.com],
59
- Gem::SourceInfoCache.cache_data.keys
60
- end
61
-
62
- def test_execute_add_nonexistent_source
63
- util_setup_fake_fetcher
64
-
65
- @si = Gem::SourceIndex.new @gem1.full_name => @gem1.name
66
-
67
- @fetcher.data['http://beta-gems.example.com/yaml'] = proc do
68
- raise Gem::RemoteFetcher::FetchError, 'it died'
69
- end
70
-
71
-
72
- Gem::RemoteFetcher.instance_variable_set :@fetcher, @fetcher
73
-
74
- cmd = Gem::Commands::SourcesCommand.new
75
- cmd.send :handle_options, %w[--add http://beta-gems.example.com]
76
-
77
- util_setup_source_info_cache
78
-
79
- ui = MockGemUi.new
80
- use_ui ui do
81
- cmd.execute
82
- end
83
-
84
- expected = <<-EOF
85
- Error fetching http://beta-gems.example.com:
86
- \tit died
87
- EOF
88
-
89
- assert_equal expected, ui.output
90
- assert_equal '', ui.error
91
- end
92
-
93
- def test_execute_add_bad_uri
94
- cmd = Gem::Commands::SourcesCommand.new
95
- cmd.send :handle_options, %w[--add beta-gems.example.com]
96
-
97
- util_setup_source_info_cache
98
-
99
- ui = MockGemUi.new
100
- use_ui ui do
101
- cmd.execute
102
- end
103
-
104
- expected = <<-EOF
105
- beta-gems.example.com is not a URI
106
- EOF
107
-
108
- assert_equal expected, ui.output
109
- assert_equal '', ui.error
110
- end
111
-
112
- def test_execute_remove
113
- cmd = Gem::Commands::SourcesCommand.new
114
- cmd.send :handle_options, %w[--remove http://gems.example.com]
115
-
116
- util_setup_source_info_cache
117
-
118
- ui = MockGemUi.new
119
- use_ui ui do
120
- cmd.execute
121
- end
122
-
123
- expected = <<-EOF
124
- http://gems.example.com removed from sources
125
- EOF
126
-
127
- assert_equal expected, ui.output
128
- assert_equal '', ui.error
129
-
130
- Gem::SourceInfoCache.cache.flush
131
- assert_equal [], Gem::SourceInfoCache.cache_data.keys
132
- end
133
-
134
- end
135
-
@@ -1,51 +0,0 @@
1
- #!/usr/bin/env ruby
2
- #--
3
- # Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
4
- # All rights reserved.
5
- # See LICENSE.txt for permissions.
6
- #++
7
-
8
-
9
- require 'test/unit'
10
- require 'rubygems'
11
- require 'test/mockgemui'
12
- require 'test/gemenvironment'
13
-
14
- Gem.manage_gems
15
-
16
- class TestGemLoadPaths < Test::Unit::TestCase
17
- include Gem::DefaultUserInteraction
18
-
19
- def setup
20
- TestEnvironment.create
21
- Gem.clear_paths
22
- Gem.use_paths("test/data/gemhome")
23
- end
24
-
25
- def test_all_load_paths
26
- assert_equal [
27
- "test/data/gemhome/gems/a-0.0.1/lib",
28
- "test/data/gemhome/gems/a-0.0.2/lib",
29
- "test/data/gemhome/gems/b-0.0.2/lib",
30
- "test/data/gemhome/gems/c-1.2/lib"].sort,
31
- Gem.all_load_paths.sort
32
- end
33
-
34
- def test_latest_load_paths
35
- assert_equal [
36
- "test/data/gemhome/gems/a-0.0.2/lib",
37
- "test/data/gemhome/gems/b-0.0.2/lib",
38
- "test/data/gemhome/gems/c-1.2/lib"].sort,
39
- Gem.latest_load_paths.sort
40
- end
41
-
42
- def test_required_location
43
- assert_equal "test/data/gemhome/gems/c-1.2/lib/code.rb",
44
- Gem.required_location("c", "code.rb")
45
- assert_equal "test/data/gemhome/gems/a-0.0.1/lib/code.rb",
46
- Gem.required_location("a", "code.rb", "<0.0.2")
47
- assert_equal "test/data/gemhome/gems/a-0.0.2/lib/code.rb",
48
- Gem.required_location("a", "code.rb", "=0.0.2")
49
- end
50
-
51
- end
@@ -1,170 +0,0 @@
1
- #!/usr/bin/env ruby
2
- #--
3
- # Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
4
- # All rights reserved.
5
- # See LICENSE.txt for permissions.
6
- #++
7
-
8
-
9
- require 'test/unit'
10
- require 'fileutils'
11
- require 'rubygems'
12
- require 'test/gemutilities'
13
-
14
- class TestGemPaths < RubyGemTestCase
15
- def setup
16
- super
17
- Gem.clear_paths
18
- ENV['GEM_HOME'] = nil
19
- ENV['GEM_PATH'] = nil
20
- @additional = ['a', 'b'].map { |f| File.join(@tempdir, f) }
21
- end
22
-
23
- def teardown
24
- super
25
- ENV['GEM_HOME'] = nil
26
- ENV['GEM_PATH'] = nil
27
- end
28
-
29
- DEFAULT_DIR_RE = %r{/ruby/gems/[0-9.]+}
30
-
31
- def test_default_dir
32
- assert_match DEFAULT_DIR_RE, Gem.dir
33
- end
34
-
35
- def test_default_dir_subdirectories
36
- Gem::DIRECTORIES.each do |filename|
37
- assert File.exists?(File.join(Gem.dir, filename)), "expected #{filename} to exist"
38
- end
39
- end
40
-
41
- def test_gem_home
42
- ENV['GEM_HOME'] = @gemhome
43
- assert_equal @gemhome, Gem.dir
44
- end
45
-
46
- def test_gem_home_subdirectories
47
- ENV['GEM_HOME'] = @gemhome
48
- ['cache', 'doc', 'gems', 'specifications'].each do |filename|
49
- assert File.exists?(File.join(@gemhome, filename)), "expected #{filename} to exist"
50
- end
51
- end
52
-
53
- def test_default_path
54
- assert_equal [Gem.dir], Gem.path
55
- end
56
-
57
- def test_additional_paths
58
- create_additional_gem_dirs
59
- ENV['GEM_PATH'] = @additional.join(File::PATH_SEPARATOR)
60
- assert_equal @additional, Gem.path[0,2]
61
- assert_equal 3, Gem.path.size
62
- assert_match DEFAULT_DIR_RE, Gem.path.last
63
- end
64
-
65
- def test_dir_path_overlap
66
- create_additional_gem_dirs
67
- ENV['GEM_HOME'] = @gemhome
68
- ENV['GEM_PATH'] = @additional.join(File::PATH_SEPARATOR)
69
- assert_equal @gemhome, Gem.dir
70
- assert_equal @additional + [Gem.dir], Gem.path
71
- end
72
-
73
- def test_dir_path_overlaping_duplicates_removed
74
- create_additional_gem_dirs
75
- dirs = [@gemhome] + @additional + [File.join(@tempdir, 'a')]
76
- ENV['GEM_HOME'] = @gemhome
77
- ENV['GEM_PATH'] = dirs.join(File::PATH_SEPARATOR)
78
- assert_equal @gemhome, Gem.dir
79
- assert_equal [Gem.dir] + @additional, Gem.path
80
- end
81
-
82
- def test_path_use_home
83
- create_additional_gem_dirs
84
- Gem.use_paths(@gemhome)
85
- assert_equal @gemhome, Gem.dir
86
- assert_equal [Gem.dir], Gem.path
87
- end
88
-
89
- def test_path_use_home_and_dirs
90
- create_additional_gem_dirs
91
- Gem.use_paths(@gemhome, @additional)
92
- assert_equal @gemhome, Gem.dir
93
- assert_equal @additional+[Gem.dir], Gem.path
94
- end
95
-
96
- def test_user_home
97
- if ENV['HOME']
98
- assert_equal ENV['HOME'], Gem.user_home
99
- end
100
- end
101
-
102
- def test_ensure_gem_directories_new
103
- FileUtils.rm_r(@gemhome)
104
- Gem.use_paths(@gemhome)
105
- Gem.send(:ensure_gem_subdirectories, @gemhome)
106
- assert File.exist?(File.join(@gemhome, "cache"))
107
- end
108
-
109
- def test_ensure_gem_directories_missing_parents
110
- gemdir = File.join(@tempdir, "a/b/c/gemdir")
111
- FileUtils.rm_r(File.join(@tempdir, "a")) rescue nil
112
- Gem.use_paths(gemdir)
113
- Gem.send(:ensure_gem_subdirectories, gemdir)
114
- assert File.exist?("#{gemdir}/cache")
115
- end
116
-
117
- def test_ensure_gem_directories_write_protected
118
- return if win_platform? #This test works only for FS that support write protection
119
-
120
- gemdir = File.join(@tempdir, "egd")
121
- FileUtils.rm_r gemdir rescue nil
122
- FileUtils.mkdir_p gemdir
123
- FileUtils.chmod 0400, gemdir
124
- Gem.use_paths(gemdir)
125
- Gem.send(:ensure_gem_subdirectories, gemdir)
126
- assert ! File.exist?("#{gemdir}/cache")
127
- ensure
128
- FileUtils.chmod(0600, gemdir) rescue nil
129
- FileUtils.rm_r gemdir rescue nil
130
- end
131
-
132
- def test_ensure_gem_directories_with_parents_write_protected
133
- return if win_platform? #This test works only for FS that support write protection
134
-
135
- parent = File.join(@tempdir, "egd")
136
- gemdir = "#{parent}/a/b/c"
137
-
138
- FileUtils.rm_r parent rescue nil
139
- FileUtils.mkdir_p parent
140
- FileUtils.chmod 0400, parent
141
- Gem.use_paths(gemdir)
142
- Gem.send(:ensure_gem_subdirectories, gemdir)
143
- assert !File.exist?("#{gemdir}/cache")
144
- ensure
145
- FileUtils.chmod(0600, parent) rescue nil
146
- FileUtils.rm_r parent rescue nil
147
- end
148
-
149
- private
150
-
151
- def create_additional_gem_dirs
152
- create_gem_dir(@gemhome)
153
- @additional.each do |dir| create_gem_dir(dir) end
154
- end
155
-
156
- def create_gem_dir(fn)
157
- Gem::DIRECTORIES.each do |subdir|
158
- FileUtils.mkdir_p(File.join(fn, subdir))
159
- end
160
- end
161
-
162
- def redirect_stderr(io)
163
- old_err = $stderr
164
- $stderr = io
165
- yield
166
- ensure
167
- $stderr = old_err
168
- end
169
- end
170
-
@@ -1,369 +0,0 @@
1
- #--
2
- # Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
3
- # All rights reserved.
4
- # See LICENSE.txt for permissions.
5
- #++
6
-
7
- require 'fileutils'
8
- require 'tmpdir'
9
- require 'test/unit'
10
- require 'rubygems'
11
- require 'test/gemutilities'
12
- require 'test/io_capture'
13
-
14
- Gem::manage_gems
15
-
16
- class Gem::Installer
17
- attr_accessor :options, :directory
18
- end
19
-
20
- class TestInstaller < RubyGemTestCase
21
- include Gem::IoCapture
22
-
23
- def setup
24
- super
25
- @spec = quick_gem("a")
26
- @installer = Gem::Installer.new :fake, {}
27
- end
28
-
29
- def util_gem_dir(version = '0.0.2')
30
- File.join "gems", "a-#{version}" # HACK
31
- end
32
-
33
- def util_gem_bindir(version = '0.0.2')
34
- File.join util_gem_dir(version), "bin"
35
- end
36
-
37
- def util_inst_bindir
38
- File.join @gemhome, "bin"
39
- end
40
-
41
- def util_make_exec(version = '0.0.2')
42
- @spec.executables = ["my_exec"]
43
- write_file(File.join(util_gem_bindir(version), "my_exec")) do |f|
44
- f.puts "#!/bin/ruby"
45
- end
46
- end
47
-
48
- def test_build_extensions_none
49
- ui = MockGemUi.new
50
- use_ui ui do @installer.build_extensions util_gem_dir, @spec end
51
-
52
- assert_equal '', ui.output
53
- assert_equal '', ui.error
54
- end
55
-
56
- def test_build_extensions_extconf_bad
57
- @spec.extensions << 'extconf.rb'
58
-
59
- ui = MockGemUi.new
60
- e = assert_raise Gem::Installer::ExtensionBuildError do
61
- use_ui ui do
62
- @installer.build_extensions util_gem_dir, @spec
63
- end
64
- end
65
-
66
- assert_match(/\AERROR: Failed to build gem native extension.$/, e.message)
67
-
68
- assert_equal "Building native extensions. This could take a while...\n",
69
- ui.output
70
- assert_equal '', ui.error
71
- end
72
-
73
- def test_build_extensions_unsupported
74
- @spec.extensions << nil
75
-
76
- ui = MockGemUi.new
77
- e = assert_raise Gem::Installer::ExtensionBuildError do
78
- use_ui ui do
79
- @installer.build_extensions util_gem_dir, @spec
80
- end
81
- end
82
-
83
- assert_match(/^No builder for extension ''$/, e.message)
84
-
85
- assert_equal "Building native extensions. This could take a while...\n",
86
- ui.output
87
- assert_equal '', ui.error
88
- end
89
-
90
- def test_extract_files
91
- format = Object.new
92
- def format.file_entries
93
- [[{'size' => 7, 'mode' => 0400, 'path' => 'thefile'}, 'thefile']]
94
- end
95
-
96
- @installer.extract_files @tempdir, format
97
-
98
- assert_equal 'thefile', File.read(File.join(@tempdir, 'thefile'))
99
- end
100
-
101
- def test_extract_files_bad_dest
102
- e = assert_raise ArgumentError do
103
- @installer.extract_files 'somedir', nil
104
- end
105
-
106
- assert_equal 'format required to extract from', e.message
107
- end
108
-
109
- def test_extract_files_relative
110
- format = Object.new
111
- def format.file_entries
112
- [[{'size' => 10, 'mode' => 0644, 'path' => '../thefile'}, '../thefile']]
113
- end
114
-
115
- e = assert_raise Gem::InstallError do
116
- @installer.extract_files @tempdir, format
117
- end
118
-
119
- assert_equal "attempt to install file into \"../thefile\" under #{@tempdir.inspect}",
120
- e.message
121
- assert_equal false, File.file?(File.join(@tempdir, '../thefile')),
122
- "You may need to remove this file if you broke the test once"
123
- end
124
-
125
- def test_extract_files_absolute
126
- format = Object.new
127
- def format.file_entries
128
- [[{'size' => 8, 'mode' => 0644, 'path' => '/thefile'}, '/thefile']]
129
- end
130
-
131
- e = assert_raise Gem::InstallError do
132
- @installer.extract_files @tempdir, format
133
- end
134
-
135
- assert_equal 'attempt to install file into "/thefile"', e.message
136
- assert_equal false, File.file?(File.join('/thefile')),
137
- "You may need to remove this file if you broke the test once"
138
- end
139
-
140
- def test_generate_bin_scripts
141
- @installer.options[:wrappers] = true
142
- util_make_exec
143
-
144
- @installer.generate_bin @spec, @gemhome
145
- assert_equal true, File.directory?(util_inst_bindir)
146
- installed_exec = File.join(util_inst_bindir, "my_exec")
147
- assert_equal true, File.exist?(installed_exec)
148
- assert_equal(0100755, File.stat(installed_exec).mode) unless win_platform?
149
-
150
- wrapper = File.read installed_exec
151
- assert_match(/generated by RubyGems/, wrapper)
152
- end
153
-
154
- def test_generate_bin_scripts_no_execs
155
- @installer.options[:wrappers] = true
156
- @installer.generate_bin @spec, @gemhome
157
- assert_equal false, File.exist?(util_inst_bindir)
158
- end
159
-
160
- def test_generate_bin_scripts_no_perms
161
- @installer.options[:wrappers] = true
162
- util_make_exec
163
-
164
- Dir.mkdir util_inst_bindir
165
- File.chmod 0000, util_inst_bindir
166
-
167
- assert_raises Gem::FilePermissionError do
168
- @installer.generate_bin @spec, @gemhome
169
- end
170
-
171
- ensure
172
- File.chmod 0700, util_inst_bindir unless $DEBUG
173
- end
174
-
175
- def test_generate_bin_symlinks
176
- return if win_platform? #Windows FS do not support symlinks
177
-
178
- @installer.options[:wrappers] = false
179
- util_make_exec
180
- @installer.directory = util_gem_dir
181
-
182
- @installer.generate_bin @spec, @gemhome
183
- assert_equal true, File.directory?(util_inst_bindir)
184
- installed_exec = File.join(util_inst_bindir, "my_exec")
185
- assert_equal true, File.symlink?(installed_exec)
186
- assert_equal(File.join(util_gem_dir, "bin", "my_exec"),
187
- File.readlink(installed_exec))
188
- end
189
-
190
- def test_generate_bin_symlinks_no_execs
191
- @installer.options[:wrappers] = false
192
- @installer.generate_bin @spec, @gemhome
193
- assert_equal false, File.exist?(util_inst_bindir)
194
- end
195
-
196
- def test_generate_bin_symlinks_no_perms
197
- @installer.options[:wrappers] = false
198
- util_make_exec
199
- @installer.directory = util_gem_dir
200
-
201
- Dir.mkdir util_inst_bindir
202
- File.chmod 0000, util_inst_bindir
203
-
204
- assert_raises Gem::FilePermissionError do
205
- @installer.generate_bin @spec, @gemhome
206
- end
207
-
208
- ensure
209
- File.chmod 0700, util_inst_bindir unless $DEBUG
210
- end
211
-
212
- def test_generate_bin_symlinks_update_newer
213
- return if win_platform? #Windows FS do not support symlinks
214
-
215
- @installer.options[:wrappers] = false
216
- util_make_exec
217
- @installer.directory = File.join @gemhome, util_gem_dir
218
-
219
- @installer.generate_bin @spec, @gemhome
220
- installed_exec = File.join(util_inst_bindir, "my_exec")
221
- assert_equal(File.join(@gemhome, util_gem_dir, "bin", "my_exec"),
222
- File.readlink(installed_exec))
223
-
224
- @spec = Gem::Specification.new do |s|
225
- s.files = ['lib/code.rb']
226
- s.name = "a"
227
- s.version = "0.0.3"
228
- s.summary = "summary"
229
- s.description = "desc"
230
- s.require_path = 'lib'
231
- end
232
-
233
- util_make_exec '0.0.3'
234
- @installer.directory = File.join @gemhome, util_gem_dir('0.0.3')
235
- @installer.generate_bin @spec, @gemhome
236
- installed_exec = File.join(util_inst_bindir, "my_exec")
237
- assert_equal(File.join(@gemhome, util_gem_dir('0.0.3'), "bin", "my_exec"),
238
- File.readlink(installed_exec),
239
- "Ensure symlink moved to latest version")
240
- end
241
-
242
- def test_generate_bin_symlinks_update_older
243
- return if win_platform? #Windows FS do not support symlinks
244
-
245
- @installer.options[:wrappers] = false
246
- util_make_exec
247
- @installer.directory = File.join @gemhome, util_gem_dir
248
-
249
- @installer.generate_bin @spec, @gemhome
250
- installed_exec = File.join(util_inst_bindir, "my_exec")
251
- assert_equal(File.join(@gemhome, util_gem_dir, "bin", "my_exec"),
252
- File.readlink(installed_exec))
253
-
254
- @spec = Gem::Specification.new do |s|
255
- s.files = ['lib/code.rb']
256
- s.name = "a"
257
- s.version = "0.0.1"
258
- s.summary = "summary"
259
- s.description = "desc"
260
- s.require_path = 'lib'
261
- end
262
-
263
- util_make_exec '0.0.1'
264
- @installer.directory = File.join @gemhome, util_gem_dir('0.0.1')
265
- @installer.generate_bin @spec, @gemhome
266
- installed_exec = File.join(util_inst_bindir, "my_exec")
267
- assert_equal(File.join(@gemhome, util_gem_dir('0.0.2'), "bin", "my_exec"),
268
- File.readlink(installed_exec),
269
- "Ensure symlink not moved")
270
- end
271
-
272
- def test_generate_bin_symlinks_update_remove_wrapper
273
- return if win_platform? #Windows FS do not support symlinks
274
-
275
- @installer.options[:wrappers] = true
276
- util_make_exec
277
- @installer.directory = util_gem_dir
278
-
279
- @installer.generate_bin @spec, @gemhome
280
- installed_exec = File.join(util_inst_bindir, "my_exec")
281
- assert_equal true, File.exists?(installed_exec)
282
-
283
- @spec = Gem::Specification.new do |s|
284
- s.files = ['lib/code.rb']
285
- s.name = "a"
286
- s.version = "0.0.3"
287
- s.summary = "summary"
288
- s.description = "desc"
289
- s.require_path = 'lib'
290
- end
291
-
292
- @installer.options[:wrappers] = false
293
- util_make_exec '0.0.3'
294
- @installer.directory = util_gem_dir '0.0.3'
295
- @installer.generate_bin @spec, @gemhome
296
- installed_exec = File.join(util_inst_bindir, "my_exec")
297
- assert_equal(File.join(util_gem_dir('0.0.3'), "bin", "my_exec"),
298
- File.readlink(installed_exec),
299
- "Ensure symlink moved to latest version")
300
- end
301
-
302
- def test_generated_bin_uses_default_shebang
303
- return if win_platform? #Windows FS do not support symlinks
304
-
305
- @installer.options[:wrappers] = true
306
- util_make_exec
307
- @installer.directory = util_gem_dir
308
-
309
- @installer.generate_bin @spec, @gemhome
310
-
311
- default_shebang = File.join(Config::CONFIG['bindir'], Config::CONFIG['ruby_install_name'])
312
- shebang_line = open("#{@gemhome}/bin/my_exec") { |f| f.readlines.first }
313
- assert_match(/\A#!/, shebang_line)
314
- assert_match(/#{default_shebang}/, shebang_line)
315
- end
316
-
317
- def test_generate_bin_symlinks_win32
318
- old_arch = Config::CONFIG["arch"]
319
- Config::CONFIG["arch"] = "win32"
320
- @installer.options[:wrappers] = false
321
- util_make_exec
322
- @installer.directory = util_gem_dir
323
-
324
- serr = capture_stderr {
325
- @installer.generate_bin @spec, @gemhome
326
- }
327
- assert_equal true, File.directory?(util_inst_bindir)
328
- installed_exec = File.join(util_inst_bindir, "my_exec")
329
- assert_equal true, File.exist?(installed_exec)
330
-
331
- assert_match(/unable/i, serr)
332
- assert_match(/win32/i, serr)
333
- assert_match(/symlinks/i, serr)
334
- assert_match(/wrapper/i, serr)
335
-
336
- expected_mode = win_platform? ? 0100644 : 0100755
337
- assert_equal expected_mode, File.stat(installed_exec).mode
338
-
339
- wrapper = File.read installed_exec
340
- assert_match(/generated by RubyGems/, wrapper)
341
- ensure
342
- Config::CONFIG["arch"] = old_arch
343
- end
344
-
345
- def test_install_bad_gem
346
- # broken-1.0.0.gem is the first 1k of a-0.0.1.gem
347
- gem = File.join 'test', 'data', 'broken-1.0.0.gem'
348
- cache_gem = File.join @gemhome, 'cache', 'broken-1.0.0.gem'
349
- FileUtils.cp gem, cache_gem
350
-
351
- installer = Gem::Installer.new cache_gem
352
- e = assert_raise Gem::InstallError do
353
- installer.install
354
- end
355
-
356
- assert_equal "invalid gem format for #{cache_gem}", e.message
357
- end
358
-
359
- def test_install_with_message
360
- @gem = File.join 'test', 'data', "PostMessage-0.0.1.gem"
361
- sout = capture_stdout {
362
- @installer = Gem::Installer.new @gem, {}
363
- @installer.install
364
- }
365
- assert_equal "I am a shiny gem!\n", sout
366
- end
367
-
368
- end
369
-