rubygems-update 3.1.6 → 3.3.22

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (703) hide show
  1. checksums.yaml +4 -4
  2. data/{History.txt → CHANGELOG.md} +1452 -514
  3. data/CODE_OF_CONDUCT.md +55 -19
  4. data/CONTRIBUTING.md +74 -27
  5. data/Manifest.txt +154 -117
  6. data/POLICIES.md +27 -19
  7. data/README.md +10 -8
  8. data/UPGRADING.md +5 -81
  9. data/bin/gem +3 -8
  10. data/bin/update_rubygems +5 -5
  11. data/bundler/CHANGELOG.md +2358 -1430
  12. data/bundler/README.md +7 -9
  13. data/bundler/UPGRADING.md +27 -34
  14. data/bundler/bundler.gemspec +8 -11
  15. data/bundler/exe/bundle +10 -8
  16. data/bundler/exe/bundler +1 -1
  17. data/bundler/lib/bundler/.document +1 -0
  18. data/bundler/lib/bundler/build_metadata.rb +4 -12
  19. data/bundler/lib/bundler/cli/add.rb +1 -1
  20. data/bundler/lib/bundler/cli/binstubs.rb +6 -2
  21. data/bundler/lib/bundler/cli/cache.rb +3 -8
  22. data/bundler/lib/bundler/cli/check.rb +4 -2
  23. data/bundler/lib/bundler/cli/clean.rb +1 -1
  24. data/bundler/lib/bundler/cli/common.rb +31 -3
  25. data/bundler/lib/bundler/cli/config.rb +10 -1
  26. data/bundler/lib/bundler/cli/console.rb +1 -1
  27. data/bundler/lib/bundler/cli/doctor.rb +25 -6
  28. data/bundler/lib/bundler/cli/exec.rb +5 -10
  29. data/bundler/lib/bundler/cli/fund.rb +36 -0
  30. data/bundler/lib/bundler/cli/gem.rb +219 -28
  31. data/bundler/lib/bundler/cli/info.rb +38 -6
  32. data/bundler/lib/bundler/cli/init.rb +3 -3
  33. data/bundler/lib/bundler/cli/inject.rb +1 -1
  34. data/bundler/lib/bundler/cli/install.rb +25 -54
  35. data/bundler/lib/bundler/cli/issue.rb +5 -4
  36. data/bundler/lib/bundler/cli/list.rb +19 -11
  37. data/bundler/lib/bundler/cli/lock.rb +5 -1
  38. data/bundler/lib/bundler/cli/open.rb +1 -2
  39. data/bundler/lib/bundler/cli/outdated.rb +105 -76
  40. data/bundler/lib/bundler/cli/platform.rb +2 -2
  41. data/bundler/lib/bundler/cli/plugin.rb +10 -0
  42. data/bundler/lib/bundler/cli/pristine.rb +5 -0
  43. data/bundler/lib/bundler/cli/remove.rb +1 -2
  44. data/bundler/lib/bundler/cli/show.rb +2 -2
  45. data/bundler/lib/bundler/cli/update.rb +20 -9
  46. data/bundler/lib/bundler/cli.rb +106 -83
  47. data/bundler/lib/bundler/compact_index_client/cache.rb +6 -23
  48. data/bundler/lib/bundler/compact_index_client/gem_parser.rb +28 -0
  49. data/bundler/lib/bundler/compact_index_client/updater.rb +29 -25
  50. data/bundler/lib/bundler/compact_index_client.rb +3 -9
  51. data/bundler/lib/bundler/current_ruby.rb +17 -6
  52. data/bundler/lib/bundler/definition.rb +297 -396
  53. data/bundler/lib/bundler/dep_proxy.rb +16 -9
  54. data/bundler/lib/bundler/dependency.rb +22 -77
  55. data/bundler/lib/bundler/digest.rb +71 -0
  56. data/bundler/lib/bundler/dsl.rb +76 -83
  57. data/bundler/lib/bundler/endpoint_specification.rb +16 -14
  58. data/bundler/lib/bundler/env.rb +2 -2
  59. data/bundler/lib/bundler/environment_preserver.rb +29 -2
  60. data/bundler/lib/bundler/errors.rb +30 -3
  61. data/bundler/lib/bundler/feature_flag.rb +0 -9
  62. data/bundler/lib/bundler/fetcher/base.rb +7 -9
  63. data/bundler/lib/bundler/fetcher/compact_index.rb +11 -16
  64. data/bundler/lib/bundler/fetcher/downloader.rb +10 -7
  65. data/bundler/lib/bundler/fetcher/index.rb +2 -30
  66. data/bundler/lib/bundler/fetcher.rb +24 -25
  67. data/bundler/lib/bundler/friendly_errors.rb +46 -47
  68. data/bundler/lib/bundler/gem_helper.rb +53 -31
  69. data/bundler/lib/bundler/gem_helpers.rb +43 -24
  70. data/bundler/lib/bundler/gem_version_promoter.rb +10 -20
  71. data/bundler/lib/bundler/graph.rb +1 -1
  72. data/bundler/lib/bundler/index.rb +19 -25
  73. data/bundler/lib/bundler/injector.rb +38 -6
  74. data/bundler/lib/bundler/inline.rb +4 -13
  75. data/bundler/lib/bundler/installer/gem_installer.rb +19 -24
  76. data/bundler/lib/bundler/installer/parallel_installer.rb +46 -25
  77. data/bundler/lib/bundler/installer/standalone.rb +58 -11
  78. data/bundler/lib/bundler/installer.rb +51 -81
  79. data/bundler/lib/bundler/lazy_specification.rb +79 -36
  80. data/bundler/lib/bundler/lockfile_generator.rb +3 -3
  81. data/bundler/lib/bundler/lockfile_parser.rb +19 -44
  82. data/bundler/lib/bundler/man/.document +1 -0
  83. data/bundler/{man → lib/bundler/man}/bundle-add.1 +21 -5
  84. data/bundler/{man/bundle-add.ronn → lib/bundler/man/bundle-add.1.ronn} +16 -4
  85. data/bundler/{man → lib/bundler/man}/bundle-binstubs.1 +5 -3
  86. data/bundler/{man/bundle-binstubs.ronn → lib/bundler/man/bundle-binstubs.1.ronn} +2 -4
  87. data/bundler/{man → lib/bundler/man}/bundle-cache.1 +7 -1
  88. data/bundler/{man/bundle-cache.ronn → lib/bundler/man/bundle-cache.1.ronn} +7 -0
  89. data/bundler/{man → lib/bundler/man}/bundle-check.1 +1 -1
  90. data/bundler/{man → lib/bundler/man}/bundle-clean.1 +1 -1
  91. data/bundler/{man → lib/bundler/man}/bundle-config.1 +65 -47
  92. data/bundler/{man/bundle-config.ronn → lib/bundler/man/bundle-config.1.ronn} +74 -65
  93. data/bundler/lib/bundler/man/bundle-console.1 +53 -0
  94. data/bundler/lib/bundler/man/bundle-console.1.ronn +44 -0
  95. data/bundler/{man → lib/bundler/man}/bundle-doctor.1 +1 -1
  96. data/bundler/{man → lib/bundler/man}/bundle-exec.1 +2 -2
  97. data/bundler/{man/bundle-exec.ronn → lib/bundler/man/bundle-exec.1.ronn} +1 -1
  98. data/bundler/{man → lib/bundler/man}/bundle-gem.1 +38 -3
  99. data/bundler/{man/bundle-gem.ronn → lib/bundler/man/bundle-gem.1.ronn} +46 -7
  100. data/bundler/lib/bundler/man/bundle-help.1 +13 -0
  101. data/bundler/lib/bundler/man/bundle-help.1.ronn +12 -0
  102. data/bundler/{man → lib/bundler/man}/bundle-info.1 +1 -1
  103. data/bundler/{man → lib/bundler/man}/bundle-init.1 +1 -1
  104. data/bundler/{man → lib/bundler/man}/bundle-inject.1 +5 -2
  105. data/bundler/{man/bundle-inject.ronn → lib/bundler/man/bundle-inject.1.ronn} +3 -1
  106. data/bundler/{man → lib/bundler/man}/bundle-install.1 +35 -4
  107. data/bundler/{man/bundle-install.ronn → lib/bundler/man/bundle-install.1.ronn} +33 -5
  108. data/bundler/{man → lib/bundler/man}/bundle-list.1 +7 -7
  109. data/bundler/{man/bundle-list.ronn → lib/bundler/man/bundle-list.1.ronn} +6 -6
  110. data/bundler/{man → lib/bundler/man}/bundle-lock.1 +1 -1
  111. data/bundler/{man → lib/bundler/man}/bundle-open.1 +1 -1
  112. data/bundler/{man → lib/bundler/man}/bundle-outdated.1 +3 -10
  113. data/bundler/{man/bundle-outdated.ronn → lib/bundler/man/bundle-outdated.1.ronn} +1 -10
  114. data/bundler/{man → lib/bundler/man}/bundle-platform.1 +16 -6
  115. data/bundler/{man/bundle-platform.ronn → lib/bundler/man/bundle-platform.1.ronn} +14 -7
  116. data/bundler/lib/bundler/man/bundle-plugin.1 +81 -0
  117. data/bundler/lib/bundler/man/bundle-plugin.1.ronn +59 -0
  118. data/bundler/{man → lib/bundler/man}/bundle-pristine.1 +1 -1
  119. data/bundler/{man → lib/bundler/man}/bundle-remove.1 +1 -1
  120. data/bundler/{man → lib/bundler/man}/bundle-show.1 +1 -1
  121. data/bundler/{man → lib/bundler/man}/bundle-update.1 +5 -5
  122. data/bundler/{man/bundle-update.ronn → lib/bundler/man/bundle-update.1.ronn} +5 -4
  123. data/bundler/lib/bundler/man/bundle-version.1 +35 -0
  124. data/bundler/lib/bundler/man/bundle-version.1.ronn +24 -0
  125. data/bundler/{man → lib/bundler/man}/bundle-viz.1 +4 -1
  126. data/bundler/{man/bundle-viz.ronn → lib/bundler/man/bundle-viz.1.ronn} +2 -0
  127. data/bundler/{man → lib/bundler/man}/bundle.1 +15 -10
  128. data/bundler/{man/bundle.ronn → lib/bundler/man/bundle.1.ronn} +12 -7
  129. data/bundler/{man → lib/bundler/man}/gemfile.5 +106 -80
  130. data/bundler/{man → lib/bundler/man}/gemfile.5.ronn +94 -83
  131. data/bundler/{man → lib/bundler/man}/index.txt +4 -0
  132. data/bundler/lib/bundler/match_metadata.rb +13 -0
  133. data/bundler/lib/bundler/match_platform.rb +0 -1
  134. data/bundler/lib/bundler/match_remote_metadata.rb +29 -0
  135. data/bundler/lib/bundler/mirror.rb +2 -2
  136. data/bundler/lib/bundler/plugin/api/source.rb +25 -9
  137. data/bundler/lib/bundler/plugin/dsl.rb +1 -1
  138. data/bundler/lib/bundler/plugin/index.rb +13 -1
  139. data/bundler/lib/bundler/plugin/installer/git.rb +0 -4
  140. data/bundler/lib/bundler/plugin/installer/rubygems.rb +1 -5
  141. data/bundler/lib/bundler/plugin/installer.rb +11 -11
  142. data/bundler/lib/bundler/plugin/source_list.rb +5 -1
  143. data/bundler/lib/bundler/plugin.rb +58 -11
  144. data/bundler/lib/bundler/process_lock.rb +1 -1
  145. data/bundler/lib/bundler/remote_specification.rb +11 -6
  146. data/bundler/lib/bundler/resolver/base.rb +50 -0
  147. data/bundler/lib/bundler/resolver/spec_group.rb +64 -57
  148. data/bundler/lib/bundler/resolver.rb +234 -230
  149. data/bundler/lib/bundler/retry.rb +2 -2
  150. data/bundler/lib/bundler/ruby_dsl.rb +1 -1
  151. data/bundler/lib/bundler/ruby_version.rb +6 -19
  152. data/bundler/lib/bundler/rubygems_ext.rb +194 -33
  153. data/bundler/lib/bundler/rubygems_gem_installer.rb +87 -16
  154. data/bundler/lib/bundler/rubygems_integration.rb +71 -153
  155. data/bundler/lib/bundler/runtime.rb +22 -26
  156. data/bundler/lib/bundler/self_manager.rb +168 -0
  157. data/bundler/lib/bundler/settings.rb +145 -66
  158. data/bundler/lib/bundler/setup.rb +2 -2
  159. data/bundler/lib/bundler/shared_helpers.rb +17 -32
  160. data/bundler/lib/bundler/similarity_detector.rb +1 -1
  161. data/bundler/lib/bundler/source/git/git_proxy.rb +88 -84
  162. data/bundler/lib/bundler/source/git.rb +50 -32
  163. data/bundler/lib/bundler/source/metadata.rb +3 -7
  164. data/bundler/lib/bundler/source/path/installer.rb +10 -10
  165. data/bundler/lib/bundler/source/path.rb +10 -4
  166. data/bundler/lib/bundler/source/rubygems/remote.rb +1 -1
  167. data/bundler/lib/bundler/source/rubygems.rb +201 -179
  168. data/bundler/lib/bundler/source/rubygems_aggregate.rb +68 -0
  169. data/bundler/lib/bundler/source.rb +25 -5
  170. data/bundler/lib/bundler/source_list.rb +105 -63
  171. data/bundler/lib/bundler/source_map.rb +71 -0
  172. data/bundler/lib/bundler/spec_set.rb +62 -57
  173. data/bundler/lib/bundler/stub_specification.rb +30 -10
  174. data/bundler/lib/bundler/templates/Executable +2 -4
  175. data/bundler/lib/bundler/templates/Executable.bundler +8 -8
  176. data/bundler/lib/bundler/templates/Executable.standalone +2 -4
  177. data/bundler/lib/bundler/templates/Gemfile +0 -2
  178. data/bundler/lib/bundler/templates/gems.rb +0 -3
  179. data/bundler/lib/bundler/templates/newgem/CHANGELOG.md.tt +5 -0
  180. data/bundler/lib/bundler/templates/newgem/CODE_OF_CONDUCT.md.tt +57 -47
  181. data/bundler/lib/bundler/templates/newgem/Gemfile.tt +12 -1
  182. data/bundler/lib/bundler/templates/newgem/README.md.tt +9 -14
  183. data/bundler/lib/bundler/templates/newgem/Rakefile.tt +32 -5
  184. data/bundler/lib/bundler/templates/newgem/bin/console.tt +1 -0
  185. data/bundler/lib/bundler/templates/newgem/circleci/config.yml.tt +13 -0
  186. data/bundler/lib/bundler/templates/newgem/ext/newgem/extconf.rb.tt +2 -0
  187. data/bundler/lib/bundler/templates/newgem/github/workflows/main.yml.tt +27 -0
  188. data/bundler/lib/bundler/templates/newgem/gitlab-ci.yml.tt +9 -0
  189. data/bundler/lib/bundler/templates/newgem/lib/newgem/version.rb.tt +2 -0
  190. data/bundler/lib/bundler/templates/newgem/lib/newgem.rb.tt +4 -2
  191. data/bundler/lib/bundler/templates/newgem/newgem.gemspec.tt +27 -17
  192. data/bundler/lib/bundler/templates/newgem/rubocop.yml.tt +13 -0
  193. data/bundler/lib/bundler/templates/newgem/sig/newgem.rbs.tt +8 -0
  194. data/bundler/lib/bundler/templates/newgem/spec/newgem_spec.rb.tt +2 -0
  195. data/bundler/lib/bundler/templates/newgem/spec/spec_helper.rb.tt +2 -1
  196. data/bundler/lib/bundler/templates/newgem/standard.yml.tt +3 -0
  197. data/bundler/lib/bundler/templates/newgem/test/{test_helper.rb.tt → minitest/test_helper.rb.tt} +2 -0
  198. data/bundler/lib/bundler/templates/newgem/test/{newgem_test.rb.tt → minitest/test_newgem.rb.tt} +3 -1
  199. data/bundler/lib/bundler/templates/newgem/test/test-unit/newgem_test.rb.tt +15 -0
  200. data/bundler/lib/bundler/templates/newgem/test/test-unit/test_helper.rb.tt +6 -0
  201. data/bundler/lib/bundler/ui/shell.rb +6 -6
  202. data/bundler/lib/bundler/uri_credentials_filter.rb +3 -1
  203. data/bundler/lib/bundler/vendor/.document +1 -0
  204. data/bundler/lib/bundler/vendor/connection_pool/LICENSE +20 -0
  205. data/bundler/lib/bundler/vendor/connection_pool/lib/connection_pool/timed_stack.rb +19 -21
  206. data/bundler/lib/bundler/vendor/connection_pool/lib/connection_pool/version.rb +1 -1
  207. data/bundler/lib/bundler/vendor/connection_pool/lib/connection_pool/wrapper.rb +57 -0
  208. data/bundler/lib/bundler/vendor/connection_pool/lib/connection_pool.rb +39 -74
  209. data/bundler/lib/bundler/vendor/fileutils/LICENSE.txt +22 -0
  210. data/bundler/lib/bundler/vendor/molinillo/LICENSE +9 -0
  211. data/bundler/lib/bundler/vendor/molinillo/lib/molinillo/delegates/specification_provider.rb +7 -0
  212. data/bundler/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/tag.rb +2 -2
  213. data/bundler/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/vertex.rb +11 -5
  214. data/bundler/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph.rb +37 -5
  215. data/bundler/lib/bundler/vendor/molinillo/lib/molinillo/errors.rb +34 -28
  216. data/bundler/lib/bundler/vendor/molinillo/lib/molinillo/gem_metadata.rb +1 -1
  217. data/bundler/lib/bundler/vendor/molinillo/lib/molinillo/modules/specification_provider.rb +12 -1
  218. data/bundler/lib/bundler/vendor/molinillo/lib/molinillo/resolution.rb +49 -47
  219. data/bundler/lib/bundler/vendor/molinillo/lib/molinillo.rb +0 -1
  220. data/bundler/lib/bundler/vendor/net-http-persistent/README.rdoc +82 -0
  221. data/bundler/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent.rb +82 -189
  222. data/bundler/lib/bundler/vendor/thor/LICENSE.md +20 -0
  223. data/bundler/lib/bundler/vendor/thor/lib/thor/actions/create_link.rb +2 -1
  224. data/bundler/lib/bundler/vendor/thor/lib/thor/actions/file_manipulation.rb +9 -7
  225. data/bundler/lib/bundler/vendor/thor/lib/thor/actions/inject_into_file.rb +1 -2
  226. data/bundler/lib/bundler/vendor/thor/lib/thor/actions.rb +7 -3
  227. data/bundler/lib/bundler/vendor/thor/lib/thor/base.rb +9 -0
  228. data/bundler/lib/bundler/vendor/thor/lib/thor/core_ext/hash_with_indifferent_access.rb +6 -0
  229. data/bundler/lib/bundler/vendor/thor/lib/thor/error.rb +10 -5
  230. data/bundler/lib/bundler/vendor/thor/lib/thor/parser/arguments.rb +5 -1
  231. data/bundler/lib/bundler/vendor/thor/lib/thor/parser/options.rb +28 -9
  232. data/bundler/lib/bundler/vendor/thor/lib/thor/shell/basic.rb +27 -6
  233. data/bundler/lib/bundler/vendor/thor/lib/thor/shell/color.rb +5 -1
  234. data/bundler/lib/bundler/vendor/thor/lib/thor/shell.rb +1 -1
  235. data/bundler/lib/bundler/vendor/thor/lib/thor/util.rb +1 -1
  236. data/bundler/lib/bundler/vendor/thor/lib/thor/version.rb +1 -1
  237. data/bundler/lib/bundler/vendor/thor/lib/thor.rb +5 -13
  238. data/bundler/lib/bundler/vendor/tmpdir/lib/tmpdir.rb +154 -0
  239. data/bundler/lib/bundler/vendor/tsort/LICENSE.txt +22 -0
  240. data/bundler/lib/bundler/vendor/tsort/lib/tsort.rb +452 -0
  241. data/bundler/lib/bundler/vendor/uri/LICENSE.txt +22 -0
  242. data/bundler/lib/bundler/vendor/uri/lib/uri/common.rb +17 -80
  243. data/bundler/lib/bundler/vendor/uri/lib/uri/ftp.rb +0 -1
  244. data/bundler/lib/bundler/vendor/uri/lib/uri/generic.rb +5 -6
  245. data/bundler/lib/bundler/vendor/uri/lib/uri/http.rb +0 -1
  246. data/bundler/lib/bundler/vendor/uri/lib/uri/https.rb +0 -1
  247. data/bundler/lib/bundler/vendor/uri/lib/uri/ldap.rb +1 -1
  248. data/bundler/lib/bundler/vendor/uri/lib/uri/mailto.rb +0 -1
  249. data/bundler/lib/bundler/vendor/uri/lib/uri/rfc2396_parser.rb +1 -14
  250. data/bundler/lib/bundler/vendor/uri/lib/uri/rfc3986_parser.rb +1 -12
  251. data/bundler/lib/bundler/vendor/uri/lib/uri/version.rb +1 -1
  252. data/bundler/lib/bundler/vendor/uri/lib/uri/ws.rb +84 -0
  253. data/bundler/lib/bundler/vendor/uri/lib/uri/wss.rb +22 -0
  254. data/bundler/lib/bundler/vendor/uri/lib/uri.rb +0 -1
  255. data/bundler/lib/bundler/vendored_persistent.rb +0 -7
  256. data/bundler/lib/bundler/vendored_tmpdir.rb +4 -0
  257. data/bundler/lib/bundler/vendored_tsort.rb +4 -0
  258. data/bundler/lib/bundler/version.rb +1 -1
  259. data/bundler/lib/bundler/worker.rb +20 -5
  260. data/bundler/lib/bundler/yaml_serializer.rb +1 -1
  261. data/bundler/lib/bundler.rb +79 -47
  262. data/hide_lib_for_update/note.txt +0 -4
  263. data/lib/rubygems/available_set.rb +7 -9
  264. data/lib/rubygems/basic_specification.rb +23 -21
  265. data/lib/rubygems/bundler_version_finder.rb +26 -53
  266. data/lib/rubygems/command.rb +48 -45
  267. data/lib/rubygems/command_manager.rb +20 -14
  268. data/lib/rubygems/commands/build_command.rb +47 -27
  269. data/lib/rubygems/commands/cert_command.rb +78 -75
  270. data/lib/rubygems/commands/check_command.rb +20 -22
  271. data/lib/rubygems/commands/cleanup_command.rb +30 -26
  272. data/lib/rubygems/commands/contents_command.rb +16 -18
  273. data/lib/rubygems/commands/dependency_command.rb +39 -51
  274. data/lib/rubygems/commands/environment_command.rb +11 -10
  275. data/lib/rubygems/commands/fetch_command.rb +33 -16
  276. data/lib/rubygems/commands/generate_index_command.rb +17 -19
  277. data/lib/rubygems/commands/help_command.rb +6 -6
  278. data/lib/rubygems/commands/info_command.rb +10 -7
  279. data/lib/rubygems/commands/install_command.rb +29 -27
  280. data/lib/rubygems/commands/list_command.rb +9 -8
  281. data/lib/rubygems/commands/lock_command.rb +5 -7
  282. data/lib/rubygems/commands/mirror_command.rb +3 -5
  283. data/lib/rubygems/commands/open_command.rb +10 -14
  284. data/lib/rubygems/commands/outdated_command.rb +5 -7
  285. data/lib/rubygems/commands/owner_command.rb +26 -16
  286. data/lib/rubygems/commands/pristine_command.rb +61 -49
  287. data/lib/rubygems/commands/push_command.rb +22 -59
  288. data/lib/rubygems/commands/query_command.rb +21 -351
  289. data/lib/rubygems/commands/rdoc_command.rb +23 -25
  290. data/lib/rubygems/commands/search_command.rb +8 -8
  291. data/lib/rubygems/commands/server_command.rb +16 -77
  292. data/lib/rubygems/commands/setup_command.rb +255 -229
  293. data/lib/rubygems/commands/signin_command.rb +9 -11
  294. data/lib/rubygems/commands/signout_command.rb +7 -9
  295. data/lib/rubygems/commands/sources_command.rb +27 -25
  296. data/lib/rubygems/commands/specification_command.rb +25 -21
  297. data/lib/rubygems/commands/stale_command.rb +3 -5
  298. data/lib/rubygems/commands/uninstall_command.rb +41 -43
  299. data/lib/rubygems/commands/unpack_command.rb +13 -15
  300. data/lib/rubygems/commands/update_command.rb +132 -74
  301. data/lib/rubygems/commands/which_command.rb +7 -9
  302. data/lib/rubygems/commands/yank_command.rb +16 -19
  303. data/lib/rubygems/compatibility.rb +4 -2
  304. data/lib/rubygems/config_file.rb +42 -26
  305. data/lib/rubygems/core_ext/kernel_gem.rb +1 -1
  306. data/lib/rubygems/core_ext/kernel_require.rb +6 -3
  307. data/lib/rubygems/core_ext/kernel_warn.rb +12 -13
  308. data/lib/rubygems/core_ext/tcpsocket_init.rb +52 -0
  309. data/lib/rubygems/defaults.rb +108 -32
  310. data/lib/rubygems/dependency.rb +21 -22
  311. data/lib/rubygems/dependency_installer.rb +19 -91
  312. data/lib/rubygems/dependency_list.rb +13 -15
  313. data/lib/rubygems/deprecate.rb +102 -8
  314. data/lib/rubygems/doctor.rb +22 -22
  315. data/lib/rubygems/errors.rb +6 -21
  316. data/lib/rubygems/exceptions.rb +33 -34
  317. data/lib/rubygems/ext/build_error.rb +2 -0
  318. data/lib/rubygems/ext/builder.rb +48 -54
  319. data/lib/rubygems/ext/cargo_builder/link_flag_converter.rb +23 -0
  320. data/lib/rubygems/ext/cargo_builder.rb +321 -0
  321. data/lib/rubygems/ext/cmake_builder.rb +6 -9
  322. data/lib/rubygems/ext/configure_builder.rb +5 -8
  323. data/lib/rubygems/ext/ext_conf_builder.rb +42 -66
  324. data/lib/rubygems/ext/rake_builder.rb +7 -10
  325. data/lib/rubygems/ext.rb +7 -6
  326. data/lib/rubygems/gem_runner.rb +15 -26
  327. data/lib/rubygems/gemcutter_utilities.rb +153 -32
  328. data/lib/rubygems/indexer.rb +30 -49
  329. data/lib/rubygems/install_default_message.rb +2 -2
  330. data/lib/rubygems/install_message.rb +2 -2
  331. data/lib/rubygems/install_update_options.rb +73 -64
  332. data/lib/rubygems/installer.rb +194 -151
  333. data/lib/rubygems/installer_uninstaller_utils.rb +29 -0
  334. data/lib/rubygems/local_remote_options.rb +22 -24
  335. data/lib/rubygems/mock_gem_ui.rb +2 -8
  336. data/lib/rubygems/name_tuple.rb +9 -14
  337. data/lib/rubygems/openssl.rb +7 -0
  338. data/lib/rubygems/optparse/.document +1 -0
  339. data/lib/rubygems/optparse/COPYING +56 -0
  340. data/lib/rubygems/optparse/lib/optionparser.rb +2 -0
  341. data/lib/rubygems/optparse/lib/optparse/ac.rb +54 -0
  342. data/lib/rubygems/optparse/lib/optparse/date.rb +18 -0
  343. data/lib/rubygems/optparse/lib/optparse/kwargs.rb +22 -0
  344. data/lib/rubygems/optparse/lib/optparse/shellwords.rb +7 -0
  345. data/lib/rubygems/optparse/lib/optparse/time.rb +11 -0
  346. data/lib/rubygems/optparse/lib/optparse/uri.rb +7 -0
  347. data/lib/rubygems/optparse/lib/optparse/version.rb +71 -0
  348. data/lib/rubygems/optparse/lib/optparse.rb +2303 -0
  349. data/lib/rubygems/optparse.rb +3 -0
  350. data/lib/rubygems/package/digest_io.rb +0 -2
  351. data/lib/rubygems/package/file_source.rb +2 -4
  352. data/lib/rubygems/package/io_source.rb +4 -2
  353. data/lib/rubygems/package/old.rb +9 -11
  354. data/lib/rubygems/package/tar_header.rb +54 -56
  355. data/lib/rubygems/package/tar_reader/entry.rb +2 -5
  356. data/lib/rubygems/package/tar_reader.rb +1 -4
  357. data/lib/rubygems/package/tar_writer.rb +8 -18
  358. data/lib/rubygems/package.rb +101 -117
  359. data/lib/rubygems/package_task.rb +5 -11
  360. data/lib/rubygems/path_support.rb +2 -9
  361. data/lib/rubygems/platform.rb +101 -76
  362. data/lib/rubygems/psych_tree.rb +1 -3
  363. data/lib/rubygems/query_utils.rb +351 -0
  364. data/lib/rubygems/rdoc.rb +2 -14
  365. data/lib/rubygems/remote_fetcher.rb +48 -74
  366. data/lib/rubygems/request/connection_pools.rb +6 -10
  367. data/lib/rubygems/request/http_pool.rb +2 -4
  368. data/lib/rubygems/request/https_pool.rb +0 -2
  369. data/lib/rubygems/request.rb +26 -31
  370. data/lib/rubygems/request_set/gem_dependency_api.rb +23 -25
  371. data/lib/rubygems/request_set/lockfile/parser.rb +26 -28
  372. data/lib/rubygems/request_set/lockfile/tokenizer.rb +5 -7
  373. data/lib/rubygems/request_set/lockfile.rb +17 -21
  374. data/lib/rubygems/request_set.rb +27 -40
  375. data/lib/rubygems/requirement.rb +28 -48
  376. data/lib/rubygems/resolver/activation_request.rb +12 -6
  377. data/lib/rubygems/resolver/api_set/gem_parser.rb +20 -0
  378. data/lib/rubygems/resolver/api_set.rb +32 -25
  379. data/lib/rubygems/resolver/api_specification.rb +29 -15
  380. data/lib/rubygems/resolver/best_set.rb +7 -9
  381. data/lib/rubygems/resolver/composed_set.rb +3 -5
  382. data/lib/rubygems/resolver/conflict.rb +12 -14
  383. data/lib/rubygems/resolver/current_set.rb +0 -2
  384. data/lib/rubygems/resolver/dependency_request.rb +3 -5
  385. data/lib/rubygems/resolver/git_set.rb +2 -4
  386. data/lib/rubygems/resolver/git_specification.rb +6 -8
  387. data/lib/rubygems/resolver/index_set.rb +4 -6
  388. data/lib/rubygems/resolver/index_specification.rb +38 -7
  389. data/lib/rubygems/resolver/installed_specification.rb +4 -6
  390. data/lib/rubygems/resolver/installer_set.rb +66 -24
  391. data/lib/rubygems/resolver/local_specification.rb +2 -4
  392. data/lib/rubygems/resolver/lock_set.rb +6 -8
  393. data/lib/rubygems/resolver/lock_specification.rb +4 -6
  394. data/lib/rubygems/resolver/molinillo/LICENSE +9 -0
  395. data/lib/rubygems/resolver/molinillo/lib/molinillo/delegates/resolution_state.rb +7 -0
  396. data/lib/rubygems/resolver/molinillo/lib/molinillo/delegates/specification_provider.rb +8 -0
  397. data/lib/rubygems/resolver/molinillo/lib/molinillo/dependency_graph/action.rb +1 -0
  398. data/lib/rubygems/resolver/molinillo/lib/molinillo/dependency_graph/add_edge_no_circular.rb +2 -1
  399. data/lib/rubygems/resolver/molinillo/lib/molinillo/dependency_graph/add_vertex.rb +2 -1
  400. data/lib/rubygems/resolver/molinillo/lib/molinillo/dependency_graph/delete_edge.rb +2 -1
  401. data/lib/rubygems/resolver/molinillo/lib/molinillo/dependency_graph/detach_vertex_named.rb +2 -1
  402. data/lib/rubygems/resolver/molinillo/lib/molinillo/dependency_graph/log.rb +7 -6
  403. data/lib/rubygems/resolver/molinillo/lib/molinillo/dependency_graph/set_payload.rb +2 -1
  404. data/lib/rubygems/resolver/molinillo/lib/molinillo/dependency_graph/tag.rb +4 -3
  405. data/lib/rubygems/resolver/molinillo/lib/molinillo/dependency_graph/vertex.rb +51 -12
  406. data/lib/rubygems/resolver/molinillo/lib/molinillo/dependency_graph.rb +41 -8
  407. data/lib/rubygems/resolver/molinillo/lib/molinillo/errors.rb +76 -8
  408. data/lib/rubygems/resolver/molinillo/lib/molinillo/gem_metadata.rb +2 -1
  409. data/lib/rubygems/resolver/molinillo/lib/molinillo/modules/specification_provider.rb +13 -1
  410. data/lib/rubygems/resolver/molinillo/lib/molinillo/modules/ui.rb +3 -1
  411. data/lib/rubygems/resolver/molinillo/lib/molinillo/resolution.rb +510 -165
  412. data/lib/rubygems/resolver/molinillo/lib/molinillo/resolver.rb +3 -2
  413. data/lib/rubygems/resolver/molinillo/lib/molinillo/state.rb +8 -4
  414. data/lib/rubygems/resolver/molinillo/lib/molinillo.rb +6 -5
  415. data/lib/rubygems/resolver/molinillo.rb +1 -1
  416. data/lib/rubygems/resolver/requirement_list.rb +0 -2
  417. data/lib/rubygems/resolver/set.rb +0 -3
  418. data/lib/rubygems/resolver/source_set.rb +0 -2
  419. data/lib/rubygems/resolver/spec_specification.rb +14 -2
  420. data/lib/rubygems/resolver/specification.rb +14 -4
  421. data/lib/rubygems/resolver/stats.rb +0 -2
  422. data/lib/rubygems/resolver/vendor_set.rb +1 -3
  423. data/lib/rubygems/resolver/vendor_specification.rb +3 -5
  424. data/lib/rubygems/resolver.rb +53 -51
  425. data/lib/rubygems/s3_uri_signer.rb +7 -15
  426. data/lib/rubygems/safe_yaml.rb +14 -16
  427. data/lib/rubygems/security/policies.rb +11 -11
  428. data/lib/rubygems/security/policy.rb +25 -29
  429. data/lib/rubygems/security/signer.rb +13 -16
  430. data/lib/rubygems/security/trust_dir.rb +4 -5
  431. data/lib/rubygems/security.rb +103 -69
  432. data/lib/rubygems/security_option.rb +7 -7
  433. data/lib/rubygems/source/git.rb +30 -30
  434. data/lib/rubygems/source/installed.rb +1 -3
  435. data/lib/rubygems/source/local.rb +4 -6
  436. data/lib/rubygems/source/lock.rb +0 -2
  437. data/lib/rubygems/source/specific_file.rb +1 -3
  438. data/lib/rubygems/source/vendor.rb +0 -2
  439. data/lib/rubygems/source.rb +44 -38
  440. data/lib/rubygems/source_list.rb +9 -16
  441. data/lib/rubygems/spec_fetcher.rb +49 -48
  442. data/lib/rubygems/specification.rb +338 -295
  443. data/lib/rubygems/specification_policy.rb +112 -61
  444. data/lib/rubygems/stub_specification.rb +21 -28
  445. data/lib/rubygems/text.rb +21 -20
  446. data/lib/rubygems/tsort/.document +1 -0
  447. data/lib/rubygems/tsort/LICENSE.txt +22 -0
  448. data/lib/rubygems/tsort/lib/tsort.rb +454 -0
  449. data/lib/rubygems/tsort.rb +3 -0
  450. data/lib/rubygems/uninstaller.rb +98 -45
  451. data/lib/rubygems/unknown_command_spell_checker.rb +21 -0
  452. data/lib/rubygems/uri.rb +126 -0
  453. data/lib/rubygems/uri_formatter.rb +2 -3
  454. data/lib/rubygems/user_interaction.rb +43 -54
  455. data/lib/rubygems/util/licenses.rb +115 -10
  456. data/lib/rubygems/util/list.rb +0 -2
  457. data/lib/rubygems/util.rb +18 -12
  458. data/lib/rubygems/validator.rb +6 -8
  459. data/lib/rubygems/version.rb +29 -20
  460. data/lib/rubygems/version_option.rb +11 -5
  461. data/lib/rubygems.rb +192 -289
  462. data/rubygems-update.gemspec +4 -4
  463. data/setup.rb +11 -22
  464. data/test/rubygems/data/excon-0.7.7.gemspec.rz +0 -0
  465. data/test/rubygems/data/null-required-ruby-version.gemspec.rz +0 -0
  466. data/test/rubygems/data/null-required-rubygems-version.gemspec.rz +0 -0
  467. data/test/rubygems/data/pry-0.4.7.gemspec.rz +0 -0
  468. data/test/rubygems/encrypted_private_key.pem +26 -26
  469. data/{lib/rubygems/test_case.rb → test/rubygems/helper.rb} +380 -314
  470. data/{lib → test}/rubygems/installer_test_case.rb +38 -24
  471. data/{lib → test}/rubygems/package/tar_test_case.rb +4 -6
  472. data/test/rubygems/packages/ascii_binder-0.1.10.1.gem +0 -0
  473. data/test/rubygems/packages/ill-formatted-platform-1.0.0.10.gem +0 -0
  474. data/test/rubygems/plugin/exception/rubygems_plugin.rb +1 -1
  475. data/test/rubygems/plugin/load/rubygems_plugin.rb +0 -2
  476. data/test/rubygems/plugin/standarderror/rubygems_plugin.rb +1 -1
  477. data/test/rubygems/private_ec_key.pem +9 -0
  478. data/test/rubygems/rubygems/commands/crash_command.rb +0 -2
  479. data/test/rubygems/rubygems_plugin.rb +2 -4
  480. data/test/rubygems/specifications/bar-0.0.2.gemspec +0 -2
  481. data/test/rubygems/specifications/rubyforge-0.0.1.gemspec +4 -6
  482. data/test/rubygems/test_bundled_ca.rb +43 -50
  483. data/test/rubygems/test_config.rb +5 -7
  484. data/test/rubygems/test_deprecate.rb +87 -10
  485. data/test/rubygems/test_exit.rb +11 -0
  486. data/test/rubygems/test_gem.rb +719 -639
  487. data/test/rubygems/test_gem_available_set.rb +24 -26
  488. data/test/rubygems/test_gem_bundler_version_finder.rb +37 -44
  489. data/test/rubygems/test_gem_command.rb +78 -49
  490. data/test/rubygems/test_gem_command_manager.rb +98 -35
  491. data/test/rubygems/test_gem_commands_build_command.rb +275 -57
  492. data/test/rubygems/test_gem_commands_cert_command.rb +180 -125
  493. data/test/rubygems/test_gem_commands_check_command.rb +9 -11
  494. data/test/rubygems/test_gem_commands_cleanup_command.rb +78 -69
  495. data/test/rubygems/test_gem_commands_contents_command.rb +73 -42
  496. data/test/rubygems/test_gem_commands_dependency_command.rb +38 -40
  497. data/test/rubygems/test_gem_commands_environment_command.rb +60 -38
  498. data/test/rubygems/test_gem_commands_fetch_command.rb +163 -32
  499. data/test/rubygems/test_gem_commands_generate_index_command.rb +8 -14
  500. data/test/rubygems/test_gem_commands_help_command.rb +34 -16
  501. data/test/rubygems/test_gem_commands_info_command.rb +33 -9
  502. data/test/rubygems/test_gem_commands_install_command.rb +401 -198
  503. data/test/rubygems/test_gem_commands_list_command.rb +5 -7
  504. data/test/rubygems/test_gem_commands_lock_command.rb +11 -13
  505. data/test/rubygems/test_gem_commands_mirror.rb +3 -5
  506. data/test/rubygems/test_gem_commands_open_command.rb +16 -19
  507. data/test/rubygems/test_gem_commands_outdated_command.rb +23 -7
  508. data/test/rubygems/test_gem_commands_owner_command.rb +100 -46
  509. data/test/rubygems/test_gem_commands_pristine_command.rb +131 -99
  510. data/test/rubygems/test_gem_commands_push_command.rb +134 -66
  511. data/test/rubygems/test_gem_commands_query_command.rb +91 -91
  512. data/test/rubygems/test_gem_commands_search_command.rb +2 -4
  513. data/test/rubygems/test_gem_commands_server_command.rb +6 -50
  514. data/test/rubygems/test_gem_commands_setup_command.rb +288 -179
  515. data/test/rubygems/test_gem_commands_signin_command.rb +162 -28
  516. data/test/rubygems/test_gem_commands_signout_command.rb +3 -10
  517. data/test/rubygems/test_gem_commands_sources_command.rb +139 -32
  518. data/test/rubygems/test_gem_commands_specification_command.rb +81 -55
  519. data/test/rubygems/test_gem_commands_stale_command.rb +4 -6
  520. data/test/rubygems/test_gem_commands_uninstall_command.rb +80 -82
  521. data/test/rubygems/test_gem_commands_unpack_command.rb +32 -34
  522. data/test/rubygems/test_gem_commands_update_command.rb +335 -88
  523. data/test/rubygems/test_gem_commands_which_command.rb +12 -14
  524. data/test/rubygems/test_gem_commands_yank_command.rb +80 -44
  525. data/test/rubygems/test_gem_config_file.rb +114 -97
  526. data/test/rubygems/test_gem_dependency.rb +87 -87
  527. data/test/rubygems/test_gem_dependency_installer.rb +277 -391
  528. data/test/rubygems/test_gem_dependency_list.rb +57 -59
  529. data/test/rubygems/test_gem_dependency_resolution_error.rb +5 -7
  530. data/test/rubygems/test_gem_doctor.rb +73 -47
  531. data/test/rubygems/test_gem_ext_builder.rb +115 -109
  532. data/test/rubygems/test_gem_ext_cargo_builder/custom_name/.gitignore +1 -0
  533. data/test/rubygems/test_gem_ext_cargo_builder/custom_name/Cargo.lock +243 -0
  534. data/test/rubygems/test_gem_ext_cargo_builder/custom_name/Cargo.toml +10 -0
  535. data/test/rubygems/test_gem_ext_cargo_builder/custom_name/build.rb +21 -0
  536. data/test/rubygems/test_gem_ext_cargo_builder/custom_name/custom_name.gemspec +10 -0
  537. data/test/rubygems/test_gem_ext_cargo_builder/custom_name/src/lib.rs +27 -0
  538. data/test/rubygems/test_gem_ext_cargo_builder/rust_ruby_example/.gitignore +1 -0
  539. data/test/rubygems/test_gem_ext_cargo_builder/rust_ruby_example/Cargo.lock +243 -0
  540. data/test/rubygems/test_gem_ext_cargo_builder/rust_ruby_example/Cargo.toml +10 -0
  541. data/test/rubygems/test_gem_ext_cargo_builder/rust_ruby_example/build.rb +21 -0
  542. data/test/rubygems/test_gem_ext_cargo_builder/rust_ruby_example/rust_ruby_example.gemspec +8 -0
  543. data/test/rubygems/test_gem_ext_cargo_builder/rust_ruby_example/src/lib.rs +39 -0
  544. data/test/rubygems/test_gem_ext_cargo_builder.rb +178 -0
  545. data/test/rubygems/test_gem_ext_cargo_builder_link_flag_converter.rb +33 -0
  546. data/test/rubygems/test_gem_ext_cargo_builder_unit.rb +75 -0
  547. data/test/rubygems/test_gem_ext_cmake_builder.rb +31 -38
  548. data/test/rubygems/test_gem_ext_configure_builder.rb +23 -39
  549. data/test/rubygems/test_gem_ext_ext_conf_builder.rb +66 -82
  550. data/test/rubygems/test_gem_ext_rake_builder.rb +49 -32
  551. data/test/rubygems/test_gem_gem_runner.rb +51 -8
  552. data/test/rubygems/test_gem_gemcutter_utilities.rb +87 -76
  553. data/test/rubygems/test_gem_impossible_dependencies_error.rb +4 -6
  554. data/test/rubygems/test_gem_indexer.rb +62 -64
  555. data/test/rubygems/test_gem_install_update_options.rb +31 -21
  556. data/test/rubygems/test_gem_installer.rb +798 -491
  557. data/test/rubygems/test_gem_local_remote_options.rb +11 -13
  558. data/test/rubygems/test_gem_name_tuple.rb +4 -6
  559. data/test/rubygems/test_gem_package.rb +318 -283
  560. data/test/rubygems/test_gem_package_old.rb +18 -20
  561. data/test/rubygems/test_gem_package_tar_header.rb +64 -47
  562. data/test/rubygems/test_gem_package_tar_reader.rb +8 -10
  563. data/test/rubygems/test_gem_package_tar_reader_entry.rb +18 -20
  564. data/test/rubygems/test_gem_package_tar_writer.rb +96 -100
  565. data/test/rubygems/test_gem_package_task.rb +58 -25
  566. data/test/rubygems/test_gem_path_support.rb +15 -21
  567. data/test/rubygems/test_gem_platform.rb +354 -201
  568. data/test/rubygems/test_gem_rdoc.rb +19 -21
  569. data/test/rubygems/test_gem_remote_fetcher.rb +376 -337
  570. data/test/rubygems/test_gem_request.rb +114 -86
  571. data/test/rubygems/test_gem_request_connection_pools.rb +30 -34
  572. data/test/rubygems/test_gem_request_set.rb +123 -124
  573. data/test/rubygems/test_gem_request_set_gem_dependency_api.rb +222 -226
  574. data/test/rubygems/test_gem_request_set_lockfile.rb +93 -95
  575. data/test/rubygems/test_gem_request_set_lockfile_parser.rb +68 -70
  576. data/test/rubygems/test_gem_request_set_lockfile_tokenizer.rb +136 -138
  577. data/test/rubygems/test_gem_requirement.rb +133 -54
  578. data/test/rubygems/test_gem_resolver.rb +149 -117
  579. data/test/rubygems/test_gem_resolver_activation_request.rb +6 -8
  580. data/test/rubygems/test_gem_resolver_api_set.rb +79 -78
  581. data/test/rubygems/test_gem_resolver_api_specification.rb +47 -49
  582. data/test/rubygems/test_gem_resolver_best_set.rb +43 -22
  583. data/test/rubygems/test_gem_resolver_composed_set.rb +1 -3
  584. data/test/rubygems/test_gem_resolver_conflict.rb +12 -14
  585. data/test/rubygems/test_gem_resolver_dependency_request.rb +15 -17
  586. data/test/rubygems/test_gem_resolver_git_set.rb +22 -24
  587. data/test/rubygems/test_gem_resolver_git_specification.rb +22 -23
  588. data/test/rubygems/test_gem_resolver_index_set.rb +14 -16
  589. data/test/rubygems/test_gem_resolver_index_specification.rb +16 -18
  590. data/test/rubygems/test_gem_resolver_installed_specification.rb +5 -7
  591. data/test/rubygems/test_gem_resolver_installer_set.rb +104 -44
  592. data/test/rubygems/test_gem_resolver_local_specification.rb +7 -9
  593. data/test/rubygems/test_gem_resolver_lock_set.rb +15 -17
  594. data/test/rubygems/test_gem_resolver_lock_specification.rb +17 -19
  595. data/test/rubygems/test_gem_resolver_requirement_list.rb +1 -3
  596. data/test/rubygems/test_gem_resolver_specification.rb +8 -12
  597. data/test/rubygems/test_gem_resolver_vendor_set.rb +9 -11
  598. data/test/rubygems/test_gem_resolver_vendor_specification.rb +10 -12
  599. data/test/rubygems/test_gem_security.rb +104 -78
  600. data/test/rubygems/test_gem_security_policy.rb +92 -97
  601. data/test/rubygems/test_gem_security_signer.rb +45 -47
  602. data/test/rubygems/test_gem_security_trust_dir.rb +12 -14
  603. data/test/rubygems/test_gem_silent_ui.rb +46 -42
  604. data/test/rubygems/test_gem_source.rb +53 -52
  605. data/test/rubygems/test_gem_source_fetch_problem.rb +16 -8
  606. data/test/rubygems/test_gem_source_git.rb +69 -69
  607. data/test/rubygems/test_gem_source_installed.rb +16 -18
  608. data/test/rubygems/test_gem_source_list.rb +5 -6
  609. data/test/rubygems/test_gem_source_local.rb +15 -17
  610. data/test/rubygems/test_gem_source_lock.rb +31 -33
  611. data/test/rubygems/test_gem_source_specific_file.rb +18 -20
  612. data/test/rubygems/test_gem_source_subpath_problem.rb +49 -0
  613. data/test/rubygems/test_gem_source_vendor.rb +13 -15
  614. data/test/rubygems/test_gem_spec_fetcher.rb +74 -67
  615. data/test/rubygems/test_gem_specification.rb +888 -1024
  616. data/test/rubygems/test_gem_stream_ui.rb +23 -23
  617. data/test/rubygems/test_gem_stub_specification.rb +39 -57
  618. data/test/rubygems/test_gem_text.rb +8 -4
  619. data/test/rubygems/test_gem_uninstaller.rb +233 -104
  620. data/test/rubygems/test_gem_unsatisfiable_dependency_error.rb +3 -5
  621. data/test/rubygems/test_gem_uri.rb +39 -0
  622. data/test/rubygems/test_gem_uri_formatter.rb +14 -16
  623. data/test/rubygems/test_gem_util.rb +37 -35
  624. data/test/rubygems/test_gem_validator.rb +10 -12
  625. data/test/rubygems/test_gem_version.rb +31 -31
  626. data/test/rubygems/test_gem_version_option.rb +16 -18
  627. data/test/rubygems/test_kernel.rb +46 -60
  628. data/test/rubygems/test_project_sanity.rb +8 -3
  629. data/test/rubygems/test_remote_fetch_error.rb +7 -9
  630. data/test/rubygems/test_require.rb +240 -167
  631. data/test/rubygems/test_rubygems.rb +74 -0
  632. data/{lib/rubygems/test_utilities.rb → test/rubygems/utilities.rb} +30 -39
  633. data/test/test_changelog_generator.rb +17 -0
  634. metadata +158 -146
  635. data/.bundle/config +0 -2
  636. data/.rubocop.yml +0 -91
  637. data/Gemfile +0 -8
  638. data/Gemfile.lock +0 -43
  639. data/Rakefile +0 -428
  640. data/bundler/CODE_OF_CONDUCT.md +0 -136
  641. data/bundler/lib/bundler/gemdeps.rb +0 -29
  642. data/bundler/lib/bundler/psyched_yaml.rb +0 -37
  643. data/bundler/lib/bundler/vendor/connection_pool/lib/connection_pool/monotonic_time.rb +0 -66
  644. data/bundler/lib/bundler/vendor/molinillo/lib/molinillo/compatibility.rb +0 -26
  645. data/bundler/man/bundle-add.1.txt +0 -58
  646. data/bundler/man/bundle-binstubs.1.txt +0 -48
  647. data/bundler/man/bundle-cache.1.txt +0 -78
  648. data/bundler/man/bundle-check.1.txt +0 -33
  649. data/bundler/man/bundle-clean.1.txt +0 -26
  650. data/bundler/man/bundle-config.1.txt +0 -528
  651. data/bundler/man/bundle-doctor.1.txt +0 -44
  652. data/bundler/man/bundle-exec.1.txt +0 -178
  653. data/bundler/man/bundle-gem.1.txt +0 -91
  654. data/bundler/man/bundle-info.1.txt +0 -21
  655. data/bundler/man/bundle-init.1.txt +0 -34
  656. data/bundler/man/bundle-inject.1.txt +0 -32
  657. data/bundler/man/bundle-install.1.txt +0 -401
  658. data/bundler/man/bundle-list.1.txt +0 -43
  659. data/bundler/man/bundle-lock.1.txt +0 -93
  660. data/bundler/man/bundle-open.1.txt +0 -29
  661. data/bundler/man/bundle-outdated.1.txt +0 -131
  662. data/bundler/man/bundle-platform.1.txt +0 -57
  663. data/bundler/man/bundle-pristine.1.txt +0 -44
  664. data/bundler/man/bundle-remove.1.txt +0 -34
  665. data/bundler/man/bundle-show.1.txt +0 -27
  666. data/bundler/man/bundle-update.1.txt +0 -390
  667. data/bundler/man/bundle-viz.1.txt +0 -39
  668. data/bundler/man/bundle.1.txt +0 -116
  669. data/bundler/man/gemfile.5.txt +0 -649
  670. data/lib/rubygems/psych_additions.rb +0 -10
  671. data/lib/rubygems/server.rb +0 -879
  672. data/lib/rubygems/source_local.rb +0 -7
  673. data/lib/rubygems/source_specific_file.rb +0 -6
  674. data/lib/rubygems/syck_hack.rb +0 -79
  675. data/lib/rubygems/uri_parser.rb +0 -36
  676. data/lib/rubygems/uri_parsing.rb +0 -23
  677. data/lib/ubygems.rb +0 -14
  678. data/test/rubygems/bogussources.rb +0 -9
  679. data/test/rubygems/data/null-type.gemspec.rz +0 -0
  680. data/test/rubygems/test_gem_server.rb +0 -612
  681. data/tmp/.keep +0 -0
  682. data/util/CL2notes +0 -55
  683. data/util/bisect +0 -10
  684. data/util/ci.sh +0 -62
  685. data/util/cops/deprecations.rb +0 -52
  686. data/util/create_certs.rb +0 -171
  687. data/util/create_certs.sh +0 -27
  688. data/util/create_encrypted_key.rb +0 -16
  689. data/util/generate_spdx_license_list.rb +0 -63
  690. data/util/patch_with_prs.rb +0 -77
  691. data/util/rubocop +0 -8
  692. data/util/update_bundled_ca_certificates.rb +0 -137
  693. data/util/update_changelog.rb +0 -64
  694. /data/bundler/{man/bundle-check.ronn → lib/bundler/man/bundle-check.1.ronn} +0 -0
  695. /data/bundler/{man/bundle-clean.ronn → lib/bundler/man/bundle-clean.1.ronn} +0 -0
  696. /data/bundler/{man/bundle-doctor.ronn → lib/bundler/man/bundle-doctor.1.ronn} +0 -0
  697. /data/bundler/{man/bundle-info.ronn → lib/bundler/man/bundle-info.1.ronn} +0 -0
  698. /data/bundler/{man/bundle-init.ronn → lib/bundler/man/bundle-init.1.ronn} +0 -0
  699. /data/bundler/{man/bundle-lock.ronn → lib/bundler/man/bundle-lock.1.ronn} +0 -0
  700. /data/bundler/{man/bundle-open.ronn → lib/bundler/man/bundle-open.1.ronn} +0 -0
  701. /data/bundler/{man/bundle-pristine.ronn → lib/bundler/man/bundle-pristine.1.ronn} +0 -0
  702. /data/bundler/{man/bundle-remove.ronn → lib/bundler/man/bundle-remove.1.ronn} +0 -0
  703. /data/bundler/{man/bundle-show.ronn → lib/bundler/man/bundle-show.1.ronn} +0 -0
@@ -1,26 +1,7 @@
1
1
  # frozen_string_literal: true
2
- require 'rubygems/installer_test_case'
2
+ require_relative "installer_test_case"
3
3
 
4
4
  class TestGemInstaller < Gem::InstallerTestCase
5
-
6
- @@symlink_supported = nil
7
-
8
- # Our CI does not currently hit the "symlink not supported" case, but this is
9
- # needed for Windows developers without symlink support enabled (the default
10
- # for non admin) to be able to run the tests successfully
11
- def symlink_supported?
12
- if @@symlink_supported.nil?
13
- begin
14
- File.symlink("", "")
15
- rescue Errno::ENOENT, Errno::EEXIST
16
- @@symlink_supported = true
17
- rescue NotImplementedError, SystemCallError
18
- @@symlink_supported = false
19
- end
20
- end
21
- @@symlink_supported
22
- end
23
-
24
5
  def setup
25
6
  super
26
7
  common_installer_setup
@@ -37,11 +18,12 @@ class TestGemInstaller < Gem::InstallerTestCase
37
18
  end
38
19
 
39
20
  def test_app_script_text
40
- installer = setup_base_installer
21
+ load_relative "no" do
22
+ installer = setup_base_installer
41
23
 
42
- util_make_exec @spec, ''
24
+ util_make_exec @spec, ""
43
25
 
44
- expected = <<-EOF
26
+ expected = <<-EOF
45
27
  #!#{Gem.ruby}
46
28
  #
47
29
  # This file was generated by RubyGems.
@@ -52,6 +34,8 @@ class TestGemInstaller < Gem::InstallerTestCase
52
34
 
53
35
  require 'rubygems'
54
36
 
37
+ Gem.use_gemdeps
38
+
55
39
  version = \">= 0.a\"
56
40
 
57
41
  str = ARGV.first
@@ -69,10 +53,11 @@ else
69
53
  gem "a", version
70
54
  load Gem.bin_path("a", "executable", version)
71
55
  end
72
- EOF
56
+ EOF
73
57
 
74
- wrapper = installer.app_script_text 'executable'
75
- assert_equal expected, wrapper
58
+ wrapper = installer.app_script_text "executable"
59
+ assert_equal expected, wrapper
60
+ end
76
61
  end
77
62
 
78
63
  def test_check_executable_overwrite
@@ -81,12 +66,12 @@ end
81
66
  installer.generate_bin
82
67
 
83
68
  @spec = Gem::Specification.new do |s|
84
- s.files = ['lib/code.rb']
69
+ s.files = ["lib/code.rb"]
85
70
  s.name = "a"
86
71
  s.version = "3"
87
72
  s.summary = "summary"
88
73
  s.description = "desc"
89
- s.require_path = 'lib'
74
+ s.require_path = "lib"
90
75
  end
91
76
 
92
77
  util_make_exec
@@ -94,27 +79,27 @@ end
94
79
  installer.wrappers = true
95
80
  installer.generate_bin
96
81
 
97
- installed_exec = File.join util_inst_bindir, 'executable'
98
- assert_path_exists installed_exec
82
+ installed_exec = File.join util_inst_bindir, "executable"
83
+ assert_path_exist installed_exec
99
84
 
100
85
  wrapper = File.read installed_exec
101
- assert_match %r|generated by RubyGems|, wrapper
86
+ assert_match %r{generated by RubyGems}, wrapper
102
87
  end
103
88
 
104
89
  def test_check_executable_overwrite_default_bin_dir
105
- installer = setup_base_installer
90
+ installer = setup_base_installer(false)
106
91
 
107
92
  bindir(Gem.bindir) do
108
93
  util_conflict_executable false
109
94
 
110
95
  ui = Gem::MockGemUi.new "n\n"
111
96
  use_ui ui do
112
- e = assert_raises Gem::InstallError do
97
+ e = assert_raise Gem::InstallError do
113
98
  installer.generate_bin
114
99
  end
115
100
 
116
- conflicted = File.join @gemhome, 'bin', 'executable'
117
- assert_match %r%\A"executable" from a conflicts with (?:#{Regexp.quote(conflicted)}|installed executable from conflict)\z%,
101
+ conflicted = File.join @gemhome, "bin", "executable"
102
+ assert_match %r{\A"executable" from a conflicts with (?:#{Regexp.quote(conflicted)}|installed executable from conflict)\z},
118
103
  e.message
119
104
  end
120
105
  end
@@ -126,15 +111,15 @@ end
126
111
  installer.generate_bin
127
112
 
128
113
  @spec = Gem::Specification.new do |s|
129
- s.files = ['lib/code.rb']
114
+ s.files = ["lib/code.rb"]
130
115
  s.name = "a"
131
116
  s.version = "3"
132
117
  s.summary = "summary"
133
118
  s.description = "desc"
134
- s.require_path = 'lib'
119
+ s.require_path = "lib"
135
120
  end
136
121
 
137
- File.open File.join(util_inst_bindir, 'executable'), 'w' do |io|
122
+ File.open File.join(util_inst_bindir, "executable"), "w" do |io|
138
123
  io.write <<-EXEC
139
124
  #!/usr/local/bin/ruby
140
125
  #
@@ -145,31 +130,31 @@ gem 'other', version
145
130
  end
146
131
 
147
132
  util_make_exec
148
- Gem::Installer.exec_format = 'foo-%s-bar'
133
+ Gem::Installer.exec_format = "foo-%s-bar"
149
134
  installer.gem_dir = @spec.gem_dir
150
135
  installer.wrappers = true
151
136
  installer.format_executable = true
152
137
 
153
138
  installer.generate_bin # should not raise
154
139
 
155
- installed_exec = File.join util_inst_bindir, 'foo-executable-bar'
156
- assert_path_exists installed_exec
140
+ installed_exec = File.join util_inst_bindir, "foo-executable-bar"
141
+ assert_path_exist installed_exec
157
142
 
158
143
  wrapper = File.read installed_exec
159
- assert_match %r|generated by RubyGems|, wrapper
144
+ assert_match %r{generated by RubyGems}, wrapper
160
145
  ensure
161
146
  Gem::Installer.exec_format = nil
162
147
  end
163
148
 
164
149
  def test_check_executable_overwrite_other_gem
165
- installer = setup_base_installer
150
+ installer = setup_base_installer(false)
166
151
 
167
152
  util_conflict_executable true
168
153
 
169
154
  ui = Gem::MockGemUi.new "n\n"
170
155
 
171
156
  use_ui ui do
172
- e = assert_raises Gem::InstallError do
157
+ e = assert_raise Gem::InstallError do
173
158
  installer.generate_bin
174
159
  end
175
160
 
@@ -187,11 +172,11 @@ gem 'other', version
187
172
 
188
173
  installer.generate_bin
189
174
 
190
- installed_exec = File.join util_inst_bindir, 'executable'
191
- assert_path_exists installed_exec
175
+ installed_exec = File.join util_inst_bindir, "executable"
176
+ assert_path_exist installed_exec
192
177
 
193
178
  wrapper = File.read installed_exec
194
- assert_match %r|generated by RubyGems|, wrapper
179
+ assert_match %r{generated by RubyGems}, wrapper
195
180
  end
196
181
 
197
182
  def test_check_executable_overwrite_other_non_gem
@@ -202,11 +187,11 @@ gem 'other', version
202
187
 
203
188
  installer.generate_bin
204
189
 
205
- installed_exec = File.join util_inst_bindir, 'executable'
206
- assert_path_exists installed_exec
190
+ installed_exec = File.join util_inst_bindir, "executable"
191
+ assert_path_exist installed_exec
207
192
 
208
193
  wrapper = File.read installed_exec
209
- assert_match %r|generated by RubyGems|, wrapper
194
+ assert_match %r{generated by RubyGems}, wrapper
210
195
  end unless Gem.win_platform?
211
196
 
212
197
  def test_check_that_user_bin_dir_is_in_path
@@ -215,11 +200,21 @@ gem 'other', version
215
200
  bin_dir = installer.bin_dir
216
201
 
217
202
  if Gem.win_platform?
218
- bin_dir = bin_dir.downcase.gsub(File::SEPARATOR, File::ALT_SEPARATOR)
203
+ bin_dir = bin_dir.downcase
204
+ end
205
+
206
+ orig_PATH, ENV["PATH"] =
207
+ ENV["PATH"], [ENV["PATH"], bin_dir].join(File::PATH_SEPARATOR)
208
+
209
+ use_ui @ui do
210
+ installer.check_that_user_bin_dir_is_in_path
219
211
  end
220
212
 
221
- orig_PATH, ENV['PATH'] =
222
- ENV['PATH'], [ENV['PATH'], bin_dir].join(File::PATH_SEPARATOR)
213
+ assert_empty @ui.error
214
+
215
+ return unless win_platform?
216
+
217
+ ENV["PATH"] = [orig_PATH, bin_dir.tr(File::SEPARATOR, File::ALT_SEPARATOR)].join(File::PATH_SEPARATOR)
223
218
 
224
219
  use_ui @ui do
225
220
  installer.check_that_user_bin_dir_is_in_path
@@ -227,17 +222,17 @@ gem 'other', version
227
222
 
228
223
  assert_empty @ui.error
229
224
  ensure
230
- ENV['PATH'] = orig_PATH
225
+ ENV["PATH"] = orig_PATH
231
226
  end
232
227
 
233
228
  def test_check_that_user_bin_dir_is_in_path_tilde
234
- skip "Tilde is PATH is not supported under MS Windows" if win_platform?
229
+ pend "Tilde is PATH is not supported under MS Windows" if win_platform?
235
230
 
236
- orig_PATH, ENV['PATH'] =
237
- ENV['PATH'], [ENV['PATH'], '~/bin'].join(File::PATH_SEPARATOR)
231
+ orig_PATH, ENV["PATH"] =
232
+ ENV["PATH"], [ENV["PATH"], "~/bin"].join(File::PATH_SEPARATOR)
238
233
 
239
234
  installer = setup_base_installer
240
- installer.bin_dir.replace File.join @userhome, 'bin'
235
+ installer.bin_dir.replace File.join @userhome, "bin"
241
236
 
242
237
  use_ui @ui do
243
238
  installer.check_that_user_bin_dir_is_in_path
@@ -245,7 +240,7 @@ gem 'other', version
245
240
 
246
241
  assert_empty @ui.error
247
242
  ensure
248
- ENV['PATH'] = orig_PATH unless win_platform?
243
+ ENV["PATH"] = orig_PATH unless win_platform?
249
244
  end
250
245
 
251
246
  def test_check_that_user_bin_dir_is_in_path_not_in_path
@@ -258,7 +253,7 @@ gem 'other', version
258
253
  expected = installer.bin_dir
259
254
 
260
255
  if Gem.win_platform?
261
- expected = expected.downcase.gsub(File::SEPARATOR, File::ALT_SEPARATOR)
256
+ expected = expected.downcase
262
257
  end
263
258
 
264
259
  assert_match expected, @ui.error
@@ -267,27 +262,27 @@ gem 'other', version
267
262
  def test_ensure_dependency
268
263
  installer = setup_base_installer
269
264
 
270
- util_spec 'a'
265
+ util_spec "a"
271
266
 
272
- dep = Gem::Dependency.new 'a', '>= 2'
267
+ dep = Gem::Dependency.new "a", ">= 2"
273
268
  assert installer.ensure_dependency(@spec, dep)
274
269
 
275
- dep = Gem::Dependency.new 'b', '> 2'
276
- e = assert_raises Gem::InstallError do
270
+ dep = Gem::Dependency.new "b", "> 2"
271
+ e = assert_raise Gem::InstallError do
277
272
  installer.ensure_dependency @spec, dep
278
273
  end
279
274
 
280
- assert_equal 'a requires b (> 2)', e.message
275
+ assert_equal "a requires b (> 2)", e.message
281
276
  end
282
277
 
283
278
  def test_ensure_loadable_spec
284
- a, a_gem = util_gem 'a', 2 do |s|
285
- s.add_dependency 'garbage ~> 5'
279
+ a, a_gem = util_gem "a", 2 do |s|
280
+ s.add_dependency "garbage ~> 5"
286
281
  end
287
282
 
288
283
  installer = Gem::Installer.at a_gem
289
284
 
290
- e = assert_raises Gem::InstallError do
285
+ e = assert_raise Gem::InstallError do
291
286
  installer.ensure_loadable_spec
292
287
  end
293
288
 
@@ -296,16 +291,16 @@ gem 'other', version
296
291
  end
297
292
 
298
293
  def test_ensure_loadable_spec_security_policy
299
- skip 'openssl is missing' unless defined?(OpenSSL::SSL)
294
+ pend "openssl is missing" unless Gem::HAVE_OPENSSL
300
295
 
301
- _, a_gem = util_gem 'a', 2 do |s|
302
- s.add_dependency 'garbage ~> 5'
296
+ _, a_gem = util_gem "a", 2 do |s|
297
+ s.add_dependency "garbage ~> 5"
303
298
  end
304
299
 
305
300
  policy = Gem::Security::HighSecurity
306
301
  installer = Gem::Installer.at a_gem, :security_policy => policy
307
302
 
308
- assert_raises Gem::Security::Exception do
303
+ assert_raise Gem::Security::Exception do
309
304
  installer.ensure_loadable_spec
310
305
  end
311
306
  end
@@ -315,7 +310,7 @@ gem 'other', version
315
310
 
316
311
  installer.extract_files
317
312
 
318
- assert_path_exists File.join @spec.gem_dir, 'bin/executable'
313
+ assert_path_exist File.join @spec.gem_dir, "bin/executable"
319
314
  end
320
315
 
321
316
  def test_generate_bin_bindir
@@ -324,12 +319,12 @@ gem 'other', version
324
319
  installer.wrappers = true
325
320
 
326
321
  @spec.executables = %w[executable]
327
- @spec.bindir = 'bin'
322
+ @spec.bindir = "bin"
328
323
 
329
- exec_file = installer.formatted_program_filename 'executable'
324
+ exec_file = installer.formatted_program_filename "executable"
330
325
  exec_path = File.join @spec.gem_dir, exec_file
331
- File.open exec_path, 'w' do |f|
332
- f.puts '#!/usr/bin/ruby'
326
+ File.open exec_path, "w" do |f|
327
+ f.puts "#!/usr/bin/ruby"
333
328
  end
334
329
 
335
330
  installer.gem_dir = @spec.gem_dir
@@ -337,12 +332,12 @@ gem 'other', version
337
332
  installer.generate_bin
338
333
 
339
334
  assert_directory_exists util_inst_bindir
340
- installed_exec = File.join(util_inst_bindir, 'executable')
341
- assert_path_exists installed_exec
335
+ installed_exec = File.join(util_inst_bindir, "executable")
336
+ assert_path_exist installed_exec
342
337
  assert_equal mask, File.stat(installed_exec).mode unless win_platform?
343
338
 
344
339
  wrapper = File.read installed_exec
345
- assert_match %r|generated by RubyGems|, wrapper
340
+ assert_match %r{generated by RubyGems}, wrapper
346
341
  end
347
342
 
348
343
  def test_generate_bin_bindir_with_user_install_warning
@@ -354,10 +349,10 @@ gem 'other', version
354
349
 
355
350
  options = {
356
351
  :bin_dir => bin_dir,
357
- :install_dir => "/non/existent"
352
+ :install_dir => "/non/existent",
358
353
  }
359
354
 
360
- inst = Gem::Installer.at '', options
355
+ inst = Gem::Installer.at "", options
361
356
 
362
357
  Gem::Installer.path_warning = false
363
358
 
@@ -380,12 +375,12 @@ gem 'other', version
380
375
 
381
376
  installer.generate_bin
382
377
  assert_directory_exists util_inst_bindir
383
- installed_exec = File.join util_inst_bindir, 'executable'
384
- assert_path_exists installed_exec
378
+ installed_exec = File.join util_inst_bindir, "executable"
379
+ assert_path_exist installed_exec
385
380
  assert_equal mask, File.stat(installed_exec).mode unless win_platform?
386
381
 
387
382
  wrapper = File.read installed_exec
388
- assert_match %r|generated by RubyGems|, wrapper
383
+ assert_match %r{generated by RubyGems}, wrapper
389
384
  end
390
385
 
391
386
  def test_generate_bin_script_format
@@ -396,11 +391,11 @@ gem 'other', version
396
391
  util_make_exec
397
392
  installer.gem_dir = @spec.gem_dir
398
393
 
399
- Gem::Installer.exec_format = 'foo-%s-bar'
394
+ Gem::Installer.exec_format = "foo-%s-bar"
400
395
  installer.generate_bin
401
396
  assert_directory_exists util_inst_bindir
402
- installed_exec = File.join util_inst_bindir, 'foo-executable-bar'
403
- assert_path_exists installed_exec
397
+ installed_exec = File.join util_inst_bindir, "foo-executable-bar"
398
+ assert_path_exist installed_exec
404
399
  ensure
405
400
  Gem::Installer.exec_format = nil
406
401
  end
@@ -412,11 +407,11 @@ gem 'other', version
412
407
  util_make_exec
413
408
  installer.gem_dir = @spec.gem_dir
414
409
 
415
- Gem::Installer.exec_format = 'foo-%s-bar'
410
+ Gem::Installer.exec_format = "foo-%s-bar"
416
411
  installer.generate_bin
417
412
  assert_directory_exists util_inst_bindir
418
- installed_exec = File.join util_inst_bindir, 'executable'
419
- assert_path_exists installed_exec
413
+ installed_exec = File.join util_inst_bindir, "executable"
414
+ assert_path_exist installed_exec
420
415
  ensure
421
416
  Gem::Installer.exec_format = nil
422
417
  end
@@ -427,24 +422,24 @@ gem 'other', version
427
422
  installer.wrappers = true
428
423
 
429
424
  gem_dir = File.join("#{@gemhome}2", "gems", @spec.full_name)
430
- gem_bindir = File.join gem_dir, 'bin'
425
+ gem_bindir = File.join gem_dir, "bin"
431
426
  FileUtils.mkdir_p gem_bindir
432
- File.open File.join(gem_bindir, 'executable'), 'w' do |f|
427
+ File.open File.join(gem_bindir, "executable"), "w" do |f|
433
428
  f.puts "#!/bin/ruby"
434
429
  end
435
430
 
436
431
  installer.gem_home = "#{@gemhome}2"
437
432
  installer.gem_dir = gem_dir
438
- installer.bin_dir = File.join "#{@gemhome}2", 'bin'
433
+ installer.bin_dir = File.join "#{@gemhome}2", "bin"
439
434
 
440
435
  installer.generate_bin
441
436
 
442
- installed_exec = File.join("#{@gemhome}2", "bin", 'executable')
443
- assert_path_exists installed_exec
437
+ installed_exec = File.join("#{@gemhome}2", "bin", "executable")
438
+ assert_path_exist installed_exec
444
439
  assert_equal mask, File.stat(installed_exec).mode unless win_platform?
445
440
 
446
441
  wrapper = File.read installed_exec
447
- assert_match %r|generated by RubyGems|, wrapper
442
+ assert_match %r{generated by RubyGems}, wrapper
448
443
  end
449
444
 
450
445
  def test_generate_bin_script_no_execs
@@ -455,7 +450,7 @@ gem 'other', version
455
450
  installer.wrappers = true
456
451
  installer.generate_bin
457
452
 
458
- refute_path_exists util_inst_bindir, 'bin dir was created when not needed'
453
+ assert_path_not_exist util_inst_bindir, "bin dir was created when not needed"
459
454
  end
460
455
 
461
456
  def test_generate_bin_script_no_perms
@@ -467,18 +462,18 @@ gem 'other', version
467
462
  Dir.mkdir util_inst_bindir
468
463
 
469
464
  if win_platform?
470
- skip('test_generate_bin_script_no_perms skipped on MS Windows')
465
+ pend("test_generate_bin_script_no_perms skipped on MS Windows")
471
466
  elsif Process.uid.zero?
472
- skip('test_generate_bin_script_no_perms skipped in root privilege')
467
+ pend("test_generate_bin_script_no_perms skipped in root privilege")
473
468
  else
474
469
  FileUtils.chmod 0000, util_inst_bindir
475
470
 
476
- assert_raises Gem::FilePermissionError do
471
+ assert_raise Gem::FilePermissionError do
477
472
  installer.generate_bin
478
473
  end
479
474
  end
480
475
  ensure
481
- FileUtils.chmod 0755, util_inst_bindir unless ($DEBUG or win_platform?)
476
+ FileUtils.chmod 0755, util_inst_bindir unless ($DEBUG || win_platform?)
482
477
  end
483
478
 
484
479
  def test_generate_bin_script_no_shebang
@@ -487,21 +482,21 @@ gem 'other', version
487
482
  installer.wrappers = true
488
483
  @spec.executables = %w[executable]
489
484
 
490
- gem_dir = File.join @gemhome, 'gems', @spec.full_name
491
- gem_bindir = File.join gem_dir, 'bin'
485
+ gem_dir = File.join @gemhome, "gems", @spec.full_name
486
+ gem_bindir = File.join gem_dir, "bin"
492
487
  FileUtils.mkdir_p gem_bindir
493
- File.open File.join(gem_bindir, 'executable'), 'w' do |f|
488
+ File.open File.join(gem_bindir, "executable"), "w" do |f|
494
489
  f.puts "blah blah blah"
495
490
  end
496
491
 
497
492
  installer.generate_bin
498
493
 
499
- installed_exec = File.join @gemhome, 'bin', 'executable'
500
- assert_path_exists installed_exec
494
+ installed_exec = File.join @gemhome, "bin", "executable"
495
+ assert_path_exist installed_exec
501
496
  assert_equal mask, File.stat(installed_exec).mode unless win_platform?
502
497
 
503
498
  wrapper = File.read installed_exec
504
- assert_match %r|generated by RubyGems|, wrapper
499
+ assert_match %r{generated by RubyGems}, wrapper
505
500
  # HACK some gems don't have #! in their executables, restore 2008/06
506
501
  #assert_no_match %r|generated by RubyGems|, wrapper
507
502
  end
@@ -512,9 +507,9 @@ gem 'other', version
512
507
  installer.wrappers = true
513
508
  util_make_exec
514
509
  installer.gem_dir = @spec.gem_dir
515
- installed_exec = File.join(util_inst_bindir, 'executable')
510
+ installed_exec = File.join(util_inst_bindir, "executable")
516
511
 
517
- real_exec = File.join @spec.gem_dir, 'bin', 'executable'
512
+ real_exec = File.join @spec.gem_dir, "bin", "executable"
518
513
 
519
514
  # fake --no-wrappers for previous install
520
515
  unless Gem.win_platform?
@@ -524,17 +519,17 @@ gem 'other', version
524
519
 
525
520
  installer.generate_bin
526
521
  assert_directory_exists util_inst_bindir
527
- assert_path_exists installed_exec
522
+ assert_path_exist installed_exec
528
523
  assert_equal mask, File.stat(installed_exec).mode unless win_platform?
529
524
 
530
- assert_match %r|generated by RubyGems|, File.read(installed_exec)
525
+ assert_match %r{generated by RubyGems}, File.read(installed_exec)
531
526
 
532
- refute_match %r|generated by RubyGems|, File.read(real_exec),
533
- 'real executable overwritten'
527
+ refute_match %r{generated by RubyGems}, File.read(real_exec),
528
+ "real executable overwritten"
534
529
  end
535
530
 
536
531
  def test_generate_bin_symlink
537
- skip "Symlinks not supported or not enabled" unless symlink_supported?
532
+ pend "Symlinks not supported or not enabled" unless symlink_supported?
538
533
 
539
534
  installer = setup_base_installer
540
535
 
@@ -544,9 +539,9 @@ gem 'other', version
544
539
 
545
540
  installer.generate_bin
546
541
  assert_directory_exists util_inst_bindir
547
- installed_exec = File.join util_inst_bindir, 'executable'
542
+ installed_exec = File.join util_inst_bindir, "executable"
548
543
  assert_equal true, File.symlink?(installed_exec)
549
- assert_equal(File.join(@spec.gem_dir, 'bin', 'executable'),
544
+ assert_equal(File.join(@spec.gem_dir, "bin", "executable"),
550
545
  File.readlink(installed_exec))
551
546
  end
552
547
 
@@ -558,7 +553,7 @@ gem 'other', version
558
553
  installer.wrappers = false
559
554
  installer.generate_bin
560
555
 
561
- refute_path_exists util_inst_bindir
556
+ assert_path_not_exist util_inst_bindir
562
557
  end
563
558
 
564
559
  def test_generate_bin_symlink_no_perms
@@ -571,22 +566,22 @@ gem 'other', version
571
566
  Dir.mkdir util_inst_bindir
572
567
 
573
568
  if win_platform?
574
- skip('test_generate_bin_symlink_no_perms skipped on MS Windows')
569
+ pend("test_generate_bin_symlink_no_perms skipped on MS Windows")
575
570
  elsif Process.uid.zero?
576
- skip('test_user_install_disabled_read_only test skipped in root privilege')
571
+ pend("test_user_install_disabled_read_only test skipped in root privilege")
577
572
  else
578
573
  FileUtils.chmod 0000, util_inst_bindir
579
574
 
580
- assert_raises Gem::FilePermissionError do
575
+ assert_raise Gem::FilePermissionError do
581
576
  installer.generate_bin
582
577
  end
583
578
  end
584
579
  ensure
585
- FileUtils.chmod 0755, util_inst_bindir unless ($DEBUG or win_platform?)
580
+ FileUtils.chmod 0755, util_inst_bindir unless ($DEBUG || win_platform?)
586
581
  end
587
582
 
588
583
  def test_generate_bin_symlink_update_newer
589
- skip "Symlinks not supported or not enabled" unless symlink_supported?
584
+ pend "Symlinks not supported or not enabled" unless symlink_supported?
590
585
 
591
586
  installer = setup_base_installer
592
587
 
@@ -595,30 +590,30 @@ gem 'other', version
595
590
  installer.gem_dir = @spec.gem_dir
596
591
 
597
592
  installer.generate_bin
598
- installed_exec = File.join(util_inst_bindir, 'executable')
599
- assert_equal(File.join(@spec.gem_dir, 'bin', 'executable'),
593
+ installed_exec = File.join(util_inst_bindir, "executable")
594
+ assert_equal(File.join(@spec.gem_dir, "bin", "executable"),
600
595
  File.readlink(installed_exec))
601
596
 
602
597
  @spec = Gem::Specification.new do |s|
603
- s.files = ['lib/code.rb']
598
+ s.files = ["lib/code.rb"]
604
599
  s.name = "a"
605
600
  s.version = "3"
606
601
  s.summary = "summary"
607
602
  s.description = "desc"
608
- s.require_path = 'lib'
603
+ s.require_path = "lib"
609
604
  end
610
605
 
611
606
  util_make_exec
612
607
  installer.gem_dir = @spec.gem_dir
613
608
  installer.generate_bin
614
- installed_exec = File.join(util_inst_bindir, 'executable')
615
- assert_equal(@spec.bin_file('executable'),
609
+ installed_exec = File.join(util_inst_bindir, "executable")
610
+ assert_equal(@spec.bin_file("executable"),
616
611
  File.readlink(installed_exec),
617
612
  "Ensure symlink moved to latest version")
618
613
  end
619
614
 
620
615
  def test_generate_bin_symlink_update_older
621
- skip "Symlinks not supported or not enabled" unless symlink_supported?
616
+ pend "Symlinks not supported or not enabled" unless symlink_supported?
622
617
 
623
618
  installer = setup_base_installer
624
619
 
@@ -627,17 +622,17 @@ gem 'other', version
627
622
  installer.gem_dir = @spec.gem_dir
628
623
 
629
624
  installer.generate_bin
630
- installed_exec = File.join(util_inst_bindir, 'executable')
631
- assert_equal(File.join(@spec.gem_dir, 'bin', 'executable'),
625
+ installed_exec = File.join(util_inst_bindir, "executable")
626
+ assert_equal(File.join(@spec.gem_dir, "bin", "executable"),
632
627
  File.readlink(installed_exec))
633
628
 
634
629
  spec = Gem::Specification.new do |s|
635
- s.files = ['lib/code.rb']
630
+ s.files = ["lib/code.rb"]
636
631
  s.name = "a"
637
632
  s.version = "1"
638
633
  s.summary = "summary"
639
634
  s.description = "desc"
640
- s.require_path = 'lib'
635
+ s.require_path = "lib"
641
636
  end
642
637
 
643
638
  util_make_exec
@@ -648,15 +643,15 @@ gem 'other', version
648
643
 
649
644
  installer.generate_bin
650
645
 
651
- installed_exec = File.join util_inst_bindir, 'executable'
652
- expected = File.join @spec.gem_dir, 'bin', 'executable'
646
+ installed_exec = File.join util_inst_bindir, "executable"
647
+ expected = File.join @spec.gem_dir, "bin", "executable"
653
648
  assert_equal(expected,
654
649
  File.readlink(installed_exec),
655
650
  "Ensure symlink not moved")
656
651
  end
657
652
 
658
653
  def test_generate_bin_symlink_update_remove_wrapper
659
- skip "Symlinks not supported or not enabled" unless symlink_supported?
654
+ pend "Symlinks not supported or not enabled" unless symlink_supported?
660
655
 
661
656
  installer = setup_base_installer
662
657
 
@@ -666,16 +661,16 @@ gem 'other', version
666
661
 
667
662
  installer.generate_bin
668
663
 
669
- installed_exec = File.join util_inst_bindir, 'executable'
670
- assert_path_exists installed_exec
664
+ installed_exec = File.join util_inst_bindir, "executable"
665
+ assert_path_exist installed_exec
671
666
 
672
667
  @spec = Gem::Specification.new do |s|
673
- s.files = ['lib/code.rb']
668
+ s.files = ["lib/code.rb"]
674
669
  s.name = "a"
675
670
  s.version = "3"
676
671
  s.summary = "summary"
677
672
  s.description = "desc"
678
- s.require_path = 'lib'
673
+ s.require_path = "lib"
679
674
  end
680
675
  util_make_exec
681
676
 
@@ -685,8 +680,8 @@ gem 'other', version
685
680
 
686
681
  installer.generate_bin
687
682
 
688
- installed_exec = File.join util_inst_bindir, 'executable'
689
- assert_equal(@spec.bin_file('executable'),
683
+ installed_exec = File.join util_inst_bindir, "executable"
684
+ assert_equal(@spec.bin_file("executable"),
690
685
  File.readlink(installed_exec),
691
686
  "Ensure symlink moved to latest version")
692
687
  end
@@ -696,7 +691,7 @@ gem 'other', version
696
691
  Gem.win_platform = true
697
692
  old_alt_separator = File::ALT_SEPARATOR
698
693
  File.__send__(:remove_const, :ALT_SEPARATOR)
699
- File.const_set(:ALT_SEPARATOR, '\\')
694
+ File.const_set(:ALT_SEPARATOR, "\\")
700
695
 
701
696
  installer = setup_base_installer
702
697
 
@@ -709,8 +704,8 @@ gem 'other', version
709
704
  end
710
705
 
711
706
  assert_directory_exists util_inst_bindir
712
- installed_exec = File.join(util_inst_bindir, 'executable')
713
- assert_path_exists installed_exec
707
+ installed_exec = File.join(util_inst_bindir, "executable")
708
+ assert_path_exist installed_exec
714
709
 
715
710
  if symlink_supported?
716
711
  assert File.symlink?(installed_exec)
@@ -729,24 +724,191 @@ gem 'other', version
729
724
  end
730
725
 
731
726
  def test_generate_bin_uses_default_shebang
732
- skip "Symlinks not supported or not enabled" unless symlink_supported?
727
+ pend "Symlinks not supported or not enabled" unless symlink_supported?
733
728
 
734
- installer = setup_base_installer
729
+ load_relative "no" do
730
+ installer = setup_base_installer
735
731
 
736
- installer.wrappers = true
737
- util_make_exec
732
+ installer.wrappers = true
733
+ util_make_exec
738
734
 
739
- installer.generate_bin
735
+ installer.generate_bin
736
+
737
+ default_shebang = Gem.ruby
738
+ shebang_line = File.open("#{@gemhome}/bin/executable") {|f| f.readlines.first }
739
+ assert_match(/\A#!/, shebang_line)
740
+ assert_match(/#{default_shebang}/, shebang_line)
741
+ end
742
+ end
743
+
744
+ def test_generate_bin_with_dangling_symlink
745
+ gem_with_dangling_symlink = File.expand_path("packages/ascii_binder-0.1.10.1.gem", __dir__)
746
+
747
+ installer = Gem::Installer.at(
748
+ gem_with_dangling_symlink,
749
+ :user_install => false,
750
+ :force => true
751
+ )
752
+
753
+ build_rake_in do
754
+ use_ui @ui do
755
+ installer.install
756
+ end
757
+ end
758
+
759
+ errors = @ui.error.split("\n")
760
+ assert_equal "WARNING: ascii_binder-0.1.10.1 ships with a dangling symlink named bin/ascii_binder pointing to missing bin/asciibinder file. Ignoring", errors.shift
761
+ assert_empty errors
762
+
763
+ assert_empty @ui.output
764
+ end
765
+
766
+ def test_generate_plugins
767
+ installer = util_setup_installer do |spec|
768
+ write_file File.join(@tempdir, "lib", "rubygems_plugin.rb") do |io|
769
+ io.write "puts __FILE__"
770
+ end
771
+
772
+ spec.files += %w[lib/rubygems_plugin.rb]
773
+ end
774
+
775
+ build_rake_in do
776
+ installer.install
777
+ end
778
+
779
+ plugin_path = File.join Gem.plugindir, "a_plugin.rb"
780
+
781
+ FileUtils.rm plugin_path
782
+
783
+ installer.generate_plugins
784
+
785
+ assert File.exist?(plugin_path), "plugin not written"
786
+ end
787
+
788
+ def test_generate_plugins_with_install_dir
789
+ spec = quick_gem "a" do |s|
790
+ write_file File.join(@tempdir, "lib", "rubygems_plugin.rb") do |io|
791
+ io.write "puts __FILE__"
792
+ end
793
+
794
+ s.files += %w[lib/rubygems_plugin.rb]
795
+ end
796
+
797
+ util_build_gem spec
798
+
799
+ plugin_path = File.join "#{@gemhome}2", "plugins", "a_plugin.rb"
800
+ installer = util_installer spec, "#{@gemhome}2"
801
+
802
+ assert_equal spec, installer.install
803
+
804
+ assert File.exist?(plugin_path), "plugin not written to install_dir"
805
+ end
806
+
807
+ def test_generate_plugins_with_user_install
808
+ spec = quick_gem "a" do |s|
809
+ write_file File.join(@tempdir, "lib", "rubygems_plugin.rb") do |io|
810
+ io.write "puts __FILE__"
811
+ end
812
+
813
+ s.files += %w[lib/rubygems_plugin.rb]
814
+ end
815
+
816
+ util_build_gem spec
817
+
818
+ File.chmod(0555, Gem.plugindir)
819
+ system_path = File.join(Gem.plugindir, "a_plugin.rb")
820
+ user_path = File.join(Gem.plugindir(Gem.user_dir), "a_plugin.rb")
821
+ installer = util_installer spec, Gem.dir, :user
740
822
 
741
- default_shebang = Gem.ruby
742
- shebang_line = open("#{@gemhome}/bin/executable") { |f| f.readlines.first }
743
- assert_match(/\A#!/, shebang_line)
744
- assert_match(/#{default_shebang}/, shebang_line)
823
+ assert_equal spec, installer.install
824
+
825
+ assert !File.exist?(system_path), "plugin incorrectly written to system plugins_dir"
826
+ assert File.exist?(user_path), "plugin not written to user plugins_dir"
827
+ end
828
+
829
+ def test_generate_plugins_with_build_root
830
+ spec = quick_gem "a" do |s|
831
+ write_file File.join(@tempdir, "lib", "rubygems_plugin.rb") do |io|
832
+ io.write "puts __FILE__"
833
+ end
834
+
835
+ s.files += %w[lib/rubygems_plugin.rb]
836
+ end
837
+
838
+ util_build_gem spec
839
+
840
+ File.chmod(0555, Gem.plugindir)
841
+ system_path = File.join(Gem.plugindir, "a_plugin.rb")
842
+
843
+ build_root = File.join(@tempdir, "build_root")
844
+ build_root_path = File.join(build_root, Gem.plugindir.gsub(/^[a-zA-Z]:/, ""), "a_plugin.rb")
845
+
846
+ installer = Gem::Installer.at spec.cache_file, :build_root => build_root
847
+
848
+ assert_equal spec, installer.install
849
+
850
+ assert !File.exist?(system_path), "plugin written incorrect written to system plugins_dir"
851
+ assert File.exist?(build_root_path), "plugin not written to build_root"
852
+
853
+ refute_includes File.read(build_root_path), build_root
854
+ end
855
+
856
+ def test_keeps_plugins_up_to_date
857
+ # NOTE: version a-2 is already installed by setup hooks
858
+
859
+ write_file File.join(@tempdir, "lib", "rubygems_plugin.rb") do |io|
860
+ io.write "puts __FILE__"
861
+ end
862
+
863
+ build_rake_in do
864
+ util_setup_installer do |spec|
865
+ spec.version = "1"
866
+ spec.files += %w[lib/rubygems_plugin.rb]
867
+ end.install
868
+
869
+ plugin_path = File.join Gem.plugindir, "a_plugin.rb"
870
+ refute File.exist?(plugin_path), "old version installed while newer version without plugin also installed, but plugin written"
871
+
872
+ util_setup_installer do |spec|
873
+ spec.version = "2"
874
+ spec.files += %w[lib/rubygems_plugin.rb]
875
+ end.install
876
+
877
+ plugin_path = File.join Gem.plugindir, "a_plugin.rb"
878
+ assert File.exist?(plugin_path), "latest version reinstalled, but plugin not written"
879
+ assert_match %r{\Arequire.*a-2/lib/rubygems_plugin\.rb}, File.read(plugin_path), "written plugin has incorrect content"
880
+
881
+ util_setup_installer do |spec|
882
+ spec.version = "3"
883
+ spec.files += %w[lib/rubygems_plugin.rb]
884
+ end.install
885
+
886
+ plugin_path = File.join Gem.plugindir, "a_plugin.rb"
887
+ assert File.exist?(plugin_path), "latest version installed, but plugin removed"
888
+ assert_match %r{\Arequire.*a-3/lib/rubygems_plugin\.rb}, File.read(plugin_path), "written plugin has incorrect content"
889
+
890
+ util_setup_installer do |spec|
891
+ spec.version = "4"
892
+ end.install
893
+
894
+ refute File.exist?(plugin_path), "new version installed without a plugin while older version with a plugin installed, but plugin not removed"
895
+ end
896
+ end
897
+
898
+ def test_generates_plugins_dir_under_install_dir_if_not_there
899
+ Gem.use_paths "#{@gemhome}2" # Set GEM_HOME to an uninitialized repo
900
+
901
+ @spec = util_spec "a"
902
+
903
+ path = Gem::Package.build @spec
904
+
905
+ installer = Gem::Installer.at path, :install_dir => "#{@gemhome}3"
906
+ assert_equal @spec, installer.install
745
907
  end
746
908
 
747
909
  def test_initialize
748
- spec = util_spec 'a' do |s|
749
- s.platform = Gem::Platform.new 'mswin32'
910
+ spec = util_spec "a" do |s|
911
+ s.platform = Gem::Platform.new "mswin32"
750
912
  end
751
913
 
752
914
  gem = File.join @tempdir, spec.file_name
@@ -757,8 +919,8 @@ gem 'other', version
757
919
 
758
920
  installer = Gem::Installer.at gem
759
921
 
760
- assert_equal File.join(@gemhome, 'gems', spec.full_name), installer.gem_dir
761
- assert_equal File.join(@gemhome, 'bin'), installer.bin_dir
922
+ assert_equal File.join(@gemhome, "gems", spec.full_name), installer.gem_dir
923
+ assert_equal File.join(@gemhome, "bin"), installer.bin_dir
762
924
  end
763
925
 
764
926
  def test_initialize_user_install
@@ -766,7 +928,7 @@ gem 'other', version
766
928
 
767
929
  installer = Gem::Installer.at @gem, :user_install => true
768
930
 
769
- assert_equal File.join(Gem.user_dir, 'gems', @spec.full_name),
931
+ assert_equal File.join(Gem.user_dir, "gems", @spec.full_name),
770
932
  installer.gem_dir
771
933
  assert_equal Gem.bindir(Gem.user_dir), installer.bin_dir
772
934
  end
@@ -777,7 +939,7 @@ gem 'other', version
777
939
  installer =
778
940
  Gem::Installer.at @gem, :user_install => true, :bin_dir => @tempdir
779
941
 
780
- assert_equal File.join(Gem.user_dir, 'gems', @spec.full_name),
942
+ assert_equal File.join(Gem.user_dir, "gems", @spec.full_name),
781
943
  installer.gem_dir
782
944
  assert_equal @tempdir, installer.bin_dir
783
945
  end
@@ -785,29 +947,26 @@ gem 'other', version
785
947
  def test_install
786
948
  installer = util_setup_installer
787
949
 
788
- gemdir = File.join @gemhome, 'gems', @spec.full_name
789
- cache_file = File.join @gemhome, 'cache', @spec.file_name
790
- stub_exe = File.join @gemhome, 'bin', 'executable'
791
- rakefile = File.join gemdir, 'ext', 'a', 'Rakefile'
792
- spec_file = File.join @gemhome, 'specifications', @spec.spec_name
950
+ gemdir = File.join @gemhome, "gems", @spec.full_name
951
+ cache_file = File.join @gemhome, "cache", @spec.file_name
952
+ stub_exe = File.join @gemhome, "bin", "executable"
953
+ rakefile = File.join gemdir, "ext", "a", "Rakefile"
954
+ spec_file = File.join @gemhome, "specifications", @spec.spec_name
793
955
 
794
956
  Gem.pre_install do
795
- refute_path_exists cache_file, 'cache file must not exist yet'
796
- refute_path_exists spec_file, 'spec file must not exist yet'
957
+ assert_path_not_exist cache_file, "cache file must not exist yet"
797
958
  true
798
959
  end
799
960
 
800
961
  Gem.post_build do
801
- assert_path_exists gemdir, 'gem install dir must exist'
802
- assert_path_exists rakefile, 'gem executable must exist'
803
- refute_path_exists stub_exe, 'gem executable must not exist'
804
- refute_path_exists spec_file, 'spec file must not exist yet'
962
+ assert_path_exist gemdir, "gem install dir must exist"
963
+ assert_path_exist rakefile, "gem executable must exist"
964
+ assert_path_not_exist stub_exe, "gem executable must not exist"
805
965
  true
806
966
  end
807
967
 
808
968
  Gem.post_install do
809
- assert_path_exists cache_file, 'cache file must exist'
810
- assert_path_exists spec_file, 'spec file must exist'
969
+ assert_path_exist cache_file, "cache file must exist"
811
970
  end
812
971
 
813
972
  @newspec = nil
@@ -818,21 +977,21 @@ gem 'other', version
818
977
  end
819
978
 
820
979
  assert_equal @spec, @newspec
821
- assert_path_exists gemdir
822
- assert_path_exists stub_exe, 'gem executable must exist'
980
+ assert_path_exist gemdir
981
+ assert_path_exist stub_exe, "gem executable must exist"
823
982
 
824
- exe = File.join gemdir, 'bin', 'executable'
825
- assert_path_exists exe
983
+ exe = File.join gemdir, "bin", "executable"
984
+ assert_path_exist exe
826
985
 
827
986
  exe_mode = File.stat(exe).mode & 0111
828
987
  assert_equal 0111, exe_mode, "0%o" % exe_mode unless win_platform?
829
988
 
830
- assert_path_exists File.join gemdir, 'lib', 'code.rb'
989
+ assert_path_exist File.join gemdir, "lib", "code.rb"
831
990
 
832
- assert_path_exists rakefile
991
+ assert_path_exist rakefile
833
992
 
834
993
  assert_equal spec_file, @newspec.loaded_from
835
- assert_path_exists spec_file
994
+ assert_path_exist spec_file
836
995
 
837
996
  assert_same installer, @post_build_hook_arg
838
997
  assert_same installer, @post_install_hook_arg
@@ -844,7 +1003,7 @@ gem 'other', version
844
1003
 
845
1004
  installer.wrappers = true
846
1005
 
847
- gemdir = File.join @gemhome, 'gems', @spec.full_name
1006
+ gemdir = File.join @gemhome, "gems", @spec.full_name
848
1007
 
849
1008
  @newspec = nil
850
1009
  build_rake_in do
@@ -853,9 +1012,9 @@ gem 'other', version
853
1012
  end
854
1013
  end
855
1014
 
856
- exe = File.join gemdir, 'bin', 'executable'
1015
+ exe = File.join gemdir, "bin", "executable"
857
1016
 
858
- e = assert_raises RuntimeError do
1017
+ e = assert_raise RuntimeError do
859
1018
  instance_eval File.read(exe)
860
1019
  end
861
1020
 
@@ -867,10 +1026,10 @@ gem 'other', version
867
1026
 
868
1027
  # build old version that has a bin file
869
1028
  installer = util_setup_gem do |spec|
870
- File.open File.join('bin', 'executable'), 'w' do |f|
1029
+ File.open File.join("bin", "executable"), "w" do |f|
871
1030
  f.puts "require 'code'"
872
1031
  end
873
- File.open File.join('lib', 'code.rb'), 'w' do |f|
1032
+ File.open File.join("lib", "code.rb"), "w" do |f|
874
1033
  f.puts 'raise "I have an executable"'
875
1034
  end
876
1035
  end
@@ -882,15 +1041,15 @@ gem 'other', version
882
1041
  end
883
1042
  end
884
1043
 
885
- old_bin_file = File.join installer.bin_dir, 'executable'
1044
+ old_bin_file = File.join installer.bin_dir, "executable"
886
1045
 
887
1046
  # build new version that doesn't have a bin file
888
1047
  installer = util_setup_gem do |spec|
889
- FileUtils.rm File.join('bin', 'executable')
890
- spec.files.delete File.join('bin', 'executable')
891
- spec.executables.delete 'executable'
1048
+ FileUtils.rm File.join("bin", "executable")
1049
+ spec.files.delete File.join("bin", "executable")
1050
+ spec.executables.delete "executable"
892
1051
  spec.version = @spec.version.bump
893
- File.open File.join('lib', 'code.rb'), 'w' do |f|
1052
+ File.open File.join("lib", "code.rb"), "w" do |f|
894
1053
  f.puts 'raise "I do not have an executable"'
895
1054
  end
896
1055
  end
@@ -901,13 +1060,13 @@ gem 'other', version
901
1060
  end
902
1061
  end
903
1062
 
904
- e = assert_raises RuntimeError do
1063
+ e = assert_raise RuntimeError do
905
1064
  instance_eval File.read(old_bin_file)
906
1065
  end
907
1066
 
908
1067
  # We expect the bin stub to activate the version that actually contains
909
1068
  # the binstub.
910
- assert_match('I have an executable', e.message)
1069
+ assert_match("I have an executable", e.message)
911
1070
  end
912
1071
 
913
1072
  def test_install_creates_binstub_that_understand_version
@@ -922,14 +1081,14 @@ gem 'other', version
922
1081
  end
923
1082
  end
924
1083
 
925
- exe = File.join @gemhome, 'bin', 'executable'
1084
+ exe = File.join @gemhome, "bin", "executable"
926
1085
 
927
1086
  ARGV.unshift "_3.0_"
928
1087
 
929
1088
  begin
930
1089
  Gem::Specification.reset
931
1090
 
932
- e = assert_raises Gem::GemNotFoundException do
1091
+ e = assert_raise Gem::GemNotFoundException do
933
1092
  instance_eval File.read(exe)
934
1093
  end
935
1094
  ensure
@@ -940,11 +1099,17 @@ gem 'other', version
940
1099
  end
941
1100
 
942
1101
  def test_install_creates_binstub_that_prefers_user_installed_gem_to_default
943
- install_default_gems new_default_spec('default', '2')
1102
+ default_spec = new_default_spec("default", "2", nil, "exe/executable")
1103
+ default_spec.executables = "executable"
1104
+ install_default_gems default_spec
1105
+
1106
+ exe = File.join @gemhome, "bin", "executable"
1107
+
1108
+ assert_path_exist exe, "default gem's executable not installed"
944
1109
 
945
1110
  installer = util_setup_installer do |spec|
946
- spec.name = 'default'
947
- spec.version = '2'
1111
+ spec.name = "default"
1112
+ spec.version = "2"
948
1113
  end
949
1114
 
950
1115
  util_clear_gems
@@ -958,9 +1123,7 @@ gem 'other', version
958
1123
  end
959
1124
  end
960
1125
 
961
- exe = File.join @gemhome, 'bin', 'executable'
962
-
963
- e = assert_raises RuntimeError do
1126
+ e = assert_raise RuntimeError do
964
1127
  instance_eval File.read(exe)
965
1128
  end
966
1129
 
@@ -979,7 +1142,7 @@ gem 'other', version
979
1142
  end
980
1143
  end
981
1144
 
982
- exe = File.join @gemhome, 'bin', 'executable'
1145
+ exe = File.join @gemhome, "bin", "executable"
983
1146
 
984
1147
  extra_arg = "\xE4pfel".dup.force_encoding("UTF-8")
985
1148
  ARGV.unshift extra_arg
@@ -987,7 +1150,7 @@ gem 'other', version
987
1150
  begin
988
1151
  Gem::Specification.reset
989
1152
 
990
- e = assert_raises RuntimeError do
1153
+ e = assert_raise RuntimeError do
991
1154
  instance_eval File.read(exe)
992
1155
  end
993
1156
  ensure
@@ -1006,16 +1169,16 @@ gem 'other', version
1006
1169
  end
1007
1170
  end
1008
1171
 
1009
- gemdir = File.join(@gemhome, 'gems', @spec.full_name)
1010
- assert_path_exists File.join gemdir, 'lib', 'code.rb'
1172
+ gemdir = File.join(@gemhome, "gems", @spec.full_name)
1173
+ assert_path_exist File.join gemdir, "lib", "code.rb"
1011
1174
 
1012
1175
  installer = util_setup_installer
1013
1176
 
1014
1177
  # Morph spec to have lib/other.rb instead of code.rb and recreate
1015
- @spec.files = File.join('lib', 'other.rb')
1178
+ @spec.files = File.join("lib", "other.rb")
1016
1179
  Dir.chdir @tempdir do
1017
- File.open File.join('lib', 'other.rb'), 'w' do |f|
1018
- f.puts '1'
1180
+ File.open File.join("lib", "other.rb"), "w" do |f|
1181
+ f.puts "1"
1019
1182
  end
1020
1183
 
1021
1184
  use_ui ui do
@@ -1023,56 +1186,71 @@ gem 'other', version
1023
1186
  Gem::Package.build @spec
1024
1187
  end
1025
1188
  end
1026
- installer = Gem::Installer.at @gem
1189
+ installer = Gem::Installer.at @gem, :force => true
1027
1190
  build_rake_in do
1028
1191
  use_ui @ui do
1029
1192
  assert_equal @spec, installer.install
1030
1193
  end
1031
1194
  end
1032
1195
 
1033
- assert_path_exists File.join gemdir, 'lib', 'other.rb'
1034
- refute_path_exists File.join gemdir, 'lib', 'code.rb',
1196
+ assert_path_exist File.join gemdir, "lib", "other.rb"
1197
+ assert_path_not_exist File.join gemdir, "lib", "code.rb",
1035
1198
  "code.rb from prior install of same gem shouldn't remain here"
1036
1199
  end
1037
1200
 
1038
1201
  def test_install_force
1202
+ _, missing_dep_gem = util_gem "missing_dep", "1" do |s|
1203
+ s.add_dependency "doesnt_exist", "1"
1204
+ end
1205
+
1039
1206
  use_ui @ui do
1040
- installer = Gem::Installer.at old_ruby_required('= 1.4.6'), :force => true
1207
+ installer = Gem::Installer.at missing_dep_gem, :force => true
1041
1208
  installer.install
1042
1209
  end
1043
1210
 
1044
- gem_dir = File.join(@gemhome, 'gems', 'old_ruby_required-1')
1045
- assert_path_exists gem_dir
1211
+ gem_dir = File.join(@gemhome, "gems", "missing_dep-1")
1212
+ assert_path_exist gem_dir
1213
+ end
1214
+
1215
+ def test_install_build_root
1216
+ build_root = File.join(@tempdir, "build_root")
1217
+
1218
+ @gem = setup_base_gem
1219
+ installer = Gem::Installer.at @gem, :build_root => build_root
1220
+
1221
+ assert_equal @spec, installer.install
1046
1222
  end
1047
1223
 
1048
1224
  def test_install_missing_dirs
1049
1225
  installer = setup_base_installer
1050
1226
 
1051
- FileUtils.rm_f File.join(Gem.dir, 'cache')
1052
- FileUtils.rm_f File.join(Gem.dir, 'doc')
1053
- FileUtils.rm_f File.join(Gem.dir, 'specifications')
1227
+ FileUtils.rm_rf File.join(Gem.dir, "doc")
1228
+ FileUtils.rm_rf File.join(Gem.dir, "specifications")
1054
1229
 
1055
1230
  use_ui @ui do
1056
1231
  installer.install
1057
1232
  end
1058
1233
 
1059
- assert_directory_exists File.join(Gem.dir, 'cache')
1060
- assert_directory_exists File.join(Gem.dir, 'doc')
1061
- assert_directory_exists File.join(Gem.dir, 'specifications')
1234
+ assert_directory_exists File.join(Gem.dir, "doc")
1235
+ assert_directory_exists File.join(Gem.dir, "specifications")
1062
1236
 
1063
- assert_path_exists File.join @gemhome, 'cache', @spec.file_name
1064
- assert_path_exists File.join @gemhome, 'specifications', @spec.spec_name
1237
+ assert_path_exist File.join @gemhome, "cache", @spec.file_name
1238
+ assert_path_exist File.join @gemhome, "specifications", @spec.spec_name
1065
1239
  end
1066
1240
 
1067
1241
  def test_install_post_build_false
1068
- installer = setup_base_installer
1242
+ @spec = util_spec "a"
1243
+
1244
+ util_build_gem @spec
1245
+
1246
+ installer = util_installer @spec, @gemhome
1069
1247
 
1070
1248
  Gem.post_build do
1071
1249
  false
1072
1250
  end
1073
1251
 
1074
1252
  use_ui @ui do
1075
- e = assert_raises Gem::InstallError do
1253
+ e = assert_raise Gem::InstallError do
1076
1254
  installer.install
1077
1255
  end
1078
1256
 
@@ -1081,11 +1259,11 @@ gem 'other', version
1081
1259
  assert_equal "post-build hook at #{location} failed for a-2", e.message
1082
1260
  end
1083
1261
 
1084
- spec_file = File.join @gemhome, 'specifications', @spec.spec_name
1085
- refute_path_exists spec_file
1262
+ spec_file = File.join @gemhome, "specifications", @spec.spec_name
1263
+ assert_path_not_exist spec_file
1086
1264
 
1087
- gem_dir = File.join @gemhome, 'gems', @spec.full_name
1088
- refute_path_exists gem_dir
1265
+ gem_dir = File.join @gemhome, "gems", @spec.full_name
1266
+ assert_path_not_exist gem_dir
1089
1267
  end
1090
1268
 
1091
1269
  def test_install_post_build_nil
@@ -1099,22 +1277,26 @@ gem 'other', version
1099
1277
  installer.install
1100
1278
  end
1101
1279
 
1102
- spec_file = File.join @gemhome, 'specifications', @spec.spec_name
1103
- assert_path_exists spec_file
1280
+ spec_file = File.join @gemhome, "specifications", @spec.spec_name
1281
+ assert_path_exist spec_file
1104
1282
 
1105
- gem_dir = File.join @gemhome, 'gems', @spec.full_name
1106
- assert_path_exists gem_dir
1283
+ gem_dir = File.join @gemhome, "gems", @spec.full_name
1284
+ assert_path_exist gem_dir
1107
1285
  end
1108
1286
 
1109
1287
  def test_install_pre_install_false
1110
- installer = setup_base_installer
1288
+ @spec = util_spec "a"
1289
+
1290
+ util_build_gem @spec
1291
+
1292
+ installer = util_installer @spec, @gemhome
1111
1293
 
1112
1294
  Gem.pre_install do
1113
1295
  false
1114
1296
  end
1115
1297
 
1116
1298
  use_ui @ui do
1117
- e = assert_raises Gem::InstallError do
1299
+ e = assert_raise Gem::InstallError do
1118
1300
  installer.install
1119
1301
  end
1120
1302
 
@@ -1123,8 +1305,8 @@ gem 'other', version
1123
1305
  assert_equal "pre-install hook at #{location} failed for a-2", e.message
1124
1306
  end
1125
1307
 
1126
- spec_file = File.join @gemhome, 'specifications', @spec.spec_name
1127
- refute_path_exists spec_file
1308
+ spec_file = File.join @gemhome, "specifications", @spec.spec_name
1309
+ assert_path_not_exist spec_file
1128
1310
  end
1129
1311
 
1130
1312
  def test_install_pre_install_nil
@@ -1138,13 +1320,13 @@ gem 'other', version
1138
1320
  installer.install
1139
1321
  end
1140
1322
 
1141
- spec_file = File.join @gemhome, 'specifications', @spec.spec_name
1142
- assert_path_exists spec_file
1323
+ spec_file = File.join @gemhome, "specifications", @spec.spec_name
1324
+ assert_path_exist spec_file
1143
1325
  end
1144
1326
 
1145
1327
  def test_install_with_message
1146
1328
  @spec = setup_base_spec
1147
- @spec.post_install_message = 'I am a shiny gem!'
1329
+ @spec.post_install_message = "I am a shiny gem!"
1148
1330
 
1149
1331
  use_ui @ui do
1150
1332
  path = Gem::Package.build @spec
@@ -1153,12 +1335,12 @@ gem 'other', version
1153
1335
  installer.install
1154
1336
  end
1155
1337
 
1156
- assert_match %r|I am a shiny gem!|, @ui.output
1338
+ assert_match %r{I am a shiny gem!}, @ui.output
1157
1339
  end
1158
1340
 
1159
1341
  def test_install_with_skipped_message
1160
1342
  @spec = setup_base_spec
1161
- @spec.post_install_message = 'I am a shiny gem!'
1343
+ @spec.post_install_message = "I am a shiny gem!"
1162
1344
 
1163
1345
  use_ui @ui do
1164
1346
  path = Gem::Package.build @spec
@@ -1167,7 +1349,7 @@ gem 'other', version
1167
1349
  installer.install
1168
1350
  end
1169
1351
 
1170
- refute_match %r|I am a shiny gem!|, @ui.output
1352
+ refute_match %r{I am a shiny gem!}, @ui.output
1171
1353
  end
1172
1354
 
1173
1355
  def test_install_extension_dir
@@ -1191,9 +1373,9 @@ gem 'other', version
1191
1373
  installer.install
1192
1374
  end
1193
1375
 
1194
- expected_makefile = File.join gemhome2, 'gems', @spec.full_name, 'Makefile'
1376
+ expected_makefile = File.join gemhome2, "gems", @spec.full_name, "Makefile"
1195
1377
 
1196
- assert_path_exists expected_makefile
1378
+ assert_path_exist expected_makefile
1197
1379
  end
1198
1380
 
1199
1381
  def test_install_extension_dir_is_removed_on_reinstall
@@ -1222,15 +1404,15 @@ gem 'other', version
1222
1404
  write_file should_be_removed do |io|
1223
1405
  io.write "DELETE ME ON REINSTALL"
1224
1406
  end
1225
- assert_path_exists should_be_removed
1407
+ assert_path_exist should_be_removed
1226
1408
 
1227
1409
  # reinstall the gem, this is also the same as pristine
1228
1410
  use_ui @ui do
1229
- installer = Gem::Installer.at path
1411
+ installer = Gem::Installer.at path, :force => true
1230
1412
  installer.install
1231
1413
  end
1232
1414
 
1233
- refute_path_exists should_be_removed
1415
+ assert_path_not_exist should_be_removed
1234
1416
  end
1235
1417
 
1236
1418
  def test_install_user_extension_dir
@@ -1256,15 +1438,15 @@ gem 'other', version
1256
1438
  installer.install
1257
1439
  end
1258
1440
 
1259
- expected_makefile = File.join Gem.user_dir, 'gems', @spec.full_name, 'Makefile'
1441
+ expected_makefile = File.join Gem.user_dir, "gems", @spec.full_name, "Makefile"
1260
1442
 
1261
- assert_path_exists expected_makefile
1262
- assert_path_exists expected_extension_dir
1263
- refute_path_exists File.join expected_extension_dir, 'gem_make.out'
1443
+ assert_path_exist expected_makefile
1444
+ assert_path_exist expected_extension_dir
1445
+ assert_path_not_exist File.join expected_extension_dir, "gem_make.out"
1264
1446
  end
1265
1447
 
1266
1448
  def test_find_lib_file_after_install
1267
- skip "extensions don't quite work on jruby" if Gem.java_platform?
1449
+ pend "extensions don't quite work on jruby" if Gem.java_platform?
1268
1450
 
1269
1451
  @spec = setup_base_spec
1270
1452
  @spec.extensions << "extconf.rb"
@@ -1290,7 +1472,7 @@ gem 'other', version
1290
1472
  end
1291
1473
 
1292
1474
  Dir.mkdir File.join(@tempdir, "lib")
1293
- write_file File.join(@tempdir, 'lib', "b.rb") do |io|
1475
+ write_file File.join(@tempdir, "lib", "b.rb") do |io|
1294
1476
  io.write "# b.rb"
1295
1477
  end
1296
1478
 
@@ -1303,14 +1485,15 @@ gem 'other', version
1303
1485
  installer.install
1304
1486
  end
1305
1487
 
1306
- expected = File.join @spec.full_require_paths.find { |path|
1307
- File.exist? File.join path, 'b.rb'
1308
- }, 'b.rb'
1309
- assert_equal expected, @spec.matches_for_glob('b.rb').first
1488
+ expected = File.join @spec.full_require_paths.find {|path|
1489
+ File.exist? File.join path, "b.rb"
1490
+ }, "b.rb"
1491
+ assert_equal expected, @spec.matches_for_glob("b.rb").first
1310
1492
  end
1311
1493
 
1312
1494
  def test_install_extension_and_script
1313
- skip "Makefile creation crashes on jruby" if Gem.java_platform?
1495
+ pend "Makefile creation crashes on jruby" if Gem.java_platform?
1496
+ pend if /mswin/ =~ RUBY_PLATFORM && ENV.key?("GITHUB_ACTIONS") # not working from the beginning
1314
1497
 
1315
1498
  @spec = setup_base_spec
1316
1499
  @spec.extensions << "extconf.rb"
@@ -1338,76 +1521,78 @@ gem 'other', version
1338
1521
  RUBY
1339
1522
  end
1340
1523
 
1341
- refute_path_exists File.join @spec.gem_dir, rb
1342
- refute_path_exists File.join @spec.gem_dir, rb2
1524
+ assert_path_not_exist File.join @spec.gem_dir, rb
1525
+ assert_path_not_exist File.join @spec.gem_dir, rb2
1343
1526
  use_ui @ui do
1344
1527
  path = Gem::Package.build @spec
1345
1528
 
1346
1529
  installer = Gem::Installer.at path
1347
1530
  installer.install
1348
1531
  end
1349
- assert_path_exists File.join @spec.gem_dir, rb
1350
- assert_path_exists File.join @spec.gem_dir, rb2
1532
+ assert_path_exist File.join @spec.gem_dir, rb
1533
+ assert_path_exist File.join @spec.gem_dir, rb2
1351
1534
  end
1352
1535
 
1353
1536
  def test_install_extension_flat
1354
- skip "extensions don't quite work on jruby" if Gem.java_platform?
1537
+ pend "extensions don't quite work on jruby" if Gem.java_platform?
1355
1538
 
1356
- @spec = setup_base_spec
1357
- @spec.require_paths = ["."]
1539
+ begin
1540
+ @spec = setup_base_spec
1541
+ @spec.require_paths = ["."]
1358
1542
 
1359
- @spec.extensions << "extconf.rb"
1543
+ @spec.extensions << "extconf.rb"
1360
1544
 
1361
- write_file File.join(@tempdir, "extconf.rb") do |io|
1362
- io.write <<-RUBY
1363
- require "mkmf"
1545
+ write_file File.join(@tempdir, "extconf.rb") do |io|
1546
+ io.write <<-RUBY
1547
+ require "mkmf"
1364
1548
 
1365
- CONFIG['CC'] = '$(TOUCH) $@ ||'
1366
- CONFIG['LDSHARED'] = '$(TOUCH) $@ ||'
1367
- $ruby = '#{Gem.ruby}'
1549
+ CONFIG['CC'] = '$(TOUCH) $@ ||'
1550
+ CONFIG['LDSHARED'] = '$(TOUCH) $@ ||'
1551
+ $ruby = '#{Gem.ruby}'
1368
1552
 
1369
- create_makefile("#{@spec.name}")
1370
- RUBY
1371
- end
1553
+ create_makefile("#{@spec.name}")
1554
+ RUBY
1555
+ end
1372
1556
 
1373
- # empty depend file for no auto dependencies
1374
- @spec.files += %W"depend #{@spec.name}.c".each do |file|
1375
- write_file File.join(@tempdir, file)
1376
- end
1557
+ # empty depend file for no auto dependencies
1558
+ @spec.files += %W[depend #{@spec.name}.c].each do |file|
1559
+ write_file File.join(@tempdir, file)
1560
+ end
1377
1561
 
1378
- so = File.join(@spec.gem_dir, "#{@spec.name}.#{RbConfig::CONFIG["DLEXT"]}")
1379
- refute_path_exists so
1380
- use_ui @ui do
1381
- path = Gem::Package.build @spec
1562
+ so = File.join(@spec.gem_dir, "#{@spec.name}.#{RbConfig::CONFIG["DLEXT"]}")
1563
+ assert_path_not_exist so
1564
+ use_ui @ui do
1565
+ path = Gem::Package.build @spec
1382
1566
 
1383
- installer = Gem::Installer.at path
1384
- installer.install
1385
- end
1386
- assert_path_exists so
1387
- rescue
1388
- puts '-' * 78
1389
- puts File.read File.join(@gemhome, 'gems', 'a-2', 'Makefile')
1390
- puts '-' * 78
1567
+ installer = Gem::Installer.at path
1568
+ installer.install
1569
+ end
1570
+ assert_path_exist so
1571
+ rescue
1572
+ puts "-" * 78
1573
+ puts File.read File.join(@gemhome, "gems", "a-2", "Makefile")
1574
+ puts "-" * 78
1391
1575
 
1392
- path = File.join(@gemhome, 'gems', 'a-2', 'gem_make.out')
1576
+ path = File.join(@gemhome, "gems", "a-2", "gem_make.out")
1393
1577
 
1394
- if File.exist?(path)
1395
- puts File.read(path)
1396
- puts '-' * 78
1397
- end
1578
+ if File.exist?(path)
1579
+ puts File.read(path)
1580
+ puts "-" * 78
1581
+ end
1398
1582
 
1399
- raise
1583
+ raise
1584
+ end
1400
1585
  end
1401
1586
 
1402
1587
  def test_installation_satisfies_dependency_eh
1403
1588
  installer = setup_base_installer
1404
1589
 
1405
- util_spec 'a'
1590
+ util_spec "a"
1406
1591
 
1407
- dep = Gem::Dependency.new 'a', '>= 2'
1592
+ dep = Gem::Dependency.new "a", ">= 2"
1408
1593
  assert installer.installation_satisfies_dependency?(dep)
1409
1594
 
1410
- dep = Gem::Dependency.new 'a', '> 2'
1595
+ dep = Gem::Dependency.new "a", "> 2"
1411
1596
  refute installer.installation_satisfies_dependency?(dep)
1412
1597
  end
1413
1598
 
@@ -1416,19 +1601,20 @@ gem 'other', version
1416
1601
  installer.options[:development] = true
1417
1602
  installer.options[:dev_shallow] = true
1418
1603
 
1419
- util_spec 'a'
1604
+ util_spec "a"
1420
1605
 
1421
- dep = Gem::Dependency.new 'a', :development
1606
+ dep = Gem::Dependency.new "a", :development
1422
1607
  assert installer.installation_satisfies_dependency?(dep)
1423
1608
  end
1424
1609
 
1425
1610
  def test_pre_install_checks_dependencies
1426
1611
  installer = setup_base_installer
1427
- @spec.add_dependency 'b', '> 5'
1612
+ @spec.add_dependency "b", "> 5"
1428
1613
  installer = util_setup_gem
1614
+ installer.force = false
1429
1615
 
1430
1616
  use_ui @ui do
1431
- assert_raises Gem::InstallError do
1617
+ assert_raise Gem::InstallError do
1432
1618
  installer.install
1433
1619
  end
1434
1620
  end
@@ -1436,7 +1622,7 @@ gem 'other', version
1436
1622
 
1437
1623
  def test_pre_install_checks_dependencies_ignore
1438
1624
  installer = util_setup_installer
1439
- @spec.add_dependency 'b', '> 5'
1625
+ @spec.add_dependency "b", "> 5"
1440
1626
  installer.ignore_dependencies = true
1441
1627
 
1442
1628
  build_rake_in do
@@ -1450,16 +1636,16 @@ gem 'other', version
1450
1636
  gemhome2 = "#{@gemhome}2"
1451
1637
 
1452
1638
  @gem = setup_base_gem
1453
- @spec.add_dependency 'd'
1639
+ @spec.add_dependency "d"
1454
1640
 
1455
- quick_gem 'd', 2
1641
+ quick_gem "d", 2
1456
1642
 
1457
1643
  gem = File.join @gemhome, @spec.file_name
1458
1644
 
1459
1645
  FileUtils.mv @gemhome, gemhome2
1460
1646
  FileUtils.mkdir @gemhome
1461
1647
 
1462
- FileUtils.mv File.join(gemhome2, 'cache', @spec.file_name), gem
1648
+ FileUtils.mv File.join(gemhome2, "cache", @spec.file_name), gem
1463
1649
 
1464
1650
  # Don't leak any already activated gems into the installer, require
1465
1651
  # that it work everything out on it's own.
@@ -1474,56 +1660,8 @@ gem 'other', version
1474
1660
  end
1475
1661
  end
1476
1662
 
1477
- def test_pre_install_checks_ruby_version
1478
- use_ui @ui do
1479
- installer = Gem::Installer.at old_ruby_required('= 1.4.6')
1480
- e = assert_raises Gem::RuntimeRequirementNotMetError do
1481
- installer.pre_install_checks
1482
- end
1483
- rv = Gem.ruby_version
1484
- assert_equal "old_ruby_required requires Ruby version = 1.4.6. The current ruby version is #{rv}.",
1485
- e.message
1486
- end
1487
- end
1488
-
1489
- def test_pre_install_checks_ruby_version_with_prereleases
1490
- util_set_RUBY_VERSION '2.6.0', -1, '63539', 'ruby 2.6.0preview2 (2018-05-31 trunk 63539) [x86_64-linux]'
1491
-
1492
- installer = Gem::Installer.at old_ruby_required('>= 2.6.0.preview2')
1493
- assert installer.pre_install_checks
1494
-
1495
- installer = Gem::Installer.at old_ruby_required('> 2.6.0.preview2')
1496
- e = assert_raises Gem::RuntimeRequirementNotMetError do
1497
- assert installer.pre_install_checks
1498
- end
1499
- assert_equal "old_ruby_required requires Ruby version > 2.6.0.preview2. The current ruby version is 2.6.0.preview2.",
1500
- e.message
1501
- ensure
1502
- util_restore_RUBY_VERSION
1503
- end
1504
-
1505
- def test_pre_install_checks_wrong_rubygems_version
1506
- spec = util_spec 'old_rubygems_required', '1' do |s|
1507
- s.required_rubygems_version = '< 0'
1508
- end
1509
-
1510
- util_build_gem spec
1511
-
1512
- gem = File.join(@gemhome, 'cache', spec.file_name)
1513
-
1514
- use_ui @ui do
1515
- installer = Gem::Installer.at gem
1516
- e = assert_raises Gem::RuntimeRequirementNotMetError do
1517
- installer.pre_install_checks
1518
- end
1519
- rgv = Gem::VERSION
1520
- assert_equal "old_rubygems_required requires RubyGems version < 0. The current RubyGems version is #{rgv}. " +
1521
- "Try 'gem update --system' to update RubyGems itself.", e.message
1522
- end
1523
- end
1524
-
1525
1663
  def test_pre_install_checks_malicious_name
1526
- spec = util_spec '../malicious', '1'
1664
+ spec = util_spec "../malicious", "1"
1527
1665
  def spec.full_name # so the spec is buildable
1528
1666
  "malicious-1"
1529
1667
  end
@@ -1531,19 +1669,19 @@ gem 'other', version
1531
1669
 
1532
1670
  util_build_gem spec
1533
1671
 
1534
- gem = File.join(@gemhome, 'cache', spec.file_name)
1672
+ gem = File.join(@gemhome, "cache", spec.file_name)
1535
1673
 
1536
1674
  use_ui @ui do
1537
1675
  installer = Gem::Installer.at gem
1538
- e = assert_raises Gem::InstallError do
1676
+ e = assert_raise Gem::InstallError do
1539
1677
  installer.pre_install_checks
1540
1678
  end
1541
- assert_equal '#<Gem::Specification name=../malicious version=1> has an invalid name', e.message
1679
+ assert_equal "#<Gem::Specification name=../malicious version=1> has an invalid name", e.message
1542
1680
  end
1543
1681
  end
1544
1682
 
1545
1683
  def test_pre_install_checks_malicious_name_before_eval
1546
- spec = util_spec "malicious\n::Object.const_set(:FROM_EVAL, true)#", '1'
1684
+ spec = util_spec "malicious\n::Object.const_set(:FROM_EVAL, true)#", "1"
1547
1685
  def spec.full_name # so the spec is buildable
1548
1686
  "malicious-1"
1549
1687
  end
@@ -1551,11 +1689,11 @@ gem 'other', version
1551
1689
 
1552
1690
  util_build_gem spec
1553
1691
 
1554
- gem = File.join(@gemhome, 'cache', spec.file_name)
1692
+ gem = File.join(@gemhome, "cache", spec.file_name)
1555
1693
 
1556
1694
  use_ui @ui do
1557
1695
  installer = Gem::Installer.at gem
1558
- e = assert_raises Gem::InstallError do
1696
+ e = assert_raise Gem::InstallError do
1559
1697
  installer.pre_install_checks
1560
1698
  end
1561
1699
  assert_equal "#<Gem::Specification name=malicious\n::Object.const_set(:FROM_EVAL, true)# version=1> has an invalid name", e.message
@@ -1564,7 +1702,7 @@ gem 'other', version
1564
1702
  end
1565
1703
 
1566
1704
  def test_pre_install_checks_malicious_require_paths_before_eval
1567
- spec = util_spec "malicious", '1'
1705
+ spec = util_spec "malicious", "1"
1568
1706
  def spec.full_name # so the spec is buildable
1569
1707
  "malicious-1"
1570
1708
  end
@@ -1573,11 +1711,11 @@ gem 'other', version
1573
1711
 
1574
1712
  util_build_gem spec
1575
1713
 
1576
- gem = File.join(@gemhome, 'cache', spec.file_name)
1714
+ gem = File.join(@gemhome, "cache", spec.file_name)
1577
1715
 
1578
1716
  use_ui @ui do
1579
1717
  installer = Gem::Installer.at gem
1580
- e = assert_raises Gem::InstallError do
1718
+ e = assert_raise Gem::InstallError do
1581
1719
  installer.pre_install_checks
1582
1720
  end
1583
1721
  assert_equal "#<Gem::Specification name=malicious version=1> has an invalid require_paths", e.message
@@ -1585,9 +1723,9 @@ gem 'other', version
1585
1723
  end
1586
1724
 
1587
1725
  def test_pre_install_checks_malicious_extensions_before_eval
1588
- skip "mswin environment disallow to create file contained the carriage return code." if Gem.win_platform?
1726
+ pend "mswin environment disallow to create file contained the carriage return code." if Gem.win_platform?
1589
1727
 
1590
- spec = util_spec "malicious", '1'
1728
+ spec = util_spec "malicious", "1"
1591
1729
  def spec.full_name # so the spec is buildable
1592
1730
  "malicious-1"
1593
1731
  end
@@ -1596,11 +1734,11 @@ gem 'other', version
1596
1734
 
1597
1735
  util_build_gem spec
1598
1736
 
1599
- gem = File.join(@gemhome, 'cache', spec.file_name)
1737
+ gem = File.join(@gemhome, "cache", spec.file_name)
1600
1738
 
1601
1739
  use_ui @ui do
1602
1740
  installer = Gem::Installer.at gem
1603
- e = assert_raises Gem::InstallError do
1741
+ e = assert_raise Gem::InstallError do
1604
1742
  installer.pre_install_checks
1605
1743
  end
1606
1744
  assert_equal "#<Gem::Specification name=malicious version=1> has an invalid extensions", e.message
@@ -1608,7 +1746,7 @@ gem 'other', version
1608
1746
  end
1609
1747
 
1610
1748
  def test_pre_install_checks_malicious_specification_version_before_eval
1611
- spec = util_spec "malicious", '1'
1749
+ spec = util_spec "malicious", "1"
1612
1750
  def spec.full_name # so the spec is buildable
1613
1751
  "malicious-1"
1614
1752
  end
@@ -1617,11 +1755,11 @@ gem 'other', version
1617
1755
 
1618
1756
  util_build_gem spec
1619
1757
 
1620
- gem = File.join(@gemhome, 'cache', spec.file_name)
1758
+ gem = File.join(@gemhome, "cache", spec.file_name)
1621
1759
 
1622
1760
  use_ui @ui do
1623
1761
  installer = Gem::Installer.at gem
1624
- e = assert_raises Gem::InstallError do
1762
+ e = assert_raise Gem::InstallError do
1625
1763
  installer.pre_install_checks
1626
1764
  end
1627
1765
  assert_equal "#<Gem::Specification name=malicious version=1> has an invalid specification_version", e.message
@@ -1629,196 +1767,332 @@ gem 'other', version
1629
1767
  end
1630
1768
 
1631
1769
  def test_pre_install_checks_malicious_dependencies_before_eval
1632
- spec = util_spec "malicious", '1'
1770
+ spec = util_spec "malicious", "1"
1633
1771
  def spec.full_name # so the spec is buildable
1634
1772
  "malicious-1"
1635
1773
  end
1636
1774
  def spec.validate(*args); end
1637
- spec.add_dependency "b\nfoo", '> 5'
1775
+ spec.add_dependency "b\nfoo", "> 5"
1638
1776
 
1639
1777
  util_build_gem spec
1640
1778
 
1641
- gem = File.join(@gemhome, 'cache', spec.file_name)
1779
+ gem = File.join(@gemhome, "cache", spec.file_name)
1642
1780
 
1643
1781
  use_ui @ui do
1644
1782
  installer = Gem::Installer.at gem
1645
1783
  installer.ignore_dependencies = true
1646
- e = assert_raises Gem::InstallError do
1784
+ e = assert_raise Gem::InstallError do
1647
1785
  installer.pre_install_checks
1648
1786
  end
1649
1787
  assert_equal "#<Gem::Specification name=malicious version=1> has an invalid dependencies", e.message
1650
1788
  end
1651
1789
  end
1652
1790
 
1791
+ def test_pre_install_checks_malicious_platform_before_eval
1792
+ gem_with_ill_formated_platform = File.expand_path("packages/ill-formatted-platform-1.0.0.10.gem", __dir__)
1793
+
1794
+ installer = Gem::Installer.at(
1795
+ gem_with_ill_formated_platform,
1796
+ :install_dir => @gem_home,
1797
+ :user_install => false,
1798
+ :force => true
1799
+ )
1800
+
1801
+ use_ui @ui do
1802
+ e = assert_raise Gem::InstallError do
1803
+ installer.pre_install_checks
1804
+ end
1805
+
1806
+ assert_equal "x86-mswin32\n system('id > /tmp/nyangawa')# is an invalid platform", e.message
1807
+ assert_empty @ui.output
1808
+ end
1809
+ end
1810
+
1653
1811
  def test_shebang
1654
- installer = setup_base_installer
1812
+ load_relative "no" do
1813
+ installer = setup_base_installer
1655
1814
 
1656
- util_make_exec @spec, "#!/usr/bin/ruby"
1815
+ util_make_exec @spec, "#!/usr/bin/ruby"
1657
1816
 
1658
- shebang = installer.shebang 'executable'
1817
+ shebang = installer.shebang "executable"
1659
1818
 
1660
- assert_equal "#!#{Gem.ruby}", shebang
1819
+ assert_equal "#!#{Gem.ruby}", shebang
1820
+ end
1661
1821
  end
1662
1822
 
1663
1823
  def test_process_options
1664
1824
  installer = setup_base_installer
1665
1825
 
1666
1826
  assert_nil installer.build_root
1667
- assert_equal File.join(@gemhome, 'bin'), installer.bin_dir
1827
+ assert_equal File.join(@gemhome, "bin"), installer.bin_dir
1668
1828
  assert_equal @gemhome, installer.gem_home
1669
1829
  end
1670
1830
 
1671
1831
  def test_process_options_build_root
1672
- build_root = File.join @tempdir, 'build_root'
1832
+ build_root = File.join @tempdir, "build_root"
1833
+ bin_dir = File.join(build_root, @gemhome.gsub(/^[a-zA-Z]:/, ""), "bin")
1834
+ gem_home = File.join(build_root, @gemhome.gsub(/^[a-zA-Z]:/, ""))
1835
+ plugins_dir = File.join(build_root, @gemhome.gsub(/^[a-zA-Z]:/, ""), "plugins")
1673
1836
 
1674
1837
  @gem = setup_base_gem
1675
- installer = Gem::Installer.at @gem, :build_root => build_root
1838
+ installer = use_ui(@ui) { Gem::Installer.at @gem, :build_root => build_root }
1839
+
1840
+ assert_equal build_root, installer.build_root
1841
+ assert_equal bin_dir, installer.bin_dir
1842
+ assert_equal gem_home, installer.gem_home
1843
+
1844
+ errors = @ui.error.split("\n")
1676
1845
 
1677
- assert_equal Pathname(build_root), installer.build_root
1678
- assert_equal File.join(build_root, @gemhome, 'bin'), installer.bin_dir
1679
- assert_equal File.join(build_root, @gemhome), installer.gem_home
1846
+ assert_equal "WARNING: You build with buildroot.", errors.shift
1847
+ assert_equal " Build root: #{build_root}", errors.shift
1848
+ assert_equal " Bin dir: #{bin_dir}", errors.shift
1849
+ assert_equal " Gem home: #{gem_home}", errors.shift
1850
+ assert_equal " Plugins dir: #{plugins_dir}", errors.shift
1680
1851
  end
1681
1852
 
1682
1853
  def test_shebang_arguments
1683
- installer = setup_base_installer
1854
+ load_relative "no" do
1855
+ installer = setup_base_installer
1684
1856
 
1685
- util_make_exec @spec, "#!/usr/bin/ruby -ws"
1857
+ util_make_exec @spec, "#!/usr/bin/ruby -ws"
1686
1858
 
1687
- shebang = installer.shebang 'executable'
1859
+ shebang = installer.shebang "executable"
1688
1860
 
1689
- assert_equal "#!#{Gem.ruby} -ws", shebang
1861
+ assert_equal "#!#{Gem.ruby} -ws", shebang
1862
+ end
1863
+ end
1864
+
1865
+ def test_shebang_arguments_with_load_relative
1866
+ load_relative "yes" do
1867
+ installer = setup_base_installer
1868
+
1869
+ util_make_exec @spec, "#!/usr/bin/ruby -ws"
1870
+
1871
+ shebang = installer.shebang "executable"
1872
+
1873
+ shebang_lines = shebang.split "\n"
1874
+
1875
+ assert_equal "#!/bin/sh", shebang_lines.shift
1876
+ assert_includes shebang_lines, "#!#{Gem.ruby} -ws"
1877
+ end
1690
1878
  end
1691
1879
 
1692
1880
  def test_shebang_empty
1693
- installer = setup_base_installer
1881
+ load_relative "no" do
1882
+ installer = setup_base_installer
1694
1883
 
1695
- util_make_exec @spec, ''
1884
+ util_make_exec @spec, ""
1696
1885
 
1697
- shebang = installer.shebang 'executable'
1698
- assert_equal "#!#{Gem.ruby}", shebang
1886
+ shebang = installer.shebang "executable"
1887
+ assert_equal "#!#{Gem.ruby}", shebang
1888
+ end
1699
1889
  end
1700
1890
 
1701
1891
  def test_shebang_env
1702
- installer = setup_base_installer
1892
+ load_relative "no" do
1893
+ installer = setup_base_installer
1703
1894
 
1704
- util_make_exec @spec, "#!/usr/bin/env ruby"
1895
+ util_make_exec @spec, "#!/usr/bin/env ruby"
1705
1896
 
1706
- shebang = installer.shebang 'executable'
1897
+ shebang = installer.shebang "executable"
1707
1898
 
1708
- assert_equal "#!#{Gem.ruby}", shebang
1899
+ assert_equal "#!#{Gem.ruby}", shebang
1900
+ end
1709
1901
  end
1710
1902
 
1711
1903
  def test_shebang_env_arguments
1712
- installer = setup_base_installer
1904
+ load_relative "no" do
1905
+ installer = setup_base_installer
1906
+
1907
+ util_make_exec @spec, "#!/usr/bin/env ruby -ws"
1908
+
1909
+ shebang = installer.shebang "executable"
1713
1910
 
1714
- util_make_exec @spec, "#!/usr/bin/env ruby -ws"
1911
+ assert_equal "#!#{Gem.ruby} -ws", shebang
1912
+ end
1913
+ end
1715
1914
 
1716
- shebang = installer.shebang 'executable'
1915
+ def test_shebang_env_arguments_with_load_relative
1916
+ load_relative "yes" do
1917
+ installer = setup_base_installer
1717
1918
 
1718
- assert_equal "#!#{Gem.ruby} -ws", shebang
1919
+ util_make_exec @spec, "#!/usr/bin/env ruby -ws"
1920
+
1921
+ shebang = installer.shebang "executable"
1922
+
1923
+ shebang_lines = shebang.split "\n"
1924
+
1925
+ assert_equal "#!/bin/sh", shebang_lines.shift
1926
+ assert_includes shebang_lines, "#!#{Gem.ruby} -ws"
1927
+ end
1719
1928
  end
1720
1929
 
1721
1930
  def test_shebang_env_shebang
1722
1931
  installer = setup_base_installer
1723
1932
 
1724
- util_make_exec @spec, ''
1933
+ util_make_exec @spec, ""
1725
1934
  installer.env_shebang = true
1726
1935
 
1727
- shebang = installer.shebang 'executable'
1936
+ shebang = installer.shebang "executable"
1728
1937
 
1729
- env_shebang = "/usr/bin/env" unless Gem.win_platform?
1938
+ bin_env = get_bin_env
1730
1939
 
1731
- assert_equal("#!#{env_shebang} #{RbConfig::CONFIG['ruby_install_name']}",
1940
+ assert_equal("#!#{bin_env} #{RbConfig::CONFIG['ruby_install_name']}",
1732
1941
  shebang)
1733
1942
  end
1734
1943
 
1735
1944
  def test_shebang_nested
1736
- installer = setup_base_installer
1945
+ load_relative "no" do
1946
+ installer = setup_base_installer
1737
1947
 
1738
- util_make_exec @spec, "#!/opt/local/ruby/bin/ruby"
1948
+ util_make_exec @spec, "#!/opt/local/ruby/bin/ruby"
1739
1949
 
1740
- shebang = installer.shebang 'executable'
1950
+ shebang = installer.shebang "executable"
1741
1951
 
1742
- assert_equal "#!#{Gem.ruby}", shebang
1952
+ assert_equal "#!#{Gem.ruby}", shebang
1953
+ end
1743
1954
  end
1744
1955
 
1745
1956
  def test_shebang_nested_arguments
1746
- installer = setup_base_installer
1957
+ load_relative "no" do
1958
+ installer = setup_base_installer
1959
+
1960
+ util_make_exec @spec, "#!/opt/local/ruby/bin/ruby -ws"
1961
+
1962
+ shebang = installer.shebang "executable"
1963
+
1964
+ assert_equal "#!#{Gem.ruby} -ws", shebang
1965
+ end
1966
+ end
1747
1967
 
1748
- util_make_exec @spec, "#!/opt/local/ruby/bin/ruby -ws"
1968
+ def test_shebang_nested_arguments_with_load_relative
1969
+ load_relative "yes" do
1970
+ installer = setup_base_installer
1749
1971
 
1750
- shebang = installer.shebang 'executable'
1972
+ util_make_exec @spec, "#!/opt/local/ruby/bin/ruby -ws"
1751
1973
 
1752
- assert_equal "#!#{Gem.ruby} -ws", shebang
1974
+ shebang = installer.shebang "executable"
1975
+
1976
+ shebang_lines = shebang.split "\n"
1977
+
1978
+ assert_equal "#!/bin/sh", shebang_lines.shift
1979
+ assert_includes shebang_lines, "#!#{Gem.ruby} -ws"
1980
+ end
1753
1981
  end
1754
1982
 
1755
1983
  def test_shebang_version
1756
- installer = setup_base_installer
1984
+ load_relative "no" do
1985
+ installer = setup_base_installer
1757
1986
 
1758
- util_make_exec @spec, "#!/usr/bin/ruby18"
1987
+ util_make_exec @spec, "#!/usr/bin/ruby18"
1759
1988
 
1760
- shebang = installer.shebang 'executable'
1989
+ shebang = installer.shebang "executable"
1761
1990
 
1762
- assert_equal "#!#{Gem.ruby}", shebang
1991
+ assert_equal "#!#{Gem.ruby}", shebang
1992
+ end
1763
1993
  end
1764
1994
 
1765
1995
  def test_shebang_version_arguments
1766
- installer = setup_base_installer
1996
+ load_relative "no" do
1997
+ installer = setup_base_installer
1767
1998
 
1768
- util_make_exec @spec, "#!/usr/bin/ruby18 -ws"
1999
+ util_make_exec @spec, "#!/usr/bin/ruby18 -ws"
1769
2000
 
1770
- shebang = installer.shebang 'executable'
2001
+ shebang = installer.shebang "executable"
1771
2002
 
1772
- assert_equal "#!#{Gem.ruby} -ws", shebang
2003
+ assert_equal "#!#{Gem.ruby} -ws", shebang
2004
+ end
2005
+ end
2006
+
2007
+ def test_shebang_version_arguments_with_load_relative
2008
+ load_relative "yes" do
2009
+ installer = setup_base_installer
2010
+
2011
+ util_make_exec @spec, "#!/usr/bin/ruby18 -ws"
2012
+
2013
+ shebang = installer.shebang "executable"
2014
+
2015
+ shebang_lines = shebang.split "\n"
2016
+
2017
+ assert_equal "#!/bin/sh", shebang_lines.shift
2018
+ assert_includes shebang_lines, "#!#{Gem.ruby} -ws"
2019
+ end
1773
2020
  end
1774
2021
 
1775
2022
  def test_shebang_version_env
1776
- installer = setup_base_installer
2023
+ load_relative "no" do
2024
+ installer = setup_base_installer
1777
2025
 
1778
- util_make_exec @spec, "#!/usr/bin/env ruby18"
2026
+ util_make_exec @spec, "#!/usr/bin/env ruby18"
1779
2027
 
1780
- shebang = installer.shebang 'executable'
2028
+ shebang = installer.shebang "executable"
1781
2029
 
1782
- assert_equal "#!#{Gem.ruby}", shebang
2030
+ assert_equal "#!#{Gem.ruby}", shebang
2031
+ end
1783
2032
  end
1784
2033
 
1785
2034
  def test_shebang_version_env_arguments
1786
- installer = setup_base_installer
2035
+ load_relative "no" do
2036
+ installer = setup_base_installer
1787
2037
 
1788
- util_make_exec @spec, "#!/usr/bin/env ruby18 -ws"
2038
+ util_make_exec @spec, "#!/usr/bin/env ruby18 -ws"
1789
2039
 
1790
- shebang = installer.shebang 'executable'
2040
+ shebang = installer.shebang "executable"
1791
2041
 
1792
- assert_equal "#!#{Gem.ruby} -ws", shebang
2042
+ assert_equal "#!#{Gem.ruby} -ws", shebang
2043
+ end
2044
+ end
2045
+
2046
+ def test_shebang_version_env_arguments_with_load_relative
2047
+ load_relative "yes" do
2048
+ installer = setup_base_installer
2049
+
2050
+ util_make_exec @spec, "#!/usr/bin/env ruby18 -ws"
2051
+
2052
+ shebang = installer.shebang "executable"
2053
+
2054
+ shebang_lines = shebang.split "\n"
2055
+
2056
+ assert_equal "#!/bin/sh", shebang_lines.shift
2057
+ assert_includes shebang_lines, "#!#{Gem.ruby} -ws"
2058
+ end
1793
2059
  end
1794
2060
 
1795
2061
  def test_shebang_custom
1796
2062
  installer = setup_base_installer
1797
2063
 
1798
2064
  conf = Gem::ConfigFile.new []
1799
- conf[:custom_shebang] = 'test'
2065
+ conf[:custom_shebang] = "test"
1800
2066
 
1801
2067
  Gem.configuration = conf
1802
2068
 
1803
2069
  util_make_exec @spec, "#!/usr/bin/ruby"
1804
2070
 
1805
- shebang = installer.shebang 'executable'
2071
+ shebang = installer.shebang "executable"
1806
2072
 
1807
2073
  assert_equal "#!test", shebang
1808
2074
  end
1809
2075
 
2076
+ def get_bin_env
2077
+ if win_platform?
2078
+ ""
2079
+ else
2080
+ %w[/usr/bin/env /bin/env].find {|f| File.executable?(f) }
2081
+ end
2082
+ end
2083
+
1810
2084
  def test_shebang_custom_with_expands
1811
2085
  installer = setup_base_installer
1812
2086
 
1813
- bin_env = win_platform? ? '' : '/usr/bin/env'
2087
+ bin_env = get_bin_env
1814
2088
  conf = Gem::ConfigFile.new []
1815
- conf[:custom_shebang] = '1 $env 2 $ruby 3 $exec 4 $name'
2089
+ conf[:custom_shebang] = "1 $env 2 $ruby 3 $exec 4 $name"
1816
2090
 
1817
2091
  Gem.configuration = conf
1818
2092
 
1819
2093
  util_make_exec @spec, "#!/usr/bin/ruby"
1820
2094
 
1821
- shebang = installer.shebang 'executable'
2095
+ shebang = installer.shebang "executable"
1822
2096
 
1823
2097
  assert_equal "#!1 #{bin_env} 2 #{Gem.ruby} 3 executable 4 a", shebang
1824
2098
  end
@@ -1826,15 +2100,15 @@ gem 'other', version
1826
2100
  def test_shebang_custom_with_expands_and_arguments
1827
2101
  installer = setup_base_installer
1828
2102
 
1829
- bin_env = win_platform? ? '' : '/usr/bin/env'
2103
+ bin_env = get_bin_env
1830
2104
  conf = Gem::ConfigFile.new []
1831
- conf[:custom_shebang] = '1 $env 2 $ruby 3 $exec'
2105
+ conf[:custom_shebang] = "1 $env 2 $ruby 3 $exec"
1832
2106
 
1833
2107
  Gem.configuration = conf
1834
2108
 
1835
2109
  util_make_exec @spec, "#!/usr/bin/ruby -ws"
1836
2110
 
1837
- shebang = installer.shebang 'executable'
2111
+ shebang = installer.shebang "executable"
1838
2112
 
1839
2113
  assert_equal "#!1 #{bin_env} 2 #{Gem.ruby} -ws 3 executable", shebang
1840
2114
  end
@@ -1842,20 +2116,20 @@ gem 'other', version
1842
2116
  def test_unpack
1843
2117
  installer = util_setup_installer
1844
2118
 
1845
- dest = File.join @gemhome, 'gems', @spec.full_name
2119
+ dest = File.join @gemhome, "gems", @spec.full_name
1846
2120
 
1847
2121
  Gem::Deprecate.skip_during do
1848
2122
  installer.unpack dest
1849
2123
  end
1850
2124
 
1851
- assert_path_exists File.join dest, 'lib', 'code.rb'
1852
- assert_path_exists File.join dest, 'bin', 'executable'
2125
+ assert_path_exist File.join dest, "lib", "code.rb"
2126
+ assert_path_exist File.join dest, "bin", "executable"
1853
2127
  end
1854
2128
 
1855
2129
  def test_write_build_info_file
1856
2130
  installer = setup_base_installer
1857
2131
 
1858
- refute_path_exists @spec.build_info_file
2132
+ assert_path_not_exist @spec.build_info_file
1859
2133
 
1860
2134
  installer.build_args = %w[
1861
2135
  --with-libyaml-dir /usr/local/Cellar/libyaml/0.1.4
@@ -1863,7 +2137,7 @@ gem 'other', version
1863
2137
 
1864
2138
  installer.write_build_info_file
1865
2139
 
1866
- assert_path_exists @spec.build_info_file
2140
+ assert_path_exist @spec.build_info_file
1867
2141
 
1868
2142
  expected = "--with-libyaml-dir\n/usr/local/Cellar/libyaml/0.1.4\n"
1869
2143
 
@@ -1873,11 +2147,11 @@ gem 'other', version
1873
2147
  def test_write_build_info_file_empty
1874
2148
  installer = setup_base_installer
1875
2149
 
1876
- refute_path_exists @spec.build_info_file
2150
+ assert_path_not_exist @spec.build_info_file
1877
2151
 
1878
2152
  installer.write_build_info_file
1879
2153
 
1880
- refute_path_exists @spec.build_info_file
2154
+ assert_path_not_exist @spec.build_info_file
1881
2155
  end
1882
2156
 
1883
2157
  def test_write_build_info_file_install_dir
@@ -1890,38 +2164,38 @@ gem 'other', version
1890
2164
 
1891
2165
  installer.write_build_info_file
1892
2166
 
1893
- refute_path_exists @spec.build_info_file
1894
- assert_path_exists \
1895
- File.join("#{@gemhome}2", 'build_info', "#{@spec.full_name}.info")
2167
+ assert_path_not_exist @spec.build_info_file
2168
+ assert_path_exist \
2169
+ File.join("#{@gemhome}2", "build_info", "#{@spec.full_name}.info")
1896
2170
  end
1897
2171
 
1898
2172
  def test_write_cache_file
1899
2173
  @gem = setup_base_gem
1900
- cache_file = File.join @gemhome, 'cache', @spec.file_name
2174
+ cache_file = File.join @gemhome, "cache", @spec.file_name
1901
2175
  gem = File.join @gemhome, @spec.file_name
1902
2176
 
1903
2177
  FileUtils.mv cache_file, gem
1904
- refute_path_exists cache_file
2178
+ assert_path_not_exist cache_file
1905
2179
 
1906
2180
  installer = Gem::Installer.at gem
1907
2181
  installer.gem_home = @gemhome
1908
2182
 
1909
2183
  installer.write_cache_file
1910
2184
 
1911
- assert_path_exists cache_file
2185
+ assert_path_exist cache_file
1912
2186
  end
1913
2187
 
1914
2188
  def test_write_spec
1915
2189
  @spec = setup_base_spec
1916
2190
  FileUtils.rm @spec.spec_file
1917
- refute_path_exists @spec.spec_file
2191
+ assert_path_not_exist @spec.spec_file
1918
2192
 
1919
2193
  installer = Gem::Installer.for_spec @spec
1920
2194
  installer.gem_home = @gemhome
1921
2195
 
1922
2196
  installer.write_spec
1923
2197
 
1924
- assert_path_exists @spec.spec_file
2198
+ assert_path_exist @spec.spec_file
1925
2199
 
1926
2200
  loaded = Gem::Specification.load @spec.spec_file
1927
2201
 
@@ -1933,7 +2207,7 @@ gem 'other', version
1933
2207
  def test_write_spec_writes_cached_spec
1934
2208
  @spec = setup_base_spec
1935
2209
  FileUtils.rm @spec.spec_file
1936
- refute_path_exists @spec.spec_file
2210
+ assert_path_not_exist @spec.spec_file
1937
2211
 
1938
2212
  @spec.files = %w[a.rb b.rb c.rb]
1939
2213
 
@@ -1951,11 +2225,11 @@ gem 'other', version
1951
2225
  def test_dir
1952
2226
  installer = setup_base_installer
1953
2227
 
1954
- assert_match %r!/gemhome/gems/a-2$!, installer.dir
2228
+ assert_match %r{/gemhome/gems/a-2$}, installer.dir
1955
2229
  end
1956
2230
 
1957
2231
  def test_default_gem_loaded_from
1958
- spec = util_spec 'a'
2232
+ spec = util_spec "a"
1959
2233
  installer = Gem::Installer.for_spec spec, :install_as_default => true
1960
2234
  installer.install
1961
2235
  assert_predicate spec, :default_gem?
@@ -1964,7 +2238,7 @@ gem 'other', version
1964
2238
  def test_default_gem_without_wrappers
1965
2239
  installer = setup_base_installer
1966
2240
 
1967
- FileUtils.rm_f File.join(Gem.dir, 'specifications')
2241
+ FileUtils.rm_rf File.join(Gem.default_dir, "specifications")
1968
2242
 
1969
2243
  installer.wrappers = false
1970
2244
  installer.options[:install_as_default] = true
@@ -1974,24 +2248,30 @@ gem 'other', version
1974
2248
  installer.install
1975
2249
  end
1976
2250
 
1977
- assert_directory_exists File.join(@spec.gem_dir, 'bin')
1978
- installed_exec = File.join @spec.gem_dir, 'bin', 'executable'
1979
- assert_path_exists installed_exec
2251
+ assert_directory_exists File.join(@spec.gem_dir, "bin")
2252
+ installed_exec = File.join @spec.gem_dir, "bin", "executable"
2253
+ assert_path_exist installed_exec
1980
2254
 
1981
- assert_directory_exists File.join(Gem.default_dir, 'specifications')
1982
- assert_directory_exists File.join(Gem.default_dir, 'specifications', 'default')
2255
+ assert_directory_exists File.join(Gem.default_dir, "specifications")
2256
+ assert_directory_exists File.join(Gem.default_dir, "specifications", "default")
1983
2257
 
1984
- default_spec = eval File.read File.join(Gem.default_dir, 'specifications', 'default', 'a-2.gemspec')
2258
+ default_spec = eval File.read File.join(Gem.default_dir, "specifications", "default", "a-2.gemspec")
1985
2259
  assert_equal Gem::Version.new("2"), default_spec.version
1986
- assert_equal ['bin/executable'], default_spec.files
2260
+ assert_equal ["bin/executable"], default_spec.files
1987
2261
 
1988
2262
  assert_directory_exists util_inst_bindir
1989
2263
 
1990
- installed_exec = File.join util_inst_bindir, 'executable'
1991
- assert_path_exists installed_exec
2264
+ installed_exec = File.join util_inst_bindir, "executable"
2265
+ assert_path_exist installed_exec
1992
2266
 
1993
2267
  wrapper = File.read installed_exec
1994
- refute_match %r|generated by RubyGems|, wrapper
2268
+
2269
+ if symlink_supported?
2270
+ refute_match %r{generated by RubyGems}, wrapper
2271
+ else # when symlink not supported, it warns and fallbacks back to installing wrapper
2272
+ assert_match %r{Unable to use symlinks, installing wrapper}, @ui.error
2273
+ assert_match %r{generated by RubyGems}, wrapper
2274
+ end
1995
2275
  end
1996
2276
 
1997
2277
  def test_default_gem_with_wrappers
@@ -2007,16 +2287,16 @@ gem 'other', version
2007
2287
 
2008
2288
  assert_directory_exists util_inst_bindir
2009
2289
 
2010
- installed_exec = File.join util_inst_bindir, 'executable'
2011
- assert_path_exists installed_exec
2290
+ installed_exec = File.join util_inst_bindir, "executable"
2291
+ assert_path_exist installed_exec
2012
2292
 
2013
2293
  wrapper = File.read installed_exec
2014
- assert_match %r|generated by RubyGems|, wrapper
2294
+ assert_match %r{generated by RubyGems}, wrapper
2015
2295
  end
2016
2296
 
2017
2297
  def test_default_gem_with_exe_as_bindir
2018
- @spec = quick_gem 'c' do |spec|
2019
- util_make_exec spec, '#!/usr/bin/ruby', 'exe'
2298
+ @spec = quick_gem "c" do |spec|
2299
+ util_make_exec spec, "#!/usr/bin/ruby", "exe"
2020
2300
  end
2021
2301
 
2022
2302
  util_build_gem @spec
@@ -2032,21 +2312,38 @@ gem 'other', version
2032
2312
  installer.install
2033
2313
  end
2034
2314
 
2035
- assert_directory_exists File.join(@spec.gem_dir, 'exe')
2036
- installed_exec = File.join @spec.gem_dir, 'exe', 'executable'
2037
- assert_path_exists installed_exec
2315
+ assert_directory_exists File.join(@spec.gem_dir, "exe")
2316
+ installed_exec = File.join @spec.gem_dir, "exe", "executable"
2317
+ assert_path_exist installed_exec
2318
+
2319
+ assert_directory_exists File.join(Gem.default_dir, "specifications")
2320
+ assert_directory_exists File.join(Gem.default_dir, "specifications", "default")
2038
2321
 
2039
- assert_directory_exists File.join(Gem.default_dir, 'specifications')
2040
- assert_directory_exists File.join(Gem.default_dir, 'specifications', 'default')
2322
+ default_spec = eval File.read File.join(Gem.default_dir, "specifications", "default", "c-2.gemspec")
2323
+ assert_equal Gem::Version.new("2"), default_spec.version
2324
+ assert_equal ["exe/executable"], default_spec.files
2325
+ end
2326
+
2327
+ def test_default_gem_to_specific_install_dir
2328
+ @gem = setup_base_gem
2329
+ installer = util_installer @spec, "#{@gemhome}2"
2330
+ installer.options[:install_as_default] = true
2331
+
2332
+ use_ui @ui do
2333
+ installer.install
2334
+ end
2041
2335
 
2042
- default_spec = eval File.read File.join(Gem.default_dir, 'specifications', 'default', 'c-2.gemspec')
2336
+ assert_directory_exists File.join("#{@gemhome}2", "specifications")
2337
+ assert_directory_exists File.join("#{@gemhome}2", "specifications", "default")
2338
+
2339
+ default_spec = eval File.read File.join("#{@gemhome}2", "specifications", "default", "a-2.gemspec")
2043
2340
  assert_equal Gem::Version.new("2"), default_spec.version
2044
- assert_equal ['exe/executable'], default_spec.files
2341
+ assert_equal ["bin/executable"], default_spec.files
2045
2342
  end
2046
2343
 
2047
2344
  def test_package_attribute
2048
- gem = quick_gem 'c' do |spec|
2049
- util_make_exec spec, '#!/usr/bin/ruby', 'exe'
2345
+ gem = quick_gem "c" do |spec|
2346
+ util_make_exec spec, "#!/usr/bin/ruby", "exe"
2050
2347
  end
2051
2348
 
2052
2349
  installer = util_installer(gem, @gemhome)
@@ -2054,25 +2351,27 @@ gem 'other', version
2054
2351
  assert_kind_of(Gem::Package, installer.package)
2055
2352
  end
2056
2353
 
2057
- def old_ruby_required(requirement)
2058
- spec = util_spec 'old_ruby_required', '1' do |s|
2059
- s.required_ruby_version = requirement
2354
+ def test_gem_attribute
2355
+ gem = quick_gem "c" do |spec|
2356
+ util_make_exec spec, "#!/usr/bin/ruby", "exe"
2060
2357
  end
2061
2358
 
2062
- util_build_gem spec
2063
-
2064
- spec.cache_file
2359
+ installer = util_installer(gem, @gemhome)
2360
+ assert_respond_to(installer, :gem)
2361
+ assert_kind_of(String, installer.gem)
2065
2362
  end
2066
2363
 
2364
+ private
2365
+
2067
2366
  def util_execless
2068
- @spec = util_spec 'z'
2367
+ @spec = util_spec "z"
2069
2368
  util_build_gem @spec
2070
2369
 
2071
2370
  util_installer @spec, @gemhome
2072
2371
  end
2073
2372
 
2074
2373
  def util_conflict_executable(wrappers)
2075
- conflict = quick_gem 'conflict' do |spec|
2374
+ conflict = quick_gem "conflict" do |spec|
2076
2375
  util_make_exec spec
2077
2376
  end
2078
2377
 
@@ -2084,7 +2383,15 @@ gem 'other', version
2084
2383
  end
2085
2384
 
2086
2385
  def mask
2087
- 0100755 & (~File.umask)
2386
+ 0100755
2088
2387
  end
2089
2388
 
2389
+ def load_relative(value)
2390
+ orig_LIBRUBY_RELATIVE = RbConfig::CONFIG["LIBRUBY_RELATIVE"]
2391
+ RbConfig::CONFIG["LIBRUBY_RELATIVE"] = value
2392
+
2393
+ yield
2394
+ ensure
2395
+ RbConfig::CONFIG["LIBRUBY_RELATIVE"] = orig_LIBRUBY_RELATIVE
2396
+ end
2090
2397
  end