rubygems-update 1.8.30 → 2.0.0.preview2

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 (241) hide show
  1. checksums.yaml +6 -6
  2. checksums.yaml.gz.sig +0 -0
  3. data.tar.gz.sig +3 -0
  4. data/.autotest +6 -3
  5. data/History.txt +137 -63
  6. data/LICENSE.txt +1 -5
  7. data/Manifest.txt +69 -32
  8. data/README.rdoc +11 -9
  9. data/Rakefile +24 -38
  10. data/bin/gem +0 -9
  11. data/bin/update_rubygems +1 -0
  12. data/lib/rubygems.rb +193 -405
  13. data/lib/rubygems/available_set.rb +95 -0
  14. data/lib/rubygems/command.rb +88 -45
  15. data/lib/rubygems/command_manager.rb +67 -40
  16. data/lib/rubygems/commands/build_command.rb +5 -23
  17. data/lib/rubygems/commands/cert_command.rb +199 -57
  18. data/lib/rubygems/commands/check_command.rb +14 -39
  19. data/lib/rubygems/commands/cleanup_command.rb +9 -1
  20. data/lib/rubygems/commands/contents_command.rb +30 -12
  21. data/lib/rubygems/commands/dependency_command.rb +3 -8
  22. data/lib/rubygems/commands/environment_command.rb +13 -8
  23. data/lib/rubygems/commands/fetch_command.rb +3 -16
  24. data/lib/rubygems/commands/generate_index_command.rb +7 -47
  25. data/lib/rubygems/commands/help_command.rb +1 -1
  26. data/lib/rubygems/commands/install_command.rb +69 -36
  27. data/lib/rubygems/commands/list_command.rb +6 -4
  28. data/lib/rubygems/commands/lock_command.rb +1 -1
  29. data/lib/rubygems/commands/mirror_command.rb +17 -0
  30. data/lib/rubygems/commands/outdated_command.rb +6 -3
  31. data/lib/rubygems/commands/owner_command.rb +13 -5
  32. data/lib/rubygems/commands/pristine_command.rb +19 -4
  33. data/lib/rubygems/commands/push_command.rb +12 -1
  34. data/lib/rubygems/commands/query_command.rb +43 -27
  35. data/lib/rubygems/commands/rdoc_command.rb +23 -28
  36. data/lib/rubygems/commands/search_command.rb +4 -18
  37. data/lib/rubygems/commands/server_command.rb +1 -1
  38. data/lib/rubygems/commands/setup_command.rb +124 -38
  39. data/lib/rubygems/commands/sources_command.rb +16 -16
  40. data/lib/rubygems/commands/specification_command.rb +11 -13
  41. data/lib/rubygems/commands/uninstall_command.rb +24 -7
  42. data/lib/rubygems/commands/unpack_command.rb +7 -3
  43. data/lib/rubygems/commands/update_command.rb +22 -36
  44. data/lib/rubygems/commands/yank_command.rb +98 -0
  45. data/lib/rubygems/compatibility.rb +51 -0
  46. data/lib/rubygems/config_file.rb +82 -54
  47. data/lib/rubygems/core_ext/kernel_gem.rb +53 -0
  48. data/lib/rubygems/core_ext/kernel_require.rb +119 -0
  49. data/lib/rubygems/defaults.rb +10 -21
  50. data/lib/rubygems/dependency.rb +61 -10
  51. data/lib/rubygems/dependency_installer.rb +157 -69
  52. data/lib/rubygems/dependency_list.rb +11 -19
  53. data/lib/rubygems/dependency_resolver.rb +562 -0
  54. data/lib/rubygems/deprecate.rb +40 -40
  55. data/lib/rubygems/errors.rb +77 -24
  56. data/lib/rubygems/exceptions.rb +25 -7
  57. data/lib/rubygems/ext/builder.rb +20 -23
  58. data/lib/rubygems/ext/configure_builder.rb +2 -2
  59. data/lib/rubygems/ext/ext_conf_builder.rb +5 -45
  60. data/lib/rubygems/ext/rake_builder.rb +2 -2
  61. data/lib/rubygems/gem_runner.rb +3 -16
  62. data/lib/rubygems/gemcutter_utilities.rb +22 -7
  63. data/lib/rubygems/indexer.rb +6 -159
  64. data/lib/rubygems/install_message.rb +12 -0
  65. data/lib/rubygems/install_update_options.rb +56 -18
  66. data/lib/rubygems/installer.rb +244 -134
  67. data/lib/rubygems/installer_test_case.rb +71 -19
  68. data/lib/rubygems/mock_gem_ui.rb +17 -0
  69. data/lib/rubygems/name_tuple.rb +110 -0
  70. data/lib/rubygems/package.rb +514 -43
  71. data/lib/rubygems/package/digest_io.rb +64 -0
  72. data/lib/rubygems/package/old.rb +147 -0
  73. data/lib/rubygems/package/tar_header.rb +18 -55
  74. data/lib/rubygems/package/tar_reader.rb +20 -3
  75. data/lib/rubygems/package/tar_writer.rb +63 -7
  76. data/lib/rubygems/package_task.rb +3 -4
  77. data/lib/rubygems/path_support.rb +14 -7
  78. data/lib/rubygems/platform.rb +19 -26
  79. data/lib/rubygems/rdoc.rb +316 -0
  80. data/lib/rubygems/remote_fetcher.rb +117 -54
  81. data/lib/rubygems/request_set.rb +182 -0
  82. data/lib/rubygems/requirement.rb +63 -26
  83. data/lib/rubygems/security.rb +295 -555
  84. data/lib/rubygems/security/policies.rb +115 -0
  85. data/lib/rubygems/security/policy.rb +227 -0
  86. data/lib/rubygems/security/signer.rb +136 -0
  87. data/lib/rubygems/security/trust_dir.rb +104 -0
  88. data/lib/rubygems/server.rb +45 -55
  89. data/lib/rubygems/source.rb +144 -0
  90. data/lib/rubygems/source_list.rb +87 -0
  91. data/lib/rubygems/source_local.rb +92 -0
  92. data/lib/rubygems/source_specific_file.rb +28 -0
  93. data/lib/rubygems/spec_fetcher.rb +116 -184
  94. data/lib/rubygems/specification.rb +731 -335
  95. data/lib/rubygems/ssl_certs/AddTrustExternalCARoot.pem +88 -30
  96. data/lib/rubygems/ssl_certs/Entrust_net-Secure-Server-Certification-Authority.pem +90 -0
  97. data/lib/rubygems/ssl_certs/VerisignClass3PublicPrimaryCertificationAuthority-G2.pem +57 -0
  98. data/lib/rubygems/syck_hack.rb +2 -0
  99. data/lib/rubygems/test_case.rb +199 -109
  100. data/lib/rubygems/test_utilities.rb +25 -5
  101. data/lib/rubygems/uninstaller.rb +62 -20
  102. data/lib/rubygems/user_interaction.rb +10 -0
  103. data/lib/rubygems/validator.rb +33 -40
  104. data/lib/rubygems/version.rb +19 -8
  105. data/setup.rb +8 -1
  106. data/test/rubygems/alternate_cert.pem +9 -0
  107. data/test/rubygems/alternate_cert_32.pem +9 -0
  108. data/test/rubygems/alternate_key.pem +9 -0
  109. data/test/rubygems/bad_rake.rb +1 -0
  110. data/test/rubygems/child_cert.pem +9 -0
  111. data/test/rubygems/child_cert_32.pem +9 -0
  112. data/test/rubygems/child_key.pem +9 -0
  113. data/test/rubygems/data/null-type.gemspec.rz +0 -0
  114. data/test/rubygems/expired_cert.pem +9 -0
  115. data/test/rubygems/future_cert.pem +9 -0
  116. data/test/rubygems/future_cert_32.pem +9 -0
  117. data/test/rubygems/good_rake.rb +1 -0
  118. data/test/rubygems/grandchild_cert.pem +9 -0
  119. data/test/rubygems/grandchild_cert_32.pem +9 -0
  120. data/test/rubygems/grandchild_key.pem +9 -0
  121. data/test/rubygems/invalid_issuer_cert.pem +9 -0
  122. data/test/rubygems/invalid_issuer_cert_32.pem +9 -0
  123. data/test/rubygems/invalid_key.pem +9 -0
  124. data/test/rubygems/invalid_signer_cert.pem +9 -0
  125. data/test/rubygems/invalid_signer_cert_32.pem +9 -0
  126. data/test/rubygems/invalidchild_cert.pem +9 -0
  127. data/test/rubygems/invalidchild_cert_32.pem +9 -0
  128. data/test/rubygems/invalidchild_key.pem +9 -0
  129. data/test/rubygems/plugin/exception/rubygems_plugin.rb +1 -1
  130. data/test/rubygems/plugin/standarderror/rubygems_plugin.rb +1 -1
  131. data/test/rubygems/private_key.pem +7 -25
  132. data/test/rubygems/public_cert.pem +8 -18
  133. data/test/rubygems/public_cert_32.pem +10 -0
  134. data/test/rubygems/public_key.pem +4 -0
  135. data/test/rubygems/rubygems/commands/crash_command.rb +1 -1
  136. data/test/rubygems/test_config.rb +4 -6
  137. data/test/rubygems/test_deprecate.rb +76 -0
  138. data/test/rubygems/test_gem.rb +318 -83
  139. data/test/rubygems/test_gem_available_set.rb +106 -0
  140. data/test/rubygems/test_gem_command.rb +10 -0
  141. data/test/rubygems/test_gem_command_manager.rb +55 -9
  142. data/test/rubygems/test_gem_commands_build_command.rb +11 -19
  143. data/test/rubygems/test_gem_commands_cert_command.rb +441 -42
  144. data/test/rubygems/test_gem_commands_cleanup_command.rb +29 -1
  145. data/test/rubygems/test_gem_commands_contents_command.rb +23 -0
  146. data/test/rubygems/test_gem_commands_dependency_command.rb +5 -0
  147. data/test/rubygems/test_gem_commands_fetch_command.rb +19 -20
  148. data/test/rubygems/test_gem_commands_generate_index_command.rb +2 -83
  149. data/test/rubygems/test_gem_commands_help_command.rb +2 -1
  150. data/test/rubygems/test_gem_commands_install_command.rb +647 -48
  151. data/test/rubygems/test_gem_commands_mirror.rb +32 -0
  152. data/test/rubygems/test_gem_commands_owner_command.rb +4 -8
  153. data/test/rubygems/test_gem_commands_pristine_command.rb +99 -4
  154. data/test/rubygems/test_gem_commands_push_command.rb +62 -8
  155. data/test/rubygems/test_gem_commands_query_command.rb +51 -0
  156. data/test/rubygems/test_gem_commands_search_command.rb +25 -0
  157. data/test/rubygems/test_gem_commands_setup_command.rb +45 -0
  158. data/test/rubygems/test_gem_commands_sources_command.rb +21 -6
  159. data/test/rubygems/test_gem_commands_specification_command.rb +33 -1
  160. data/test/rubygems/test_gem_commands_uninstall_command.rb +91 -31
  161. data/test/rubygems/test_gem_commands_unpack_command.rb +3 -3
  162. data/test/rubygems/test_gem_commands_update_command.rb +56 -38
  163. data/test/rubygems/test_gem_commands_which_command.rb +4 -4
  164. data/test/rubygems/test_gem_commands_yank_command.rb +97 -0
  165. data/test/rubygems/test_gem_config_file.rb +66 -21
  166. data/test/rubygems/test_gem_dependency.rb +46 -0
  167. data/test/rubygems/test_gem_dependency_installer.rb +228 -18
  168. data/test/rubygems/test_gem_dependency_list.rb +0 -9
  169. data/test/rubygems/test_gem_dependency_resolver.rb +327 -0
  170. data/test/rubygems/test_gem_ext_configure_builder.rb +4 -4
  171. data/test/rubygems/test_gem_ext_ext_conf_builder.rb +21 -49
  172. data/test/rubygems/test_gem_ext_rake_builder.rb +13 -13
  173. data/test/rubygems/test_gem_gem_runner.rb +27 -5
  174. data/test/rubygems/test_gem_gemcutter_utilities.rb +19 -0
  175. data/test/rubygems/test_gem_indexer.rb +14 -227
  176. data/test/rubygems/test_gem_install_update_options.rb +83 -3
  177. data/test/rubygems/test_gem_installer.rb +211 -236
  178. data/test/rubygems/test_gem_local_remote_options.rb +8 -2
  179. data/test/rubygems/test_gem_name_tuple.rb +15 -0
  180. data/test/rubygems/test_gem_package.rb +547 -0
  181. data/test/rubygems/test_gem_package_old.rb +37 -0
  182. data/test/rubygems/test_gem_package_tar_reader.rb +32 -0
  183. data/test/rubygems/test_gem_package_tar_writer.rb +84 -1
  184. data/test/rubygems/test_gem_path_support.rb +4 -30
  185. data/test/rubygems/test_gem_platform.rb +3 -6
  186. data/test/rubygems/test_gem_rdoc.rb +245 -0
  187. data/test/rubygems/test_gem_remote_fetcher.rb +51 -5
  188. data/test/rubygems/test_gem_request_set.rb +70 -0
  189. data/test/rubygems/test_gem_requirement.rb +53 -24
  190. data/test/rubygems/test_gem_security.rb +189 -43
  191. data/test/rubygems/test_gem_security_policy.rb +376 -0
  192. data/test/rubygems/test_gem_security_signer.rb +184 -0
  193. data/test/rubygems/test_gem_security_trust_dir.rb +94 -0
  194. data/test/rubygems/test_gem_server.rb +31 -36
  195. data/test/rubygems/test_gem_silent_ui.rb +2 -2
  196. data/test/rubygems/test_gem_source.rb +188 -0
  197. data/test/rubygems/test_gem_source_list.rb +87 -0
  198. data/test/rubygems/test_gem_source_local.rb +83 -0
  199. data/test/rubygems/test_gem_source_specific_file.rb +33 -0
  200. data/test/rubygems/test_gem_spec_fetcher.rb +91 -255
  201. data/test/rubygems/test_gem_specification.rb +293 -39
  202. data/test/rubygems/test_gem_uninstaller.rb +136 -13
  203. data/test/rubygems/test_gem_validator.rb +14 -41
  204. data/test/rubygems/test_gem_version.rb +15 -21
  205. data/test/rubygems/test_require.rb +193 -0
  206. data/test/rubygems/wrong_key_cert.pem +9 -0
  207. data/test/rubygems/wrong_key_cert_32.pem +9 -0
  208. metadata +171 -83
  209. metadata.gz.sig +1 -0
  210. data/CVE-2013-4287.txt +0 -36
  211. data/CVE-2013-4363.txt +0 -45
  212. data/ci_build.sh +0 -27
  213. data/cruise_config.rb +0 -32
  214. data/lib/rbconfig/datadir.rb +0 -13
  215. data/lib/rubygems/builder.rb +0 -99
  216. data/lib/rubygems/custom_require.rb +0 -69
  217. data/lib/rubygems/doc_manager.rb +0 -243
  218. data/lib/rubygems/format.rb +0 -82
  219. data/lib/rubygems/gem_openssl.rb +0 -90
  220. data/lib/rubygems/gem_path_searcher.rb +0 -172
  221. data/lib/rubygems/old_format.rb +0 -153
  222. data/lib/rubygems/package/f_sync_dir.rb +0 -23
  223. data/lib/rubygems/package/tar_input.rb +0 -234
  224. data/lib/rubygems/package/tar_output.rb +0 -146
  225. data/lib/rubygems/require_paths_builder.rb +0 -18
  226. data/lib/rubygems/source_index.rb +0 -406
  227. data/lib/rubygems/ssl_certs/AddTrustExternalCARoot-2048.pem +0 -25
  228. data/lib/rubygems/ssl_certs/Class3PublicPrimaryCertificationAuthority.pem +0 -14
  229. data/lib/rubygems/ssl_certs/DigiCertHighAssuranceEVRootCA.pem +0 -23
  230. data/lib/rubygems/ssl_certs/EntrustnetSecureServerCertificationAuthority.pem +0 -28
  231. data/lib/rubygems/ssl_certs/GeoTrustGlobalCA.pem +0 -20
  232. data/test/rubygems/test_bundled_ca.rb +0 -59
  233. data/test/rubygems/test_gem_builder.rb +0 -44
  234. data/test/rubygems/test_gem_doc_manager.rb +0 -32
  235. data/test/rubygems/test_gem_ext_builder.rb +0 -58
  236. data/test/rubygems/test_gem_format.rb +0 -88
  237. data/test/rubygems/test_gem_gem_path_searcher.rb +0 -94
  238. data/test/rubygems/test_gem_package_tar_input.rb +0 -129
  239. data/test/rubygems/test_gem_package_tar_output.rb +0 -101
  240. data/test/rubygems/test_gem_source_index.rb +0 -250
  241. data/util/update_bundled_ca_certificates.rb +0 -103
@@ -1,24 +1,104 @@
1
1
  require 'rubygems/installer_test_case'
2
2
  require 'rubygems/install_update_options'
3
3
  require 'rubygems/command'
4
+ require 'rubygems/dependency_installer'
4
5
 
5
6
  class TestGemInstallUpdateOptions < Gem::InstallerTestCase
6
7
 
7
8
  def setup
8
9
  super
9
10
 
10
- @cmd = Gem::Command.new 'dummy', 'dummy'
11
+ @cmd = Gem::Command.new 'dummy', 'dummy',
12
+ Gem::DependencyInstaller::DEFAULT_OPTIONS
11
13
  @cmd.extend Gem::InstallUpdateOptions
12
14
  @cmd.add_install_update_options
13
15
  end
14
16
 
15
17
  def test_add_install_update_options
16
- args = %w[-i /install_to --rdoc --ri -E -f -w -P HighSecurity
17
- --ignore-dependencies --format-exec --include-dependencies]
18
+ args = %w[
19
+ --document
20
+ --format-exec
21
+ --ignore-dependencies
22
+ --rdoc
23
+ --ri
24
+ -E
25
+ -P HighSecurity
26
+ -f
27
+ -i /install_to
28
+ -w
29
+ ]
18
30
 
19
31
  assert @cmd.handles?(args)
20
32
  end
21
33
 
34
+ def test_doc
35
+ @cmd.handle_options %w[--doc]
36
+
37
+ assert_equal %w[ri], @cmd.options[:document].sort
38
+ end
39
+
40
+ def test_doc_rdoc
41
+ @cmd.handle_options %w[--doc=rdoc]
42
+
43
+ assert_equal %w[rdoc], @cmd.options[:document]
44
+
45
+ @cmd.handle_options %w[--doc ri]
46
+
47
+ assert_equal %w[ri], @cmd.options[:document]
48
+ end
49
+
50
+ def test_doc_rdoc_ri
51
+ @cmd.handle_options %w[--doc=rdoc,ri]
52
+
53
+ assert_equal %w[rdoc ri], @cmd.options[:document]
54
+ end
55
+
56
+ def test_doc_no
57
+ @cmd.handle_options %w[--no-doc]
58
+
59
+ assert_equal [], @cmd.options[:document]
60
+ end
61
+
62
+ def test_document
63
+ @cmd.handle_options %w[--document]
64
+
65
+ assert_equal %w[ri], @cmd.options[:document].sort
66
+ end
67
+
68
+ def test_document_no
69
+ @cmd.handle_options %w[--no-document]
70
+
71
+ assert_equal %w[], @cmd.options[:document]
72
+ end
73
+
74
+ def test_document_rdoc
75
+ @cmd.handle_options %w[--document=rdoc]
76
+
77
+ assert_equal %w[rdoc], @cmd.options[:document]
78
+
79
+ @cmd.handle_options %w[--document ri]
80
+
81
+ assert_equal %w[ri], @cmd.options[:document]
82
+ end
83
+
84
+ def test_rdoc
85
+ @cmd.handle_options %w[--rdoc]
86
+
87
+ assert_equal %w[rdoc ri], @cmd.options[:document].sort
88
+ end
89
+
90
+ def test_rdoc_no
91
+ @cmd.handle_options %w[--no-rdoc]
92
+
93
+ assert_equal %w[ri], @cmd.options[:document]
94
+ end
95
+
96
+ def test_ri
97
+ @cmd.handle_options %w[--no-ri]
98
+
99
+ assert_equal %w[], @cmd.options[:document]
100
+ end
101
+
22
102
  def test_security_policy
23
103
  @cmd.handle_options %w[-P HighSecurity]
24
104
 
@@ -2,24 +2,24 @@ require 'rubygems/installer_test_case'
2
2
 
3
3
  class TestGemInstaller < Gem::InstallerTestCase
4
4
 
5
- def util_setup_install
6
- @gemhome = @installer_tmp
7
- Gem.use_paths @installer_tmp
5
+ def setup
6
+ super
8
7
 
9
- @spec = Gem::Specification.find_by_name 'a'
10
- @user_spec = Gem::Specification.find_by_name 'b'
8
+ if __name__ =~ /^test_install(_|$)/ then
9
+ FileUtils.rm_r @spec.gem_dir
10
+ FileUtils.rm_r @user_spec.gem_dir
11
+ end
11
12
 
12
- @installer.spec = @spec
13
- @installer.gem_home = @installer_tmp
14
- @installer.gem_dir = @spec.gem_dir
15
- @user_installer.spec = @user_spec
16
- @user_installer.gem_home = @installer_tmp
13
+ @config = Gem.configuration
17
14
  end
18
15
 
19
- def test_app_script_text
20
- util_setup_install
16
+ def teardown
17
+ super
21
18
 
22
- @spec.version = 2
19
+ Gem.configuration = @config
20
+ end
21
+
22
+ def test_app_script_text
23
23
  util_make_exec @spec, ''
24
24
 
25
25
  expected = <<-EOF
@@ -53,8 +53,6 @@ load Gem.bin_path('a', 'executable', version)
53
53
  end
54
54
 
55
55
  def test_build_extensions_none
56
- util_setup_install
57
-
58
56
  use_ui @ui do
59
57
  @installer.build_extensions
60
58
  end
@@ -66,8 +64,7 @@ load Gem.bin_path('a', 'executable', version)
66
64
  end
67
65
 
68
66
  def test_build_extensions_extconf_bad
69
- util_setup_install
70
-
67
+ @installer.spec = @spec
71
68
  @spec.extensions << 'extconf.rb'
72
69
 
73
70
  e = assert_raises Gem::Installer::ExtensionBuildError do
@@ -91,9 +88,9 @@ load Gem.bin_path('a', 'executable', version)
91
88
  end
92
89
 
93
90
  def test_build_extensions_unsupported
94
- util_setup_install
95
-
96
- gem_make_out = File.join @gemhome, 'gems', @spec.full_name, 'gem_make.out'
91
+ @installer.spec = @spec
92
+ FileUtils.mkdir_p @spec.gem_dir
93
+ gem_make_out = File.join @spec.gem_dir, 'gem_make.out'
97
94
  @spec.extensions << nil
98
95
 
99
96
  e = assert_raises Gem::Installer::ExtensionBuildError do
@@ -113,95 +110,148 @@ load Gem.bin_path('a', 'executable', version)
113
110
  FileUtils.rm_f gem_make_out
114
111
  end
115
112
 
116
- def test_ensure_dependency
117
- util_setup_install
113
+ def test_build_extensions_with_build_args
114
+ args = ["--aa", "--bb"]
115
+ @installer.build_args = args
116
+ @installer.spec = @spec
117
+ @spec.extensions << 'extconf.rb'
118
118
 
119
- dep = Gem::Dependency.new 'a', '>= 2'
120
- assert @installer.ensure_dependency(@spec, dep)
119
+ File.open File.join(@spec.gem_dir, "extconf.rb"), "w" do |f|
120
+ f.write <<-'RUBY'
121
+ puts "IN EXTCONF"
122
+ File.open 'extconf_args', 'w' do |f|
123
+ f.puts ARGV.inspect
124
+ end
125
+
126
+ File.open 'Makefile', 'w' do |f|
127
+ f.puts "default:\n\techo built"
128
+ f.puts "install:\n\techo installed"
129
+ end
130
+ RUBY
131
+ end
121
132
 
122
- dep = Gem::Dependency.new 'b', '> 2'
123
- e = assert_raises Gem::InstallError do
124
- @installer.ensure_dependency @spec, dep
133
+ use_ui @ui do
134
+ @installer.build_extensions
125
135
  end
126
136
 
127
- assert_equal 'a requires b (> 2)', e.message
137
+ path = File.join @spec.gem_dir, "extconf_args"
138
+
139
+ assert_equal args.inspect, File.read(path).strip
128
140
  end
129
141
 
130
- def test_extract_files
131
- util_setup_install
142
+ def test_check_executable_overwrite
143
+ @installer.generate_bin
132
144
 
133
- format = Object.new
134
- def format.file_entries
135
- [[{'size' => 7, 'mode' => 0400, 'path' => 'thefile'}, 'content']]
145
+ @spec = Gem::Specification.new do |s|
146
+ s.files = ['lib/code.rb']
147
+ s.name = "a"
148
+ s.version = "3"
149
+ s.summary = "summary"
150
+ s.description = "desc"
151
+ s.require_path = 'lib'
136
152
  end
137
153
 
138
- @installer.format = format
154
+ util_make_exec
155
+ @installer.gem_dir = util_gem_dir @spec
156
+ @installer.wrappers = true
157
+ @installer.generate_bin
139
158
 
140
- @installer.extract_files
159
+ installed_exec = File.join util_inst_bindir, 'executable'
160
+ assert File.exist? installed_exec
141
161
 
142
- thefile_path = File.join(util_gem_dir, 'thefile')
143
- assert_equal 'content', File.read(thefile_path)
162
+ wrapper = File.read installed_exec
163
+ assert_match %r|generated by RubyGems|, wrapper
164
+ end
144
165
 
145
- unless Gem.win_platform? then
146
- assert_equal 0400, File.stat(thefile_path).mode & 0777
166
+ def test_check_executable_overwrite_default_bin_dir
167
+ if defined?(RUBY_FRAMEWORK_VERSION)
168
+ orig_RUBY_FRAMEWORK_VERSION = RUBY_FRAMEWORK_VERSION
169
+ Object.send :remove_const, :RUBY_FRAMEWORK_VERSION
147
170
  end
148
- end
171
+ orig_bindir = Gem::ConfigMap[:bindir]
172
+ Gem::ConfigMap[:bindir] = Gem.bindir
149
173
 
150
- def test_extract_files_bad_dest
151
- util_setup_install
174
+ util_conflict_executable false
152
175
 
153
- @installer.gem_dir = 'somedir'
154
- @installer.format = nil
155
- e = assert_raises ArgumentError do
156
- @installer.extract_files
157
- end
176
+ ui = Gem::MockGemUi.new "n\n"
177
+ use_ui ui do
178
+ e = assert_raises Gem::InstallError do
179
+ @installer.generate_bin
180
+ end
158
181
 
159
- assert_equal 'format required to extract from', e.message
182
+ conflicted = File.join @gemhome, 'bin', 'executable'
183
+ assert_match /\A"executable" from a conflicts with (?:#{Regexp.quote(conflicted)}|installed executable from conflict)\z/,
184
+ e.message
185
+ end
186
+ ensure
187
+ Object.const_set :RUBY_FRAMEWORK_VERSION, orig_RUBY_FRAMEWORK_VERSION if
188
+ orig_RUBY_FRAMEWORK_VERSION
189
+ Gem::ConfigMap[:bindir] = orig_bindir
160
190
  end
161
191
 
162
- def test_extract_files_relative
163
- util_setup_install
192
+ def test_check_executable_overwrite_other_gem
193
+ util_conflict_executable true
164
194
 
165
- format = Object.new
166
- def format.file_entries
167
- [[{'size' => 10, 'mode' => 0644, 'path' => '../thefile'}, '../thefile']]
168
- end
195
+ ui = Gem::MockGemUi.new "n\n"
169
196
 
170
- @installer.format = format
197
+ use_ui ui do
198
+ e = assert_raises Gem::InstallError do
199
+ @installer.generate_bin
200
+ end
171
201
 
172
- e = assert_raises Gem::InstallError do
173
- @installer.extract_files
202
+ assert_equal '"executable" from a conflicts with installed executable from conflict',
203
+ e.message
174
204
  end
205
+ end
175
206
 
176
- dir = util_gem_dir
177
- expected = "attempt to install file into \"../thefile\" under #{dir}"
178
- assert_equal expected, e.message
179
- assert_equal false, File.file?(File.join(@tempdir, '../thefile')),
180
- "You may need to remove this file if you broke the test once"
207
+ def test_check_executable_overwrite_other_gem_force
208
+ util_conflict_executable true
209
+ @installer.wrappers = true
210
+ @installer.force = true
211
+
212
+ @installer.generate_bin
213
+
214
+ installed_exec = File.join util_inst_bindir, 'executable'
215
+ assert File.exist? installed_exec
216
+
217
+ wrapper = File.read installed_exec
218
+ assert_match %r|generated by RubyGems|, wrapper
181
219
  end
182
220
 
183
- def test_extract_files_absolute
184
- util_setup_install
221
+ def test_check_executable_overwrite_other_non_gem
222
+ util_conflict_executable false
223
+ @installer.wrappers = true
224
+
225
+ @installer.generate_bin
185
226
 
186
- format = Object.new
187
- def format.file_entries
188
- [[{'size' => 8, 'mode' => 0644, 'path' => '/thefile'}, '/thefile']]
189
- end
227
+ installed_exec = File.join util_inst_bindir, 'executable'
228
+ assert File.exist? installed_exec
190
229
 
191
- @installer.format = format
230
+ wrapper = File.read installed_exec
231
+ assert_match %r|generated by RubyGems|, wrapper
232
+ end unless Gem.win_platform?
192
233
 
234
+ def test_ensure_dependency
235
+ quick_spec 'a'
236
+
237
+ dep = Gem::Dependency.new 'a', '>= 2'
238
+ assert @installer.ensure_dependency(@spec, dep)
239
+
240
+ dep = Gem::Dependency.new 'b', '> 2'
193
241
  e = assert_raises Gem::InstallError do
194
- @installer.extract_files
242
+ @installer.ensure_dependency @spec, dep
195
243
  end
196
244
 
197
- assert_equal 'attempt to install file into /thefile', e.message
198
- assert_equal false, File.file?(File.join('/thefile')),
199
- "You may need to remove this file if you broke the test once"
245
+ assert_equal 'a requires b (> 2)', e.message
200
246
  end
201
247
 
202
- def test_generate_bin_bindir
203
- util_setup_install
248
+ def test_extract_files
249
+ @installer.extract_files
250
+
251
+ assert_path_exists File.join util_gem_dir, 'bin/executable'
252
+ end
204
253
 
254
+ def test_generate_bin_bindir
205
255
  @installer.wrappers = true
206
256
 
207
257
  @spec.executables = %w[executable]
@@ -227,8 +277,6 @@ load Gem.bin_path('a', 'executable', version)
227
277
  end
228
278
 
229
279
  def test_generate_bin_bindir_with_user_install_warning
230
- util_setup_install
231
-
232
280
  bin_dir = Gem.win_platform? ? File.expand_path(ENV["WINDIR"]).upcase :
233
281
  "/usr/bin"
234
282
 
@@ -237,7 +285,7 @@ load Gem.bin_path('a', 'executable', version)
237
285
  :install_dir => "/non/existant"
238
286
  }
239
287
 
240
- inst = Gem::Installer.new nil, options
288
+ inst = Gem::Installer.new '', options
241
289
 
242
290
  Gem::Installer.path_warning = false
243
291
 
@@ -249,16 +297,14 @@ load Gem.bin_path('a', 'executable', version)
249
297
  end
250
298
 
251
299
  def test_generate_bin_script
252
- util_setup_install
253
-
254
300
  @installer.wrappers = true
255
301
  util_make_exec
256
302
  @installer.gem_dir = util_gem_dir
257
303
 
258
304
  @installer.generate_bin
259
- assert_equal true, File.directory?(util_inst_bindir)
260
- installed_exec = File.join(util_inst_bindir, 'executable')
261
- assert_equal true, File.exist?(installed_exec)
305
+ assert File.directory? util_inst_bindir
306
+ installed_exec = File.join util_inst_bindir, 'executable'
307
+ assert File.exist? installed_exec
262
308
  assert_equal mask, File.stat(installed_exec).mode unless win_platform?
263
309
 
264
310
  wrapper = File.read installed_exec
@@ -266,8 +312,6 @@ load Gem.bin_path('a', 'executable', version)
266
312
  end
267
313
 
268
314
  def test_generate_bin_script_format
269
- util_setup_install
270
-
271
315
  @installer.format_executable = true
272
316
  @installer.wrappers = true
273
317
  util_make_exec
@@ -283,8 +327,6 @@ load Gem.bin_path('a', 'executable', version)
283
327
  end
284
328
 
285
329
  def test_generate_bin_script_format_disabled
286
- util_setup_install
287
-
288
330
  @installer.wrappers = true
289
331
  util_make_exec
290
332
  @installer.gem_dir = util_gem_dir
@@ -299,10 +341,7 @@ load Gem.bin_path('a', 'executable', version)
299
341
  end
300
342
 
301
343
  def test_generate_bin_script_install_dir
302
- util_setup_install
303
-
304
344
  @installer.wrappers = true
305
- @spec.executables = %w[executable]
306
345
 
307
346
  gem_dir = File.join("#{@gemhome}2", "gems", @spec.full_name)
308
347
  gem_bindir = File.join gem_dir, 'bin'
@@ -313,11 +352,12 @@ load Gem.bin_path('a', 'executable', version)
313
352
 
314
353
  @installer.gem_home = "#{@gemhome}2"
315
354
  @installer.gem_dir = gem_dir
355
+ @installer.bin_dir = File.join "#{@gemhome}2", 'bin'
316
356
 
317
357
  @installer.generate_bin
318
358
 
319
359
  installed_exec = File.join("#{@gemhome}2", "bin", 'executable')
320
- assert_equal true, File.exist?(installed_exec)
360
+ assert File.exist? installed_exec
321
361
  assert_equal mask, File.stat(installed_exec).mode unless win_platform?
322
362
 
323
363
  wrapper = File.read installed_exec
@@ -325,8 +365,6 @@ load Gem.bin_path('a', 'executable', version)
325
365
  end
326
366
 
327
367
  def test_generate_bin_script_no_execs
328
- util_setup_install
329
-
330
368
  util_execless
331
369
 
332
370
  @installer.wrappers = true
@@ -336,8 +374,6 @@ load Gem.bin_path('a', 'executable', version)
336
374
  end
337
375
 
338
376
  def test_generate_bin_script_no_perms
339
- util_setup_install
340
-
341
377
  @installer.wrappers = true
342
378
  util_make_exec
343
379
 
@@ -357,8 +393,6 @@ load Gem.bin_path('a', 'executable', version)
357
393
  end
358
394
 
359
395
  def test_generate_bin_script_no_shebang
360
- util_setup_install
361
-
362
396
  @installer.wrappers = true
363
397
  @spec.executables = %w[executable]
364
398
 
@@ -382,8 +416,6 @@ load Gem.bin_path('a', 'executable', version)
382
416
  end
383
417
 
384
418
  def test_generate_bin_script_wrappers
385
- util_setup_install
386
-
387
419
  @installer.wrappers = true
388
420
  util_make_exec
389
421
  @installer.gem_dir = util_gem_dir
@@ -409,8 +441,6 @@ load Gem.bin_path('a', 'executable', version)
409
441
  end
410
442
 
411
443
  def test_generate_bin_symlink
412
- util_setup_install
413
-
414
444
  return if win_platform? #Windows FS do not support symlinks
415
445
 
416
446
  @installer.wrappers = false
@@ -426,8 +456,6 @@ load Gem.bin_path('a', 'executable', version)
426
456
  end
427
457
 
428
458
  def test_generate_bin_symlink_no_execs
429
- util_setup_install
430
-
431
459
  util_execless
432
460
 
433
461
  @installer.wrappers = false
@@ -437,8 +465,6 @@ load Gem.bin_path('a', 'executable', version)
437
465
  end
438
466
 
439
467
  def test_generate_bin_symlink_no_perms
440
- util_setup_install
441
-
442
468
  @installer.wrappers = false
443
469
  util_make_exec
444
470
  @installer.gem_dir = util_gem_dir
@@ -459,8 +485,6 @@ load Gem.bin_path('a', 'executable', version)
459
485
  end
460
486
 
461
487
  def test_generate_bin_symlink_update_newer
462
- util_setup_install
463
-
464
488
  return if win_platform? #Windows FS do not support symlinks
465
489
 
466
490
  @installer.wrappers = false
@@ -481,7 +505,6 @@ load Gem.bin_path('a', 'executable', version)
481
505
  s.require_path = 'lib'
482
506
  end
483
507
 
484
- @spec.version = 3
485
508
  util_make_exec
486
509
  @installer.gem_dir = util_gem_dir @spec
487
510
  @installer.generate_bin
@@ -492,8 +515,6 @@ load Gem.bin_path('a', 'executable', version)
492
515
  end
493
516
 
494
517
  def test_generate_bin_symlink_update_older
495
- util_setup_install
496
-
497
518
  return if win_platform? #Windows FS do not support symlinks
498
519
 
499
520
  @installer.wrappers = false
@@ -530,8 +551,6 @@ load Gem.bin_path('a', 'executable', version)
530
551
  end
531
552
 
532
553
  def test_generate_bin_symlink_update_remove_wrapper
533
- util_setup_install
534
-
535
554
  return if win_platform? #Windows FS do not support symlinks
536
555
 
537
556
  @installer.wrappers = true
@@ -539,8 +558,9 @@ load Gem.bin_path('a', 'executable', version)
539
558
  @installer.gem_dir = util_gem_dir
540
559
 
541
560
  @installer.generate_bin
561
+
542
562
  installed_exec = File.join util_inst_bindir, 'executable'
543
- assert_equal true, File.exist?(installed_exec)
563
+ assert File.exist? installed_exec
544
564
 
545
565
  @spec = Gem::Specification.new do |s|
546
566
  s.files = ['lib/code.rb']
@@ -550,21 +570,21 @@ load Gem.bin_path('a', 'executable', version)
550
570
  s.description = "desc"
551
571
  s.require_path = 'lib'
552
572
  end
573
+ util_make_exec
553
574
 
575
+ util_installer @spec, @gemhome
554
576
  @installer.wrappers = false
555
- @spec.version = 3
556
- util_make_exec
557
577
  @installer.gem_dir = util_gem_dir
578
+
558
579
  @installer.generate_bin
559
- installed_exec = File.join(util_inst_bindir, 'executable')
560
- assert_equal(File.join(util_gem_dir, 'bin', 'executable'),
580
+
581
+ installed_exec = File.join util_inst_bindir, 'executable'
582
+ assert_equal(@spec.bin_file('executable'),
561
583
  File.readlink(installed_exec),
562
584
  "Ensure symlink moved to latest version")
563
585
  end
564
586
 
565
587
  def test_generate_bin_symlink_win32
566
- util_setup_install
567
-
568
588
  old_win_platform = Gem.win_platform?
569
589
  Gem.win_platform = true
570
590
  @installer.wrappers = false
@@ -589,8 +609,6 @@ load Gem.bin_path('a', 'executable', version)
589
609
  end
590
610
 
591
611
  def test_generate_bin_uses_default_shebang
592
- util_setup_install
593
-
594
612
  return if win_platform? #Windows FS do not support symlinks
595
613
 
596
614
  @installer.wrappers = true
@@ -748,7 +766,8 @@ load Gem.bin_path('a', 'executable', version)
748
766
 
749
767
  exe = File.join @gemhome, 'bin', 'executable'
750
768
 
751
- ARGV.unshift "\xE4pfel".force_encoding("UTF-8")
769
+ extra_arg = "\xE4pfel".force_encoding("UTF-8")
770
+ ARGV.unshift extra_arg
752
771
 
753
772
  begin
754
773
  Gem::Specification.reset
@@ -757,7 +776,7 @@ load Gem.bin_path('a', 'executable', version)
757
776
  instance_eval File.read(exe)
758
777
  end
759
778
  ensure
760
- ARGV.shift if ARGV.first == "\xE4pfel"
779
+ ARGV.shift if ARGV.first == extra_arg
761
780
  end
762
781
 
763
782
  assert_match(/ran executable/, e.message)
@@ -784,7 +803,7 @@ load Gem.bin_path('a', 'executable', version)
784
803
  File.open File.join('lib', 'other.rb'), 'w' do |f| f.puts '1' end
785
804
  use_ui ui do
786
805
  FileUtils.rm @gem
787
- Gem::Builder.new(@spec).build
806
+ Gem::Package.build @spec
788
807
  end
789
808
  end
790
809
  @installer = Gem::Installer.new @gem
@@ -799,27 +818,6 @@ load Gem.bin_path('a', 'executable', version)
799
818
  "code.rb from prior install of same gem shouldn't remain here")
800
819
  end
801
820
 
802
- def test_install_bad_gem
803
- gem = nil
804
-
805
- use_ui @ui do
806
- Dir.chdir @tempdir do Gem::Builder.new(@spec).build end
807
- gem = File.join @tempdir, @spec.file_name
808
- end
809
-
810
- gem_data = File.open gem, 'rb' do |fp| fp.read 1024 end
811
- File.open gem, 'wb' do |fp| fp.write gem_data end
812
-
813
- e = assert_raises Gem::InstallError do
814
- use_ui @ui do
815
- @installer = Gem::Installer.new gem
816
- @installer.install
817
- end
818
- end
819
-
820
- assert_equal "invalid gem format for #{gem}", e.message
821
- end
822
-
823
821
  def test_install_check_dependencies
824
822
  @spec.add_dependency 'b', '> 5'
825
823
  util_setup_gem
@@ -833,13 +831,15 @@ load Gem.bin_path('a', 'executable', version)
833
831
 
834
832
  def test_install_check_dependencies_install_dir
835
833
  gemhome2 = "#{@gemhome}2"
836
- @spec.add_dependency 'b'
834
+ @spec.add_dependency 'd'
837
835
 
838
- quick_gem 'b', 2
836
+ quick_gem 'd', 2
839
837
 
840
838
  FileUtils.mv @gemhome, gemhome2
841
839
 
842
- Gem::Specification.dirs = [gemhome2] # TODO: switch all dirs= to use_paths
840
+ # Don't leak any already activated gems into the installer, require
841
+ # that it work everything out on it's own.
842
+ Gem::Specification.reset
843
843
 
844
844
  util_setup_gem
845
845
 
@@ -897,8 +897,6 @@ load Gem.bin_path('a', 'executable', version)
897
897
  FileUtils.rm_f File.join(Gem.dir, 'specifications')
898
898
 
899
899
  use_ui @ui do
900
- Dir.chdir @tempdir do Gem::Builder.new(@spec).build end
901
-
902
900
  @installer.install
903
901
  end
904
902
 
@@ -992,7 +990,7 @@ load Gem.bin_path('a', 'executable', version)
992
990
  @spec.post_install_message = 'I am a shiny gem!'
993
991
 
994
992
  use_ui @ui do
995
- path = Gem::Builder.new(@spec).build
993
+ path = Gem::Package.build @spec
996
994
 
997
995
  @installer = Gem::Installer.new path
998
996
  @installer.install
@@ -1031,48 +1029,8 @@ load Gem.bin_path('a', 'executable', version)
1031
1029
  end
1032
1030
  end
1033
1031
 
1034
- def test_install_extension_flat
1035
- skip '1.8 mkmf.rb does not create TOUCH' if RUBY_VERSION < '1.9'
1036
- @spec.require_paths = ["."]
1037
-
1038
- @spec.extensions << "extconf.rb"
1039
-
1040
- write_file File.join(@tempdir, "extconf.rb") do |io|
1041
- io.write <<-RUBY
1042
- require "mkmf"
1043
-
1044
- CONFIG['CC'] = '$(TOUCH) $@ ||'
1045
- CONFIG['LDSHARED'] = '$(TOUCH) $@ ||'
1046
-
1047
- create_makefile("#{@spec.name}")
1048
- RUBY
1049
- end
1050
-
1051
- # empty depend file for no auto dependencies
1052
- @spec.files += %W"depend #{@spec.name}.c".each {|file|
1053
- write_file File.join(@tempdir, file)
1054
- }
1055
-
1056
- so = File.join(@gemhome, 'gems', @spec.full_name, "#{@spec.name}.#{RbConfig::CONFIG["DLEXT"]}")
1057
- assert !File.exist?(so)
1058
- use_ui @ui do
1059
- path = Gem::Builder.new(@spec).build
1060
-
1061
- @installer = Gem::Installer.new path
1062
- @installer.install
1063
- end
1064
- assert File.exist?(so), so
1065
- rescue
1066
- puts '-' * 78
1067
- puts File.read File.join(@gemhome, 'gems', 'a-2', 'Makefile')
1068
- puts '-' * 78
1069
- puts File.read File.join(@gemhome, 'gems', 'a-2', 'gem_make.out')
1070
- puts '-' * 78
1071
- raise
1072
- end
1073
-
1074
1032
  def test_installation_satisfies_dependency_eh
1075
- util_setup_install
1033
+ quick_spec 'a'
1076
1034
 
1077
1035
  dep = Gem::Dependency.new 'a', '>= 2'
1078
1036
  assert @installer.installation_satisfies_dependency?(dep)
@@ -1082,8 +1040,6 @@ load Gem.bin_path('a', 'executable', version)
1082
1040
  end
1083
1041
 
1084
1042
  def test_shebang
1085
- util_setup_install
1086
-
1087
1043
  util_make_exec @spec, "#!/usr/bin/ruby"
1088
1044
 
1089
1045
  shebang = @installer.shebang 'executable'
@@ -1092,8 +1048,6 @@ load Gem.bin_path('a', 'executable', version)
1092
1048
  end
1093
1049
 
1094
1050
  def test_shebang_arguments
1095
- util_setup_install
1096
-
1097
1051
  util_make_exec @spec, "#!/usr/bin/ruby -ws"
1098
1052
 
1099
1053
  shebang = @installer.shebang 'executable'
@@ -1102,8 +1056,6 @@ load Gem.bin_path('a', 'executable', version)
1102
1056
  end
1103
1057
 
1104
1058
  def test_shebang_empty
1105
- util_setup_install
1106
-
1107
1059
  util_make_exec @spec, ''
1108
1060
 
1109
1061
  shebang = @installer.shebang 'executable'
@@ -1111,8 +1063,6 @@ load Gem.bin_path('a', 'executable', version)
1111
1063
  end
1112
1064
 
1113
1065
  def test_shebang_env
1114
- util_setup_install
1115
-
1116
1066
  util_make_exec @spec, "#!/usr/bin/env ruby"
1117
1067
 
1118
1068
  shebang = @installer.shebang 'executable'
@@ -1121,8 +1071,6 @@ load Gem.bin_path('a', 'executable', version)
1121
1071
  end
1122
1072
 
1123
1073
  def test_shebang_env_arguments
1124
- util_setup_install
1125
-
1126
1074
  util_make_exec @spec, "#!/usr/bin/env ruby -ws"
1127
1075
 
1128
1076
  shebang = @installer.shebang 'executable'
@@ -1131,8 +1079,6 @@ load Gem.bin_path('a', 'executable', version)
1131
1079
  end
1132
1080
 
1133
1081
  def test_shebang_env_shebang
1134
- util_setup_install
1135
-
1136
1082
  util_make_exec @spec, ''
1137
1083
  @installer.env_shebang = true
1138
1084
 
@@ -1145,8 +1091,6 @@ load Gem.bin_path('a', 'executable', version)
1145
1091
  end
1146
1092
 
1147
1093
  def test_shebang_nested
1148
- util_setup_install
1149
-
1150
1094
  util_make_exec @spec, "#!/opt/local/ruby/bin/ruby"
1151
1095
 
1152
1096
  shebang = @installer.shebang 'executable'
@@ -1155,8 +1099,6 @@ load Gem.bin_path('a', 'executable', version)
1155
1099
  end
1156
1100
 
1157
1101
  def test_shebang_nested_arguments
1158
- util_setup_install
1159
-
1160
1102
  util_make_exec @spec, "#!/opt/local/ruby/bin/ruby -ws"
1161
1103
 
1162
1104
  shebang = @installer.shebang 'executable'
@@ -1165,8 +1107,6 @@ load Gem.bin_path('a', 'executable', version)
1165
1107
  end
1166
1108
 
1167
1109
  def test_shebang_version
1168
- util_setup_install
1169
-
1170
1110
  util_make_exec @spec, "#!/usr/bin/ruby18"
1171
1111
 
1172
1112
  shebang = @installer.shebang 'executable'
@@ -1175,8 +1115,6 @@ load Gem.bin_path('a', 'executable', version)
1175
1115
  end
1176
1116
 
1177
1117
  def test_shebang_version_arguments
1178
- util_setup_install
1179
-
1180
1118
  util_make_exec @spec, "#!/usr/bin/ruby18 -ws"
1181
1119
 
1182
1120
  shebang = @installer.shebang 'executable'
@@ -1185,8 +1123,6 @@ load Gem.bin_path('a', 'executable', version)
1185
1123
  end
1186
1124
 
1187
1125
  def test_shebang_version_env
1188
- util_setup_install
1189
-
1190
1126
  util_make_exec @spec, "#!/usr/bin/env ruby18"
1191
1127
 
1192
1128
  shebang = @installer.shebang 'executable'
@@ -1195,8 +1131,6 @@ load Gem.bin_path('a', 'executable', version)
1195
1131
  end
1196
1132
 
1197
1133
  def test_shebang_version_env_arguments
1198
- util_setup_install
1199
-
1200
1134
  util_make_exec @spec, "#!/usr/bin/env ruby18 -ws"
1201
1135
 
1202
1136
  shebang = @installer.shebang 'executable'
@@ -1204,9 +1138,48 @@ load Gem.bin_path('a', 'executable', version)
1204
1138
  assert_equal "#!#{Gem.ruby} -ws", shebang
1205
1139
  end
1206
1140
 
1207
- def test_unpack
1208
- util_setup_install
1141
+ def test_shebang_custom
1142
+ conf = Gem::ConfigFile.new []
1143
+ conf[:custom_shebang] = 'test'
1144
+
1145
+ Gem.configuration = conf
1146
+
1147
+ util_make_exec @spec, "#!/usr/bin/ruby"
1148
+
1149
+ shebang = @installer.shebang 'executable'
1150
+
1151
+ assert_equal "#!test", shebang
1152
+ end
1153
+
1154
+ def test_shebang_custom_with_expands
1155
+ bin_env = win_platform? ? '' : '/usr/bin/env'
1156
+ conf = Gem::ConfigFile.new []
1157
+ conf[:custom_shebang] = '1 $env 2 $ruby 3 $exec 4 $name'
1158
+
1159
+ Gem.configuration = conf
1209
1160
 
1161
+ util_make_exec @spec, "#!/usr/bin/ruby"
1162
+
1163
+ shebang = @installer.shebang 'executable'
1164
+
1165
+ assert_equal "#!1 #{bin_env} 2 #{Gem.ruby} 3 executable 4 a", shebang
1166
+ end
1167
+
1168
+ def test_shebang_custom_with_expands_and_arguments
1169
+ bin_env = win_platform? ? '' : '/usr/bin/env'
1170
+ conf = Gem::ConfigFile.new []
1171
+ conf[:custom_shebang] = '1 $env 2 $ruby 3 $exec'
1172
+
1173
+ Gem.configuration = conf
1174
+
1175
+ util_make_exec @spec, "#!/usr/bin/ruby -ws"
1176
+
1177
+ shebang = @installer.shebang 'executable'
1178
+
1179
+ assert_equal "#!1 #{bin_env} 2 #{Gem.ruby} -ws 3 executable", shebang
1180
+ end
1181
+
1182
+ def test_unpack
1210
1183
  util_setup_gem
1211
1184
 
1212
1185
  dest = File.join @gemhome, 'gems', @spec.full_name
@@ -1218,29 +1191,21 @@ load Gem.bin_path('a', 'executable', version)
1218
1191
  end
1219
1192
 
1220
1193
  def test_write_spec
1221
- util_setup_install
1222
-
1223
- spec_dir = File.join @gemhome, 'specifications'
1224
- spec_file = File.join spec_dir, @spec.spec_name
1225
- FileUtils.rm spec_file
1226
- refute File.exist?(spec_file)
1194
+ FileUtils.rm @spec.spec_file
1195
+ refute File.exist?(@spec.spec_file)
1227
1196
 
1228
1197
  @installer.spec = @spec
1229
1198
  @installer.gem_home = @gemhome
1230
1199
 
1231
1200
  @installer.write_spec
1232
1201
 
1233
- assert File.exist?(spec_file)
1234
- assert_equal @spec, eval(File.read(spec_file))
1202
+ assert File.exist?(@spec.spec_file)
1203
+ assert_equal @spec, eval(File.read(@spec.spec_file))
1235
1204
  end
1236
1205
 
1237
1206
  def test_write_spec_writes_cached_spec
1238
- util_setup_install
1239
-
1240
- spec_dir = File.join @gemhome, 'specifications'
1241
- spec_file = File.join spec_dir, @spec.spec_name
1242
- FileUtils.rm spec_file
1243
- refute File.exist?(spec_file)
1207
+ FileUtils.rm @spec.spec_file
1208
+ refute File.exist?(@spec.spec_file)
1244
1209
 
1245
1210
  @spec.files = %w[a.rb b.rb c.rb]
1246
1211
 
@@ -1252,13 +1217,11 @@ load Gem.bin_path('a', 'executable', version)
1252
1217
  # cached specs have no file manifest:
1253
1218
  @spec.files = []
1254
1219
 
1255
- assert_equal @spec, eval(File.read(spec_file))
1220
+ assert_equal @spec, eval(File.read(@spec.spec_file))
1256
1221
  end
1257
1222
 
1258
1223
  def test_dir
1259
- util_setup_install
1260
-
1261
- assert_match %r!/installer/gems/a-2$!, @installer.dir
1224
+ assert_match %r!/gemhome/gems/a-2$!, @installer.dir
1262
1225
  end
1263
1226
 
1264
1227
  def old_ruby_required
@@ -1278,6 +1241,18 @@ load Gem.bin_path('a', 'executable', version)
1278
1241
  @installer = util_installer @spec, @gemhome
1279
1242
  end
1280
1243
 
1244
+ def util_conflict_executable wrappers
1245
+ conflict = quick_gem 'conflict' do |spec|
1246
+ util_make_exec spec
1247
+ end
1248
+
1249
+ util_build_gem conflict
1250
+
1251
+ installer = util_installer conflict, @gemhome
1252
+ installer.wrappers = wrappers
1253
+ installer.generate_bin
1254
+ end
1255
+
1281
1256
  def mask
1282
1257
  0100755 & (~File.umask)
1283
1258
  end