rubygems-update 3.0.3 → 3.4.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (795) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +5556 -0
  3. data/CODE_OF_CONDUCT.md +62 -24
  4. data/CONTRIBUTING.md +111 -21
  5. data/MAINTAINERS.txt +1 -6
  6. data/Manifest.txt +209 -101
  7. data/POLICIES.md +65 -22
  8. data/README.md +23 -15
  9. data/UPGRADING.md +5 -81
  10. data/bin/gem +2 -16
  11. data/bin/update_rubygems +5 -5
  12. data/bundler/CHANGELOG.md +2619 -1256
  13. data/bundler/LICENSE.md +18 -19
  14. data/bundler/README.md +11 -12
  15. data/bundler/UPGRADING.md +222 -0
  16. data/bundler/bundler.gemspec +13 -33
  17. data/bundler/exe/bundle +26 -11
  18. data/bundler/exe/bundler +1 -1
  19. data/bundler/lib/bundler/.document +1 -0
  20. data/bundler/lib/bundler/build_metadata.rb +5 -13
  21. data/bundler/lib/bundler/capistrano.rb +4 -4
  22. data/bundler/lib/bundler/cli/add.rb +28 -16
  23. data/bundler/lib/bundler/cli/binstubs.rb +11 -3
  24. data/bundler/lib/bundler/cli/cache.rb +24 -17
  25. data/bundler/lib/bundler/cli/check.rb +5 -3
  26. data/bundler/lib/bundler/cli/clean.rb +1 -1
  27. data/bundler/lib/bundler/cli/common.rb +41 -13
  28. data/bundler/lib/bundler/cli/config.rb +170 -86
  29. data/bundler/lib/bundler/cli/console.rb +3 -3
  30. data/bundler/lib/bundler/cli/doctor.rb +27 -10
  31. data/bundler/lib/bundler/cli/exec.rb +8 -25
  32. data/bundler/lib/bundler/cli/fund.rb +36 -0
  33. data/bundler/lib/bundler/cli/gem.rb +261 -48
  34. data/bundler/lib/bundler/cli/info.rb +52 -8
  35. data/bundler/lib/bundler/cli/init.rb +7 -3
  36. data/bundler/lib/bundler/cli/inject.rb +1 -1
  37. data/bundler/lib/bundler/cli/install.rb +38 -66
  38. data/bundler/lib/bundler/cli/issue.rb +8 -7
  39. data/bundler/lib/bundler/cli/list.rb +19 -11
  40. data/bundler/lib/bundler/cli/lock.rb +11 -4
  41. data/bundler/lib/bundler/cli/open.rb +14 -9
  42. data/bundler/lib/bundler/cli/outdated.rb +152 -121
  43. data/bundler/lib/bundler/cli/platform.rb +2 -2
  44. data/bundler/lib/bundler/cli/plugin.rb +19 -2
  45. data/bundler/lib/bundler/cli/pristine.rb +6 -1
  46. data/bundler/lib/bundler/cli/remove.rb +1 -2
  47. data/bundler/lib/bundler/cli/show.rb +3 -3
  48. data/bundler/lib/bundler/cli/update.rb +49 -18
  49. data/bundler/lib/bundler/cli/viz.rb +1 -1
  50. data/bundler/lib/bundler/cli.rb +269 -165
  51. data/bundler/lib/bundler/compact_index_client/cache.rb +7 -24
  52. data/bundler/lib/bundler/compact_index_client/gem_parser.rb +28 -0
  53. data/bundler/lib/bundler/compact_index_client/updater.rb +58 -57
  54. data/bundler/lib/bundler/compact_index_client.rb +28 -18
  55. data/bundler/lib/bundler/constants.rb +1 -1
  56. data/bundler/lib/bundler/current_ruby.rb +26 -11
  57. data/bundler/lib/bundler/definition.rb +359 -441
  58. data/bundler/lib/bundler/dependency.rb +29 -71
  59. data/bundler/lib/bundler/deployment.rb +1 -1
  60. data/bundler/lib/bundler/digest.rb +71 -0
  61. data/bundler/lib/bundler/dsl.rb +84 -116
  62. data/bundler/lib/bundler/endpoint_specification.rb +20 -14
  63. data/bundler/lib/bundler/env.rb +10 -15
  64. data/bundler/lib/bundler/environment_preserver.rb +30 -3
  65. data/bundler/lib/bundler/errors.rb +31 -14
  66. data/bundler/lib/bundler/feature_flag.rb +13 -33
  67. data/bundler/lib/bundler/fetcher/base.rb +7 -9
  68. data/bundler/lib/bundler/fetcher/compact_index.rb +46 -39
  69. data/bundler/lib/bundler/fetcher/dependency.rb +2 -2
  70. data/bundler/lib/bundler/fetcher/downloader.rb +15 -12
  71. data/bundler/lib/bundler/fetcher/index.rb +4 -30
  72. data/bundler/lib/bundler/fetcher.rb +39 -41
  73. data/bundler/lib/bundler/force_platform.rb +18 -0
  74. data/bundler/lib/bundler/friendly_errors.rb +49 -54
  75. data/bundler/lib/bundler/gem_helper.rb +79 -43
  76. data/bundler/lib/bundler/gem_helpers.rb +44 -28
  77. data/bundler/lib/bundler/gem_tasks.rb +1 -1
  78. data/bundler/lib/bundler/gem_version_promoter.rb +54 -99
  79. data/bundler/lib/bundler/graph.rb +5 -5
  80. data/bundler/lib/bundler/index.rb +14 -52
  81. data/bundler/lib/bundler/injector.rb +50 -16
  82. data/bundler/lib/bundler/inline.rb +28 -29
  83. data/bundler/lib/bundler/installer/gem_installer.rb +22 -23
  84. data/bundler/lib/bundler/installer/parallel_installer.rb +51 -51
  85. data/bundler/lib/bundler/installer/standalone.rb +62 -12
  86. data/bundler/lib/bundler/installer.rb +46 -97
  87. data/bundler/lib/bundler/lazy_specification.rb +88 -48
  88. data/bundler/lib/bundler/lockfile_generator.rb +3 -3
  89. data/bundler/lib/bundler/lockfile_parser.rb +30 -62
  90. data/bundler/{man → lib/bundler/man}/bundle-add.1 +29 -5
  91. data/bundler/{man/bundle-add.ronn → lib/bundler/man/bundle-add.1.ronn} +22 -4
  92. data/bundler/{man → lib/bundler/man}/bundle-binstubs.1 +6 -4
  93. data/bundler/{man/bundle-binstubs.ronn → lib/bundler/man/bundle-binstubs.1.ronn} +3 -5
  94. data/bundler/lib/bundler/man/bundle-cache.1 +61 -0
  95. data/bundler/{man/bundle-package.ronn → lib/bundler/man/bundle-cache.1.ronn} +22 -15
  96. data/bundler/{man → lib/bundler/man}/bundle-check.1 +1 -1
  97. data/bundler/{man → lib/bundler/man}/bundle-clean.1 +2 -2
  98. data/bundler/{man/bundle-clean.ronn → lib/bundler/man/bundle-clean.1.ronn} +1 -1
  99. data/bundler/{man → lib/bundler/man}/bundle-config.1 +78 -60
  100. data/bundler/{man/bundle-config.ronn → lib/bundler/man/bundle-config.1.ronn} +96 -85
  101. data/bundler/lib/bundler/man/bundle-console.1 +53 -0
  102. data/bundler/lib/bundler/man/bundle-console.1.ronn +44 -0
  103. data/bundler/{man → lib/bundler/man}/bundle-doctor.1 +1 -1
  104. data/bundler/{man → lib/bundler/man}/bundle-exec.1 +6 -6
  105. data/bundler/{man/bundle-exec.ronn → lib/bundler/man/bundle-exec.1.ronn} +6 -6
  106. data/bundler/lib/bundler/man/bundle-gem.1 +105 -0
  107. data/bundler/lib/bundler/man/bundle-gem.1.ronn +117 -0
  108. data/bundler/lib/bundler/man/bundle-help.1 +13 -0
  109. data/bundler/lib/bundler/man/bundle-help.1.ronn +12 -0
  110. data/bundler/{man → lib/bundler/man}/bundle-info.1 +1 -1
  111. data/bundler/{man → lib/bundler/man}/bundle-init.1 +6 -2
  112. data/bundler/{man/bundle-init.ronn → lib/bundler/man/bundle-init.1.ronn} +3 -1
  113. data/bundler/{man → lib/bundler/man}/bundle-inject.1 +5 -2
  114. data/bundler/{man/bundle-inject.ronn → lib/bundler/man/bundle-inject.1.ronn} +3 -1
  115. data/bundler/{man → lib/bundler/man}/bundle-install.1 +42 -37
  116. data/bundler/{man/bundle-install.ronn → lib/bundler/man/bundle-install.1.ronn} +42 -38
  117. data/bundler/{man → lib/bundler/man}/bundle-list.1 +7 -7
  118. data/bundler/{man/bundle-list.ronn → lib/bundler/man/bundle-list.1.ronn} +6 -6
  119. data/bundler/{man → lib/bundler/man}/bundle-lock.1 +1 -1
  120. data/bundler/{man → lib/bundler/man}/bundle-open.1 +22 -2
  121. data/bundler/{man/bundle-open.ronn → lib/bundler/man/bundle-open.1.ronn} +9 -1
  122. data/bundler/{man → lib/bundler/man}/bundle-outdated.1 +3 -10
  123. data/bundler/{man/bundle-outdated.ronn → lib/bundler/man/bundle-outdated.1.ronn} +1 -10
  124. data/bundler/{man → lib/bundler/man}/bundle-platform.1 +16 -6
  125. data/bundler/{man/bundle-platform.ronn → lib/bundler/man/bundle-platform.1.ronn} +14 -7
  126. data/bundler/lib/bundler/man/bundle-plugin.1 +81 -0
  127. data/bundler/lib/bundler/man/bundle-plugin.1.ronn +59 -0
  128. data/bundler/{man → lib/bundler/man}/bundle-pristine.1 +1 -1
  129. data/bundler/{man → lib/bundler/man}/bundle-remove.1 +1 -1
  130. data/bundler/{man → lib/bundler/man}/bundle-show.1 +1 -1
  131. data/bundler/{man → lib/bundler/man}/bundle-update.1 +8 -8
  132. data/bundler/{man/bundle-update.ronn → lib/bundler/man/bundle-update.1.ronn} +8 -7
  133. data/bundler/lib/bundler/man/bundle-version.1 +35 -0
  134. data/bundler/lib/bundler/man/bundle-version.1.ronn +24 -0
  135. data/bundler/{man → lib/bundler/man}/bundle-viz.1 +4 -1
  136. data/bundler/{man/bundle-viz.ronn → lib/bundler/man/bundle-viz.1.ronn} +2 -0
  137. data/bundler/{man → lib/bundler/man}/bundle.1 +17 -12
  138. data/bundler/{man/bundle.ronn → lib/bundler/man/bundle.1.ronn} +14 -9
  139. data/bundler/lib/bundler/man/gemfile.5 +723 -0
  140. data/bundler/{man → lib/bundler/man}/gemfile.5.ronn +112 -95
  141. data/bundler/lib/bundler/man/index.txt +29 -0
  142. data/bundler/lib/bundler/match_metadata.rb +13 -0
  143. data/bundler/lib/bundler/match_platform.rb +1 -2
  144. data/bundler/lib/bundler/match_remote_metadata.rb +29 -0
  145. data/bundler/lib/bundler/mirror.rb +10 -12
  146. data/bundler/lib/bundler/plugin/api/source.rb +29 -15
  147. data/bundler/lib/bundler/plugin/api.rb +1 -1
  148. data/bundler/lib/bundler/plugin/dsl.rb +1 -1
  149. data/bundler/lib/bundler/plugin/index.rb +31 -8
  150. data/bundler/lib/bundler/plugin/installer/git.rb +0 -4
  151. data/bundler/lib/bundler/plugin/installer/rubygems.rb +1 -9
  152. data/bundler/lib/bundler/plugin/installer.rb +35 -22
  153. data/bundler/lib/bundler/plugin/source_list.rb +5 -1
  154. data/bundler/lib/bundler/plugin.rb +102 -42
  155. data/bundler/lib/bundler/process_lock.rb +1 -1
  156. data/bundler/lib/bundler/remote_specification.rb +15 -8
  157. data/bundler/lib/bundler/resolver/base.rb +77 -0
  158. data/bundler/lib/bundler/resolver/candidate.rb +94 -0
  159. data/bundler/lib/bundler/resolver/incompatibility.rb +15 -0
  160. data/bundler/lib/bundler/resolver/package.rb +72 -0
  161. data/bundler/lib/bundler/resolver/root.rb +25 -0
  162. data/bundler/lib/bundler/resolver/spec_group.rb +49 -73
  163. data/bundler/lib/bundler/resolver.rb +343 -300
  164. data/bundler/lib/bundler/retry.rb +4 -4
  165. data/bundler/lib/bundler/ruby_dsl.rb +1 -1
  166. data/bundler/lib/bundler/ruby_version.rb +9 -37
  167. data/bundler/lib/bundler/rubygems_ext.rb +235 -92
  168. data/bundler/lib/bundler/rubygems_gem_installer.rb +87 -21
  169. data/bundler/lib/bundler/rubygems_integration.rb +179 -515
  170. data/bundler/lib/bundler/runtime.rb +25 -40
  171. data/bundler/lib/bundler/self_manager.rb +168 -0
  172. data/bundler/lib/bundler/settings.rb +162 -118
  173. data/bundler/lib/bundler/setup.rb +11 -12
  174. data/bundler/lib/bundler/shared_helpers.rb +61 -102
  175. data/bundler/lib/bundler/similarity_detector.rb +3 -3
  176. data/bundler/lib/bundler/source/git/git_proxy.rb +257 -128
  177. data/bundler/lib/bundler/source/git.rb +84 -61
  178. data/bundler/lib/bundler/source/metadata.rb +9 -9
  179. data/bundler/lib/bundler/source/path/installer.rb +11 -32
  180. data/bundler/lib/bundler/source/path.rb +28 -17
  181. data/bundler/lib/bundler/source/rubygems/remote.rb +3 -4
  182. data/bundler/lib/bundler/source/rubygems.rb +171 -197
  183. data/bundler/lib/bundler/source/rubygems_aggregate.rb +68 -0
  184. data/bundler/lib/bundler/source.rb +30 -10
  185. data/bundler/lib/bundler/source_list.rb +112 -67
  186. data/bundler/lib/bundler/source_map.rb +71 -0
  187. data/bundler/lib/bundler/spec_set.rb +86 -72
  188. data/bundler/lib/bundler/stub_specification.rb +45 -37
  189. data/bundler/lib/bundler/templates/Executable +3 -5
  190. data/bundler/lib/bundler/templates/Executable.bundler +21 -17
  191. data/bundler/lib/bundler/templates/Executable.standalone +4 -4
  192. data/bundler/lib/bundler/templates/Gemfile +0 -2
  193. data/bundler/lib/bundler/templates/newgem/CHANGELOG.md.tt +5 -0
  194. data/bundler/lib/bundler/templates/newgem/CODE_OF_CONDUCT.md.tt +57 -47
  195. data/bundler/lib/bundler/templates/newgem/Cargo.toml.tt +7 -0
  196. data/bundler/lib/bundler/templates/newgem/Gemfile.tt +22 -2
  197. data/bundler/lib/bundler/templates/newgem/README.md.tt +13 -15
  198. data/bundler/lib/bundler/templates/newgem/Rakefile.tt +33 -5
  199. data/bundler/lib/bundler/templates/newgem/bin/console.tt +1 -0
  200. data/bundler/lib/bundler/templates/newgem/circleci/config.yml.tt +25 -0
  201. data/bundler/lib/bundler/templates/newgem/ext/newgem/Cargo.toml.tt +15 -0
  202. data/bundler/lib/bundler/templates/newgem/ext/newgem/{extconf.rb.tt → extconf-c.rb.tt} +2 -0
  203. data/bundler/lib/bundler/templates/newgem/ext/newgem/extconf-rust.rb.tt +6 -0
  204. data/bundler/lib/bundler/templates/newgem/ext/newgem/src/lib.rs.tt +12 -0
  205. data/bundler/lib/bundler/templates/newgem/github/workflows/main.yml.tt +37 -0
  206. data/bundler/lib/bundler/templates/newgem/gitignore.tt +3 -0
  207. data/bundler/lib/bundler/templates/newgem/gitlab-ci.yml.tt +18 -0
  208. data/bundler/lib/bundler/templates/newgem/lib/newgem/version.rb.tt +2 -0
  209. data/bundler/lib/bundler/templates/newgem/lib/newgem.rb.tt +4 -2
  210. data/bundler/lib/bundler/templates/newgem/newgem.gemspec.tt +36 -41
  211. data/bundler/lib/bundler/templates/newgem/rubocop.yml.tt +13 -0
  212. data/bundler/lib/bundler/templates/newgem/sig/newgem.rbs.tt +8 -0
  213. data/bundler/lib/bundler/templates/newgem/spec/newgem_spec.rb.tt +2 -0
  214. data/bundler/lib/bundler/templates/newgem/spec/spec_helper.rb.tt +2 -1
  215. data/bundler/lib/bundler/templates/newgem/standard.yml.tt +3 -0
  216. data/bundler/lib/bundler/templates/newgem/test/minitest/test_helper.rb.tt +6 -0
  217. data/bundler/lib/bundler/templates/newgem/test/{newgem_test.rb.tt → minitest/test_newgem.rb.tt} +3 -1
  218. data/bundler/lib/bundler/templates/newgem/test/test-unit/newgem_test.rb.tt +15 -0
  219. data/bundler/lib/bundler/templates/newgem/test/test-unit/test_helper.rb.tt +6 -0
  220. data/bundler/lib/bundler/ui/rg_proxy.rb +1 -1
  221. data/bundler/lib/bundler/ui/shell.rb +39 -20
  222. data/bundler/lib/bundler/ui/silent.rb +21 -5
  223. data/bundler/lib/bundler/ui.rb +3 -3
  224. data/bundler/lib/bundler/uri_credentials_filter.rb +10 -4
  225. data/bundler/lib/bundler/vendor/.document +1 -0
  226. data/bundler/lib/bundler/vendor/connection_pool/LICENSE +20 -0
  227. data/bundler/lib/bundler/vendor/connection_pool/lib/connection_pool/timed_stack.rb +174 -0
  228. data/bundler/lib/bundler/vendor/connection_pool/lib/connection_pool/version.rb +3 -0
  229. data/bundler/lib/bundler/vendor/connection_pool/lib/connection_pool/wrapper.rb +56 -0
  230. data/bundler/lib/bundler/vendor/connection_pool/lib/connection_pool.rb +128 -0
  231. data/bundler/lib/bundler/vendor/fileutils/LICENSE.txt +22 -0
  232. data/bundler/lib/bundler/vendor/fileutils/lib/fileutils.rb +1493 -425
  233. data/bundler/lib/bundler/vendor/net-http-persistent/README.rdoc +82 -0
  234. data/bundler/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/connection.rb +40 -0
  235. data/bundler/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/pool.rb +53 -0
  236. data/bundler/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/timed_stack_multi.rb +79 -0
  237. data/bundler/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent.rb +302 -462
  238. data/bundler/lib/bundler/vendor/pub_grub/LICENSE.txt +21 -0
  239. data/bundler/lib/bundler/vendor/pub_grub/lib/pub_grub/assignment.rb +20 -0
  240. data/bundler/lib/bundler/vendor/pub_grub/lib/pub_grub/basic_package_source.rb +189 -0
  241. data/bundler/lib/bundler/vendor/pub_grub/lib/pub_grub/failure_writer.rb +182 -0
  242. data/bundler/lib/bundler/vendor/pub_grub/lib/pub_grub/incompatibility.rb +155 -0
  243. data/bundler/lib/bundler/vendor/pub_grub/lib/pub_grub/package.rb +43 -0
  244. data/bundler/lib/bundler/vendor/pub_grub/lib/pub_grub/partial_solution.rb +121 -0
  245. data/bundler/lib/bundler/vendor/pub_grub/lib/pub_grub/rubygems.rb +45 -0
  246. data/bundler/lib/bundler/vendor/pub_grub/lib/pub_grub/solve_failure.rb +19 -0
  247. data/bundler/lib/bundler/vendor/pub_grub/lib/pub_grub/static_package_source.rb +60 -0
  248. data/bundler/lib/bundler/vendor/pub_grub/lib/pub_grub/term.rb +105 -0
  249. data/bundler/lib/bundler/vendor/pub_grub/lib/pub_grub/version.rb +3 -0
  250. data/bundler/lib/bundler/vendor/pub_grub/lib/pub_grub/version_constraint.rb +129 -0
  251. data/bundler/lib/bundler/vendor/pub_grub/lib/pub_grub/version_range.rb +411 -0
  252. data/bundler/lib/bundler/vendor/pub_grub/lib/pub_grub/version_solver.rb +243 -0
  253. data/bundler/lib/bundler/vendor/pub_grub/lib/pub_grub/version_union.rb +178 -0
  254. data/bundler/lib/bundler/vendor/pub_grub/lib/pub_grub.rb +31 -0
  255. data/bundler/lib/bundler/vendor/thor/LICENSE.md +20 -0
  256. data/bundler/lib/bundler/vendor/thor/lib/thor/actions/create_file.rb +1 -1
  257. data/bundler/lib/bundler/vendor/thor/lib/thor/actions/create_link.rb +3 -2
  258. data/bundler/lib/bundler/vendor/thor/lib/thor/actions/directory.rb +7 -17
  259. data/bundler/lib/bundler/vendor/thor/lib/thor/actions/file_manipulation.rb +25 -14
  260. data/bundler/lib/bundler/vendor/thor/lib/thor/actions/inject_into_file.rb +20 -10
  261. data/bundler/lib/bundler/vendor/thor/lib/thor/actions.rb +34 -15
  262. data/bundler/lib/bundler/vendor/thor/lib/thor/base.rb +63 -43
  263. data/bundler/lib/bundler/vendor/thor/lib/thor/command.rb +21 -14
  264. data/bundler/lib/bundler/vendor/thor/lib/thor/core_ext/hash_with_indifferent_access.rb +6 -0
  265. data/bundler/lib/bundler/vendor/thor/lib/thor/error.rb +83 -0
  266. data/bundler/lib/bundler/vendor/thor/lib/thor/group.rb +3 -3
  267. data/bundler/lib/bundler/vendor/thor/lib/thor/invocation.rb +1 -0
  268. data/bundler/lib/bundler/vendor/thor/lib/thor/line_editor/basic.rb +1 -1
  269. data/bundler/lib/bundler/vendor/thor/lib/thor/line_editor/readline.rb +6 -6
  270. data/bundler/lib/bundler/vendor/thor/lib/thor/line_editor.rb +2 -2
  271. data/bundler/lib/bundler/vendor/thor/lib/thor/nested_context.rb +29 -0
  272. data/bundler/lib/bundler/vendor/thor/lib/thor/parser/arguments.rb +7 -3
  273. data/bundler/lib/bundler/vendor/thor/lib/thor/parser/option.rb +20 -7
  274. data/bundler/lib/bundler/vendor/thor/lib/thor/parser/options.rb +40 -6
  275. data/bundler/lib/bundler/vendor/thor/lib/thor/parser.rb +4 -4
  276. data/bundler/lib/bundler/vendor/thor/lib/thor/rake_compat.rb +1 -0
  277. data/bundler/lib/bundler/vendor/thor/lib/thor/runner.rb +15 -14
  278. data/bundler/lib/bundler/vendor/thor/lib/thor/shell/basic.rb +88 -13
  279. data/bundler/lib/bundler/vendor/thor/lib/thor/shell/color.rb +10 -2
  280. data/bundler/lib/bundler/vendor/thor/lib/thor/shell/html.rb +3 -3
  281. data/bundler/lib/bundler/vendor/thor/lib/thor/shell.rb +5 -5
  282. data/bundler/lib/bundler/vendor/thor/lib/thor/util.rb +18 -2
  283. data/bundler/lib/bundler/vendor/thor/lib/thor/version.rb +1 -1
  284. data/bundler/lib/bundler/vendor/thor/lib/thor.rb +16 -9
  285. data/bundler/lib/bundler/vendor/tsort/LICENSE.txt +22 -0
  286. data/bundler/lib/bundler/vendor/tsort/lib/tsort.rb +452 -0
  287. data/bundler/lib/bundler/vendor/uri/LICENSE.txt +22 -0
  288. data/bundler/lib/bundler/vendor/uri/lib/uri/common.rb +729 -0
  289. data/bundler/lib/bundler/vendor/uri/lib/uri/file.rb +100 -0
  290. data/bundler/lib/bundler/vendor/uri/lib/uri/ftp.rb +267 -0
  291. data/bundler/lib/bundler/vendor/uri/lib/uri/generic.rb +1587 -0
  292. data/bundler/lib/bundler/vendor/uri/lib/uri/http.rb +125 -0
  293. data/bundler/lib/bundler/vendor/uri/lib/uri/https.rb +23 -0
  294. data/bundler/lib/bundler/vendor/uri/lib/uri/ldap.rb +261 -0
  295. data/bundler/lib/bundler/vendor/uri/lib/uri/ldaps.rb +22 -0
  296. data/bundler/lib/bundler/vendor/uri/lib/uri/mailto.rb +293 -0
  297. data/bundler/lib/bundler/vendor/uri/lib/uri/rfc2396_parser.rb +539 -0
  298. data/bundler/lib/bundler/vendor/uri/lib/uri/rfc3986_parser.rb +119 -0
  299. data/bundler/lib/bundler/vendor/uri/lib/uri/version.rb +6 -0
  300. data/bundler/lib/bundler/vendor/uri/lib/uri/ws.rb +83 -0
  301. data/bundler/lib/bundler/vendor/uri/lib/uri/wss.rb +23 -0
  302. data/bundler/lib/bundler/vendor/uri/lib/uri.rb +104 -0
  303. data/bundler/lib/bundler/vendored_fileutils.rb +1 -6
  304. data/bundler/lib/bundler/vendored_persistent.rb +2 -39
  305. data/bundler/lib/bundler/{vendored_molinillo.rb → vendored_pub_grub.rb} +1 -1
  306. data/bundler/lib/bundler/vendored_thor.rb +2 -2
  307. data/bundler/lib/bundler/vendored_tsort.rb +4 -0
  308. data/bundler/lib/bundler/vendored_uri.rb +4 -0
  309. data/bundler/lib/bundler/version.rb +5 -20
  310. data/bundler/lib/bundler/vlad.rb +2 -2
  311. data/bundler/lib/bundler/worker.rb +26 -15
  312. data/bundler/lib/bundler/yaml_serializer.rb +3 -4
  313. data/bundler/lib/bundler.rb +285 -183
  314. data/hide_lib_for_update/note.txt +0 -4
  315. data/lib/rubygems/available_set.rb +7 -8
  316. data/lib/rubygems/basic_specification.rb +44 -31
  317. data/lib/rubygems/bundler_version_finder.rb +28 -50
  318. data/lib/rubygems/command.rb +104 -46
  319. data/lib/rubygems/command_manager.rb +35 -16
  320. data/lib/rubygems/commands/build_command.rb +77 -26
  321. data/lib/rubygems/commands/cert_command.rb +78 -76
  322. data/lib/rubygems/commands/check_command.rb +20 -22
  323. data/lib/rubygems/commands/cleanup_command.rb +36 -32
  324. data/lib/rubygems/commands/contents_command.rb +16 -18
  325. data/lib/rubygems/commands/dependency_command.rb +39 -50
  326. data/lib/rubygems/commands/environment_command.rb +11 -13
  327. data/lib/rubygems/commands/fetch_command.rb +33 -16
  328. data/lib/rubygems/commands/generate_index_command.rb +18 -17
  329. data/lib/rubygems/commands/help_command.rb +7 -7
  330. data/lib/rubygems/commands/info_command.rb +11 -6
  331. data/lib/rubygems/commands/install_command.rb +45 -79
  332. data/lib/rubygems/commands/list_command.rb +9 -8
  333. data/lib/rubygems/commands/lock_command.rb +7 -9
  334. data/lib/rubygems/commands/mirror_command.rb +3 -4
  335. data/lib/rubygems/commands/open_command.rb +11 -14
  336. data/lib/rubygems/commands/outdated_command.rb +5 -6
  337. data/lib/rubygems/commands/owner_command.rb +29 -22
  338. data/lib/rubygems/commands/pristine_command.rb +61 -51
  339. data/lib/rubygems/commands/push_command.rb +26 -63
  340. data/lib/rubygems/commands/query_command.rb +21 -337
  341. data/lib/rubygems/commands/rdoc_command.rb +26 -26
  342. data/lib/rubygems/commands/search_command.rb +8 -8
  343. data/lib/rubygems/commands/server_command.rb +16 -77
  344. data/lib/rubygems/commands/setup_command.rb +282 -241
  345. data/lib/rubygems/commands/signin_command.rb +9 -10
  346. data/lib/rubygems/commands/signout_command.rb +7 -9
  347. data/lib/rubygems/commands/sources_command.rb +42 -26
  348. data/lib/rubygems/commands/specification_command.rb +25 -20
  349. data/lib/rubygems/commands/stale_command.rb +3 -3
  350. data/lib/rubygems/commands/uninstall_command.rb +58 -49
  351. data/lib/rubygems/commands/unpack_command.rb +15 -44
  352. data/lib/rubygems/commands/update_command.rb +133 -81
  353. data/lib/rubygems/commands/which_command.rb +8 -11
  354. data/lib/rubygems/commands/yank_command.rb +22 -19
  355. data/lib/rubygems/compatibility.rb +7 -5
  356. data/lib/rubygems/config_file.rb +101 -47
  357. data/lib/rubygems/core_ext/kernel_gem.rb +8 -12
  358. data/lib/rubygems/core_ext/kernel_require.rb +124 -83
  359. data/lib/rubygems/core_ext/kernel_warn.rb +35 -30
  360. data/lib/rubygems/core_ext/tcpsocket_init.rb +52 -0
  361. data/lib/rubygems/defaults.rb +131 -55
  362. data/lib/rubygems/dependency.rb +44 -27
  363. data/lib/rubygems/dependency_installer.rb +49 -205
  364. data/lib/rubygems/dependency_list.rb +24 -25
  365. data/lib/rubygems/deprecate.rb +106 -12
  366. data/lib/rubygems/doctor.rb +22 -22
  367. data/lib/rubygems/errors.rb +8 -14
  368. data/lib/rubygems/exceptions.rb +35 -33
  369. data/lib/rubygems/ext/build_error.rb +2 -0
  370. data/lib/rubygems/ext/builder.rb +71 -95
  371. data/lib/rubygems/ext/cargo_builder/link_flag_converter.rb +27 -0
  372. data/lib/rubygems/ext/cargo_builder.rb +360 -0
  373. data/lib/rubygems/ext/cmake_builder.rb +6 -7
  374. data/lib/rubygems/ext/configure_builder.rb +5 -8
  375. data/lib/rubygems/ext/ext_conf_builder.rb +45 -65
  376. data/lib/rubygems/ext/rake_builder.rb +7 -10
  377. data/lib/rubygems/ext.rb +7 -6
  378. data/lib/rubygems/gem_runner.rb +15 -26
  379. data/lib/rubygems/gemcutter_utilities.rb +179 -54
  380. data/lib/rubygems/indexer.rb +38 -53
  381. data/lib/rubygems/install_default_message.rb +2 -2
  382. data/lib/rubygems/install_message.rb +2 -2
  383. data/lib/rubygems/install_update_options.rb +73 -64
  384. data/lib/rubygems/installer.rb +230 -173
  385. data/lib/rubygems/installer_uninstaller_utils.rb +29 -0
  386. data/lib/rubygems/local_remote_options.rb +22 -24
  387. data/lib/rubygems/mock_gem_ui.rb +2 -5
  388. data/lib/rubygems/name_tuple.rb +10 -14
  389. data/lib/rubygems/openssl.rb +7 -0
  390. data/lib/rubygems/optparse/.document +1 -0
  391. data/lib/rubygems/optparse/COPYING +56 -0
  392. data/lib/rubygems/optparse/lib/optionparser.rb +2 -0
  393. data/lib/rubygems/optparse/lib/optparse/ac.rb +54 -0
  394. data/lib/rubygems/optparse/lib/optparse/date.rb +18 -0
  395. data/lib/rubygems/optparse/lib/optparse/kwargs.rb +22 -0
  396. data/lib/rubygems/optparse/lib/optparse/shellwords.rb +7 -0
  397. data/lib/rubygems/optparse/lib/optparse/time.rb +11 -0
  398. data/lib/rubygems/optparse/lib/optparse/uri.rb +7 -0
  399. data/lib/rubygems/optparse/lib/optparse/version.rb +71 -0
  400. data/lib/rubygems/optparse/lib/optparse.rb +2308 -0
  401. data/lib/rubygems/optparse.rb +3 -0
  402. data/lib/rubygems/package/digest_io.rb +0 -2
  403. data/lib/rubygems/package/file_source.rb +2 -4
  404. data/lib/rubygems/package/io_source.rb +4 -2
  405. data/lib/rubygems/package/old.rb +9 -11
  406. data/lib/rubygems/package/tar_header.rb +73 -66
  407. data/lib/rubygems/package/tar_reader/entry.rb +8 -9
  408. data/lib/rubygems/package/tar_reader.rb +16 -13
  409. data/lib/rubygems/package/tar_writer.rb +12 -22
  410. data/lib/rubygems/package.rb +142 -125
  411. data/lib/rubygems/package_task.rb +5 -11
  412. data/lib/rubygems/path_support.rb +3 -8
  413. data/lib/rubygems/platform.rb +113 -73
  414. data/lib/rubygems/psych_tree.rb +1 -1
  415. data/lib/rubygems/query_utils.rb +351 -0
  416. data/lib/rubygems/rdoc.rb +4 -16
  417. data/lib/rubygems/remote_fetcher.rb +64 -136
  418. data/lib/rubygems/request/connection_pools.rb +7 -11
  419. data/lib/rubygems/request/http_pool.rb +2 -3
  420. data/lib/rubygems/request.rb +31 -32
  421. data/lib/rubygems/request_set/gem_dependency_api.rb +135 -136
  422. data/lib/rubygems/request_set/lockfile/parser.rb +28 -28
  423. data/lib/rubygems/request_set/lockfile/tokenizer.rb +5 -5
  424. data/lib/rubygems/request_set/lockfile.rb +21 -20
  425. data/lib/rubygems/request_set.rb +30 -43
  426. data/lib/rubygems/requirement.rb +42 -64
  427. data/lib/rubygems/resolver/activation_request.rb +29 -53
  428. data/lib/rubygems/resolver/api_set/gem_parser.rb +20 -0
  429. data/lib/rubygems/resolver/api_set.rb +33 -26
  430. data/lib/rubygems/resolver/api_specification.rb +30 -16
  431. data/lib/rubygems/resolver/best_set.rb +9 -11
  432. data/lib/rubygems/resolver/composed_set.rb +3 -5
  433. data/lib/rubygems/resolver/conflict.rb +12 -19
  434. data/lib/rubygems/resolver/current_set.rb +0 -2
  435. data/lib/rubygems/resolver/dependency_request.rb +3 -5
  436. data/lib/rubygems/resolver/git_set.rb +2 -4
  437. data/lib/rubygems/resolver/git_specification.rb +6 -8
  438. data/lib/rubygems/resolver/index_set.rb +4 -6
  439. data/lib/rubygems/resolver/index_specification.rb +38 -7
  440. data/lib/rubygems/resolver/installed_specification.rb +4 -6
  441. data/lib/rubygems/resolver/installer_set.rb +69 -27
  442. data/lib/rubygems/resolver/local_specification.rb +2 -4
  443. data/lib/rubygems/resolver/lock_set.rb +7 -9
  444. data/lib/rubygems/resolver/lock_specification.rb +6 -8
  445. data/lib/rubygems/resolver/molinillo/LICENSE +9 -0
  446. data/lib/rubygems/resolver/molinillo/lib/molinillo/delegates/resolution_state.rb +7 -0
  447. data/lib/rubygems/resolver/molinillo/lib/molinillo/delegates/specification_provider.rb +8 -0
  448. data/lib/rubygems/resolver/molinillo/lib/molinillo/dependency_graph/action.rb +1 -0
  449. data/lib/rubygems/resolver/molinillo/lib/molinillo/dependency_graph/add_edge_no_circular.rb +2 -1
  450. data/lib/rubygems/resolver/molinillo/lib/molinillo/dependency_graph/add_vertex.rb +2 -1
  451. data/lib/rubygems/resolver/molinillo/lib/molinillo/dependency_graph/delete_edge.rb +2 -1
  452. data/lib/rubygems/resolver/molinillo/lib/molinillo/dependency_graph/detach_vertex_named.rb +2 -1
  453. data/lib/rubygems/resolver/molinillo/lib/molinillo/dependency_graph/log.rb +7 -6
  454. data/lib/rubygems/resolver/molinillo/lib/molinillo/dependency_graph/set_payload.rb +2 -1
  455. data/lib/rubygems/resolver/molinillo/lib/molinillo/dependency_graph/tag.rb +4 -3
  456. data/lib/rubygems/resolver/molinillo/lib/molinillo/dependency_graph/vertex.rb +51 -12
  457. data/lib/rubygems/resolver/molinillo/lib/molinillo/dependency_graph.rb +42 -9
  458. data/lib/rubygems/resolver/molinillo/lib/molinillo/errors.rb +82 -8
  459. data/lib/rubygems/resolver/molinillo/lib/molinillo/gem_metadata.rb +2 -1
  460. data/lib/rubygems/resolver/molinillo/lib/molinillo/modules/specification_provider.rb +13 -1
  461. data/lib/rubygems/resolver/molinillo/lib/molinillo/modules/ui.rb +3 -1
  462. data/lib/rubygems/resolver/molinillo/lib/molinillo/resolution.rb +510 -165
  463. data/lib/rubygems/resolver/molinillo/lib/molinillo/resolver.rb +3 -2
  464. data/lib/rubygems/resolver/molinillo/lib/molinillo/state.rb +8 -4
  465. data/lib/rubygems/resolver/molinillo/lib/molinillo.rb +6 -5
  466. data/lib/rubygems/resolver/molinillo.rb +1 -1
  467. data/lib/rubygems/resolver/requirement_list.rb +0 -1
  468. data/lib/rubygems/resolver/set.rb +0 -3
  469. data/lib/rubygems/resolver/source_set.rb +0 -2
  470. data/lib/rubygems/resolver/spec_specification.rb +14 -2
  471. data/lib/rubygems/resolver/specification.rb +14 -3
  472. data/lib/rubygems/resolver/vendor_set.rb +1 -3
  473. data/lib/rubygems/resolver/vendor_specification.rb +3 -5
  474. data/lib/rubygems/resolver.rb +58 -54
  475. data/lib/rubygems/s3_uri_signer.rb +175 -0
  476. data/lib/rubygems/safe_yaml.rb +14 -16
  477. data/lib/rubygems/security/policies.rb +47 -47
  478. data/lib/rubygems/security/policy.rb +25 -29
  479. data/lib/rubygems/security/signer.rb +16 -18
  480. data/lib/rubygems/security/trust_dir.rb +5 -6
  481. data/lib/rubygems/security.rb +90 -69
  482. data/lib/rubygems/security_option.rb +7 -8
  483. data/lib/rubygems/source/git.rb +30 -30
  484. data/lib/rubygems/source/installed.rb +1 -3
  485. data/lib/rubygems/source/local.rb +4 -6
  486. data/lib/rubygems/source/lock.rb +0 -2
  487. data/lib/rubygems/source/specific_file.rb +1 -3
  488. data/lib/rubygems/source/vendor.rb +0 -2
  489. data/lib/rubygems/source.rb +50 -38
  490. data/lib/rubygems/source_list.rb +9 -13
  491. data/lib/rubygems/spec_fetcher.rb +52 -64
  492. data/lib/rubygems/specification.rb +432 -463
  493. data/lib/rubygems/specification_policy.rb +185 -87
  494. data/lib/rubygems/ssl_certs/rubygems.org/GlobalSignRootCA_R3.pem +21 -0
  495. data/lib/rubygems/stub_specification.rb +24 -29
  496. data/lib/rubygems/text.rb +21 -21
  497. data/lib/rubygems/tsort/.document +1 -0
  498. data/lib/rubygems/tsort/LICENSE.txt +22 -0
  499. data/lib/rubygems/tsort/lib/tsort.rb +452 -0
  500. data/lib/rubygems/tsort.rb +3 -0
  501. data/lib/rubygems/uninstaller.rb +110 -57
  502. data/lib/rubygems/unknown_command_spell_checker.rb +21 -0
  503. data/lib/rubygems/update_suggestion.rb +69 -0
  504. data/lib/rubygems/uri.rb +126 -0
  505. data/lib/rubygems/uri_formatter.rb +2 -4
  506. data/lib/rubygems/user_interaction.rb +46 -49
  507. data/lib/rubygems/util/licenses.rb +511 -404
  508. data/lib/rubygems/util.rb +40 -56
  509. data/lib/rubygems/validator.rb +15 -37
  510. data/lib/rubygems/version.rb +48 -29
  511. data/lib/rubygems/version_option.rb +11 -5
  512. data/lib/rubygems.rb +305 -332
  513. data/rubygems-update.gemspec +6 -13
  514. data/setup.rb +11 -22
  515. data/test/rubygems/alternate_cert.pem +14 -14
  516. data/test/rubygems/alternate_cert_32.pem +15 -15
  517. data/test/rubygems/alternate_key.pem +25 -25
  518. data/test/rubygems/bundler_test_gem.rb +419 -0
  519. data/test/rubygems/ca_cert.pem +74 -65
  520. data/test/rubygems/child_cert.pem +15 -16
  521. data/test/rubygems/child_cert_32.pem +15 -16
  522. data/test/rubygems/child_key.pem +25 -25
  523. data/test/rubygems/client.pem +103 -45
  524. data/test/rubygems/data/excon-0.7.7.gemspec.rz +0 -0
  525. data/test/rubygems/data/null-required-ruby-version.gemspec.rz +0 -0
  526. data/test/rubygems/data/null-required-rubygems-version.gemspec.rz +0 -0
  527. data/test/rubygems/data/pry-0.4.7.gemspec.rz +0 -0
  528. data/test/rubygems/encrypted_private_key.pem +26 -26
  529. data/test/rubygems/expired_cert.pem +15 -15
  530. data/test/rubygems/future_cert.pem +15 -15
  531. data/test/rubygems/future_cert_32.pem +15 -15
  532. data/test/rubygems/grandchild_cert.pem +15 -16
  533. data/test/rubygems/grandchild_cert_32.pem +15 -16
  534. data/test/rubygems/grandchild_key.pem +25 -25
  535. data/{lib/rubygems/test_case.rb → test/rubygems/helper.rb} +505 -507
  536. data/{lib → test}/rubygems/installer_test_case.rb +115 -53
  537. data/test/rubygems/invalid_issuer_cert.pem +16 -16
  538. data/test/rubygems/invalid_issuer_cert_32.pem +16 -16
  539. data/test/rubygems/invalid_key.pem +25 -25
  540. data/test/rubygems/invalid_signer_cert.pem +15 -15
  541. data/test/rubygems/invalid_signer_cert_32.pem +15 -15
  542. data/test/rubygems/invalidchild_cert.pem +15 -16
  543. data/test/rubygems/invalidchild_cert_32.pem +15 -16
  544. data/test/rubygems/invalidchild_key.pem +25 -25
  545. data/{lib → test}/rubygems/package/tar_test_case.rb +4 -6
  546. data/test/rubygems/packages/Bluebie-legs-0.6.2.gem +0 -0
  547. data/test/rubygems/packages/ascii_binder-0.1.10.1.gem +0 -0
  548. data/test/rubygems/packages/ill-formatted-platform-1.0.0.10.gem +0 -0
  549. data/test/rubygems/plugin/exception/rubygems_plugin.rb +1 -1
  550. data/test/rubygems/plugin/standarderror/rubygems_plugin.rb +1 -1
  551. data/test/rubygems/private_ec_key.pem +9 -0
  552. data/test/rubygems/private_key.pem +25 -25
  553. data/test/rubygems/public_cert.pem +16 -16
  554. data/test/rubygems/public_cert_32.pem +15 -15
  555. data/test/rubygems/public_key.pem +7 -7
  556. data/test/rubygems/rubygems/commands/crash_command.rb +0 -2
  557. data/test/rubygems/rubygems_plugin.rb +2 -4
  558. data/test/rubygems/specifications/bar-0.0.2.gemspec +0 -2
  559. data/test/rubygems/specifications/rubyforge-0.0.1.gemspec +12 -0
  560. data/test/rubygems/ssl_cert.pem +78 -17
  561. data/test/rubygems/ssl_key.pem +25 -13
  562. data/test/rubygems/test_bundled_ca.rb +44 -47
  563. data/test/rubygems/test_config.rb +5 -7
  564. data/test/rubygems/test_deprecate.rb +90 -10
  565. data/test/rubygems/test_exit.rb +17 -0
  566. data/test/rubygems/test_gem.rb +679 -885
  567. data/test/rubygems/test_gem_available_set.rb +24 -25
  568. data/test/rubygems/test_gem_bundler_version_finder.rb +42 -42
  569. data/test/rubygems/test_gem_command.rb +186 -39
  570. data/test/rubygems/test_gem_command_manager.rb +166 -36
  571. data/test/rubygems/test_gem_commands_build_command.rb +436 -52
  572. data/test/rubygems/test_gem_commands_cert_command.rb +193 -124
  573. data/test/rubygems/test_gem_commands_check_command.rb +9 -11
  574. data/test/rubygems/test_gem_commands_cleanup_command.rb +87 -62
  575. data/test/rubygems/test_gem_commands_contents_command.rb +73 -42
  576. data/test/rubygems/test_gem_commands_dependency_command.rb +39 -41
  577. data/test/rubygems/test_gem_commands_environment_command.rb +60 -48
  578. data/test/rubygems/test_gem_commands_fetch_command.rb +163 -32
  579. data/test/rubygems/test_gem_commands_generate_index_command.rb +39 -9
  580. data/test/rubygems/test_gem_commands_help_command.rb +34 -19
  581. data/test/rubygems/test_gem_commands_info_command.rb +34 -9
  582. data/test/rubygems/test_gem_commands_install_command.rb +600 -173
  583. data/test/rubygems/test_gem_commands_list_command.rb +5 -7
  584. data/test/rubygems/test_gem_commands_lock_command.rb +11 -13
  585. data/test/rubygems/test_gem_commands_mirror.rb +3 -4
  586. data/test/rubygems/test_gem_commands_open_command.rb +16 -19
  587. data/test/rubygems/test_gem_commands_outdated_command.rb +24 -7
  588. data/test/rubygems/test_gem_commands_owner_command.rb +183 -49
  589. data/test/rubygems/test_gem_commands_pristine_command.rb +222 -89
  590. data/test/rubygems/test_gem_commands_push_command.rb +178 -69
  591. data/test/rubygems/test_gem_commands_query_command.rb +114 -89
  592. data/test/rubygems/test_gem_commands_search_command.rb +2 -4
  593. data/test/rubygems/test_gem_commands_server_command.rb +6 -46
  594. data/test/rubygems/test_gem_commands_setup_command.rb +334 -157
  595. data/test/rubygems/test_gem_commands_signin_command.rb +187 -27
  596. data/test/rubygems/test_gem_commands_signout_command.rb +3 -10
  597. data/test/rubygems/test_gem_commands_sources_command.rb +266 -33
  598. data/test/rubygems/test_gem_commands_specification_command.rb +81 -55
  599. data/test/rubygems/test_gem_commands_stale_command.rb +4 -6
  600. data/test/rubygems/test_gem_commands_uninstall_command.rb +230 -95
  601. data/test/rubygems/test_gem_commands_unpack_command.rb +32 -34
  602. data/test/rubygems/test_gem_commands_update_command.rb +412 -102
  603. data/test/rubygems/test_gem_commands_which_command.rb +12 -14
  604. data/test/rubygems/test_gem_commands_yank_command.rb +107 -26
  605. data/test/rubygems/test_gem_config_file.rb +120 -96
  606. data/test/rubygems/test_gem_dependency.rb +94 -86
  607. data/test/rubygems/test_gem_dependency_installer.rb +305 -388
  608. data/test/rubygems/test_gem_dependency_list.rb +66 -61
  609. data/test/rubygems/test_gem_dependency_resolution_error.rb +5 -7
  610. data/test/rubygems/test_gem_doctor.rb +73 -47
  611. data/test/rubygems/test_gem_ext_builder.rb +116 -106
  612. data/test/rubygems/test_gem_ext_cargo_builder/custom_name/.gitignore +1 -0
  613. data/test/rubygems/test_gem_ext_cargo_builder/custom_name/custom_name.gemspec +8 -0
  614. data/test/rubygems/test_gem_ext_cargo_builder/custom_name/ext/custom_name_lib/Cargo.lock +233 -0
  615. data/test/rubygems/test_gem_ext_cargo_builder/custom_name/ext/custom_name_lib/Cargo.toml +10 -0
  616. data/test/rubygems/test_gem_ext_cargo_builder/custom_name/ext/custom_name_lib/src/lib.rs +27 -0
  617. data/test/rubygems/test_gem_ext_cargo_builder/custom_name/lib/custom_name.rb +1 -0
  618. data/test/rubygems/test_gem_ext_cargo_builder/rust_ruby_example/.gitignore +1 -0
  619. data/test/rubygems/test_gem_ext_cargo_builder/rust_ruby_example/Cargo.lock +233 -0
  620. data/test/rubygems/test_gem_ext_cargo_builder/rust_ruby_example/Cargo.toml +10 -0
  621. data/test/rubygems/test_gem_ext_cargo_builder/rust_ruby_example/rust_ruby_example.gemspec +8 -0
  622. data/test/rubygems/test_gem_ext_cargo_builder/rust_ruby_example/src/lib.rs +51 -0
  623. data/test/rubygems/test_gem_ext_cargo_builder.rb +166 -0
  624. data/test/rubygems/test_gem_ext_cargo_builder_link_flag_converter.rb +33 -0
  625. data/test/rubygems/test_gem_ext_cargo_builder_unit.rb +60 -0
  626. data/test/rubygems/test_gem_ext_cmake_builder.rb +32 -37
  627. data/test/rubygems/test_gem_ext_configure_builder.rb +23 -31
  628. data/test/rubygems/test_gem_ext_ext_conf_builder.rb +75 -79
  629. data/test/rubygems/test_gem_ext_rake_builder.rb +49 -30
  630. data/test/rubygems/test_gem_gem_runner.rb +52 -7
  631. data/test/rubygems/test_gem_gemcutter_utilities.rb +91 -76
  632. data/test/rubygems/test_gem_impossible_dependencies_error.rb +4 -6
  633. data/test/rubygems/test_gem_indexer.rb +120 -105
  634. data/test/rubygems/test_gem_install_update_options.rb +57 -33
  635. data/test/rubygems/test_gem_installer.rb +1230 -644
  636. data/test/rubygems/test_gem_local_remote_options.rb +11 -13
  637. data/test/rubygems/test_gem_name_tuple.rb +4 -6
  638. data/test/rubygems/test_gem_package.rb +396 -266
  639. data/test/rubygems/test_gem_package_old.rb +57 -56
  640. data/test/rubygems/test_gem_package_tar_header.rb +108 -50
  641. data/test/rubygems/test_gem_package_tar_reader.rb +8 -10
  642. data/test/rubygems/test_gem_package_tar_reader_entry.rb +77 -20
  643. data/test/rubygems/test_gem_package_tar_writer.rb +107 -101
  644. data/test/rubygems/test_gem_package_task.rb +58 -25
  645. data/test/rubygems/test_gem_path_support.rb +29 -29
  646. data/test/rubygems/test_gem_platform.rb +388 -199
  647. data/test/rubygems/test_gem_rdoc.rb +20 -155
  648. data/test/rubygems/test_gem_remote_fetcher.rb +474 -303
  649. data/test/rubygems/test_gem_request.rb +128 -85
  650. data/test/rubygems/test_gem_request_connection_pools.rb +32 -32
  651. data/test/rubygems/test_gem_request_set.rb +186 -110
  652. data/test/rubygems/test_gem_request_set_gem_dependency_api.rb +280 -261
  653. data/test/rubygems/test_gem_request_set_lockfile.rb +93 -94
  654. data/test/rubygems/test_gem_request_set_lockfile_parser.rb +68 -69
  655. data/test/rubygems/test_gem_request_set_lockfile_tokenizer.rb +136 -136
  656. data/test/rubygems/test_gem_requirement.rb +140 -55
  657. data/test/rubygems/test_gem_resolver.rb +224 -115
  658. data/test/rubygems/test_gem_resolver_activation_request.rb +9 -40
  659. data/test/rubygems/test_gem_resolver_api_set.rb +79 -78
  660. data/test/rubygems/test_gem_resolver_api_specification.rb +47 -49
  661. data/test/rubygems/test_gem_resolver_best_set.rb +43 -22
  662. data/test/rubygems/test_gem_resolver_composed_set.rb +1 -3
  663. data/test/rubygems/test_gem_resolver_conflict.rb +12 -18
  664. data/test/rubygems/test_gem_resolver_dependency_request.rb +15 -17
  665. data/test/rubygems/test_gem_resolver_git_set.rb +22 -24
  666. data/test/rubygems/test_gem_resolver_git_specification.rb +22 -22
  667. data/test/rubygems/test_gem_resolver_index_set.rb +14 -16
  668. data/test/rubygems/test_gem_resolver_index_specification.rb +21 -18
  669. data/test/rubygems/test_gem_resolver_installed_specification.rb +5 -8
  670. data/test/rubygems/test_gem_resolver_installer_set.rb +106 -44
  671. data/test/rubygems/test_gem_resolver_local_specification.rb +7 -9
  672. data/test/rubygems/test_gem_resolver_lock_set.rb +15 -17
  673. data/test/rubygems/test_gem_resolver_lock_specification.rb +17 -19
  674. data/test/rubygems/test_gem_resolver_requirement_list.rb +1 -3
  675. data/test/rubygems/test_gem_resolver_specification.rb +8 -10
  676. data/test/rubygems/test_gem_resolver_vendor_set.rb +9 -11
  677. data/test/rubygems/test_gem_resolver_vendor_specification.rb +10 -12
  678. data/test/rubygems/test_gem_security.rb +109 -79
  679. data/test/rubygems/test_gem_security_policy.rb +102 -107
  680. data/test/rubygems/test_gem_security_signer.rb +51 -52
  681. data/test/rubygems/test_gem_security_trust_dir.rb +14 -16
  682. data/test/rubygems/test_gem_silent_ui.rb +47 -42
  683. data/test/rubygems/test_gem_source.rb +66 -51
  684. data/test/rubygems/test_gem_source_fetch_problem.rb +17 -8
  685. data/test/rubygems/test_gem_source_git.rb +74 -74
  686. data/test/rubygems/test_gem_source_installed.rb +16 -18
  687. data/test/rubygems/test_gem_source_list.rb +5 -5
  688. data/test/rubygems/test_gem_source_local.rb +15 -16
  689. data/test/rubygems/test_gem_source_lock.rb +31 -33
  690. data/test/rubygems/test_gem_source_specific_file.rb +18 -19
  691. data/test/rubygems/test_gem_source_subpath_problem.rb +49 -0
  692. data/test/rubygems/test_gem_source_vendor.rb +13 -15
  693. data/test/rubygems/test_gem_spec_fetcher.rb +74 -67
  694. data/test/rubygems/test_gem_specification.rb +1051 -1071
  695. data/test/rubygems/test_gem_stream_ui.rb +25 -23
  696. data/test/rubygems/test_gem_stub_specification.rb +39 -56
  697. data/test/rubygems/test_gem_text.rb +8 -3
  698. data/test/rubygems/test_gem_uninstaller.rb +269 -100
  699. data/test/rubygems/test_gem_unsatisfiable_dependency_error.rb +3 -5
  700. data/test/rubygems/test_gem_update_suggestion.rb +208 -0
  701. data/test/rubygems/test_gem_uri.rb +39 -0
  702. data/test/rubygems/test_gem_uri_formatter.rb +14 -16
  703. data/test/rubygems/test_gem_util.rb +46 -34
  704. data/test/rubygems/test_gem_validator.rb +12 -15
  705. data/test/rubygems/test_gem_version.rb +49 -34
  706. data/test/rubygems/test_gem_version_option.rb +16 -18
  707. data/test/rubygems/test_kernel.rb +61 -53
  708. data/test/rubygems/test_project_sanity.rb +20 -0
  709. data/test/rubygems/test_remote_fetch_error.rb +7 -8
  710. data/test/rubygems/test_require.rb +415 -121
  711. data/test/rubygems/test_rubygems.rb +74 -0
  712. data/{lib/rubygems/test_utilities.rb → test/rubygems/utilities.rb} +74 -50
  713. data/test/rubygems/wrong_key_cert.pem +15 -15
  714. data/test/rubygems/wrong_key_cert_32.pem +15 -15
  715. data/test/test_changelog_generator.rb +17 -0
  716. metadata +218 -244
  717. data/.rubocop.yml +0 -66
  718. data/.travis.yml +0 -38
  719. data/History.txt +0 -3965
  720. data/Rakefile +0 -372
  721. data/appveyor.yml +0 -43
  722. data/bundler/CODE_OF_CONDUCT.md +0 -42
  723. data/bundler/CONTRIBUTING.md +0 -17
  724. data/bundler/exe/bundle_ruby +0 -60
  725. data/bundler/lib/bundler/cli/package.rb +0 -49
  726. data/bundler/lib/bundler/compatibility_guard.rb +0 -14
  727. data/bundler/lib/bundler/dep_proxy.rb +0 -48
  728. data/bundler/lib/bundler/gem_remote_fetcher.rb +0 -43
  729. data/bundler/lib/bundler/gemdeps.rb +0 -29
  730. data/bundler/lib/bundler/psyched_yaml.rb +0 -37
  731. data/bundler/lib/bundler/ssl_certs/certificate_manager.rb +0 -66
  732. data/bundler/lib/bundler/ssl_certs/rubygems.global.ssl.fastly.net/DigiCertHighAssuranceEVRootCA.pem +0 -23
  733. data/bundler/lib/bundler/ssl_certs/rubygems.org/AddTrustExternalCARoot.pem +0 -25
  734. data/bundler/lib/bundler/templates/gems.rb +0 -8
  735. data/bundler/lib/bundler/templates/newgem/test/test_helper.rb.tt +0 -4
  736. data/bundler/lib/bundler/templates/newgem/travis.yml.tt +0 -7
  737. data/bundler/lib/bundler/vendor/molinillo/lib/molinillo/compatibility.rb +0 -26
  738. data/bundler/lib/bundler/vendor/molinillo/lib/molinillo/delegates/resolution_state.rb +0 -57
  739. data/bundler/lib/bundler/vendor/molinillo/lib/molinillo/delegates/specification_provider.rb +0 -81
  740. data/bundler/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/action.rb +0 -36
  741. data/bundler/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/add_edge_no_circular.rb +0 -66
  742. data/bundler/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/add_vertex.rb +0 -62
  743. data/bundler/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/delete_edge.rb +0 -63
  744. data/bundler/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/detach_vertex_named.rb +0 -61
  745. data/bundler/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/log.rb +0 -126
  746. data/bundler/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/set_payload.rb +0 -46
  747. data/bundler/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/tag.rb +0 -36
  748. data/bundler/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/vertex.rb +0 -136
  749. data/bundler/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph.rb +0 -223
  750. data/bundler/lib/bundler/vendor/molinillo/lib/molinillo/errors.rb +0 -143
  751. data/bundler/lib/bundler/vendor/molinillo/lib/molinillo/gem_metadata.rb +0 -6
  752. data/bundler/lib/bundler/vendor/molinillo/lib/molinillo/modules/specification_provider.rb +0 -101
  753. data/bundler/lib/bundler/vendor/molinillo/lib/molinillo/modules/ui.rb +0 -67
  754. data/bundler/lib/bundler/vendor/molinillo/lib/molinillo/resolution.rb +0 -837
  755. data/bundler/lib/bundler/vendor/molinillo/lib/molinillo/resolver.rb +0 -46
  756. data/bundler/lib/bundler/vendor/molinillo/lib/molinillo/state.rb +0 -58
  757. data/bundler/lib/bundler/vendor/molinillo/lib/molinillo.rb +0 -12
  758. data/bundler/lib/bundler/vendor/net-http-persistent/lib/net/http/faster.rb +0 -27
  759. data/bundler/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/ssl_reuse.rb +0 -129
  760. data/bundler/lib/bundler/vendor/thor/lib/thor/core_ext/io_binary_read.rb +0 -12
  761. data/bundler/lib/bundler/vendor/thor/lib/thor/core_ext/ordered_hash.rb +0 -129
  762. data/bundler/lib/bundler/version_ranges.rb +0 -76
  763. data/bundler/man/bundle-gem.1 +0 -80
  764. data/bundler/man/bundle-gem.ronn +0 -78
  765. data/bundler/man/bundle-package.1 +0 -55
  766. data/lib/rubygems/psych_additions.rb +0 -10
  767. data/lib/rubygems/server.rb +0 -878
  768. data/lib/rubygems/source_local.rb +0 -7
  769. data/lib/rubygems/source_specific_file.rb +0 -6
  770. data/lib/rubygems/ssl_certs/index.rubygems.org/GlobalSignRootCA.pem +0 -21
  771. data/lib/rubygems/ssl_certs/rubygems.global.ssl.fastly.net/DigiCertHighAssuranceEVRootCA.pem +0 -23
  772. data/lib/rubygems/ssl_certs/rubygems.org/AddTrustExternalCARoot.pem +0 -25
  773. data/lib/rubygems/syck_hack.rb +0 -77
  774. data/lib/ubygems.rb +0 -14
  775. data/test/rubygems/bogussources.rb +0 -9
  776. data/test/rubygems/data/null-type.gemspec.rz +0 -0
  777. data/test/rubygems/test_gem_server.rb +0 -607
  778. data/util/CL2notes +0 -55
  779. data/util/ci +0 -77
  780. data/util/create_certs.rb +0 -171
  781. data/util/create_encrypted_key.rb +0 -16
  782. data/util/generate_spdx_license_list.rb +0 -61
  783. data/util/patch_with_prs.rb +0 -77
  784. data/util/rubocop +0 -8
  785. data/util/update_bundled_ca_certificates.rb +0 -139
  786. data/util/update_changelog.rb +0 -67
  787. /data/bundler/lib/bundler/{ssl_certs → man}/.document +0 -0
  788. /data/bundler/{man/bundle-check.ronn → lib/bundler/man/bundle-check.1.ronn} +0 -0
  789. /data/bundler/{man/bundle-doctor.ronn → lib/bundler/man/bundle-doctor.1.ronn} +0 -0
  790. /data/bundler/{man/bundle-info.ronn → lib/bundler/man/bundle-info.1.ronn} +0 -0
  791. /data/bundler/{man/bundle-lock.ronn → lib/bundler/man/bundle-lock.1.ronn} +0 -0
  792. /data/bundler/{man/bundle-pristine.ronn → lib/bundler/man/bundle-pristine.1.ronn} +0 -0
  793. /data/bundler/{man/bundle-remove.ronn → lib/bundler/man/bundle-remove.1.ronn} +0 -0
  794. /data/bundler/{man/bundle-show.ronn → lib/bundler/man/bundle-show.1.ronn} +0 -0
  795. /data/{bundler/lib/bundler/ssl_certs/index.rubygems.org → lib/rubygems/ssl_certs/rubygems.org}/GlobalSignRootCA.pem +0 -0
@@ -1,112 +1,78 @@
1
1
  # frozen_string_literal: true
2
- # TODO: $SAFE = 1
3
2
 
4
- begin
5
- gem 'minitest', '~> 5.0'
6
- rescue NoMethodError, Gem::LoadError
7
- # for ruby tests
8
- end
9
-
10
- if defined? Gem::QuickLoader
11
- Gem::QuickLoader.load_full_rubygems_library
12
- else
13
- require 'rubygems'
14
- end
15
-
16
- # If bundler gemspec exists, add to stubs
17
- bundler_gemspec = File.expand_path("../../../bundler/bundler.gemspec", __FILE__)
18
- if File.exist?(bundler_gemspec)
19
- Gem::Specification.dirs.unshift File.dirname(bundler_gemspec)
20
- Gem::Specification.class_variable_set :@@stubs, nil
21
- Gem::Specification.stubs
22
- Gem::Specification.dirs.shift
23
- end
3
+ require "rubygems"
24
4
 
25
5
  begin
26
- gem 'minitest'
6
+ gem "test-unit", "~> 3.0"
27
7
  rescue Gem::LoadError
28
8
  end
29
9
 
30
- begin
31
- require 'simplecov'
32
- SimpleCov.start do
33
- add_filter "/test/"
34
- add_filter "/bundler/"
35
- add_filter "/lib/rubygems/resolver/molinillo"
36
- end
37
- rescue LoadError
38
- end
10
+ require "test/unit"
39
11
 
40
- # We have to load these up front because otherwise we'll try to load
41
- # them while we're testing rubygems, and thus we can't actually load them.
42
- unless Gem::Dependency.new('rdoc', '>= 3.10').matching_specs.empty?
43
- gem 'rdoc'
44
- gem 'json'
45
- end
46
-
47
- if Gem::USE_BUNDLER_FOR_GEMDEPS
48
- require 'bundler'
49
- end
50
- require 'minitest/autorun'
12
+ ENV["JARS_SKIP"] = "true" if Gem.java_platform? # avoid unnecessary and noisy `jar-dependencies` post install hook
51
13
 
52
- require 'rubygems/deprecate'
14
+ require "rubygems/deprecate"
53
15
 
54
- require 'fileutils'
55
- require 'pathname'
56
- require 'pp'
57
- require 'rubygems/package'
58
- require 'shellwords'
59
- require 'tmpdir'
60
- require 'uri'
61
- require 'zlib'
62
- require 'benchmark' # stdlib
63
- require 'rubygems/mock_gem_ui'
16
+ require "fileutils"
17
+ require "pathname"
18
+ require "pp"
19
+ require "rubygems/package"
20
+ require "shellwords"
21
+ require "tmpdir"
22
+ require "uri"
23
+ require "zlib"
24
+ require "benchmark" # stdlib
25
+ require "rubygems/mock_gem_ui"
64
26
 
65
27
  module Gem
66
28
 
67
29
  ##
68
- # Allows setting the gem path searcher. This method is available when
69
- # requiring 'rubygems/test_case'
30
+ # Allows setting the gem path searcher.
70
31
 
71
32
  def self.searcher=(searcher)
72
33
  @searcher = searcher
73
34
  end
74
35
 
75
36
  ##
76
- # Allows toggling Windows behavior. This method is available when requiring
77
- # 'rubygems/test_case'
37
+ # Allows toggling Windows behavior.
78
38
 
79
39
  def self.win_platform=(val)
80
40
  @@win_platform = val
81
41
  end
82
42
 
83
43
  ##
84
- # Allows setting path to Ruby. This method is available when requiring
85
- # 'rubygems/test_case'
44
+ # Allows setting path to Ruby.
86
45
 
87
46
  def self.ruby=(ruby)
88
47
  @ruby = ruby
89
48
  end
90
49
 
91
50
  ##
92
- # When rubygems/test_case is required the default user interaction is a
93
- # MockGemUi.
51
+ # Sets the default user interaction to a MockGemUi.
94
52
 
95
53
  module DefaultUserInteraction
96
54
  @ui = Gem::MockGemUi.new
97
55
  end
98
56
  end
99
57
 
58
+ require "rubygems/command"
59
+
60
+ class Gem::Command
61
+ ##
62
+ # Allows resetting the hash of specific args per command.
63
+
64
+ def self.specific_extra_args_hash=(value)
65
+ @specific_extra_args_hash = value
66
+ end
67
+ end
68
+
100
69
  ##
101
70
  # RubyGemTestCase provides a variety of methods for testing rubygems and
102
71
  # gem-related behavior in a sandbox. Through RubyGemTestCase you can install
103
72
  # and uninstall gems, fetch remote gems through a stub fetcher and be assured
104
73
  # your normal set of gems is not affected.
105
- #
106
- # Tests are always run at a safe level of 1.
107
-
108
- class Gem::TestCase < (defined?(Minitest::Test) ? Minitest::Test : MiniTest::Unit::TestCase)
109
74
 
75
+ class Gem::TestCase < Test::Unit::TestCase
110
76
  extend Gem::Deprecate
111
77
 
112
78
  attr_accessor :fetcher # :nodoc:
@@ -132,10 +98,51 @@ class Gem::TestCase < (defined?(Minitest::Test) ? Minitest::Test : MiniTest::Uni
132
98
  assert_equal expected.sort, loaded.sort if expected
133
99
  end
134
100
 
135
- # TODO: move to minitest
136
- def assert_path_exists(path, msg = nil)
137
- msg = message(msg) { "Expected path '#{path}' to exist" }
138
- assert File.exist?(path), msg
101
+ def assert_directory_exists(path, msg = nil)
102
+ msg = build_message(msg, "Expected path '#{path}' to be a directory")
103
+ assert_path_exist path
104
+ assert File.directory?(path), msg
105
+ end
106
+
107
+ def refute_directory_exists(path, msg = nil)
108
+ msg = build_message(msg, "Expected path '#{path}' not to be a directory")
109
+ assert_path_not_exist path
110
+ refute File.directory?(path), msg
111
+ end
112
+
113
+ # https://github.com/seattlerb/minitest/blob/21d9e804b63c619f602f3f4ece6c71b48974707a/lib/minitest/assertions.rb#L188
114
+ def _synchronize
115
+ yield
116
+ end
117
+
118
+ # https://github.com/seattlerb/minitest/blob/21d9e804b63c619f602f3f4ece6c71b48974707a/lib/minitest/assertions.rb#L546
119
+ def capture_subprocess_io
120
+ _synchronize do
121
+ begin
122
+ require "tempfile"
123
+
124
+ captured_stdout, captured_stderr = Tempfile.new("out"), Tempfile.new("err")
125
+
126
+ orig_stdout, orig_stderr = $stdout.dup, $stderr.dup
127
+ $stdout.reopen captured_stdout
128
+ $stderr.reopen captured_stderr
129
+
130
+ yield
131
+
132
+ $stdout.rewind
133
+ $stderr.rewind
134
+
135
+ return captured_stdout.read, captured_stderr.read
136
+ ensure
137
+ $stdout.reopen orig_stdout
138
+ $stderr.reopen orig_stderr
139
+
140
+ orig_stdout.close
141
+ orig_stderr.close
142
+ captured_stdout.close!
143
+ captured_stderr.close!
144
+ end
145
+ end
139
146
  end
140
147
 
141
148
  ##
@@ -143,74 +150,131 @@ class Gem::TestCase < (defined?(Minitest::Test) ? Minitest::Test : MiniTest::Uni
143
150
  # the original value when the block ends
144
151
 
145
152
  def enable_shared(value)
146
- enable_shared = RbConfig::CONFIG['ENABLE_SHARED']
147
- RbConfig::CONFIG['ENABLE_SHARED'] = value
153
+ enable_shared = RbConfig::CONFIG["ENABLE_SHARED"]
154
+ RbConfig::CONFIG["ENABLE_SHARED"] = value
148
155
 
149
156
  yield
150
157
  ensure
151
158
  if enable_shared
152
- RbConfig::CONFIG['enable_shared'] = enable_shared
159
+ RbConfig::CONFIG["ENABLE_SHARED"] = enable_shared
160
+ else
161
+ RbConfig::CONFIG.delete "ENABLE_SHARED"
162
+ end
163
+ end
164
+
165
+ ##
166
+ # Sets the vendordir entry in RbConfig::CONFIG to +value+ and restores the
167
+ # original value when the block ends
168
+ #
169
+ def vendordir(value)
170
+ vendordir = RbConfig::CONFIG["vendordir"]
171
+
172
+ if value
173
+ RbConfig::CONFIG["vendordir"] = value
153
174
  else
154
- RbConfig::CONFIG.delete 'enable_shared'
175
+ RbConfig::CONFIG.delete "vendordir"
176
+ end
177
+
178
+ yield
179
+ ensure
180
+ if vendordir
181
+ RbConfig::CONFIG["vendordir"] = vendordir
182
+ else
183
+ RbConfig::CONFIG.delete "vendordir"
155
184
  end
156
185
  end
157
186
 
158
- # TODO: move to minitest
159
- def refute_path_exists(path, msg = nil)
160
- msg = message(msg) { "Expected path '#{path}' to not exist" }
161
- refute File.exist?(path), msg
187
+ ##
188
+ # Sets the bindir entry in RbConfig::CONFIG to +value+ and restores the
189
+ # original value when the block ends
190
+ #
191
+ def bindir(value)
192
+ with_clean_path_to_ruby do
193
+ bindir = RbConfig::CONFIG["bindir"]
194
+
195
+ if value
196
+ RbConfig::CONFIG["bindir"] = value
197
+ else
198
+ RbConfig::CONFIG.delete "bindir"
199
+ end
200
+
201
+ begin
202
+ yield
203
+ ensure
204
+ if bindir
205
+ RbConfig::CONFIG["bindir"] = bindir
206
+ else
207
+ RbConfig::CONFIG.delete "bindir"
208
+ end
209
+ end
210
+ end
211
+ end
212
+
213
+ ##
214
+ # Sets the EXEEXT entry in RbConfig::CONFIG to +value+ and restores the
215
+ # original value when the block ends
216
+ #
217
+ def exeext(value)
218
+ exeext = RbConfig::CONFIG["EXEEXT"]
219
+
220
+ if value
221
+ RbConfig::CONFIG["EXEEXT"] = value
222
+ else
223
+ RbConfig::CONFIG.delete "EXEEXT"
224
+ end
225
+
226
+ yield
227
+ ensure
228
+ if exeext
229
+ RbConfig::CONFIG["EXEEXT"] = exeext
230
+ else
231
+ RbConfig::CONFIG.delete "EXEEXT"
232
+ end
162
233
  end
163
234
 
164
235
  def scan_make_command_lines(output)
165
236
  output.scan(/^#{Regexp.escape make_command}(?:[[:blank:]].*)?$/)
166
237
  end
167
238
 
168
- def parse_make_command_line(line)
169
- command, *args = line.shellsplit
239
+ def parse_make_command_line_targets(line)
240
+ args = line.sub(/^#{Regexp.escape make_command}/, "").shellsplit
170
241
 
171
242
  targets = []
172
- macros = {}
173
243
 
174
244
  args.each do |arg|
175
245
  case arg
176
246
  when /\A(\w+)=/
177
- macros[$1] = $'
178
247
  else
179
248
  targets << arg
180
249
  end
181
250
  end
182
251
 
183
- targets << '' if targets.empty?
252
+ targets << "" if targets.empty?
184
253
 
185
- {
186
- :command => command,
187
- :targets => targets,
188
- :macros => macros,
189
- }
254
+ targets
190
255
  end
191
256
 
192
257
  def assert_contains_make_command(target, output, msg = nil)
193
- if output.match(/\n/)
194
- msg = message(msg) {
195
- 'Expected output containing make command "%s": %s' % [
196
- ('%s %s' % [make_command, target]).rstrip,
197
- output.inspect
258
+ if output.include?("\n")
259
+ msg = build_message(msg,
260
+ "Expected output containing make command \"%s\", but was \n\nBEGIN_OF_OUTPUT\n%sEND_OF_OUTPUT" % [
261
+ ("%s %s" % [make_command, target]).rstrip,
262
+ output,
198
263
  ]
199
- }
264
+ )
200
265
  else
201
- msg = message(msg) {
202
- 'Expected make command "%s": %s' % [
203
- ('%s %s' % [make_command, target]).rstrip,
204
- output.inspect
266
+ msg = build_message(msg,
267
+ 'Expected make command "%s", but was "%s"' % [
268
+ ("%s %s" % [make_command, target]).rstrip,
269
+ output,
205
270
  ]
206
- }
271
+ )
207
272
  end
208
273
 
209
- assert scan_make_command_lines(output).any? { |line|
210
- make = parse_make_command_line(line)
274
+ assert scan_make_command_lines(output).any? {|line|
275
+ targets = parse_make_command_line_targets(line)
211
276
 
212
- if make[:targets].include?(target)
213
- yield make, line if block_given?
277
+ if targets.include?(target)
214
278
  true
215
279
  else
216
280
  false
@@ -220,13 +284,6 @@ class Gem::TestCase < (defined?(Minitest::Test) ? Minitest::Test : MiniTest::Uni
220
284
 
221
285
  include Gem::DefaultUserInteraction
222
286
 
223
- undef_method :default_test if instance_methods.include? 'default_test' or
224
- instance_methods.include? :default_test
225
-
226
- @@project_dir = Dir.pwd.untaint unless defined?(@@project_dir)
227
-
228
- @@initial_reset = false
229
-
230
287
  ##
231
288
  # #setup prepares a sandboxed location to install gems. All installs are
232
289
  # directed to a temporary directory. All install plugins are removed.
@@ -234,92 +291,62 @@ class Gem::TestCase < (defined?(Minitest::Test) ? Minitest::Test : MiniTest::Uni
234
291
  # If the +RUBY+ environment variable is set the given path is used for
235
292
  # Gem::ruby. The local platform is set to <tt>i386-mswin32</tt> for Windows
236
293
  # or <tt>i686-darwin8.10.1</tt> otherwise.
237
- #
238
- # If the +KEEP_FILES+ environment variable is set the files will not be
239
- # removed from <tt>/tmp/test_rubygems_#{$$}.#{Time.now.to_i}</tt>.
240
294
 
241
295
  def setup
242
- super
296
+ @orig_hooks = {}
297
+ @orig_env = ENV.to_hash
298
+ @tmp = File.expand_path("tmp")
243
299
 
244
- @orig_gem_home = ENV['GEM_HOME']
245
- @orig_gem_path = ENV['GEM_PATH']
246
- @orig_gem_vendor = ENV['GEM_VENDOR']
247
- @orig_gem_spec_cache = ENV['GEM_SPEC_CACHE']
248
- @orig_rubygems_gemdeps = ENV['RUBYGEMS_GEMDEPS']
249
- @orig_bundle_gemfile = ENV['BUNDLE_GEMFILE']
250
- @orig_rubygems_host = ENV['RUBYGEMS_HOST']
251
- ENV.keys.find_all { |k| k.start_with?('GEM_REQUIREMENT_') }.each do |k|
252
- ENV.delete k
253
- end
254
- @orig_gem_env_requirements = ENV.to_hash
300
+ FileUtils.mkdir_p @tmp
255
301
 
256
- ENV['GEM_VENDOR'] = nil
257
- ENV['SOURCE_DATE_EPOCH'] = nil
302
+ @tempdir = Dir.mktmpdir("test_rubygems_", @tmp)
303
+ @tempdir.tap(&Gem::UNTAINT)
304
+
305
+ ENV["GEM_VENDOR"] = nil
306
+ ENV["GEMRC"] = nil
307
+ ENV["XDG_CACHE_HOME"] = nil
308
+ ENV["XDG_CONFIG_HOME"] = nil
309
+ ENV["XDG_DATA_HOME"] = nil
310
+ ENV["XDG_STATE_HOME"] = nil
311
+ ENV["SOURCE_DATE_EPOCH"] = nil
312
+ ENV["BUNDLER_VERSION"] = nil
313
+ ENV["RUBYGEMS_PREVENT_UPDATE_SUGGESTION"] = "true"
258
314
 
259
315
  @current_dir = Dir.pwd
260
316
  @fetcher = nil
261
317
 
262
- if Gem::USE_BUNDLER_FOR_GEMDEPS
263
- Bundler.ui = Bundler::UI::Silent.new
264
- end
265
318
  @back_ui = Gem::DefaultUserInteraction.ui
266
319
  @ui = Gem::MockGemUi.new
267
320
  # This needs to be a new instance since we call use_ui(@ui) when we want to
268
321
  # capture output
269
322
  Gem::DefaultUserInteraction.ui = Gem::MockGemUi.new
270
323
 
271
- tmpdir = File.expand_path Dir.tmpdir
272
- tmpdir.untaint
273
-
274
- if ENV['KEEP_FILES']
275
- @tempdir = File.join(tmpdir, "test_rubygems_#{$$}.#{Time.now.to_i}")
276
- else
277
- @tempdir = File.join(tmpdir, "test_rubygems_#{$$}")
278
- end
279
- @tempdir.untaint
280
-
281
- FileUtils.mkdir_p @tempdir
324
+ @orig_SYSTEM_WIDE_CONFIG_FILE = Gem::ConfigFile::SYSTEM_WIDE_CONFIG_FILE
325
+ Gem::ConfigFile.send :remove_const, :SYSTEM_WIDE_CONFIG_FILE
326
+ Gem::ConfigFile.send :const_set, :SYSTEM_WIDE_CONFIG_FILE,
327
+ File.join(@tempdir, "system-gemrc")
282
328
 
283
- # This makes the tempdir consistent on OS X.
284
- # File.expand_path Dir.tmpdir #=> "/var/..."
285
- # Dir.chdir Dir.tmpdir do File.expand_path '.' end #=> "/private/var/..."
286
- # TODO use File#realpath above instead of #expand_path once 1.8 support is
287
- # dropped.
288
- Dir.chdir @tempdir do
289
- @tempdir = File.expand_path '.'
290
- @tempdir.untaint
291
- end
329
+ @gemhome = File.join @tempdir, "gemhome"
330
+ @userhome = File.join @tempdir, "userhome"
331
+ @statehome = File.join @tempdir, "statehome"
332
+ ENV["GEM_SPEC_CACHE"] = File.join @tempdir, "spec_cache"
292
333
 
293
- # This makes the tempdir consistent on Windows.
294
- # Dir.tmpdir may return short path name, but Dir[Dir.tmpdir] returns long
295
- # path name. https://bugs.ruby-lang.org/issues/10819
296
- # File.expand_path or File.realpath doesn't convert path name to long path
297
- # name. Only Dir[] (= Dir.glob) works.
298
- # Short and long path name is specific to Windows filesystem.
299
- if win_platform?
300
- @tempdir = Dir[@tempdir][0]
301
- @tempdir.untaint
334
+ @orig_ruby = if ENV["RUBY"]
335
+ ruby = Gem.ruby
336
+ Gem.ruby = ENV["RUBY"]
337
+ ruby
302
338
  end
303
339
 
304
- @gemhome = File.join @tempdir, 'gemhome'
305
- @userhome = File.join @tempdir, 'userhome'
306
- ENV["GEM_SPEC_CACHE"] = File.join @tempdir, 'spec_cache'
307
-
308
- @orig_ruby = if ENV['RUBY']
309
- ruby = Gem.ruby
310
- Gem.ruby = ENV['RUBY']
311
- ruby
312
- end
313
-
314
- @git = ENV['GIT'] || 'git'
340
+ @git = ENV["GIT"] || "git#{RbConfig::CONFIG['EXEEXT']}"
315
341
 
316
342
  Gem.ensure_gem_subdirectories @gemhome
343
+ Gem.ensure_default_gem_subdirectories @gemhome
317
344
 
318
345
  @orig_LOAD_PATH = $LOAD_PATH.dup
319
- $LOAD_PATH.map! { |s|
320
- expand_path = File.expand_path(s)
346
+ $LOAD_PATH.map! do |s|
347
+ expand_path = File.realpath(s) rescue File.expand_path(s)
321
348
  if expand_path != s
322
- expand_path.untaint
349
+ expand_path.tap(&Gem::UNTAINT)
323
350
  if s.instance_variable_defined?(:@gem_prelude_index)
324
351
  expand_path.instance_variable_set(:@gem_prelude_index, expand_path)
325
352
  end
@@ -327,48 +354,50 @@ class Gem::TestCase < (defined?(Minitest::Test) ? Minitest::Test : MiniTest::Uni
327
354
  s = expand_path
328
355
  end
329
356
  s
330
- }
357
+ end
331
358
 
332
359
  Dir.chdir @tempdir
333
360
 
334
- @orig_ENV_HOME = ENV['HOME']
335
- ENV['HOME'] = @userhome
361
+ ENV["HOME"] = @userhome
362
+ Gem.instance_variable_set :@config_file, nil
336
363
  Gem.instance_variable_set :@user_home, nil
364
+ Gem.instance_variable_set :@config_home, nil
365
+ Gem.instance_variable_set :@data_home, nil
366
+ Gem.instance_variable_set :@state_home, @statehome
337
367
  Gem.instance_variable_set :@gemdeps, nil
338
368
  Gem.instance_variable_set :@env_requirements_by_name, nil
339
369
  Gem.send :remove_instance_variable, :@ruby_version if
340
370
  Gem.instance_variables.include? :@ruby_version
341
371
 
342
- FileUtils.mkdir_p @gemhome
343
372
  FileUtils.mkdir_p @userhome
344
373
 
345
- @orig_gem_private_key_passphrase = ENV['GEM_PRIVATE_KEY_PASSPHRASE']
346
- ENV['GEM_PRIVATE_KEY_PASSPHRASE'] = PRIVATE_KEY_PASSPHRASE
347
-
348
- @default_dir = File.join @tempdir, 'default'
349
- @default_spec_dir = File.join @default_dir, "specifications", "default"
350
- Gem.instance_variable_set :@default_dir, @default_dir
351
- FileUtils.mkdir_p @default_spec_dir
374
+ ENV["GEM_PRIVATE_KEY_PASSPHRASE"] = PRIVATE_KEY_PASSPHRASE
352
375
 
353
- # We use Gem::Specification.reset the first time only so that if there
354
- # are unresolved deps that leak into the whole test suite, they're at least
355
- # reported once.
356
- if @@initial_reset
357
- Gem::Specification.unresolved_deps.clear # done to avoid cross-test warnings
376
+ Gem.instance_variable_set(:@default_specifications_dir, nil)
377
+ if Gem.java_platform?
378
+ @orig_default_gem_home = RbConfig::CONFIG["default_gem_home"]
379
+ RbConfig::CONFIG["default_gem_home"] = @gemhome
358
380
  else
359
- @@initial_reset = true
360
- Gem::Specification.reset
381
+ Gem.instance_variable_set(:@default_dir, @gemhome)
361
382
  end
362
- Gem.use_paths(@gemhome)
363
383
 
364
- Gem::Security.reset
384
+ @orig_bindir = RbConfig::CONFIG["bindir"]
385
+ RbConfig::CONFIG["bindir"] = File.join @gemhome, "bin"
386
+
387
+ @orig_sitelibdir = RbConfig::CONFIG["sitelibdir"]
388
+ new_sitelibdir = @orig_sitelibdir.sub(RbConfig::CONFIG["prefix"], @gemhome)
389
+ $LOAD_PATH.insert(Gem.load_path_insert_index, new_sitelibdir)
390
+ RbConfig::CONFIG["sitelibdir"] = new_sitelibdir
391
+
392
+ @orig_mandir = RbConfig::CONFIG["mandir"]
393
+ RbConfig::CONFIG["mandir"] = File.join @gemhome, "share", "man"
394
+
395
+ Gem::Specification.unresolved_deps.clear
396
+ Gem.use_paths(@gemhome)
365
397
 
366
398
  Gem.loaded_specs.clear
399
+ Gem.instance_variable_set(:@activated_gem_paths, 0)
367
400
  Gem.clear_default_specs
368
- Gem::Specification.unresolved_deps.clear
369
- if Gem::USE_BUNDLER_FOR_GEMDEPS
370
- Bundler.reset!
371
- end
372
401
 
373
402
  Gem.configuration.verbose = true
374
403
  Gem.configuration.update_sources = true
@@ -381,18 +410,15 @@ class Gem::TestCase < (defined?(Minitest::Test) ? Minitest::Test : MiniTest::Uni
381
410
 
382
411
  Gem.searcher = nil
383
412
  Gem::SpecFetcher.fetcher = nil
384
- @orig_BASERUBY = RbConfig::CONFIG['BASERUBY']
385
- RbConfig::CONFIG['BASERUBY'] = RbConfig::CONFIG['ruby_install_name']
386
413
 
387
- @orig_arch = RbConfig::CONFIG['arch']
414
+ @orig_arch = RbConfig::CONFIG["arch"]
388
415
 
389
416
  if win_platform?
390
- util_set_arch 'i386-mswin32'
417
+ util_set_arch "i386-mswin32"
391
418
  else
392
- util_set_arch 'i686-darwin8.10.1'
419
+ util_set_arch "i686-darwin8.10.1"
393
420
  end
394
421
 
395
- @orig_hooks = {}
396
422
  %w[post_install_hooks done_installing_hooks post_uninstall_hooks pre_uninstall_hooks pre_install_hooks pre_reset_hooks post_reset_hooks post_build_hooks].each do |name|
397
423
  @orig_hooks[name] = Gem.send(name).dup
398
424
  end
@@ -403,29 +429,21 @@ class Gem::TestCase < (defined?(Minitest::Test) ? Minitest::Test : MiniTest::Uni
403
429
 
404
430
  ##
405
431
  # #teardown restores the process to its original state and removes the
406
- # tempdir unless the +KEEP_FILES+ environment variable was set.
432
+ # tempdir
407
433
 
408
434
  def teardown
409
435
  $LOAD_PATH.replace @orig_LOAD_PATH if @orig_LOAD_PATH
410
436
  if @orig_LOADED_FEATURES
411
437
  if @orig_LOAD_PATH
412
- paths = @orig_LOAD_PATH.map {|path| File.join(File.expand_path(path), "/")}
413
438
  ($LOADED_FEATURES - @orig_LOADED_FEATURES).each do |feat|
414
- unless paths.any? {|path| feat.start_with?(path)}
415
- $LOADED_FEATURES.delete(feat)
416
- end
439
+ $LOADED_FEATURES.delete(feat) if feat.start_with?(@tmp)
417
440
  end
418
441
  else
419
442
  $LOADED_FEATURES.replace @orig_LOADED_FEATURES
420
443
  end
421
444
  end
422
445
 
423
- if @orig_BASERUBY
424
- RbConfig::CONFIG['BASERUBY'] = @orig_BASERUBY
425
- else
426
- RbConfig::CONFIG.delete('BASERUBY')
427
- end
428
- RbConfig::CONFIG['arch'] = @orig_arch
446
+ RbConfig::CONFIG["arch"] = @orig_arch
429
447
 
430
448
  if defined? Gem::RemoteFetcher
431
449
  Gem::RemoteFetcher.fetcher = nil
@@ -433,34 +451,27 @@ class Gem::TestCase < (defined?(Minitest::Test) ? Minitest::Test : MiniTest::Uni
433
451
 
434
452
  Dir.chdir @current_dir
435
453
 
436
- FileUtils.rm_rf @tempdir unless ENV['KEEP_FILES']
454
+ FileUtils.rm_rf @tempdir
437
455
 
438
- ENV.clear
439
- @orig_gem_env_requirements.each do |k,v|
440
- ENV[k] = v
441
- end
456
+ restore_env
442
457
 
443
- ENV['GEM_HOME'] = @orig_gem_home
444
- ENV['GEM_PATH'] = @orig_gem_path
445
- ENV['GEM_VENDOR'] = @orig_gem_vendor
446
- ENV['GEM_SPEC_CACHE'] = @orig_gem_spec_cache
447
- ENV['RUBYGEMS_GEMDEPS'] = @orig_rubygems_gemdeps
448
- ENV['BUNDLE_GEMFILE'] = @orig_bundle_gemfile
449
- ENV['RUBYGEMS_HOST'] = @orig_rubygems_host
458
+ Gem::ConfigFile.send :remove_const, :SYSTEM_WIDE_CONFIG_FILE
459
+ Gem::ConfigFile.send :const_set, :SYSTEM_WIDE_CONFIG_FILE,
460
+ @orig_SYSTEM_WIDE_CONFIG_FILE
450
461
 
451
462
  Gem.ruby = @orig_ruby if @orig_ruby
452
463
 
453
- if @orig_ENV_HOME
454
- ENV['HOME'] = @orig_ENV_HOME
464
+ RbConfig::CONFIG["mandir"] = @orig_mandir
465
+ RbConfig::CONFIG["sitelibdir"] = @orig_sitelibdir
466
+ RbConfig::CONFIG["bindir"] = @orig_bindir
467
+
468
+ Gem.instance_variable_set :@default_specifications_dir, nil
469
+ if Gem.java_platform?
470
+ RbConfig::CONFIG["default_gem_home"] = @orig_default_gem_home
455
471
  else
456
- ENV.delete 'HOME'
472
+ Gem.instance_variable_set :@default_dir, nil
457
473
  end
458
474
 
459
- Gem.instance_variable_set :@default_dir, nil
460
-
461
- ENV['GEM_PRIVATE_KEY_PASSPHRASE'] = @orig_gem_private_key_passphrase
462
-
463
- Gem::Specification._clear_load_cache
464
475
  Gem::Specification.unresolved_deps.clear
465
476
  Gem::refresh
466
477
 
@@ -471,6 +482,17 @@ class Gem::TestCase < (defined?(Minitest::Test) ? Minitest::Test : MiniTest::Uni
471
482
  @back_ui.close
472
483
  end
473
484
 
485
+ def credential_setup
486
+ @temp_cred = File.join(@userhome, ".gem", "credentials")
487
+ FileUtils.mkdir_p File.dirname(@temp_cred)
488
+ File.write @temp_cred, ":rubygems_api_key: 701229f217cdf23b1344c7b4b54ca97"
489
+ File.chmod 0600, @temp_cred
490
+ end
491
+
492
+ def credential_teardown
493
+ FileUtils.rm_rf @temp_cred
494
+ end
495
+
474
496
  def common_installer_setup
475
497
  common_installer_teardown
476
498
 
@@ -508,16 +530,20 @@ class Gem::TestCase < (defined?(Minitest::Test) ? Minitest::Test : MiniTest::Uni
508
530
  Gem.pre_uninstall_hooks.clear
509
531
  end
510
532
 
533
+ def without_any_upwards_gemfiles
534
+ ENV["BUNDLE_GEMFILE"] = File.join(@tempdir, "Gemfile")
535
+ end
536
+
511
537
  ##
512
538
  # A git_gem is used with a gem dependencies file. The gem created here
513
539
  # has no files, just a gem specification for the given +name+ and +version+.
514
540
  #
515
541
  # Yields the +specification+ to the block, if given
516
542
 
517
- def git_gem(name = 'a', version = 1)
543
+ def git_gem(name = "a", version = 1)
518
544
  have_git?
519
545
 
520
- directory = File.join 'git', name
546
+ directory = File.join "git", name
521
547
  directory = File.expand_path directory
522
548
 
523
549
  git_spec = Gem::Specification.new name, version do |specification|
@@ -528,22 +554,23 @@ class Gem::TestCase < (defined?(Minitest::Test) ? Minitest::Test : MiniTest::Uni
528
554
 
529
555
  gemspec = "#{name}.gemspec"
530
556
 
531
- File.open File.join(directory, gemspec), 'w' do |io|
557
+ File.open File.join(directory, gemspec), "w" do |io|
532
558
  io.write git_spec.to_ruby
533
559
  end
534
560
 
535
561
  head = nil
536
562
 
537
563
  Dir.chdir directory do
538
- unless File.exist? '.git'
539
- system @git, 'init', '--quiet'
540
- system @git, 'config', 'user.name', 'RubyGems Tests'
541
- system @git, 'config', 'user.email', 'rubygems@example'
564
+ unless File.exist? ".git"
565
+ system @git, "init", "--quiet"
566
+ system @git, "checkout", "-b", "master", "--quiet"
567
+ system @git, "config", "user.name", "RubyGems Tests"
568
+ system @git, "config", "user.email", "rubygems@example"
542
569
  end
543
570
 
544
- system @git, 'add', gemspec
545
- system @git, 'commit', '-a', '-m', 'a non-empty commit message', '--quiet'
546
- head = Gem::Util.popen(@git, 'rev-parse', 'master').strip
571
+ system @git, "add", gemspec
572
+ system @git, "commit", "-a", "-m", "a non-empty commit message", "--quiet"
573
+ head = Gem::Util.popen(@git, "rev-parse", "master").strip
547
574
  end
548
575
 
549
576
  return name, git_spec.version, directory, head
@@ -555,13 +582,13 @@ class Gem::TestCase < (defined?(Minitest::Test) ? Minitest::Test : MiniTest::Uni
555
582
  def have_git?
556
583
  return if in_path? @git
557
584
 
558
- skip 'cannot find git executable, use GIT environment variable to set'
585
+ pend "cannot find git executable, use GIT environment variable to set"
559
586
  end
560
587
 
561
588
  def in_path?(executable) # :nodoc:
562
- return true if %r%\A([A-Z]:|/)% =~ executable and File.exist? executable
589
+ return true if %r{\A([A-Z]:|/)} =~ executable && File.exist?(executable)
563
590
 
564
- ENV['PATH'].split(File::PATH_SEPARATOR).any? do |directory|
591
+ ENV["PATH"].split(File::PATH_SEPARATOR).any? do |directory|
565
592
  File.exist? File.join directory, executable
566
593
  end
567
594
  end
@@ -570,9 +597,9 @@ class Gem::TestCase < (defined?(Minitest::Test) ? Minitest::Test : MiniTest::Uni
570
597
  # Builds and installs the Gem::Specification +spec+
571
598
 
572
599
  def install_gem(spec, options = {})
573
- require 'rubygems/installer'
600
+ require "rubygems/installer"
574
601
 
575
- gem = File.join @tempdir, "gems", "#{spec.full_name}.gem"
602
+ gem = spec.cache_file
576
603
 
577
604
  unless File.exist? gem
578
605
  use_ui Gem::MockGemUi.new do
@@ -581,10 +608,10 @@ class Gem::TestCase < (defined?(Minitest::Test) ? Minitest::Test : MiniTest::Uni
581
608
  end
582
609
  end
583
610
 
584
- gem = File.join(@tempdir, File.basename(spec.cache_file)).untaint
611
+ gem = File.join(@tempdir, File.basename(gem)).tap(&Gem::UNTAINT)
585
612
  end
586
613
 
587
- Gem::Installer.at(gem, options.merge({:wrappers => true})).install
614
+ Gem::Installer.at(gem, options.merge({ :wrappers => true })).install
588
615
  end
589
616
 
590
617
  ##
@@ -597,25 +624,13 @@ class Gem::TestCase < (defined?(Minitest::Test) ? Minitest::Test : MiniTest::Uni
597
624
  ##
598
625
  # Uninstalls the Gem::Specification +spec+
599
626
  def uninstall_gem(spec)
600
- require 'rubygems/uninstaller'
627
+ require "rubygems/uninstaller"
601
628
 
602
- Class.new(Gem::Uninstaller) {
629
+ Class.new(Gem::Uninstaller) do
603
630
  def ask_if_ok(spec)
604
631
  true
605
632
  end
606
- }.new(spec.name, :executables => true, :user_install => true).uninstall
607
- end
608
-
609
- ##
610
- # creates a temporary directory with hax
611
- # TODO: deprecate and remove
612
-
613
- def create_tmpdir
614
- tmpdir = nil
615
- Dir.chdir Dir.tmpdir do tmpdir = Dir.pwd end # HACK OSX /private/tmp
616
- tmpdir = File.join tmpdir, "test_rubygems_#{$$}"
617
- FileUtils.mkdir_p tmpdir
618
- return tmpdir
633
+ end.new(spec.name, :executables => true, :user_install => true).uninstall
619
634
  end
620
635
 
621
636
  ##
@@ -632,7 +647,7 @@ class Gem::TestCase < (defined?(Minitest::Test) ? Minitest::Test : MiniTest::Uni
632
647
  # Reads a Marshal file at +path+
633
648
 
634
649
  def read_cache(path)
635
- File.open path.dup.untaint, 'rb' do |io|
650
+ File.open path.dup.tap(&Gem::UNTAINT), "rb" do |io|
636
651
  Marshal.load io.read
637
652
  end
638
653
  end
@@ -652,13 +667,35 @@ class Gem::TestCase < (defined?(Minitest::Test) ? Minitest::Test : MiniTest::Uni
652
667
  dir = File.dirname path
653
668
  FileUtils.mkdir_p dir unless File.directory? dir
654
669
 
655
- File.open path, 'wb' do |io|
670
+ File.open path, "wb" do |io|
656
671
  yield io if block_given?
657
672
  end
658
673
 
659
674
  path
660
675
  end
661
676
 
677
+ ##
678
+ # Load a YAML string, the psych 3 way
679
+
680
+ def load_yaml(yaml)
681
+ if Psych.respond_to?(:unsafe_load)
682
+ Psych.unsafe_load(yaml)
683
+ else
684
+ Psych.load(yaml)
685
+ end
686
+ end
687
+
688
+ ##
689
+ # Load a YAML file, the psych 3 way
690
+
691
+ def load_yaml_file(file)
692
+ if Psych.respond_to?(:unsafe_load_file)
693
+ Psych.unsafe_load_file(file)
694
+ else
695
+ Psych.load_file(file)
696
+ end
697
+ end
698
+
662
699
  def all_spec_names
663
700
  Gem::Specification.map(&:full_name)
664
701
  end
@@ -673,44 +710,33 @@ class Gem::TestCase < (defined?(Minitest::Test) ? Minitest::Test : MiniTest::Uni
673
710
  #
674
711
  # Use this with #write_file to build an installed gem.
675
712
 
676
- def quick_gem(name, version='2')
677
- require 'rubygems/specification'
713
+ def quick_gem(name, version="2")
714
+ require "rubygems/specification"
678
715
 
679
716
  spec = Gem::Specification.new do |s|
680
717
  s.platform = Gem::Platform::RUBY
681
718
  s.name = name
682
719
  s.version = version
683
- s.author = 'A User'
684
- s.email = 'example@example.com'
685
- s.homepage = 'http://example.com'
720
+ s.author = "A User"
721
+ s.email = "example@example.com"
722
+ s.homepage = "http://example.com"
686
723
  s.summary = "this is a summary"
687
724
  s.description = "This is a test description"
688
725
 
689
726
  yield(s) if block_given?
690
727
  end
691
728
 
692
- Gem::Specification.map # HACK: force specs to (re-)load before we write
693
-
694
729
  written_path = write_file spec.spec_file do |io|
695
730
  io.write spec.to_ruby_for_cache
696
731
  end
697
732
 
698
- spec.loaded_from = spec.loaded_from = written_path
733
+ spec.loaded_from = written_path
699
734
 
700
735
  Gem::Specification.reset
701
736
 
702
737
  return spec
703
738
  end
704
739
 
705
- ##
706
- # TODO: remove in RubyGems 4.0
707
-
708
- def quick_spec(name, version = '2') # :nodoc:
709
- util_spec name, version
710
- end
711
- deprecate :quick_spec, :util_spec, 2018, 12
712
-
713
-
714
740
  ##
715
741
  # Builds a gem from +spec+ and places it in <tt>File.join @gemhome,
716
742
  # 'cache'</tt>. Automatically creates files based on +spec.files+
@@ -723,7 +749,10 @@ class Gem::TestCase < (defined?(Minitest::Test) ? Minitest::Test : MiniTest::Uni
723
749
  spec.files.each do |file|
724
750
  next if File.exist? file
725
751
  FileUtils.mkdir_p File.dirname(file)
726
- File.open file, 'w' do |fp| fp.puts "# #{file}" end
752
+
753
+ File.open file, "w" do |fp|
754
+ fp.puts "# #{file}"
755
+ end
727
756
  end
728
757
 
729
758
  use_ui Gem::MockGemUi.new do
@@ -744,7 +773,7 @@ class Gem::TestCase < (defined?(Minitest::Test) ? Minitest::Test : MiniTest::Uni
744
773
  # Removes all installed gems from +@gemhome+.
745
774
 
746
775
  def util_clear_gems
747
- FileUtils.rm_rf File.join(@gemhome, "gems") # TODO: use Gem::Dirs
776
+ FileUtils.rm_rf File.join(@gemhome, "gems")
748
777
  FileUtils.mkdir File.join(@gemhome, "gems")
749
778
  FileUtils.rm_rf File.join(@gemhome, "specifications")
750
779
  FileUtils.mkdir File.join(@gemhome, "specifications")
@@ -756,7 +785,7 @@ class Gem::TestCase < (defined?(Minitest::Test) ? Minitest::Test : MiniTest::Uni
756
785
 
757
786
  def install_specs(*specs)
758
787
  specs.each do |spec|
759
- Gem::Installer.for_spec(spec).install
788
+ Gem::Installer.for_spec(spec, :force => true).install
760
789
  end
761
790
 
762
791
  Gem.searcher = nil
@@ -766,19 +795,6 @@ class Gem::TestCase < (defined?(Minitest::Test) ? Minitest::Test : MiniTest::Uni
766
795
  # Installs the provided default specs including writing the spec file
767
796
 
768
797
  def install_default_gems(*specs)
769
- install_default_specs(*specs)
770
-
771
- specs.each do |spec|
772
- File.open spec.loaded_from, 'w' do |io|
773
- io.write spec.to_ruby_for_cache
774
- end
775
- end
776
- end
777
-
778
- ##
779
- # Install the provided default specs
780
-
781
- def install_default_specs(*specs)
782
798
  specs.each do |spec|
783
799
  installer = Gem::Installer.for_spec(spec, :install_as_default => true)
784
800
  installer.install
@@ -794,69 +810,15 @@ class Gem::TestCase < (defined?(Minitest::Test) ? Minitest::Test : MiniTest::Uni
794
810
  Gem::Specification.unresolved_deps.values.map(&:to_s).sort
795
811
  end
796
812
 
797
- def save_loaded_features
798
- old_loaded_features = $LOADED_FEATURES.dup
799
- yield
800
- ensure
801
- prefix = File.dirname(__FILE__) + "/"
802
- new_features = ($LOADED_FEATURES - old_loaded_features)
803
- old_loaded_features.concat(new_features.select {|f| f.rindex(prefix, 0)})
804
- $LOADED_FEATURES.replace old_loaded_features
805
- end
806
-
807
- ##
808
- # new_spec is deprecated as it is never used.
809
- #
810
- # TODO: remove in RubyGems 4.0
811
-
812
- def new_spec(name, version, deps = nil, *files) # :nodoc:
813
- require 'rubygems/specification'
814
-
815
- spec = Gem::Specification.new do |s|
816
- s.platform = Gem::Platform::RUBY
817
- s.name = name
818
- s.version = version
819
- s.author = 'A User'
820
- s.email = 'example@example.com'
821
- s.homepage = 'http://example.com'
822
- s.summary = "this is a summary"
823
- s.description = "This is a test description"
824
-
825
- Array(deps).each do |n, req|
826
- s.add_dependency n, (req || '>= 0')
827
- end
828
-
829
- s.files.push(*files) unless files.empty?
830
-
831
- yield s if block_given?
832
- end
833
-
834
- spec.loaded_from = spec.spec_file
835
-
836
- unless files.empty?
837
- write_file spec.spec_file do |io|
838
- io.write spec.to_ruby_for_cache
839
- end
840
-
841
- util_build_gem spec
842
-
843
- cache_file = File.join @tempdir, 'gems', "#{spec.full_name}.gem"
844
- FileUtils.mkdir_p File.dirname cache_file
845
- FileUtils.mv spec.cache_file, cache_file
846
- FileUtils.rm spec.spec_file
847
- end
848
-
849
- spec
850
- end
851
- deprecate :new_spec, :none, 2018, 12
852
-
853
813
  def new_default_spec(name, version, deps = nil, *files)
854
814
  spec = util_spec name, version, deps
855
815
 
856
- spec.loaded_from = File.join(@default_spec_dir, spec.spec_name)
816
+ spec.loaded_from = File.join(@gemhome, "specifications", "default", spec.spec_name)
857
817
  spec.files = files
858
818
 
859
819
  lib_dir = File.join(@tempdir, "default_gems", "lib")
820
+ lib_dir.instance_variable_set(:@gem_prelude_index, lib_dir)
821
+ Gem.instance_variable_set(:@default_gem_load_paths, [*Gem.send(:default_gem_load_paths), lib_dir])
860
822
  $LOAD_PATH.unshift(lib_dir)
861
823
  files.each do |file|
862
824
  rb_path = File.join(lib_dir, file)
@@ -874,15 +836,15 @@ class Gem::TestCase < (defined?(Minitest::Test) ? Minitest::Test : MiniTest::Uni
874
836
  # or a +block+ can be given for full customization of the specification.
875
837
 
876
838
  def util_spec(name, version = 2, deps = nil, *files) # :yields: specification
877
- raise "deps or block, not both" if deps and block_given?
839
+ raise "deps or block, not both" if deps && block_given?
878
840
 
879
841
  spec = Gem::Specification.new do |s|
880
842
  s.platform = Gem::Platform::RUBY
881
843
  s.name = name
882
844
  s.version = version
883
- s.author = 'A User'
884
- s.email = 'example@example.com'
885
- s.homepage = 'http://example.com'
845
+ s.author = "A User"
846
+ s.email = "example@example.com"
847
+ s.homepage = "http://example.com"
886
848
  s.summary = "this is a summary"
887
849
  s.description = "This is a test description"
888
850
 
@@ -892,10 +854,8 @@ class Gem::TestCase < (defined?(Minitest::Test) ? Minitest::Test : MiniTest::Uni
892
854
  end
893
855
 
894
856
  if deps
895
- # Since Hash#each is unordered in 1.8, sort the keys and iterate that
896
- # way so the tests are deterministic on all implementations.
897
- deps.keys.sort.each do |n|
898
- spec.add_dependency n, (deps[n] || '>= 0')
857
+ deps.keys.each do |n|
858
+ spec.add_dependency n, (deps[n] || ">= 0")
899
859
  end
900
860
  end
901
861
 
@@ -906,14 +866,9 @@ class Gem::TestCase < (defined?(Minitest::Test) ? Minitest::Test : MiniTest::Uni
906
866
 
907
867
  util_build_gem spec
908
868
 
909
- cache_file = File.join @tempdir, 'gems', "#{spec.full_name}.gem"
910
- FileUtils.mkdir_p File.dirname cache_file
911
- FileUtils.mv spec.cache_file, cache_file
912
869
  FileUtils.rm spec.spec_file
913
870
  end
914
871
 
915
- Gem::Specification.reset
916
-
917
872
  return spec
918
873
  end
919
874
 
@@ -924,16 +879,10 @@ class Gem::TestCase < (defined?(Minitest::Test) ? Minitest::Test : MiniTest::Uni
924
879
  # location are returned.
925
880
 
926
881
  def util_gem(name, version, deps = nil, &block)
927
- # TODO: deprecate
928
- raise "deps or block, not both" if deps and block
929
-
930
882
  if deps
931
883
  block = proc do |s|
932
- # Since Hash#each is unordered in 1.8, sort
933
- # the keys and iterate that way so the tests are
934
- # deterministic on all implementations.
935
- deps.keys.sort.each do |n|
936
- s.add_dependency n, (deps[n] || '>= 0')
884
+ deps.keys.each do |n|
885
+ s.add_dependency n, (deps[n] || ">= 0")
937
886
  end
938
887
  end
939
888
  end
@@ -942,7 +891,7 @@ class Gem::TestCase < (defined?(Minitest::Test) ? Minitest::Test : MiniTest::Uni
942
891
 
943
892
  util_build_gem spec
944
893
 
945
- cache_file = File.join @tempdir, 'gems', "#{spec.original_name}.gem"
894
+ cache_file = File.join @tempdir, "gems", "#{spec.original_name}.gem"
946
895
  FileUtils.mkdir_p File.dirname cache_file
947
896
  FileUtils.mv spec.cache_file, cache_file
948
897
  FileUtils.rm spec.spec_file
@@ -984,11 +933,11 @@ class Gem::TestCase < (defined?(Minitest::Test) ? Minitest::Test : MiniTest::Uni
984
933
  # TODO: nuke this and fix tests. this should speed up a lot
985
934
 
986
935
  def util_make_gems(prerelease = false)
987
- @a1 = quick_gem 'a', '1' do |s|
936
+ @a1 = quick_gem "a", "1" do |s|
988
937
  s.files = %w[lib/code.rb]
989
938
  s.require_paths = %w[lib]
990
939
  s.date = Gem::Specification::TODAY - 86400
991
- s.homepage = 'http://a.example.com'
940
+ s.homepage = "http://a.example.com"
992
941
  s.email = %w[example@example.com example2@example.com]
993
942
  s.authors = %w[Example Example2]
994
943
  s.description = <<-DESC
@@ -1005,27 +954,27 @@ Also, a list:
1005
954
  s.require_paths = %w[lib]
1006
955
  end
1007
956
 
1008
- @a2 = quick_gem('a', '2', &init)
1009
- @a3a = quick_gem('a', '3.a', &init)
1010
- @a_evil9 = quick_gem('a_evil', '9', &init)
1011
- @b2 = quick_gem('b', '2', &init)
1012
- @c1_2 = quick_gem('c', '1.2', &init)
1013
- @x = quick_gem('x', '1', &init)
1014
- @dep_x = quick_gem('dep_x', '1') do |s|
957
+ @a2 = quick_gem("a", "2", &init)
958
+ @a3a = quick_gem("a", "3.a", &init)
959
+ @a_evil9 = quick_gem("a_evil", "9", &init)
960
+ @b2 = quick_gem("b", "2", &init)
961
+ @c1_2 = quick_gem("c", "1.2", &init)
962
+ @x = quick_gem("x", "1", &init)
963
+ @dep_x = quick_gem("dep_x", "1") do |s|
1015
964
  s.files = %w[lib/code.rb]
1016
965
  s.require_paths = %w[lib]
1017
- s.add_dependency 'x', '>= 1'
966
+ s.add_dependency "x", ">= 1"
1018
967
  end
1019
968
 
1020
- @pl1 = quick_gem 'pl', '1' do |s| # l for legacy
969
+ @pl1 = quick_gem "pl", "1" do |s| # l for legacy
1021
970
  s.files = %w[lib/code.rb]
1022
971
  s.require_paths = %w[lib]
1023
- s.platform = Gem::Platform.new 'i386-linux'
1024
- s.instance_variable_set :@original_platform, 'i386-linux'
972
+ s.platform = Gem::Platform.new "i386-linux"
973
+ s.instance_variable_set :@original_platform, "i386-linux"
1025
974
  end
1026
975
 
1027
976
  if prerelease
1028
- @a2_pre = quick_gem('a', '2.a', &init)
977
+ @a2_pre = quick_gem("a", "2.a", &init)
1029
978
  write_file File.join(*%W[gems #{@a2_pre.original_name} lib code.rb])
1030
979
  util_build_gem @a2_pre
1031
980
  end
@@ -1051,38 +1000,15 @@ Also, a list:
1051
1000
  # Set the platform to +arch+
1052
1001
 
1053
1002
  def util_set_arch(arch)
1054
- RbConfig::CONFIG['arch'] = arch
1003
+ RbConfig::CONFIG["arch"] = arch
1055
1004
  platform = Gem::Platform.new arch
1056
1005
 
1057
1006
  Gem.instance_variable_set :@platforms, nil
1058
1007
  Gem::Platform.instance_variable_set :@local, nil
1059
1008
 
1060
- platform
1061
- end
1062
-
1063
- ##
1064
- # Sets up a fake fetcher using the gems from #util_make_gems. Optionally
1065
- # additional +prerelease+ gems may be included.
1066
- #
1067
- # Gems created by this method may be fetched using Gem::RemoteFetcher.
1068
-
1069
- def util_setup_fake_fetcher(prerelease = false)
1070
- require 'zlib'
1071
- require 'socket'
1072
- require 'rubygems/remote_fetcher'
1073
-
1074
- @fetcher = Gem::FakeFetcher.new
1009
+ yield if block_given?
1075
1010
 
1076
- util_make_gems(prerelease)
1077
- Gem::Specification.reset
1078
-
1079
- @all_gems = [@a1, @a2, @a3a, @a_evil9, @b2, @c1_2].sort
1080
- @all_gem_names = @all_gems.map { |gem| gem.full_name }
1081
-
1082
- gem_names = [@a1.full_name, @a2.full_name, @a3a.full_name, @b2.full_name]
1083
- @gem_names = gem_names.sort.join("\n")
1084
-
1085
- Gem::RemoteFetcher.fetcher = @fetcher
1011
+ platform
1086
1012
  end
1087
1013
 
1088
1014
  ##
@@ -1096,7 +1022,6 @@ Also, a list:
1096
1022
 
1097
1023
  ##
1098
1024
  # Sets up Gem::SpecFetcher to return information from the gems in +specs+.
1099
- # Best used with +@all_gems+ from #util_setup_fake_fetcher.
1100
1025
 
1101
1026
  def util_setup_spec_fetcher(*specs)
1102
1027
  all_specs = Gem::Specification.to_a + specs
@@ -1104,7 +1029,7 @@ Also, a list:
1104
1029
 
1105
1030
  spec_fetcher = Gem::SpecFetcher.fetcher
1106
1031
 
1107
- prerelease, all = all_specs.partition { |spec| spec.version.prerelease? }
1032
+ prerelease, all = all_specs.partition {|spec| spec.version.prerelease? }
1108
1033
  latest = Gem::Specification._latest_specs all_specs
1109
1034
 
1110
1035
  spec_fetcher.specs[@uri] = []
@@ -1126,7 +1051,7 @@ Also, a list:
1126
1051
  unless Gem::RemoteFetcher === @fetcher
1127
1052
  v = Gem.marshal_version
1128
1053
 
1129
- specs = all.map { |spec| spec.name_tuple }
1054
+ specs = all.map {|spec| spec.name_tuple }
1130
1055
  s_zip = util_gzip Marshal.dump Gem::NameTuple.to_basic specs
1131
1056
 
1132
1057
  latest_specs = latest.map do |spec|
@@ -1135,26 +1060,30 @@ Also, a list:
1135
1060
 
1136
1061
  l_zip = util_gzip Marshal.dump Gem::NameTuple.to_basic latest_specs
1137
1062
 
1138
- prerelease_specs = prerelease.map { |spec| spec.name_tuple }
1063
+ prerelease_specs = prerelease.map {|spec| spec.name_tuple }
1139
1064
  p_zip = util_gzip Marshal.dump Gem::NameTuple.to_basic prerelease_specs
1140
1065
 
1141
1066
  @fetcher.data["#{@gem_repo}specs.#{v}.gz"] = s_zip
1142
1067
  @fetcher.data["#{@gem_repo}latest_specs.#{v}.gz"] = l_zip
1143
1068
  @fetcher.data["#{@gem_repo}prerelease_specs.#{v}.gz"] = p_zip
1144
1069
 
1145
- v = Gem.marshal_version
1146
-
1147
- all_specs.each do |spec|
1148
- path = "#{@gem_repo}quick/Marshal.#{v}/#{spec.original_name}.gemspec.rz"
1149
- data = Marshal.dump spec
1150
- data_deflate = Zlib::Deflate.deflate data
1151
- @fetcher.data[path] = data_deflate
1152
- end
1070
+ write_marshalled_gemspecs(*all_specs)
1153
1071
  end
1154
1072
 
1155
1073
  nil # force errors
1156
1074
  end
1157
1075
 
1076
+ def write_marshalled_gemspecs(*all_specs)
1077
+ v = Gem.marshal_version
1078
+
1079
+ all_specs.each do |spec|
1080
+ path = "#{@gem_repo}quick/Marshal.#{v}/#{spec.original_name}.gemspec.rz"
1081
+ data = Marshal.dump spec
1082
+ data_deflate = Zlib::Deflate.deflate data
1083
+ @fetcher.data[path] = data_deflate
1084
+ end
1085
+ end
1086
+
1158
1087
  ##
1159
1088
  # Deflates +data+
1160
1089
 
@@ -1162,25 +1091,24 @@ Also, a list:
1162
1091
  Zlib::Deflate.deflate data
1163
1092
  end
1164
1093
 
1165
- def util_set_RUBY_VERSION(version, patchlevel = nil, revision = nil, description = nil, engine = "ruby", engine_version = nil)
1166
- if Gem.instance_variables.include? :@ruby_version or
1167
- Gem.instance_variables.include? '@ruby_version'
1094
+ def util_set_RUBY_VERSION(version, patchlevel, revision, description, engine = "ruby", engine_version = nil)
1095
+ if Gem.instance_variables.include? :@ruby_version
1168
1096
  Gem.send :remove_instance_variable, :@ruby_version
1169
1097
  end
1170
1098
 
1171
1099
  @RUBY_VERSION = RUBY_VERSION
1172
1100
  @RUBY_PATCHLEVEL = RUBY_PATCHLEVEL if defined?(RUBY_PATCHLEVEL)
1173
1101
  @RUBY_REVISION = RUBY_REVISION if defined?(RUBY_REVISION)
1174
- @RUBY_DESCRIPTION = RUBY_DESCRIPTION if defined?(RUBY_DESCRIPTION)
1102
+ @RUBY_DESCRIPTION = RUBY_DESCRIPTION
1175
1103
  @RUBY_ENGINE = RUBY_ENGINE
1176
1104
  @RUBY_ENGINE_VERSION = RUBY_ENGINE_VERSION if defined?(RUBY_ENGINE_VERSION)
1177
1105
 
1178
1106
  util_clear_RUBY_VERSION
1179
1107
 
1180
1108
  Object.const_set :RUBY_VERSION, version
1181
- Object.const_set :RUBY_PATCHLEVEL, patchlevel if patchlevel
1182
- Object.const_set :RUBY_REVISION, revision if revision
1183
- Object.const_set :RUBY_DESCRIPTION, description if description
1109
+ Object.const_set :RUBY_PATCHLEVEL, patchlevel
1110
+ Object.const_set :RUBY_REVISION, revision
1111
+ Object.const_set :RUBY_DESCRIPTION, description
1184
1112
  Object.const_set :RUBY_ENGINE, engine
1185
1113
  Object.const_set :RUBY_ENGINE_VERSION, engine_version if engine_version
1186
1114
  end
@@ -1193,8 +1121,7 @@ Also, a list:
1193
1121
  defined?(@RUBY_PATCHLEVEL)
1194
1122
  Object.const_set :RUBY_REVISION, @RUBY_REVISION if
1195
1123
  defined?(@RUBY_REVISION)
1196
- Object.const_set :RUBY_DESCRIPTION, @RUBY_DESCRIPTION if
1197
- defined?(@RUBY_DESCRIPTION)
1124
+ Object.const_set :RUBY_DESCRIPTION, @RUBY_DESCRIPTION
1198
1125
  Object.const_set :RUBY_ENGINE, @RUBY_ENGINE
1199
1126
  Object.const_set :RUBY_ENGINE_VERSION, @RUBY_ENGINE_VERSION if
1200
1127
  defined?(@RUBY_ENGINE_VERSION)
@@ -1223,12 +1150,26 @@ Also, a list:
1223
1150
  Gem.win_platform?
1224
1151
  end
1225
1152
 
1153
+ ##
1154
+ # Is this test being run on a Java platform?
1155
+
1156
+ def self.java_platform?
1157
+ Gem.java_platform?
1158
+ end
1159
+
1160
+ ##
1161
+ # Is this test being run on a Java platform?
1162
+
1163
+ def java_platform?
1164
+ Gem.java_platform?
1165
+ end
1166
+
1226
1167
  ##
1227
1168
  # Returns whether or not we're on a version of Ruby built with VC++ (or
1228
1169
  # Borland) versus Cygwin, Mingw, etc.
1229
1170
 
1230
1171
  def self.vc_windows?
1231
- RUBY_PLATFORM.match('mswin')
1172
+ RUBY_PLATFORM.match("mswin")
1232
1173
  end
1233
1174
 
1234
1175
  ##
@@ -1236,7 +1177,15 @@ Also, a list:
1236
1177
  # Borland) versus Cygwin, Mingw, etc.
1237
1178
 
1238
1179
  def vc_windows?
1239
- RUBY_PLATFORM.match('mswin')
1180
+ RUBY_PLATFORM.match("mswin")
1181
+ end
1182
+
1183
+ ##
1184
+ # Is this test being run on a ruby/ruby repository?
1185
+ #
1186
+
1187
+ def ruby_repo?
1188
+ !ENV["GEM_COMMAND"].nil?
1240
1189
  end
1241
1190
 
1242
1191
  ##
@@ -1245,7 +1194,7 @@ Also, a list:
1245
1194
  # other platforms, including Cygwin, it will return 'make'.
1246
1195
 
1247
1196
  def self.make_command
1248
- ENV["make"] || ENV["MAKE"] || (vc_windows? ? 'nmake' : 'make')
1197
+ ENV["make"] || ENV["MAKE"] || (vc_windows? ? "nmake" : "make")
1249
1198
  end
1250
1199
 
1251
1200
  ##
@@ -1254,14 +1203,14 @@ Also, a list:
1254
1203
  # other platforms, including Cygwin, it will return 'make'.
1255
1204
 
1256
1205
  def make_command
1257
- ENV["make"] || ENV["MAKE"] || (vc_windows? ? 'nmake' : 'make')
1206
+ ENV["make"] || ENV["MAKE"] || (vc_windows? ? "nmake" : "make")
1258
1207
  end
1259
1208
 
1260
1209
  ##
1261
1210
  # Returns whether or not the nmake command could be found.
1262
1211
 
1263
1212
  def nmake_found?
1264
- system('nmake /? 1>NUL 2>&1')
1213
+ system("nmake /? 1>NUL 2>&1")
1265
1214
  end
1266
1215
 
1267
1216
  # In case we're building docs in a background process, this method waits for
@@ -1293,7 +1242,7 @@ Also, a list:
1293
1242
 
1294
1243
  def build_rake_in(good=true)
1295
1244
  gem_ruby = Gem.ruby
1296
- Gem.ruby = @@ruby
1245
+ Gem.ruby = self.class.rubybin
1297
1246
  env_rake = ENV["rake"]
1298
1247
  rake = (good ? @@good_rake : @@bad_rake)
1299
1248
  ENV["rake"] = rake
@@ -1314,37 +1263,74 @@ Also, a list:
1314
1263
  ruby = ENV["RUBY"]
1315
1264
  return ruby if ruby
1316
1265
  ruby = "ruby"
1317
- rubyexe = "#{ruby}.exe"
1266
+ rubyexe = "#{ruby}#{RbConfig::CONFIG['EXEEXT']}"
1318
1267
 
1319
1268
  3.times do
1320
- if File.exist? ruby and File.executable? ruby and !File.directory? ruby
1269
+ if File.exist?(ruby) && File.executable?(ruby) && !File.directory?(ruby)
1321
1270
  return File.expand_path(ruby)
1322
1271
  end
1323
- if File.exist? rubyexe and File.executable? rubyexe
1272
+ if File.exist?(rubyexe) && File.executable?(rubyexe)
1324
1273
  return File.expand_path(rubyexe)
1325
1274
  end
1326
1275
  ruby = File.join("..", ruby)
1327
1276
  end
1328
1277
 
1329
1278
  begin
1330
- require "rbconfig"
1331
- File.join(RbConfig::CONFIG["bindir"],
1332
- RbConfig::CONFIG["ruby_install_name"] +
1333
- RbConfig::CONFIG["EXEEXT"])
1279
+ Gem.ruby
1334
1280
  rescue LoadError
1335
1281
  "ruby"
1336
1282
  end
1337
1283
  end
1338
1284
 
1285
+ def ruby_with_rubygems_in_load_path
1286
+ [Gem.ruby, "-I", rubygems_path]
1287
+ end
1288
+
1289
+ def rubygems_path
1290
+ $LOAD_PATH.find {|p| p == File.dirname($LOADED_FEATURES.find {|f| f.end_with?("/rubygems.rb") }) }
1291
+ end
1292
+
1293
+ def bundler_path
1294
+ $LOAD_PATH.find {|p| p == File.dirname($LOADED_FEATURES.find {|f| f.end_with?("/bundler.rb") }) }
1295
+ end
1296
+
1297
+ def with_clean_path_to_ruby
1298
+ orig_ruby = Gem.ruby
1299
+
1300
+ Gem.instance_variable_set :@ruby, nil
1301
+
1302
+ yield
1303
+ ensure
1304
+ Gem.instance_variable_set :@ruby, orig_ruby
1305
+ end
1306
+
1307
+ def with_internal_encoding(encoding)
1308
+ int_enc = Encoding.default_internal
1309
+ silence_warnings { Encoding.default_internal = encoding }
1310
+
1311
+ yield
1312
+ ensure
1313
+ silence_warnings { Encoding.default_internal = int_enc }
1314
+ end
1315
+
1316
+ def silence_warnings
1317
+ old_verbose, $VERBOSE = $VERBOSE, false
1318
+ yield
1319
+ ensure
1320
+ $VERBOSE = old_verbose
1321
+ end
1322
+
1339
1323
  class << self
1340
1324
  # :nodoc:
1341
1325
  ##
1342
1326
  # Return the join path, with escaping backticks, dollars, and
1343
1327
  # double-quotes. Unlike `shellescape`, equal-sign is not escaped.
1328
+
1344
1329
  private
1330
+
1345
1331
  def escape_path(*path)
1346
1332
  path = File.join(*path)
1347
- if %r'\A[-+:/=@,.\w]+\z' =~ path
1333
+ if %r{\A[-+:/=@,.\w]+\z} =~ path
1348
1334
  path
1349
1335
  else
1350
1336
  "\"#{path.gsub(/[`$"]/, '\\&')}\""
@@ -1352,10 +1338,8 @@ Also, a list:
1352
1338
  end
1353
1339
  end
1354
1340
 
1355
- @@ruby = rubybin
1356
- gempath = File.expand_path('../../../test/rubygems', __FILE__)
1357
- @@good_rake = "#{rubybin} #{escape_path(gempath, 'good_rake.rb')}"
1358
- @@bad_rake = "#{rubybin} #{escape_path(gempath, 'bad_rake.rb')}"
1341
+ @@good_rake = "#{rubybin} #{escape_path(__dir__, 'good_rake.rb')}"
1342
+ @@bad_rake = "#{rubybin} #{escape_path(__dir__, 'bad_rake.rb')}"
1359
1343
 
1360
1344
  ##
1361
1345
  # Construct a new Gem::Dependency.
@@ -1438,8 +1422,8 @@ Also, a list:
1438
1422
  #
1439
1423
  # Yields the +specification+ to the block, if given
1440
1424
 
1441
- def vendor_gem(name = 'a', version = 1)
1442
- directory = File.join 'vendor', name
1425
+ def vendor_gem(name = "a", version = 1)
1426
+ directory = File.join "vendor", name
1443
1427
 
1444
1428
  FileUtils.mkdir_p directory
1445
1429
 
@@ -1452,12 +1436,12 @@ Also, a list:
1452
1436
  #
1453
1437
  # Yields the +specification+ to the block, if given
1454
1438
 
1455
- def save_gemspec(name = 'a', version = 1, directory = '.')
1439
+ def save_gemspec(name = "a", version = 1, directory = ".")
1456
1440
  vendor_spec = Gem::Specification.new name, version do |specification|
1457
1441
  yield specification if block_given?
1458
1442
  end
1459
1443
 
1460
- File.open File.join(directory, "#{name}.gemspec"), 'w' do |io|
1444
+ File.open File.join(directory, "#{name}.gemspec"), "w" do |io|
1461
1445
  io.write vendor_spec.to_ruby
1462
1446
  end
1463
1447
 
@@ -1469,7 +1453,6 @@ Also, a list:
1469
1453
  # It is available by requiring Gem::TestCase.
1470
1454
 
1471
1455
  class StaticSet < Gem::Resolver::Set
1472
-
1473
1456
  ##
1474
1457
  # A StaticSet ignores remote because it has a fixed set of gems.
1475
1458
 
@@ -1506,7 +1489,7 @@ Also, a list:
1506
1489
  # Finds all gems matching +dep+ in this set.
1507
1490
 
1508
1491
  def find_all(dep)
1509
- @specs.find_all { |s| dep.match? s, @prerelease }
1492
+ @specs.find_all {|s| dep.match? s, @prerelease }
1510
1493
  end
1511
1494
 
1512
1495
  ##
@@ -1543,90 +1526,105 @@ Also, a list:
1543
1526
 
1544
1527
  def self.cert_path(cert_name)
1545
1528
  if 32 == (Time.at(2**32) rescue 32)
1546
- cert_file =
1547
- File.expand_path "../../../test/rubygems/#{cert_name}_cert_32.pem",
1548
- __FILE__
1529
+ cert_file = "#{__dir__}/#{cert_name}_cert_32.pem"
1549
1530
 
1550
1531
  return cert_file if File.exist? cert_file
1551
1532
  end
1552
1533
 
1553
- File.expand_path "../../../test/rubygems/#{cert_name}_cert.pem", __FILE__
1534
+ "#{__dir__}/#{cert_name}_cert.pem"
1554
1535
  end
1555
1536
 
1556
1537
  ##
1557
- # Loads an RSA private key named +key_name+ with +passphrase+ in <tt>test/rubygems/</tt>
1538
+ # Loads a private key named +key_name+ with +passphrase+ in <tt>test/rubygems/</tt>
1558
1539
 
1559
1540
  def self.load_key(key_name, passphrase = nil)
1560
1541
  key_file = key_path key_name
1561
1542
 
1562
1543
  key = File.read key_file
1563
1544
 
1564
- OpenSSL::PKey::RSA.new key, passphrase
1545
+ OpenSSL::PKey.read key, passphrase
1565
1546
  end
1566
1547
 
1567
1548
  ##
1568
1549
  # Returns the path to the key named +key_name+ from <tt>test/rubygems</tt>
1569
1550
 
1570
1551
  def self.key_path(key_name)
1571
- File.expand_path "../../../test/rubygems/#{key_name}_key.pem", __FILE__
1552
+ "#{__dir__}/#{key_name}_key.pem"
1572
1553
  end
1573
1554
 
1574
1555
  # :stopdoc:
1575
1556
  # only available in RubyGems tests
1576
1557
 
1577
- PRIVATE_KEY_PASSPHRASE = 'Foo bar'.freeze
1558
+ PRIVATE_KEY_PASSPHRASE = "Foo bar".freeze
1578
1559
 
1579
1560
  begin
1580
- PRIVATE_KEY = load_key 'private'
1581
- PRIVATE_KEY_PATH = key_path 'private'
1561
+ PRIVATE_KEY = load_key "private"
1562
+ PRIVATE_KEY_PATH = key_path "private"
1582
1563
 
1583
1564
  # ENCRYPTED_PRIVATE_KEY is PRIVATE_KEY encrypted with PRIVATE_KEY_PASSPHRASE
1584
- ENCRYPTED_PRIVATE_KEY = load_key 'encrypted_private', PRIVATE_KEY_PASSPHRASE
1585
- ENCRYPTED_PRIVATE_KEY_PATH = key_path 'encrypted_private'
1565
+ ENCRYPTED_PRIVATE_KEY = load_key "encrypted_private", PRIVATE_KEY_PASSPHRASE
1566
+ ENCRYPTED_PRIVATE_KEY_PATH = key_path "encrypted_private"
1586
1567
 
1587
1568
  PUBLIC_KEY = PRIVATE_KEY.public_key
1588
1569
 
1589
- PUBLIC_CERT = load_cert 'public'
1590
- PUBLIC_CERT_PATH = cert_path 'public'
1570
+ PUBLIC_CERT = load_cert "public"
1571
+ PUBLIC_CERT_PATH = cert_path "public"
1591
1572
  rescue Errno::ENOENT
1592
1573
  PRIVATE_KEY = nil
1593
1574
  PUBLIC_KEY = nil
1594
1575
  PUBLIC_CERT = nil
1595
- end if defined?(OpenSSL::SSL)
1576
+ end if Gem::HAVE_OPENSSL
1596
1577
 
1597
- end
1578
+ private
1598
1579
 
1599
- # require dependencies that are not discoverable once GEM_HOME and GEM_PATH
1600
- # are wiped
1601
- begin
1602
- gem 'rake'
1603
- rescue Gem::LoadError
1604
- end
1580
+ def restore_env
1581
+ unless Gem.win_platform?
1582
+ ENV.replace(@orig_env)
1583
+ return
1584
+ end
1605
1585
 
1606
- begin
1607
- require 'rake/packagetask'
1608
- rescue LoadError
1609
- end
1586
+ # Fallback logic for Windows below to workaround
1587
+ # https://bugs.ruby-lang.org/issues/16798. Can be dropped once all
1588
+ # supported rubies include the fix for that.
1610
1589
 
1611
- begin
1612
- gem 'rdoc'
1613
- require 'rdoc'
1590
+ ENV.clear
1614
1591
 
1615
- require 'rubygems/rdoc'
1616
- rescue LoadError, Gem::LoadError
1592
+ @orig_env.each {|k, v| ENV[k] = v }
1593
+ end
1617
1594
  end
1618
1595
 
1619
- begin
1620
- gem 'builder'
1621
- require 'builder/xchar'
1622
- rescue LoadError, Gem::LoadError
1596
+ # https://github.com/seattlerb/minitest/blob/13c48a03d84a2a87855a4de0c959f96800100357/lib/minitest/mock.rb#L192
1597
+ class Object
1598
+ def stub(name, val_or_callable, *block_args)
1599
+ new_name = "__minitest_stub__#{name}"
1600
+
1601
+ metaclass = class << self; self; end
1602
+
1603
+ if respond_to?(name) && !methods.map(&:to_s).include?(name.to_s)
1604
+ metaclass.send :define_method, name do |*args|
1605
+ super(*args)
1606
+ end
1607
+ end
1608
+
1609
+ metaclass.send :alias_method, new_name, name
1610
+
1611
+ metaclass.send :define_method, name do |*args, &blk|
1612
+ if val_or_callable.respond_to? :call
1613
+ val_or_callable.call(*args, &blk)
1614
+ else
1615
+ blk.call(*block_args) if blk
1616
+ val_or_callable
1617
+ end
1618
+ end
1619
+
1620
+ metaclass.send(:ruby2_keywords, name) if metaclass.respond_to?(:ruby2_keywords, true)
1621
+
1622
+ yield self
1623
+ ensure
1624
+ metaclass.send :undef_method, name
1625
+ metaclass.send :alias_method, name, new_name
1626
+ metaclass.send :undef_method, new_name
1627
+ end unless method_defined?(:stub) # lib/resolv/test_dns.rb also has the same method definition
1623
1628
  end
1624
1629
 
1625
- require 'rubygems/test_utilities'
1626
- tmpdirs = []
1627
- tmpdirs << (ENV['GEM_HOME'] = Dir.mktmpdir("home"))
1628
- tmpdirs << (ENV['GEM_PATH'] = Dir.mktmpdir("path"))
1629
- pid = $$
1630
- END {tmpdirs.each {|dir| Dir.rmdir(dir)} if $$ == pid}
1631
- Gem.clear_paths
1632
- Gem.loaded_specs.clear
1630
+ require_relative "utilities"