rubygems-update 3.4.21 → 3.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (564) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +132 -2
  3. data/Manifest.txt +39 -221
  4. data/README.md +1 -3
  5. data/bundler/CHANGELOG.md +74 -0
  6. data/bundler/README.md +1 -2
  7. data/bundler/bundler.gemspec +4 -2
  8. data/bundler/exe/bundle +1 -10
  9. data/bundler/lib/bundler/build_metadata.rb +3 -3
  10. data/bundler/lib/bundler/capistrano.rb +1 -1
  11. data/bundler/lib/bundler/checksum.rb +245 -0
  12. data/bundler/lib/bundler/ci_detector.rb +75 -0
  13. data/bundler/lib/bundler/cli/add.rb +3 -3
  14. data/bundler/lib/bundler/cli/binstubs.rb +4 -4
  15. data/bundler/lib/bundler/cli/cache.rb +1 -1
  16. data/bundler/lib/bundler/cli/check.rb +1 -1
  17. data/bundler/lib/bundler/cli/common.rb +9 -1
  18. data/bundler/lib/bundler/cli/config.rb +8 -7
  19. data/bundler/lib/bundler/cli/console.rb +3 -2
  20. data/bundler/lib/bundler/cli/doctor.rb +2 -2
  21. data/bundler/lib/bundler/cli/exec.rb +1 -1
  22. data/bundler/lib/bundler/cli/gem.rb +31 -23
  23. data/bundler/lib/bundler/cli/info.rb +2 -13
  24. data/bundler/lib/bundler/cli/install.rb +5 -4
  25. data/bundler/lib/bundler/cli/issue.rb +1 -1
  26. data/bundler/lib/bundler/cli/lock.rb +4 -4
  27. data/bundler/lib/bundler/cli/open.rb +1 -1
  28. data/bundler/lib/bundler/cli/outdated.rb +6 -6
  29. data/bundler/lib/bundler/cli/plugin.rb +7 -14
  30. data/bundler/lib/bundler/cli/pristine.rb +38 -30
  31. data/bundler/lib/bundler/cli/show.rb +2 -2
  32. data/bundler/lib/bundler/cli/update.rb +5 -5
  33. data/bundler/lib/bundler/cli.rb +215 -263
  34. data/bundler/lib/bundler/compact_index_client/cache.rb +29 -9
  35. data/bundler/lib/bundler/compact_index_client/cache_file.rb +153 -0
  36. data/bundler/lib/bundler/compact_index_client/gem_parser.rb +7 -3
  37. data/bundler/lib/bundler/compact_index_client/updater.rb +79 -81
  38. data/bundler/lib/bundler/compact_index_client.rb +14 -7
  39. data/bundler/lib/bundler/constants.rb +1 -1
  40. data/bundler/lib/bundler/current_ruby.rb +5 -21
  41. data/bundler/lib/bundler/definition.rb +43 -16
  42. data/bundler/lib/bundler/dependency.rb +16 -12
  43. data/bundler/lib/bundler/digest.rb +2 -2
  44. data/bundler/lib/bundler/dsl.rb +43 -25
  45. data/bundler/lib/bundler/endpoint_specification.rb +6 -2
  46. data/bundler/lib/bundler/env.rb +1 -3
  47. data/bundler/lib/bundler/errors.rb +58 -0
  48. data/bundler/lib/bundler/fetcher/base.rb +3 -1
  49. data/bundler/lib/bundler/fetcher/compact_index.rb +4 -4
  50. data/bundler/lib/bundler/fetcher/downloader.rb +13 -11
  51. data/bundler/lib/bundler/fetcher/gem_remote_fetcher.rb +16 -0
  52. data/bundler/lib/bundler/fetcher/index.rb +1 -1
  53. data/bundler/lib/bundler/fetcher.rb +28 -25
  54. data/bundler/lib/bundler/friendly_errors.rb +5 -5
  55. data/bundler/lib/bundler/gem_helper.rb +1 -1
  56. data/bundler/lib/bundler/gem_helpers.rb +12 -2
  57. data/bundler/lib/bundler/graph.rb +9 -9
  58. data/bundler/lib/bundler/index.rb +1 -2
  59. data/bundler/lib/bundler/injector.rb +1 -1
  60. data/bundler/lib/bundler/inline.rb +3 -3
  61. data/bundler/lib/bundler/installer/gem_installer.rb +10 -10
  62. data/bundler/lib/bundler/installer/parallel_installer.rb +16 -8
  63. data/bundler/lib/bundler/installer/standalone.rb +2 -3
  64. data/bundler/lib/bundler/installer.rb +9 -9
  65. data/bundler/lib/bundler/lazy_specification.rb +28 -17
  66. data/bundler/lib/bundler/lockfile_generator.rb +9 -0
  67. data/bundler/lib/bundler/lockfile_parser.rb +81 -10
  68. data/bundler/lib/bundler/man/bundle-add.1 +3 -26
  69. data/bundler/lib/bundler/man/bundle-binstubs.1 +4 -16
  70. data/bundler/lib/bundler/man/bundle-cache.1 +3 -24
  71. data/bundler/lib/bundler/man/bundle-check.1 +3 -12
  72. data/bundler/lib/bundler/man/bundle-clean.1 +3 -10
  73. data/bundler/lib/bundler/man/bundle-config.1 +20 -211
  74. data/bundler/lib/bundler/man/bundle-config.1.ronn +6 -0
  75. data/bundler/lib/bundler/man/bundle-console.1 +4 -22
  76. data/bundler/lib/bundler/man/bundle-doctor.1 +4 -18
  77. data/bundler/lib/bundler/man/bundle-exec.1 +12 -73
  78. data/bundler/lib/bundler/man/bundle-gem.1 +13 -49
  79. data/bundler/lib/bundler/man/bundle-help.1 +3 -7
  80. data/bundler/lib/bundler/man/bundle-info.1 +3 -9
  81. data/bundler/lib/bundler/man/bundle-init.1 +3 -12
  82. data/bundler/lib/bundler/man/bundle-inject.1 +6 -19
  83. data/bundler/lib/bundler/man/bundle-install.1 +27 -125
  84. data/bundler/lib/bundler/man/bundle-install.1.ronn +1 -0
  85. data/bundler/lib/bundler/man/bundle-list.1 +4 -19
  86. data/bundler/lib/bundler/man/bundle-lock.1 +5 -29
  87. data/bundler/lib/bundler/man/bundle-open.1 +7 -27
  88. data/bundler/lib/bundler/man/bundle-outdated.1 +3 -55
  89. data/bundler/lib/bundler/man/bundle-outdated.1.ronn +1 -0
  90. data/bundler/lib/bundler/man/bundle-platform.1 +5 -27
  91. data/bundler/lib/bundler/man/bundle-plugin.1 +3 -29
  92. data/bundler/lib/bundler/man/bundle-pristine.1 +5 -16
  93. data/bundler/lib/bundler/man/bundle-remove.1 +4 -14
  94. data/bundler/lib/bundler/man/bundle-show.1 +3 -10
  95. data/bundler/lib/bundler/man/bundle-update.1 +18 -137
  96. data/bundler/lib/bundler/man/bundle-version.1 +3 -16
  97. data/bundler/lib/bundler/man/bundle-viz.1 +4 -16
  98. data/bundler/lib/bundler/man/bundle.1 +5 -44
  99. data/bundler/lib/bundler/man/gemfile.5 +24 -301
  100. data/bundler/lib/bundler/man/gemfile.5.ronn +4 -0
  101. data/bundler/lib/bundler/match_metadata.rb +4 -0
  102. data/bundler/lib/bundler/match_platform.rb +1 -1
  103. data/bundler/lib/bundler/plugin/api/source.rb +3 -2
  104. data/bundler/lib/bundler/plugin/index.rb +8 -0
  105. data/bundler/lib/bundler/plugin/installer.rb +1 -1
  106. data/bundler/lib/bundler/plugin.rb +12 -5
  107. data/bundler/lib/bundler/resolver/base.rb +1 -1
  108. data/bundler/lib/bundler/resolver/incompatibility.rb +1 -1
  109. data/bundler/lib/bundler/resolver/spec_group.rb +1 -4
  110. data/bundler/lib/bundler/resolver.rb +16 -16
  111. data/bundler/lib/bundler/ruby_dsl.rb +20 -12
  112. data/bundler/lib/bundler/ruby_version.rb +1 -1
  113. data/bundler/lib/bundler/rubygems_ext.rb +27 -54
  114. data/bundler/lib/bundler/rubygems_gem_installer.rb +23 -58
  115. data/bundler/lib/bundler/rubygems_integration.rb +25 -94
  116. data/bundler/lib/bundler/runtime.rb +2 -2
  117. data/bundler/lib/bundler/self_manager.rb +23 -7
  118. data/bundler/lib/bundler/settings.rb +27 -7
  119. data/bundler/lib/bundler/setup.rb +4 -1
  120. data/bundler/lib/bundler/shared_helpers.rb +35 -13
  121. data/bundler/lib/bundler/source/git/git_proxy.rb +22 -14
  122. data/bundler/lib/bundler/source/git.rb +4 -3
  123. data/bundler/lib/bundler/source/metadata.rb +16 -16
  124. data/bundler/lib/bundler/source/path.rb +7 -6
  125. data/bundler/lib/bundler/source/rubygems.rb +21 -14
  126. data/bundler/lib/bundler/source.rb +2 -0
  127. data/bundler/lib/bundler/spec_set.rb +43 -12
  128. data/bundler/lib/bundler/stub_specification.rb +1 -0
  129. data/bundler/lib/bundler/templates/Executable.bundler +1 -1
  130. data/bundler/lib/bundler/templates/newgem/README.md.tt +3 -3
  131. data/bundler/lib/bundler/templates/newgem/Rakefile.tt +2 -6
  132. data/bundler/lib/bundler/templates/newgem/ext/newgem/Cargo.toml.tt +1 -1
  133. data/bundler/lib/bundler/templates/newgem/newgem.gemspec.tt +1 -1
  134. data/bundler/lib/bundler/templates/newgem/standard.yml.tt +1 -1
  135. data/bundler/lib/bundler/ui/shell.rb +2 -2
  136. data/bundler/lib/bundler/vendor/connection_pool/lib/connection_pool/version.rb +1 -1
  137. data/bundler/lib/bundler/vendor/connection_pool/lib/connection_pool.rb +53 -6
  138. data/bundler/lib/bundler/vendor/fileutils/lib/fileutils.rb +8 -20
  139. data/bundler/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/connection.rb +4 -3
  140. data/bundler/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/pool.rb +23 -11
  141. data/bundler/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/timed_stack_multi.rb +1 -1
  142. data/bundler/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent.rb +36 -36
  143. data/bundler/lib/bundler/vendor/thor/lib/thor/actions/create_file.rb +3 -2
  144. data/bundler/lib/bundler/vendor/thor/lib/thor/actions/directory.rb +1 -1
  145. data/bundler/lib/bundler/vendor/thor/lib/thor/actions/empty_directory.rb +1 -1
  146. data/bundler/lib/bundler/vendor/thor/lib/thor/actions/file_manipulation.rb +8 -10
  147. data/bundler/lib/bundler/vendor/thor/lib/thor/actions/inject_into_file.rb +15 -4
  148. data/bundler/lib/bundler/vendor/thor/lib/thor/actions.rb +15 -15
  149. data/bundler/lib/bundler/vendor/thor/lib/thor/base.rb +140 -14
  150. data/bundler/lib/bundler/vendor/thor/lib/thor/command.rb +13 -4
  151. data/bundler/lib/bundler/vendor/thor/lib/thor/core_ext/hash_with_indifferent_access.rb +4 -0
  152. data/bundler/lib/bundler/vendor/thor/lib/thor/error.rb +16 -25
  153. data/bundler/lib/bundler/vendor/thor/lib/thor/group.rb +1 -1
  154. data/bundler/lib/bundler/vendor/thor/lib/thor/invocation.rb +1 -1
  155. data/bundler/lib/bundler/vendor/thor/lib/thor/nested_context.rb +2 -2
  156. data/bundler/lib/bundler/vendor/thor/lib/thor/parser/argument.rb +20 -1
  157. data/bundler/lib/bundler/vendor/thor/lib/thor/parser/arguments.rb +33 -17
  158. data/bundler/lib/bundler/vendor/thor/lib/thor/parser/option.rb +27 -8
  159. data/bundler/lib/bundler/vendor/thor/lib/thor/parser/options.rb +44 -6
  160. data/bundler/lib/bundler/vendor/thor/lib/thor/rake_compat.rb +2 -2
  161. data/bundler/lib/bundler/vendor/thor/lib/thor/runner.rb +40 -30
  162. data/bundler/lib/bundler/vendor/thor/lib/thor/shell/basic.rb +26 -150
  163. data/bundler/lib/bundler/vendor/thor/lib/thor/shell/color.rb +4 -46
  164. data/bundler/lib/bundler/vendor/thor/lib/thor/shell/column_printer.rb +29 -0
  165. data/bundler/lib/bundler/vendor/thor/lib/thor/shell/html.rb +3 -45
  166. data/bundler/lib/bundler/vendor/thor/lib/thor/shell/lcs_diff.rb +49 -0
  167. data/bundler/lib/bundler/vendor/thor/lib/thor/shell/table_printer.rb +134 -0
  168. data/bundler/lib/bundler/vendor/thor/lib/thor/shell/terminal.rb +42 -0
  169. data/bundler/lib/bundler/vendor/thor/lib/thor/shell/wrapped_printer.rb +38 -0
  170. data/bundler/lib/bundler/vendor/thor/lib/thor/shell.rb +1 -1
  171. data/bundler/lib/bundler/vendor/thor/lib/thor/util.rb +8 -7
  172. data/bundler/lib/bundler/vendor/thor/lib/thor/version.rb +1 -1
  173. data/bundler/lib/bundler/vendor/thor/lib/thor.rb +155 -8
  174. data/bundler/lib/bundler/vendor/tsort/lib/tsort.rb +3 -0
  175. data/bundler/lib/bundler/vendor/uri/lib/uri/common.rb +256 -132
  176. data/bundler/lib/bundler/vendor/uri/lib/uri/generic.rb +1 -0
  177. data/bundler/lib/bundler/vendor/uri/lib/uri/rfc3986_parser.rb +95 -31
  178. data/bundler/lib/bundler/vendor/uri/lib/uri/version.rb +1 -1
  179. data/bundler/lib/bundler/vendored_net_http.rb +8 -0
  180. data/bundler/lib/bundler/vendored_persistent.rb +0 -4
  181. data/bundler/lib/bundler/vendored_timeout.rb +8 -0
  182. data/bundler/lib/bundler/version.rb +1 -1
  183. data/bundler/lib/bundler/vlad.rb +1 -1
  184. data/bundler/lib/bundler/yaml_serializer.rb +9 -4
  185. data/bundler/lib/bundler.rb +38 -35
  186. data/lib/rubygems/available_set.rb +4 -4
  187. data/lib/rubygems/basic_specification.rb +35 -37
  188. data/lib/rubygems/bundler_version_finder.rb +4 -4
  189. data/lib/rubygems/ci_detector.rb +75 -0
  190. data/lib/rubygems/command.rb +15 -17
  191. data/lib/rubygems/command_manager.rb +5 -4
  192. data/lib/rubygems/commands/build_command.rb +2 -2
  193. data/lib/rubygems/commands/cert_command.rb +2 -3
  194. data/lib/rubygems/commands/check_command.rb +4 -4
  195. data/lib/rubygems/commands/cleanup_command.rb +12 -14
  196. data/lib/rubygems/commands/contents_command.rb +5 -5
  197. data/lib/rubygems/commands/dependency_command.rb +4 -5
  198. data/lib/rubygems/commands/environment_command.rb +3 -5
  199. data/lib/rubygems/commands/exec_command.rb +1 -1
  200. data/lib/rubygems/commands/fetch_command.rb +2 -2
  201. data/lib/rubygems/commands/generate_index_command.rb +39 -74
  202. data/lib/rubygems/commands/help_command.rb +4 -4
  203. data/lib/rubygems/commands/info_command.rb +2 -2
  204. data/lib/rubygems/commands/install_command.rb +8 -16
  205. data/lib/rubygems/commands/list_command.rb +2 -2
  206. data/lib/rubygems/commands/lock_command.rb +1 -1
  207. data/lib/rubygems/commands/open_command.rb +1 -1
  208. data/lib/rubygems/commands/owner_command.rb +1 -1
  209. data/lib/rubygems/commands/pristine_command.rb +13 -15
  210. data/lib/rubygems/commands/push_command.rb +2 -2
  211. data/lib/rubygems/commands/query_command.rb +4 -5
  212. data/lib/rubygems/commands/rdoc_command.rb +2 -2
  213. data/lib/rubygems/commands/search_command.rb +2 -2
  214. data/lib/rubygems/commands/setup_command.rb +33 -36
  215. data/lib/rubygems/commands/sources_command.rb +12 -12
  216. data/lib/rubygems/commands/specification_command.rb +10 -10
  217. data/lib/rubygems/commands/stale_command.rb +1 -1
  218. data/lib/rubygems/commands/uninstall_command.rb +13 -14
  219. data/lib/rubygems/commands/unpack_command.rb +7 -7
  220. data/lib/rubygems/commands/update_command.rb +11 -13
  221. data/lib/rubygems/commands/which_command.rb +1 -1
  222. data/lib/rubygems/commands/yank_command.rb +1 -1
  223. data/lib/rubygems/compatibility.rb +5 -6
  224. data/lib/rubygems/config_file.rb +7 -7
  225. data/lib/rubygems/core_ext/kernel_gem.rb +0 -2
  226. data/lib/rubygems/core_ext/kernel_require.rb +20 -49
  227. data/lib/rubygems/core_ext/kernel_warn.rb +1 -1
  228. data/lib/rubygems/core_ext/tcpsocket_init.rb +1 -1
  229. data/lib/rubygems/defaults.rb +15 -3
  230. data/lib/rubygems/dependency.rb +12 -14
  231. data/lib/rubygems/dependency_installer.rb +30 -31
  232. data/lib/rubygems/dependency_list.rb +1 -1
  233. data/lib/rubygems/deprecate.rb +16 -15
  234. data/lib/rubygems/doctor.rb +6 -6
  235. data/lib/rubygems/errors.rb +2 -6
  236. data/lib/rubygems/exceptions.rb +2 -1
  237. data/lib/rubygems/ext/builder.rb +15 -10
  238. data/lib/rubygems/ext/cargo_builder.rb +5 -5
  239. data/lib/rubygems/ext/ext_conf_builder.rb +2 -4
  240. data/lib/rubygems/ext/rake_builder.rb +1 -1
  241. data/lib/rubygems/gem_runner.rb +4 -4
  242. data/lib/rubygems/gemcutter_utilities/webauthn_listener/response.rb +3 -3
  243. data/lib/rubygems/gemcutter_utilities/webauthn_poller.rb +3 -3
  244. data/lib/rubygems/gemcutter_utilities.rb +18 -19
  245. data/lib/rubygems/install_update_options.rb +18 -19
  246. data/lib/rubygems/installer.rb +66 -45
  247. data/lib/rubygems/installer_uninstaller_utils.rb +0 -2
  248. data/lib/rubygems/local_remote_options.rb +8 -11
  249. data/lib/rubygems/name_tuple.rb +7 -9
  250. data/lib/rubygems/net/http.rb +3 -0
  251. data/lib/rubygems/net-http/LICENSE.txt +22 -0
  252. data/lib/rubygems/net-http/lib/net/http/backward.rb +40 -0
  253. data/lib/rubygems/net-http/lib/net/http/exceptions.rb +34 -0
  254. data/lib/rubygems/net-http/lib/net/http/generic_request.rb +414 -0
  255. data/lib/rubygems/net-http/lib/net/http/header.rb +981 -0
  256. data/lib/rubygems/net-http/lib/net/http/proxy_delta.rb +17 -0
  257. data/lib/rubygems/net-http/lib/net/http/request.rb +88 -0
  258. data/lib/rubygems/net-http/lib/net/http/requests.rb +425 -0
  259. data/lib/rubygems/net-http/lib/net/http/response.rb +738 -0
  260. data/lib/rubygems/net-http/lib/net/http/responses.rb +1174 -0
  261. data/lib/rubygems/net-http/lib/net/http/status.rb +84 -0
  262. data/lib/rubygems/net-http/lib/net/http.rb +2496 -0
  263. data/lib/rubygems/net-http/lib/net/https.rb +23 -0
  264. data/lib/rubygems/net-protocol/LICENSE.txt +22 -0
  265. data/lib/rubygems/net-protocol/lib/net/protocol.rb +544 -0
  266. data/lib/rubygems/optparse/lib/optparse.rb +39 -17
  267. data/lib/rubygems/package/digest_io.rb +1 -1
  268. data/lib/rubygems/package/old.rb +2 -2
  269. data/lib/rubygems/package/tar_header.rb +45 -39
  270. data/lib/rubygems/package/tar_reader/entry.rb +5 -4
  271. data/lib/rubygems/package/tar_reader.rb +14 -5
  272. data/lib/rubygems/package/tar_writer.rb +20 -18
  273. data/lib/rubygems/package.rb +28 -27
  274. data/lib/rubygems/package_task.rb +2 -2
  275. data/lib/rubygems/path_support.rb +10 -11
  276. data/lib/rubygems/platform.rb +65 -48
  277. data/lib/rubygems/query_utils.rb +7 -9
  278. data/lib/rubygems/remote_fetcher.rb +17 -17
  279. data/lib/rubygems/request/connection_pools.rb +3 -3
  280. data/lib/rubygems/request.rb +20 -17
  281. data/lib/rubygems/request_set/gem_dependency_api.rb +120 -123
  282. data/lib/rubygems/request_set/lockfile/parser.rb +9 -9
  283. data/lib/rubygems/request_set/lockfile/tokenizer.rb +20 -12
  284. data/lib/rubygems/request_set/lockfile.rb +6 -11
  285. data/lib/rubygems/request_set.rb +5 -5
  286. data/lib/rubygems/requirement.rb +7 -7
  287. data/lib/rubygems/resolv/LICENSE.txt +22 -0
  288. data/lib/rubygems/resolv/lib/resolv.rb +3387 -0
  289. data/lib/rubygems/resolver/activation_request.rb +1 -3
  290. data/lib/rubygems/resolver/api_set/gem_parser.rb +7 -3
  291. data/lib/rubygems/resolver/best_set.rb +1 -1
  292. data/lib/rubygems/resolver/composed_set.rb +1 -1
  293. data/lib/rubygems/resolver/conflict.rb +4 -12
  294. data/lib/rubygems/resolver/index_set.rb +4 -4
  295. data/lib/rubygems/resolver/index_specification.rb +2 -2
  296. data/lib/rubygems/resolver/installer_set.rb +5 -6
  297. data/lib/rubygems/resolver/lock_set.rb +1 -1
  298. data/lib/rubygems/resolver.rb +6 -13
  299. data/lib/rubygems/s3_uri_signer.rb +6 -6
  300. data/lib/rubygems/safe_marshal/elements.rb +138 -0
  301. data/lib/rubygems/safe_marshal/reader.rb +306 -0
  302. data/lib/rubygems/safe_marshal/visitors/stream_printer.rb +31 -0
  303. data/lib/rubygems/safe_marshal/visitors/to_ruby.rb +385 -0
  304. data/lib/rubygems/safe_marshal/visitors/visitor.rb +74 -0
  305. data/lib/rubygems/safe_marshal.rb +74 -0
  306. data/lib/rubygems/safe_yaml.rb +5 -28
  307. data/lib/rubygems/security/policies.rb +36 -38
  308. data/lib/rubygems/security/policy.rb +7 -11
  309. data/lib/rubygems/security/signer.rb +1 -1
  310. data/lib/rubygems/security/trust_dir.rb +4 -4
  311. data/lib/rubygems/security.rb +8 -22
  312. data/lib/rubygems/source/git.rb +1 -3
  313. data/lib/rubygems/source/installed.rb +0 -2
  314. data/lib/rubygems/source/local.rb +7 -9
  315. data/lib/rubygems/source/lock.rb +1 -3
  316. data/lib/rubygems/source/specific_file.rb +0 -1
  317. data/lib/rubygems/source/vendor.rb +0 -2
  318. data/lib/rubygems/source.rb +12 -12
  319. data/lib/rubygems/source_list.rb +5 -5
  320. data/lib/rubygems/spec_fetcher.rb +31 -31
  321. data/lib/rubygems/specification.rb +145 -150
  322. data/lib/rubygems/specification_policy.rb +61 -31
  323. data/lib/rubygems/stub_specification.rb +4 -5
  324. data/lib/rubygems/text.rb +1 -2
  325. data/lib/rubygems/timeout/LICENSE.txt +22 -0
  326. data/lib/rubygems/timeout/lib/timeout.rb +199 -0
  327. data/lib/rubygems/timeout.rb +3 -0
  328. data/lib/rubygems/tsort/lib/tsort.rb +3 -0
  329. data/lib/rubygems/uninstaller.rb +9 -11
  330. data/lib/rubygems/update_suggestion.rb +5 -18
  331. data/lib/rubygems/uri_formatter.rb +1 -1
  332. data/lib/rubygems/user_interaction.rb +17 -23
  333. data/lib/rubygems/util/licenses.rb +113 -35
  334. data/lib/rubygems/util/list.rb +3 -1
  335. data/lib/rubygems/util.rb +2 -4
  336. data/lib/rubygems/validator.rb +6 -4
  337. data/lib/rubygems/version.rb +35 -29
  338. data/lib/rubygems/version_option.rb +2 -5
  339. data/lib/rubygems/yaml_serializer.rb +9 -4
  340. data/lib/rubygems.rb +42 -42
  341. data/rubygems-update.gemspec +4 -4
  342. data/setup.rb +2 -2
  343. metadata +43 -225
  344. data/lib/rubygems/indexer.rb +0 -428
  345. data/lib/rubygems/mock_gem_ui.rb +0 -86
  346. data/test/rubygems/alternate_cert.pem +0 -19
  347. data/test/rubygems/alternate_cert_32.pem +0 -19
  348. data/test/rubygems/alternate_key.pem +0 -27
  349. data/test/rubygems/bad_rake.rb +0 -3
  350. data/test/rubygems/bundler_test_gem.rb +0 -424
  351. data/test/rubygems/ca_cert.pem +0 -77
  352. data/test/rubygems/child_cert.pem +0 -19
  353. data/test/rubygems/child_cert_32.pem +0 -19
  354. data/test/rubygems/child_key.pem +0 -27
  355. data/test/rubygems/client.pem +0 -107
  356. data/test/rubygems/data/excon-0.7.7.gemspec.rz +0 -0
  357. data/test/rubygems/data/gem-private_key.pem +0 -27
  358. data/test/rubygems/data/gem-public_cert.pem +0 -20
  359. data/test/rubygems/data/null-required-ruby-version.gemspec.rz +0 -0
  360. data/test/rubygems/data/null-required-rubygems-version.gemspec.rz +0 -0
  361. data/test/rubygems/data/pry-0.4.7.gemspec.rz +0 -0
  362. data/test/rubygems/encrypted_private_key.pem +0 -30
  363. data/test/rubygems/expired_cert.pem +0 -19
  364. data/test/rubygems/fake_certlib/openssl.rb +0 -9
  365. data/test/rubygems/foo/discover.rb +0 -1
  366. data/test/rubygems/future_cert.pem +0 -19
  367. data/test/rubygems/future_cert_32.pem +0 -19
  368. data/test/rubygems/good_rake.rb +0 -3
  369. data/test/rubygems/grandchild_cert.pem +0 -19
  370. data/test/rubygems/grandchild_cert_32.pem +0 -19
  371. data/test/rubygems/grandchild_key.pem +0 -27
  372. data/test/rubygems/helper.rb +0 -1649
  373. data/test/rubygems/installer_test_case.rb +0 -248
  374. data/test/rubygems/invalid_client.pem +0 -49
  375. data/test/rubygems/invalid_issuer_cert.pem +0 -20
  376. data/test/rubygems/invalid_issuer_cert_32.pem +0 -20
  377. data/test/rubygems/invalid_key.pem +0 -27
  378. data/test/rubygems/invalid_signer_cert.pem +0 -19
  379. data/test/rubygems/invalid_signer_cert_32.pem +0 -19
  380. data/test/rubygems/invalidchild_cert.pem +0 -19
  381. data/test/rubygems/invalidchild_cert_32.pem +0 -19
  382. data/test/rubygems/invalidchild_key.pem +0 -27
  383. data/test/rubygems/multifactor_auth_utilities.rb +0 -111
  384. data/test/rubygems/package/tar_test_case.rb +0 -175
  385. data/test/rubygems/packages/Bluebie-legs-0.6.2.gem +0 -0
  386. data/test/rubygems/packages/ascii_binder-0.1.10.1.gem +0 -0
  387. data/test/rubygems/packages/ill-formatted-platform-1.0.0.10.gem +0 -0
  388. data/test/rubygems/plugin/exception/rubygems_plugin.rb +0 -4
  389. data/test/rubygems/plugin/load/rubygems_plugin.rb +0 -5
  390. data/test/rubygems/plugin/standarderror/rubygems_plugin.rb +0 -4
  391. data/test/rubygems/private3072_key.pem +0 -40
  392. data/test/rubygems/private_ec_key.pem +0 -9
  393. data/test/rubygems/private_key.pem +0 -27
  394. data/test/rubygems/public3072_cert.pem +0 -25
  395. data/test/rubygems/public_cert.pem +0 -20
  396. data/test/rubygems/public_cert_32.pem +0 -19
  397. data/test/rubygems/public_key.pem +0 -9
  398. data/test/rubygems/rubygems/commands/crash_command.rb +0 -5
  399. data/test/rubygems/rubygems_plugin.rb +0 -24
  400. data/test/rubygems/sff/discover.rb +0 -1
  401. data/test/rubygems/simple_gem.rb +0 -68
  402. data/test/rubygems/specifications/bar-0.0.2.gemspec +0 -9
  403. data/test/rubygems/specifications/foo-0.0.1-x86-mswin32.gemspec +0 -0
  404. data/test/rubygems/specifications/rubyforge-0.0.1.gemspec +0 -14
  405. data/test/rubygems/ssl_cert.pem +0 -80
  406. data/test/rubygems/ssl_key.pem +0 -27
  407. data/test/rubygems/test_bundled_ca.rb +0 -61
  408. data/test/rubygems/test_config.rb +0 -28
  409. data/test/rubygems/test_deprecate.rb +0 -158
  410. data/test/rubygems/test_exit.rb +0 -17
  411. data/test/rubygems/test_gem.rb +0 -1799
  412. data/test/rubygems/test_gem_available_set.rb +0 -130
  413. data/test/rubygems/test_gem_bundler_version_finder.rb +0 -127
  414. data/test/rubygems/test_gem_command.rb +0 -403
  415. data/test/rubygems/test_gem_command_manager.rb +0 -400
  416. data/test/rubygems/test_gem_commands_build_command.rb +0 -739
  417. data/test/rubygems/test_gem_commands_cert_command.rb +0 -866
  418. data/test/rubygems/test_gem_commands_check_command.rb +0 -68
  419. data/test/rubygems/test_gem_commands_cleanup_command.rb +0 -292
  420. data/test/rubygems/test_gem_commands_contents_command.rb +0 -271
  421. data/test/rubygems/test_gem_commands_dependency_command.rb +0 -228
  422. data/test/rubygems/test_gem_commands_environment_command.rb +0 -169
  423. data/test/rubygems/test_gem_commands_exec_command.rb +0 -857
  424. data/test/rubygems/test_gem_commands_fetch_command.rb +0 -258
  425. data/test/rubygems/test_gem_commands_generate_index_command.rb +0 -81
  426. data/test/rubygems/test_gem_commands_help_command.rb +0 -94
  427. data/test/rubygems/test_gem_commands_info_command.rb +0 -70
  428. data/test/rubygems/test_gem_commands_install_command.rb +0 -1573
  429. data/test/rubygems/test_gem_commands_list_command.rb +0 -33
  430. data/test/rubygems/test_gem_commands_lock_command.rb +0 -67
  431. data/test/rubygems/test_gem_commands_mirror.rb +0 -20
  432. data/test/rubygems/test_gem_commands_open_command.rb +0 -101
  433. data/test/rubygems/test_gem_commands_outdated_command.rb +0 -50
  434. data/test/rubygems/test_gem_commands_owner_command.rb +0 -503
  435. data/test/rubygems/test_gem_commands_pristine_command.rb +0 -708
  436. data/test/rubygems/test_gem_commands_push_command.rb +0 -603
  437. data/test/rubygems/test_gem_commands_query_command.rb +0 -858
  438. data/test/rubygems/test_gem_commands_search_command.rb +0 -16
  439. data/test/rubygems/test_gem_commands_server_command.rb +0 -20
  440. data/test/rubygems/test_gem_commands_setup_command.rb +0 -474
  441. data/test/rubygems/test_gem_commands_signin_command.rb +0 -259
  442. data/test/rubygems/test_gem_commands_signout_command.rb +0 -30
  443. data/test/rubygems/test_gem_commands_sources_command.rb +0 -534
  444. data/test/rubygems/test_gem_commands_specification_command.rb +0 -277
  445. data/test/rubygems/test_gem_commands_stale_command.rb +0 -43
  446. data/test/rubygems/test_gem_commands_uninstall_command.rb +0 -522
  447. data/test/rubygems/test_gem_commands_unpack_command.rb +0 -224
  448. data/test/rubygems/test_gem_commands_update_command.rb +0 -836
  449. data/test/rubygems/test_gem_commands_which_command.rb +0 -85
  450. data/test/rubygems/test_gem_commands_yank_command.rb +0 -299
  451. data/test/rubygems/test_gem_config_file.rb +0 -551
  452. data/test/rubygems/test_gem_dependency.rb +0 -398
  453. data/test/rubygems/test_gem_dependency_installer.rb +0 -1190
  454. data/test/rubygems/test_gem_dependency_list.rb +0 -265
  455. data/test/rubygems/test_gem_dependency_resolution_error.rb +0 -27
  456. data/test/rubygems/test_gem_doctor.rb +0 -195
  457. data/test/rubygems/test_gem_ext_builder.rb +0 -337
  458. data/test/rubygems/test_gem_ext_cargo_builder/custom_name/.gitignore +0 -1
  459. data/test/rubygems/test_gem_ext_cargo_builder/custom_name/custom_name.gemspec +0 -10
  460. data/test/rubygems/test_gem_ext_cargo_builder/custom_name/ext/custom_name_lib/Cargo.lock +0 -249
  461. data/test/rubygems/test_gem_ext_cargo_builder/custom_name/ext/custom_name_lib/Cargo.toml +0 -10
  462. data/test/rubygems/test_gem_ext_cargo_builder/custom_name/ext/custom_name_lib/src/lib.rs +0 -27
  463. data/test/rubygems/test_gem_ext_cargo_builder/custom_name/lib/custom_name.rb +0 -3
  464. data/test/rubygems/test_gem_ext_cargo_builder/rust_ruby_example/.gitignore +0 -1
  465. data/test/rubygems/test_gem_ext_cargo_builder/rust_ruby_example/Cargo.lock +0 -249
  466. data/test/rubygems/test_gem_ext_cargo_builder/rust_ruby_example/Cargo.toml +0 -10
  467. data/test/rubygems/test_gem_ext_cargo_builder/rust_ruby_example/rust_ruby_example.gemspec +0 -10
  468. data/test/rubygems/test_gem_ext_cargo_builder/rust_ruby_example/src/lib.rs +0 -51
  469. data/test/rubygems/test_gem_ext_cargo_builder.rb +0 -167
  470. data/test/rubygems/test_gem_ext_cargo_builder_link_flag_converter.rb +0 -34
  471. data/test/rubygems/test_gem_ext_cargo_builder_unit.rb +0 -60
  472. data/test/rubygems/test_gem_ext_cmake_builder.rb +0 -84
  473. data/test/rubygems/test_gem_ext_configure_builder.rb +0 -80
  474. data/test/rubygems/test_gem_ext_ext_conf_builder.rb +0 -229
  475. data/test/rubygems/test_gem_ext_rake_builder.rb +0 -113
  476. data/test/rubygems/test_gem_gem_runner.rb +0 -119
  477. data/test/rubygems/test_gem_gemcutter_utilities.rb +0 -361
  478. data/test/rubygems/test_gem_impossible_dependencies_error.rb +0 -60
  479. data/test/rubygems/test_gem_indexer.rb +0 -381
  480. data/test/rubygems/test_gem_install_update_options.rb +0 -208
  481. data/test/rubygems/test_gem_installer.rb +0 -2512
  482. data/test/rubygems/test_gem_local_remote_options.rb +0 -133
  483. data/test/rubygems/test_gem_name_tuple.rb +0 -43
  484. data/test/rubygems/test_gem_package.rb +0 -1306
  485. data/test/rubygems/test_gem_package_old.rb +0 -91
  486. data/test/rubygems/test_gem_package_tar_header.rb +0 -226
  487. data/test/rubygems/test_gem_package_tar_reader.rb +0 -135
  488. data/test/rubygems/test_gem_package_tar_reader_entry.rb +0 -350
  489. data/test/rubygems/test_gem_package_tar_writer.rb +0 -331
  490. data/test/rubygems/test_gem_package_task.rb +0 -118
  491. data/test/rubygems/test_gem_path_support.rb +0 -139
  492. data/test/rubygems/test_gem_platform.rb +0 -497
  493. data/test/rubygems/test_gem_rdoc.rb +0 -137
  494. data/test/rubygems/test_gem_remote_fetcher.rb +0 -1227
  495. data/test/rubygems/test_gem_request.rb +0 -547
  496. data/test/rubygems/test_gem_request_connection_pools.rb +0 -152
  497. data/test/rubygems/test_gem_request_set.rb +0 -672
  498. data/test/rubygems/test_gem_request_set_gem_dependency_api.rb +0 -853
  499. data/test/rubygems/test_gem_request_set_lockfile.rb +0 -469
  500. data/test/rubygems/test_gem_request_set_lockfile_parser.rb +0 -544
  501. data/test/rubygems/test_gem_request_set_lockfile_tokenizer.rb +0 -307
  502. data/test/rubygems/test_gem_requirement.rb +0 -505
  503. data/test/rubygems/test_gem_resolver.rb +0 -859
  504. data/test/rubygems/test_gem_resolver_activation_request.rb +0 -43
  505. data/test/rubygems/test_gem_resolver_api_set.rb +0 -210
  506. data/test/rubygems/test_gem_resolver_api_specification.rb +0 -167
  507. data/test/rubygems/test_gem_resolver_best_set.rb +0 -159
  508. data/test/rubygems/test_gem_resolver_composed_set.rb +0 -44
  509. data/test/rubygems/test_gem_resolver_conflict.rb +0 -82
  510. data/test/rubygems/test_gem_resolver_dependency_request.rb +0 -83
  511. data/test/rubygems/test_gem_resolver_git_set.rb +0 -188
  512. data/test/rubygems/test_gem_resolver_git_specification.rb +0 -114
  513. data/test/rubygems/test_gem_resolver_index_set.rb +0 -88
  514. data/test/rubygems/test_gem_resolver_index_specification.rb +0 -93
  515. data/test/rubygems/test_gem_resolver_installed_specification.rb +0 -47
  516. data/test/rubygems/test_gem_resolver_installer_set.rb +0 -320
  517. data/test/rubygems/test_gem_resolver_local_specification.rb +0 -44
  518. data/test/rubygems/test_gem_resolver_lock_set.rb +0 -62
  519. data/test/rubygems/test_gem_resolver_lock_specification.rb +0 -98
  520. data/test/rubygems/test_gem_resolver_requirement_list.rb +0 -19
  521. data/test/rubygems/test_gem_resolver_specification.rb +0 -63
  522. data/test/rubygems/test_gem_resolver_vendor_set.rb +0 -82
  523. data/test/rubygems/test_gem_resolver_vendor_specification.rb +0 -82
  524. data/test/rubygems/test_gem_security.rb +0 -341
  525. data/test/rubygems/test_gem_security_policy.rb +0 -535
  526. data/test/rubygems/test_gem_security_signer.rb +0 -218
  527. data/test/rubygems/test_gem_security_trust_dir.rb +0 -99
  528. data/test/rubygems/test_gem_silent_ui.rb +0 -123
  529. data/test/rubygems/test_gem_source.rb +0 -254
  530. data/test/rubygems/test_gem_source_fetch_problem.rb +0 -37
  531. data/test/rubygems/test_gem_source_git.rb +0 -310
  532. data/test/rubygems/test_gem_source_installed.rb +0 -35
  533. data/test/rubygems/test_gem_source_list.rb +0 -119
  534. data/test/rubygems/test_gem_source_local.rb +0 -107
  535. data/test/rubygems/test_gem_source_lock.rb +0 -113
  536. data/test/rubygems/test_gem_source_specific_file.rb +0 -76
  537. data/test/rubygems/test_gem_source_subpath_problem.rb +0 -50
  538. data/test/rubygems/test_gem_source_vendor.rb +0 -30
  539. data/test/rubygems/test_gem_spec_fetcher.rb +0 -338
  540. data/test/rubygems/test_gem_specification.rb +0 -3856
  541. data/test/rubygems/test_gem_stream_ui.rb +0 -255
  542. data/test/rubygems/test_gem_stub_specification.rb +0 -278
  543. data/test/rubygems/test_gem_text.rb +0 -103
  544. data/test/rubygems/test_gem_uninstaller.rb +0 -675
  545. data/test/rubygems/test_gem_unsatisfiable_dependency_error.rb +0 -31
  546. data/test/rubygems/test_gem_update_suggestion.rb +0 -209
  547. data/test/rubygems/test_gem_uri.rb +0 -41
  548. data/test/rubygems/test_gem_uri_formatter.rb +0 -27
  549. data/test/rubygems/test_gem_util.rb +0 -91
  550. data/test/rubygems/test_gem_validator.rb +0 -42
  551. data/test/rubygems/test_gem_version.rb +0 -305
  552. data/test/rubygems/test_gem_version_option.rb +0 -165
  553. data/test/rubygems/test_kernel.rb +0 -124
  554. data/test/rubygems/test_project_sanity.rb +0 -49
  555. data/test/rubygems/test_remote_fetch_error.rb +0 -20
  556. data/test/rubygems/test_require.rb +0 -732
  557. data/test/rubygems/test_rubygems.rb +0 -76
  558. data/test/rubygems/test_webauthn_listener.rb +0 -143
  559. data/test/rubygems/test_webauthn_listener_response.rb +0 -93
  560. data/test/rubygems/test_webauthn_poller.rb +0 -124
  561. data/test/rubygems/utilities.rb +0 -436
  562. data/test/rubygems/wrong_key_cert.pem +0 -19
  563. data/test/rubygems/wrong_key_cert_32.pem +0 -19
  564. data/test/test_changelog_generator.rb +0 -17
@@ -1,1649 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "rubygems"
4
-
5
- begin
6
- gem "test-unit", "~> 3.0"
7
- rescue Gem::LoadError
8
- end
9
-
10
- require "test/unit"
11
-
12
- ENV["JARS_SKIP"] = "true" if Gem.java_platform? # avoid unnecessary and noisy `jar-dependencies` post install hook
13
-
14
- require "rubygems/deprecate"
15
-
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"
26
-
27
- module Gem
28
-
29
- ##
30
- # Allows setting the gem path searcher.
31
-
32
- def self.searcher=(searcher)
33
- @searcher = searcher
34
- end
35
-
36
- ##
37
- # Allows toggling Windows behavior.
38
-
39
- def self.win_platform=(val)
40
- @@win_platform = val
41
- end
42
-
43
- ##
44
- # Allows setting path to Ruby.
45
-
46
- def self.ruby=(ruby)
47
- @ruby = ruby
48
- end
49
-
50
- ##
51
- # Sets the default user interaction to a MockGemUi.
52
-
53
- module DefaultUserInteraction
54
- @ui = Gem::MockGemUi.new
55
- end
56
- end
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
-
69
- ##
70
- # RubyGemTestCase provides a variety of methods for testing rubygems and
71
- # gem-related behavior in a sandbox. Through RubyGemTestCase you can install
72
- # and uninstall gems, fetch remote gems through a stub fetcher and be assured
73
- # your normal set of gems is not affected.
74
-
75
- class Gem::TestCase < Test::Unit::TestCase
76
- extend Gem::Deprecate
77
-
78
- attr_accessor :fetcher # :nodoc:
79
-
80
- attr_accessor :gem_repo # :nodoc:
81
-
82
- attr_accessor :uri # :nodoc:
83
-
84
- def assert_activate(expected, *specs)
85
- specs.each do |spec|
86
- case spec
87
- when String then
88
- Gem::Specification.find_by_name(spec).activate
89
- when Gem::Specification then
90
- spec.activate
91
- else
92
- flunk spec.inspect
93
- end
94
- end
95
-
96
- loaded = Gem.loaded_specs.values.map(&:full_name)
97
-
98
- assert_equal expected.sort, loaded.sort if expected
99
- end
100
-
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
- require "tempfile"
122
-
123
- captured_stdout = Tempfile.new("out")
124
- captured_stderr = Tempfile.new("err")
125
-
126
- orig_stdout = $stdout.dup
127
- orig_stderr = $stderr.dup
128
- $stdout.reopen captured_stdout
129
- $stderr.reopen captured_stderr
130
-
131
- yield
132
-
133
- $stdout.rewind
134
- $stderr.rewind
135
-
136
- return captured_stdout.read, captured_stderr.read
137
- ensure
138
- $stdout.reopen orig_stdout
139
- $stderr.reopen orig_stderr
140
-
141
- orig_stdout.close
142
- orig_stderr.close
143
- captured_stdout.close!
144
- captured_stderr.close!
145
- end
146
- end
147
-
148
- ##
149
- # Sets the ENABLE_SHARED entry in RbConfig::CONFIG to +value+ and restores
150
- # the original value when the block ends
151
-
152
- def enable_shared(value)
153
- enable_shared = RbConfig::CONFIG["ENABLE_SHARED"]
154
- RbConfig::CONFIG["ENABLE_SHARED"] = value
155
-
156
- yield
157
- ensure
158
- if 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
174
- else
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"
184
- end
185
- end
186
-
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
233
- end
234
-
235
- def scan_make_command_lines(output)
236
- output.scan(/^#{Regexp.escape make_command}(?:[[:blank:]].*)?$/)
237
- end
238
-
239
- def parse_make_command_line_targets(line)
240
- args = line.sub(/^#{Regexp.escape make_command}/, "").shellsplit
241
-
242
- targets = []
243
-
244
- args.each do |arg|
245
- case arg
246
- when /\A(\w+)=/
247
- else
248
- targets << arg
249
- end
250
- end
251
-
252
- targets << "" if targets.empty?
253
-
254
- targets
255
- end
256
-
257
- def assert_contains_make_command(target, output, msg = nil)
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,
263
- ]
264
- )
265
- else
266
- msg = build_message(msg,
267
- 'Expected make command "%s", but was "%s"' % [
268
- ("%s %s" % [make_command, target]).rstrip,
269
- output,
270
- ]
271
- )
272
- end
273
-
274
- assert scan_make_command_lines(output).any? {|line|
275
- targets = parse_make_command_line_targets(line)
276
-
277
- if targets.include?(target)
278
- true
279
- else
280
- false
281
- end
282
- }, msg
283
- end
284
-
285
- include Gem::DefaultUserInteraction
286
-
287
- ##
288
- # #setup prepares a sandboxed location to install gems. All installs are
289
- # directed to a temporary directory. All install plugins are removed.
290
- #
291
- # If the +RUBY+ environment variable is set the given path is used for
292
- # Gem::ruby. The local platform is set to <tt>i386-mswin32</tt> for Windows
293
- # or <tt>i686-darwin8.10.1</tt> otherwise.
294
-
295
- def setup
296
- @orig_hooks = {}
297
- @orig_env = ENV.to_hash
298
- @tmp = File.expand_path("tmp")
299
-
300
- FileUtils.mkdir_p @tmp
301
-
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"
314
-
315
- @current_dir = Dir.pwd
316
- @fetcher = nil
317
-
318
- @back_ui = Gem::DefaultUserInteraction.ui
319
- @ui = Gem::MockGemUi.new
320
- # This needs to be a new instance since we call use_ui(@ui) when we want to
321
- # capture output
322
- Gem::DefaultUserInteraction.ui = Gem::MockGemUi.new
323
-
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")
328
-
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"
333
-
334
- @orig_ruby = if ENV["RUBY"]
335
- ruby = Gem.ruby
336
- Gem.ruby = ENV["RUBY"]
337
- ruby
338
- end
339
-
340
- @git = ENV["GIT"] || "git#{RbConfig::CONFIG["EXEEXT"]}"
341
-
342
- Gem.ensure_gem_subdirectories @gemhome
343
- Gem.ensure_default_gem_subdirectories @gemhome
344
-
345
- @orig_LOAD_PATH = $LOAD_PATH.dup
346
- $LOAD_PATH.map! do |s|
347
- expand_path = begin
348
- File.realpath(s)
349
- rescue StandardError
350
- File.expand_path(s)
351
- end
352
- if expand_path != s
353
- expand_path.tap(&Gem::UNTAINT)
354
- if s.instance_variable_defined?(:@gem_prelude_index)
355
- expand_path.instance_variable_set(:@gem_prelude_index, expand_path)
356
- end
357
- expand_path.freeze if s.frozen?
358
- s = expand_path
359
- end
360
- s
361
- end
362
-
363
- Dir.chdir @tempdir
364
-
365
- ENV["HOME"] = @userhome
366
- Gem.instance_variable_set :@config_file, nil
367
- Gem.instance_variable_set :@user_home, nil
368
- Gem.instance_variable_set :@config_home, nil
369
- Gem.instance_variable_set :@data_home, nil
370
- Gem.instance_variable_set :@state_home, @statehome
371
- Gem.instance_variable_set :@gemdeps, nil
372
- Gem.instance_variable_set :@env_requirements_by_name, nil
373
- Gem.send :remove_instance_variable, :@ruby_version if
374
- Gem.instance_variables.include? :@ruby_version
375
-
376
- FileUtils.mkdir_p @userhome
377
-
378
- ENV["GEM_PRIVATE_KEY_PASSPHRASE"] = PRIVATE_KEY_PASSPHRASE
379
-
380
- Gem.instance_variable_set(:@default_specifications_dir, nil)
381
- if Gem.java_platform?
382
- @orig_default_gem_home = RbConfig::CONFIG["default_gem_home"]
383
- RbConfig::CONFIG["default_gem_home"] = @gemhome
384
- else
385
- Gem.instance_variable_set(:@default_dir, @gemhome)
386
- end
387
-
388
- @orig_bindir = RbConfig::CONFIG["bindir"]
389
- RbConfig::CONFIG["bindir"] = File.join @gemhome, "bin"
390
-
391
- @orig_sitelibdir = RbConfig::CONFIG["sitelibdir"]
392
- new_sitelibdir = @orig_sitelibdir.sub(RbConfig::CONFIG["prefix"], @gemhome)
393
- $LOAD_PATH.insert(Gem.load_path_insert_index, new_sitelibdir)
394
- RbConfig::CONFIG["sitelibdir"] = new_sitelibdir
395
-
396
- @orig_mandir = RbConfig::CONFIG["mandir"]
397
- RbConfig::CONFIG["mandir"] = File.join @gemhome, "share", "man"
398
-
399
- Gem::Specification.unresolved_deps.clear
400
- Gem.use_paths(@gemhome)
401
-
402
- Gem.loaded_specs.clear
403
- Gem.instance_variable_set(:@activated_gem_paths, 0)
404
- Gem.clear_default_specs
405
-
406
- Gem.configuration.verbose = true
407
- Gem.configuration.update_sources = true
408
-
409
- Gem::RemoteFetcher.fetcher = Gem::FakeFetcher.new
410
-
411
- @gem_repo = "http://gems.example.com/"
412
- @uri = URI.parse @gem_repo
413
- Gem.sources.replace [@gem_repo]
414
-
415
- Gem.searcher = nil
416
- Gem::SpecFetcher.fetcher = nil
417
-
418
- @orig_arch = RbConfig::CONFIG["arch"]
419
-
420
- if win_platform?
421
- util_set_arch "i386-mswin32"
422
- else
423
- util_set_arch "i686-darwin8.10.1"
424
- end
425
-
426
- %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|
427
- @orig_hooks[name] = Gem.send(name).dup
428
- end
429
-
430
- @marshal_version = "#{Marshal::MAJOR_VERSION}.#{Marshal::MINOR_VERSION}"
431
- @orig_LOADED_FEATURES = $LOADED_FEATURES.dup
432
- end
433
-
434
- ##
435
- # #teardown restores the process to its original state and removes the
436
- # tempdir
437
-
438
- def teardown
439
- $LOAD_PATH.replace @orig_LOAD_PATH if @orig_LOAD_PATH
440
- if @orig_LOADED_FEATURES
441
- if @orig_LOAD_PATH
442
- ($LOADED_FEATURES - @orig_LOADED_FEATURES).each do |feat|
443
- $LOADED_FEATURES.delete(feat) if feat.start_with?(@tmp)
444
- end
445
- else
446
- $LOADED_FEATURES.replace @orig_LOADED_FEATURES
447
- end
448
- end
449
-
450
- RbConfig::CONFIG["arch"] = @orig_arch
451
-
452
- if defined? Gem::RemoteFetcher
453
- Gem::RemoteFetcher.fetcher = nil
454
- end
455
-
456
- Dir.chdir @current_dir
457
-
458
- FileUtils.rm_rf @tempdir
459
-
460
- restore_env
461
-
462
- Gem::ConfigFile.send :remove_const, :SYSTEM_WIDE_CONFIG_FILE
463
- Gem::ConfigFile.send :const_set, :SYSTEM_WIDE_CONFIG_FILE,
464
- @orig_SYSTEM_WIDE_CONFIG_FILE
465
-
466
- Gem.ruby = @orig_ruby if @orig_ruby
467
-
468
- RbConfig::CONFIG["mandir"] = @orig_mandir
469
- RbConfig::CONFIG["sitelibdir"] = @orig_sitelibdir
470
- RbConfig::CONFIG["bindir"] = @orig_bindir
471
-
472
- Gem.instance_variable_set :@default_specifications_dir, nil
473
- if Gem.java_platform?
474
- RbConfig::CONFIG["default_gem_home"] = @orig_default_gem_home
475
- else
476
- Gem.instance_variable_set :@default_dir, nil
477
- end
478
-
479
- Gem::Specification.unresolved_deps.clear
480
- Gem::refresh
481
-
482
- @orig_hooks.each do |name, hooks|
483
- Gem.send(name).replace hooks
484
- end
485
-
486
- @back_ui.close
487
- end
488
-
489
- def credential_setup
490
- @temp_cred = File.join(@userhome, ".gem", "credentials")
491
- FileUtils.mkdir_p File.dirname(@temp_cred)
492
- File.write @temp_cred, ":rubygems_api_key: 701229f217cdf23b1344c7b4b54ca97"
493
- File.chmod 0o600, @temp_cred
494
- end
495
-
496
- def credential_teardown
497
- FileUtils.rm_rf @temp_cred
498
- end
499
-
500
- def common_installer_setup
501
- common_installer_teardown
502
-
503
- Gem.post_build do |installer|
504
- @post_build_hook_arg = installer
505
- true
506
- end
507
-
508
- Gem.post_install do |installer|
509
- @post_install_hook_arg = installer
510
- end
511
-
512
- Gem.post_uninstall do |uninstaller|
513
- @post_uninstall_hook_arg = uninstaller
514
- end
515
-
516
- Gem.pre_install do |installer|
517
- @pre_install_hook_arg = installer
518
- true
519
- end
520
-
521
- Gem.pre_uninstall do |uninstaller|
522
- @pre_uninstall_hook_arg = uninstaller
523
- end
524
- end
525
-
526
- def common_installer_teardown
527
- Gem.post_build_hooks.clear
528
- Gem.post_install_hooks.clear
529
- Gem.done_installing_hooks.clear
530
- Gem.post_reset_hooks.clear
531
- Gem.post_uninstall_hooks.clear
532
- Gem.pre_install_hooks.clear
533
- Gem.pre_reset_hooks.clear
534
- Gem.pre_uninstall_hooks.clear
535
- end
536
-
537
- def without_any_upwards_gemfiles
538
- ENV["BUNDLE_GEMFILE"] = File.join(@tempdir, "Gemfile")
539
- end
540
-
541
- ##
542
- # A git_gem is used with a gem dependencies file. The gem created here
543
- # has no files, just a gem specification for the given +name+ and +version+.
544
- #
545
- # Yields the +specification+ to the block, if given
546
-
547
- def git_gem(name = "a", version = 1)
548
- have_git?
549
-
550
- directory = File.join "git", name
551
- directory = File.expand_path directory
552
-
553
- git_spec = Gem::Specification.new name, version do |specification|
554
- yield specification if block_given?
555
- end
556
-
557
- FileUtils.mkdir_p directory
558
-
559
- gemspec = "#{name}.gemspec"
560
-
561
- File.open File.join(directory, gemspec), "w" do |io|
562
- io.write git_spec.to_ruby
563
- end
564
-
565
- head = nil
566
-
567
- Dir.chdir directory do
568
- unless File.exist? ".git"
569
- system @git, "init", "--quiet"
570
- system @git, "config", "user.name", "RubyGems Tests"
571
- system @git, "config", "user.email", "rubygems@example"
572
- end
573
-
574
- system @git, "add", gemspec
575
- system @git, "commit", "-a", "-m", "a non-empty commit message", "--quiet"
576
- head = Gem::Util.popen(@git, "rev-parse", "HEAD").strip
577
- end
578
-
579
- return name, git_spec.version, directory, head
580
- end
581
-
582
- ##
583
- # Skips this test unless you have a git executable
584
-
585
- def have_git?
586
- return if in_path? @git
587
-
588
- pend "cannot find git executable, use GIT environment variable to set"
589
- end
590
-
591
- def in_path?(executable) # :nodoc:
592
- return true if %r{\A([A-Z]:|/)} =~ executable && File.exist?(executable)
593
-
594
- ENV["PATH"].split(File::PATH_SEPARATOR).any? do |directory|
595
- File.exist? File.join directory, executable
596
- end
597
- end
598
-
599
- ##
600
- # Builds and installs the Gem::Specification +spec+
601
-
602
- def install_gem(spec, options = {})
603
- require "rubygems/installer"
604
-
605
- gem = spec.cache_file
606
-
607
- unless File.exist? gem
608
- use_ui Gem::MockGemUi.new do
609
- Dir.chdir @tempdir do
610
- Gem::Package.build spec
611
- end
612
- end
613
-
614
- gem = File.join(@tempdir, File.basename(gem)).tap(&Gem::UNTAINT)
615
- end
616
-
617
- Gem::Installer.at(gem, options.merge({ :wrappers => true })).install
618
- end
619
-
620
- ##
621
- # Builds and installs the Gem::Specification +spec+ into the user dir
622
-
623
- def install_gem_user(spec)
624
- install_gem spec, :user_install => true
625
- end
626
-
627
- ##
628
- # Uninstalls the Gem::Specification +spec+
629
- def uninstall_gem(spec)
630
- require "rubygems/uninstaller"
631
-
632
- Class.new(Gem::Uninstaller) do
633
- def ask_if_ok(spec)
634
- true
635
- end
636
- end.new(spec.name, :executables => true, :user_install => true).uninstall
637
- end
638
-
639
- ##
640
- # Enables pretty-print for all tests
641
-
642
- def mu_pp(obj)
643
- s = String.new
644
- s = PP.pp obj, s
645
- s = s.force_encoding(Encoding.default_external)
646
- s.chomp
647
- end
648
-
649
- ##
650
- # Reads a Marshal file at +path+
651
-
652
- def read_cache(path)
653
- File.open path.dup.tap(&Gem::UNTAINT), "rb" do |io|
654
- Marshal.load io.read
655
- end
656
- end
657
-
658
- ##
659
- # Reads a binary file at +path+
660
-
661
- def read_binary(path)
662
- Gem.read_binary path
663
- end
664
-
665
- ##
666
- # Writes a binary file to +path+ which is relative to +@gemhome+
667
-
668
- def write_file(path)
669
- path = File.join @gemhome, path unless Pathname.new(path).absolute?
670
- dir = File.dirname path
671
- FileUtils.mkdir_p dir unless File.directory? dir
672
-
673
- File.open path, "wb" do |io|
674
- yield io if block_given?
675
- end
676
-
677
- path
678
- end
679
-
680
- ##
681
- # Load a YAML string, the psych 3 way
682
-
683
- def load_yaml(yaml)
684
- if Psych.respond_to?(:unsafe_load)
685
- Psych.unsafe_load(yaml)
686
- else
687
- Psych.load(yaml)
688
- end
689
- end
690
-
691
- ##
692
- # Load a YAML file, the psych 3 way
693
-
694
- def load_yaml_file(file)
695
- require "rubygems/config_file"
696
- Gem::ConfigFile.load_with_rubygems_config_hash(File.read(file))
697
- end
698
-
699
- def all_spec_names
700
- Gem::Specification.map(&:full_name)
701
- end
702
-
703
- ##
704
- # Creates a Gem::Specification with a minimum of extra work. +name+ and
705
- # +version+ are the gem's name and version, platform, author, email,
706
- # homepage, summary and description are defaulted. The specification is
707
- # yielded for customization.
708
- #
709
- # The gem is added to the installed gems in +@gemhome+ and the runtime.
710
- #
711
- # Use this with #write_file to build an installed gem.
712
-
713
- def quick_gem(name, version="2")
714
- require "rubygems/specification"
715
-
716
- spec = Gem::Specification.new do |s|
717
- s.platform = Gem::Platform::RUBY
718
- s.name = name
719
- s.version = version
720
- s.author = "A User"
721
- s.email = "example@example.com"
722
- s.homepage = "http://example.com"
723
- s.summary = "this is a summary"
724
- s.description = "This is a test description"
725
-
726
- yield(s) if block_given?
727
- end
728
-
729
- written_path = write_file spec.spec_file do |io|
730
- io.write spec.to_ruby_for_cache
731
- end
732
-
733
- spec.loaded_from = written_path
734
-
735
- Gem::Specification.reset
736
-
737
- return spec
738
- end
739
-
740
- ##
741
- # Builds a gem from +spec+ and places it in <tt>File.join @gemhome,
742
- # 'cache'</tt>. Automatically creates files based on +spec.files+
743
-
744
- def util_build_gem(spec)
745
- dir = spec.gem_dir
746
- FileUtils.mkdir_p dir
747
-
748
- Dir.chdir dir do
749
- spec.files.each do |file|
750
- next if File.exist? file
751
- FileUtils.mkdir_p File.dirname(file)
752
-
753
- File.open file, "w" do |fp|
754
- fp.puts "# #{file}"
755
- end
756
- end
757
-
758
- use_ui Gem::MockGemUi.new do
759
- Gem::Package.build spec
760
- end
761
-
762
- cache = spec.cache_file
763
- FileUtils.mv File.basename(cache), cache
764
- end
765
- end
766
-
767
- def util_remove_gem(spec)
768
- FileUtils.rm_rf spec.cache_file
769
- FileUtils.rm_rf spec.spec_file
770
- end
771
-
772
- ##
773
- # Removes all installed gems from +@gemhome+.
774
-
775
- def util_clear_gems
776
- FileUtils.rm_rf File.join(@gemhome, "gems")
777
- FileUtils.mkdir File.join(@gemhome, "gems")
778
- FileUtils.rm_rf File.join(@gemhome, "specifications")
779
- FileUtils.mkdir File.join(@gemhome, "specifications")
780
- Gem::Specification.reset
781
- end
782
-
783
- ##
784
- # Install the provided specs
785
-
786
- def install_specs(*specs)
787
- specs.each do |spec|
788
- Gem::Installer.for_spec(spec, :force => true).install
789
- end
790
-
791
- Gem.searcher = nil
792
- end
793
-
794
- ##
795
- # Installs the provided default specs including writing the spec file
796
-
797
- def install_default_gems(*specs)
798
- specs.each do |spec|
799
- installer = Gem::Installer.for_spec(spec, :install_as_default => true)
800
- installer.install
801
- Gem.register_default_spec(spec)
802
- end
803
- end
804
-
805
- def loaded_spec_names
806
- Gem.loaded_specs.values.map(&:full_name).sort
807
- end
808
-
809
- def unresolved_names
810
- Gem::Specification.unresolved_deps.values.map(&:to_s).sort
811
- end
812
-
813
- def new_default_spec(name, version, deps = nil, *files)
814
- spec = util_spec name, version, deps
815
-
816
- spec.loaded_from = File.join(@gemhome, "specifications", "default", spec.spec_name)
817
- spec.files = files
818
-
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])
822
- $LOAD_PATH.unshift(lib_dir)
823
- files.each do |file|
824
- rb_path = File.join(lib_dir, file)
825
- FileUtils.mkdir_p(File.dirname(rb_path))
826
- File.open(rb_path, "w") do |rb|
827
- rb << "# #{file}"
828
- end
829
- end
830
-
831
- spec
832
- end
833
-
834
- ##
835
- # Creates a spec with +name+, +version+. +deps+ can specify the dependency
836
- # or a +block+ can be given for full customization of the specification.
837
-
838
- def util_spec(name, version = 2, deps = nil, *files) # :yields: specification
839
- raise "deps or block, not both" if deps && block_given?
840
-
841
- spec = Gem::Specification.new do |s|
842
- s.platform = Gem::Platform::RUBY
843
- s.name = name
844
- s.version = version
845
- s.author = "A User"
846
- s.email = "example@example.com"
847
- s.homepage = "http://example.com"
848
- s.summary = "this is a summary"
849
- s.description = "This is a test description"
850
-
851
- s.files.push(*files) unless files.empty?
852
-
853
- yield s if block_given?
854
- end
855
-
856
- if deps
857
- deps.keys.each do |n|
858
- spec.add_dependency n, (deps[n] || ">= 0")
859
- end
860
- end
861
-
862
- unless files.empty?
863
- write_file spec.spec_file do |io|
864
- io.write spec.to_ruby_for_cache
865
- end
866
-
867
- util_build_gem spec
868
-
869
- FileUtils.rm spec.spec_file
870
- end
871
-
872
- return spec
873
- end
874
-
875
- ##
876
- # Creates a gem with +name+, +version+ and +deps+. The specification will
877
- # be yielded before gem creation for customization. The gem will be placed
878
- # in <tt>File.join @tempdir, 'gems'</tt>. The specification and .gem file
879
- # location are returned.
880
-
881
- def util_gem(name, version, deps = nil, &block)
882
- if deps
883
- block = proc do |s|
884
- deps.keys.each do |n|
885
- s.add_dependency n, (deps[n] || ">= 0")
886
- end
887
- end
888
- end
889
-
890
- spec = quick_gem(name, version, &block)
891
-
892
- util_build_gem spec
893
-
894
- cache_file = File.join @tempdir, "gems", "#{spec.original_name}.gem"
895
- FileUtils.mkdir_p File.dirname cache_file
896
- FileUtils.mv spec.cache_file, cache_file
897
- FileUtils.rm spec.spec_file
898
-
899
- spec.loaded_from = nil
900
-
901
- [spec, cache_file]
902
- end
903
-
904
- ##
905
- # Gzips +data+.
906
-
907
- def util_gzip(data)
908
- out = StringIO.new
909
-
910
- Zlib::GzipWriter.wrap out do |io|
911
- io.write data
912
- end
913
-
914
- out.string
915
- end
916
-
917
- ##
918
- # Creates several default gems which all have a lib/code.rb file. The gems
919
- # are not installed but are available in the cache dir.
920
- #
921
- # +@a1+:: gem a version 1, this is the best-described gem.
922
- # +@a2+:: gem a version 2
923
- # +@a3a:: gem a version 3.a
924
- # +@a_evil9+:: gem a_evil version 9, use this to ensure similarly-named gems
925
- # don't collide with a.
926
- # +@b2+:: gem b version 2
927
- # +@c1_2+:: gem c version 1.2
928
- # +@pl1+:: gem pl version 1, this gem has a legacy platform of i386-linux.
929
- #
930
- # Additional +prerelease+ gems may also be created:
931
- #
932
- # +@a2_pre+:: gem a version 2.a
933
- # TODO: nuke this and fix tests. this should speed up a lot
934
-
935
- def util_make_gems(prerelease = false)
936
- @a1 = quick_gem "a", "1" do |s|
937
- s.files = %w[lib/code.rb]
938
- s.require_paths = %w[lib]
939
- s.date = Gem::Specification::TODAY - 86_400
940
- s.homepage = "http://a.example.com"
941
- s.email = %w[example@example.com example2@example.com]
942
- s.authors = %w[Example Example2]
943
- s.description = <<-DESC
944
- This line is really, really long. So long, in fact, that it is more than eighty characters long! The purpose of this line is for testing wrapping behavior because sometimes people don't wrap their text to eighty characters. Without the wrapping, the text might not look good in the RSS feed.
945
-
946
- Also, a list:
947
- * An entry that\'s actually kind of sort
948
- * an entry that\'s really long, which will probably get wrapped funny. That's ok, somebody wasn't thinking straight when they made it more than eighty characters.
949
- DESC
950
- end
951
-
952
- init = proc do |s|
953
- s.files = %w[lib/code.rb]
954
- s.require_paths = %w[lib]
955
- end
956
-
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|
964
- s.files = %w[lib/code.rb]
965
- s.require_paths = %w[lib]
966
- s.add_dependency "x", ">= 1"
967
- end
968
-
969
- @pl1 = quick_gem "pl", "1" do |s| # l for legacy
970
- s.files = %w[lib/code.rb]
971
- s.require_paths = %w[lib]
972
- s.platform = Gem::Platform.new "i386-linux"
973
- s.instance_variable_set :@original_platform, "i386-linux"
974
- end
975
-
976
- if prerelease
977
- @a2_pre = quick_gem("a", "2.a", &init)
978
- write_file File.join(*%W[gems #{@a2_pre.original_name} lib code.rb])
979
- util_build_gem @a2_pre
980
- end
981
-
982
- write_file File.join(*%W[gems #{@a1.original_name} lib code.rb])
983
- write_file File.join(*%W[gems #{@a2.original_name} lib code.rb])
984
- write_file File.join(*%W[gems #{@a3a.original_name} lib code.rb])
985
- write_file File.join(*%W[gems #{@a_evil9.original_name} lib code.rb])
986
- write_file File.join(*%W[gems #{@b2.original_name} lib code.rb])
987
- write_file File.join(*%W[gems #{@c1_2.original_name} lib code.rb])
988
- write_file File.join(*%W[gems #{@pl1.original_name} lib code.rb])
989
- write_file File.join(*%W[gems #{@x.original_name} lib code.rb])
990
- write_file File.join(*%W[gems #{@dep_x.original_name} lib code.rb])
991
-
992
- [@a1, @a2, @a3a, @a_evil9, @b2, @c1_2, @pl1, @x, @dep_x].each do |spec|
993
- util_build_gem spec
994
- end
995
-
996
- FileUtils.rm_r File.join(@gemhome, "gems", @pl1.original_name)
997
- end
998
-
999
- ##
1000
- # Set the platform to +arch+
1001
-
1002
- def util_set_arch(arch)
1003
- RbConfig::CONFIG["arch"] = arch
1004
- platform = Gem::Platform.new arch
1005
-
1006
- Gem.instance_variable_set :@platforms, nil
1007
- Gem::Platform.instance_variable_set :@local, nil
1008
-
1009
- yield if block_given?
1010
-
1011
- platform
1012
- end
1013
-
1014
- ##
1015
- # Add +spec+ to +@fetcher+ serving the data in the file +path+.
1016
- # +repo+ indicates which repo to make +spec+ appear to be in.
1017
-
1018
- def add_to_fetcher(spec, path=nil, repo=@gem_repo)
1019
- path ||= spec.cache_file
1020
- @fetcher.data["#{@gem_repo}gems/#{spec.file_name}"] = read_binary(path)
1021
- end
1022
-
1023
- ##
1024
- # Sets up Gem::SpecFetcher to return information from the gems in +specs+.
1025
-
1026
- def util_setup_spec_fetcher(*specs)
1027
- all_specs = Gem::Specification.to_a + specs
1028
- Gem::Specification._resort! all_specs
1029
-
1030
- spec_fetcher = Gem::SpecFetcher.fetcher
1031
-
1032
- prerelease, all = all_specs.partition {|spec| spec.version.prerelease? }
1033
- latest = Gem::Specification._latest_specs all_specs
1034
-
1035
- spec_fetcher.specs[@uri] = []
1036
- all.each do |spec|
1037
- spec_fetcher.specs[@uri] << spec.name_tuple
1038
- end
1039
-
1040
- spec_fetcher.latest_specs[@uri] = []
1041
- latest.each do |spec|
1042
- spec_fetcher.latest_specs[@uri] << spec.name_tuple
1043
- end
1044
-
1045
- spec_fetcher.prerelease_specs[@uri] = []
1046
- prerelease.each do |spec|
1047
- spec_fetcher.prerelease_specs[@uri] << spec.name_tuple
1048
- end
1049
-
1050
- # HACK for test_download_to_cache
1051
- unless Gem::RemoteFetcher === @fetcher
1052
- v = Gem.marshal_version
1053
-
1054
- specs = all.map {|spec| spec.name_tuple }
1055
- s_zip = util_gzip Marshal.dump Gem::NameTuple.to_basic specs
1056
-
1057
- latest_specs = latest.map do |spec|
1058
- spec.name_tuple
1059
- end
1060
-
1061
- l_zip = util_gzip Marshal.dump Gem::NameTuple.to_basic latest_specs
1062
-
1063
- prerelease_specs = prerelease.map {|spec| spec.name_tuple }
1064
- p_zip = util_gzip Marshal.dump Gem::NameTuple.to_basic prerelease_specs
1065
-
1066
- @fetcher.data["#{@gem_repo}specs.#{v}.gz"] = s_zip
1067
- @fetcher.data["#{@gem_repo}latest_specs.#{v}.gz"] = l_zip
1068
- @fetcher.data["#{@gem_repo}prerelease_specs.#{v}.gz"] = p_zip
1069
-
1070
- write_marshalled_gemspecs(*all_specs)
1071
- end
1072
-
1073
- nil # force errors
1074
- end
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
-
1087
- ##
1088
- # Deflates +data+
1089
-
1090
- def util_zip(data)
1091
- Zlib::Deflate.deflate data
1092
- end
1093
-
1094
- def util_set_RUBY_VERSION(version, patchlevel, revision, description, engine = "ruby", engine_version = nil)
1095
- if Gem.instance_variables.include? :@ruby_version
1096
- Gem.send :remove_instance_variable, :@ruby_version
1097
- end
1098
-
1099
- @RUBY_VERSION = RUBY_VERSION
1100
- @RUBY_PATCHLEVEL = RUBY_PATCHLEVEL if defined?(RUBY_PATCHLEVEL)
1101
- @RUBY_REVISION = RUBY_REVISION if defined?(RUBY_REVISION)
1102
- @RUBY_DESCRIPTION = RUBY_DESCRIPTION
1103
- @RUBY_ENGINE = RUBY_ENGINE
1104
- @RUBY_ENGINE_VERSION = RUBY_ENGINE_VERSION if defined?(RUBY_ENGINE_VERSION)
1105
-
1106
- util_clear_RUBY_VERSION
1107
-
1108
- Object.const_set :RUBY_VERSION, version
1109
- Object.const_set :RUBY_PATCHLEVEL, patchlevel
1110
- Object.const_set :RUBY_REVISION, revision
1111
- Object.const_set :RUBY_DESCRIPTION, description
1112
- Object.const_set :RUBY_ENGINE, engine
1113
- Object.const_set :RUBY_ENGINE_VERSION, engine_version if engine_version
1114
- end
1115
-
1116
- def util_restore_RUBY_VERSION
1117
- util_clear_RUBY_VERSION
1118
-
1119
- Object.const_set :RUBY_VERSION, @RUBY_VERSION
1120
- Object.const_set :RUBY_PATCHLEVEL, @RUBY_PATCHLEVEL if
1121
- defined?(@RUBY_PATCHLEVEL)
1122
- Object.const_set :RUBY_REVISION, @RUBY_REVISION if
1123
- defined?(@RUBY_REVISION)
1124
- Object.const_set :RUBY_DESCRIPTION, @RUBY_DESCRIPTION
1125
- Object.const_set :RUBY_ENGINE, @RUBY_ENGINE
1126
- Object.const_set :RUBY_ENGINE_VERSION, @RUBY_ENGINE_VERSION if
1127
- defined?(@RUBY_ENGINE_VERSION)
1128
- end
1129
-
1130
- def util_clear_RUBY_VERSION
1131
- Object.send :remove_const, :RUBY_VERSION
1132
- Object.send :remove_const, :RUBY_PATCHLEVEL if defined?(RUBY_PATCHLEVEL)
1133
- Object.send :remove_const, :RUBY_REVISION if defined?(RUBY_REVISION)
1134
- Object.send :remove_const, :RUBY_DESCRIPTION if defined?(RUBY_DESCRIPTION)
1135
- Object.send :remove_const, :RUBY_ENGINE
1136
- Object.send :remove_const, :RUBY_ENGINE_VERSION if defined?(RUBY_ENGINE_VERSION)
1137
- end
1138
-
1139
- ##
1140
- # Is this test being run on a Windows platform?
1141
-
1142
- def self.win_platform?
1143
- Gem.win_platform?
1144
- end
1145
-
1146
- ##
1147
- # Is this test being run on a Windows platform?
1148
-
1149
- def win_platform?
1150
- Gem.win_platform?
1151
- end
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
-
1167
- ##
1168
- # Returns whether or not we're on a version of Ruby built with VC++ (or
1169
- # Borland) versus Cygwin, Mingw, etc.
1170
-
1171
- def self.vc_windows?
1172
- RUBY_PLATFORM.match("mswin")
1173
- end
1174
-
1175
- ##
1176
- # Returns whether or not we're on a version of Ruby built with VC++ (or
1177
- # Borland) versus Cygwin, Mingw, etc.
1178
-
1179
- def vc_windows?
1180
- RUBY_PLATFORM.match("mswin")
1181
- end
1182
-
1183
- ##
1184
- # Is this test being run on a version of Ruby built with mingw?
1185
-
1186
- def self.mingw_windows?
1187
- RUBY_PLATFORM.match("mingw")
1188
- end
1189
-
1190
- ##
1191
- # Is this test being run on a version of Ruby built with mingw?
1192
-
1193
- def mingw_windows?
1194
- RUBY_PLATFORM.match("mingw")
1195
- end
1196
-
1197
- ##
1198
- # Is this test being run on a ruby/ruby repository?
1199
- #
1200
-
1201
- def ruby_repo?
1202
- !ENV["GEM_COMMAND"].nil?
1203
- end
1204
-
1205
- ##
1206
- # Returns the make command for the current platform. For versions of Ruby
1207
- # built on MS Windows with VC++ or Borland it will return 'nmake'. On all
1208
- # other platforms, including Cygwin, it will return 'make'.
1209
-
1210
- def self.make_command
1211
- ENV["make"] || ENV["MAKE"] || (vc_windows? ? "nmake" : "make")
1212
- end
1213
-
1214
- ##
1215
- # Returns the make command for the current platform. For versions of Ruby
1216
- # built on MS Windows with VC++ or Borland it will return 'nmake'. On all
1217
- # other platforms, including Cygwin, it will return 'make'.
1218
-
1219
- def make_command
1220
- ENV["make"] || ENV["MAKE"] || (vc_windows? ? "nmake" : "make")
1221
- end
1222
-
1223
- ##
1224
- # Returns whether or not the nmake command could be found.
1225
-
1226
- def nmake_found?
1227
- system("nmake /? 1>NUL 2>&1")
1228
- end
1229
-
1230
- # In case we're building docs in a background process, this method waits for
1231
- # that process to exit (or if it's already been reaped, or never happened,
1232
- # swallows the Errno::ECHILD error).
1233
- def wait_for_child_process_to_exit
1234
- Process.wait if Process.respond_to?(:fork)
1235
- rescue Errno::ECHILD
1236
- end
1237
-
1238
- ##
1239
- # Allows tests to use a random (but controlled) port number instead of
1240
- # a hardcoded one. This helps CI tools when running parallels builds on
1241
- # the same builder slave.
1242
-
1243
- def self.process_based_port
1244
- @@process_based_port ||= 8000 + $$ % 1000
1245
- end
1246
-
1247
- ##
1248
- # See ::process_based_port
1249
-
1250
- def process_based_port
1251
- self.class.process_based_port
1252
- end
1253
-
1254
- ##
1255
- # Allows the proper version of +rake+ to be used for the test.
1256
-
1257
- def build_rake_in(good=true)
1258
- gem_ruby = Gem.ruby
1259
- Gem.ruby = self.class.rubybin
1260
- env_rake = ENV["rake"]
1261
- rake = (good ? @@good_rake : @@bad_rake)
1262
- ENV["rake"] = rake
1263
- yield rake
1264
- ensure
1265
- Gem.ruby = gem_ruby
1266
- if env_rake
1267
- ENV["rake"] = env_rake
1268
- else
1269
- ENV.delete("rake")
1270
- end
1271
- end
1272
-
1273
- ##
1274
- # Finds the path to the Ruby executable
1275
-
1276
- def self.rubybin
1277
- ruby = ENV["RUBY"]
1278
- return ruby if ruby
1279
- ruby = "ruby"
1280
- rubyexe = "#{ruby}#{RbConfig::CONFIG["EXEEXT"]}"
1281
-
1282
- 3.times do
1283
- if File.exist?(ruby) && File.executable?(ruby) && !File.directory?(ruby)
1284
- return File.expand_path(ruby)
1285
- end
1286
- if File.exist?(rubyexe) && File.executable?(rubyexe)
1287
- return File.expand_path(rubyexe)
1288
- end
1289
- ruby = File.join("..", ruby)
1290
- end
1291
-
1292
- begin
1293
- Gem.ruby
1294
- rescue LoadError
1295
- "ruby"
1296
- end
1297
- end
1298
-
1299
- def ruby_with_rubygems_in_load_path
1300
- [Gem.ruby, "-I", rubygems_path]
1301
- end
1302
-
1303
- def rubygems_path
1304
- $LOAD_PATH.find {|p| p == File.dirname($LOADED_FEATURES.find {|f| f.end_with?("/rubygems.rb") }) }
1305
- end
1306
-
1307
- def bundler_path
1308
- $LOAD_PATH.find {|p| p == File.dirname($LOADED_FEATURES.find {|f| f.end_with?("/bundler.rb") }) }
1309
- end
1310
-
1311
- def with_clean_path_to_ruby
1312
- orig_ruby = Gem.ruby
1313
-
1314
- Gem.instance_variable_set :@ruby, nil
1315
-
1316
- yield
1317
- ensure
1318
- Gem.instance_variable_set :@ruby, orig_ruby
1319
- end
1320
-
1321
- def with_internal_encoding(encoding)
1322
- int_enc = Encoding.default_internal
1323
- silence_warnings { Encoding.default_internal = encoding }
1324
-
1325
- yield
1326
- ensure
1327
- silence_warnings { Encoding.default_internal = int_enc }
1328
- end
1329
-
1330
- def silence_warnings
1331
- old_verbose = $VERBOSE
1332
- $VERBOSE = false
1333
- yield
1334
- ensure
1335
- $VERBOSE = old_verbose
1336
- end
1337
-
1338
- class << self
1339
- # :nodoc:
1340
- ##
1341
- # Return the join path, with escaping backticks, dollars, and
1342
- # double-quotes. Unlike `shellescape`, equal-sign is not escaped.
1343
-
1344
- private
1345
-
1346
- def escape_path(*path)
1347
- path = File.join(*path)
1348
- if %r{\A[-+:/=@,.\w]+\z} =~ path
1349
- path
1350
- else
1351
- "\"#{path.gsub(/[`$"]/, '\\&')}\""
1352
- end
1353
- end
1354
- end
1355
-
1356
- @@good_rake = "#{rubybin} #{escape_path(__dir__, "good_rake.rb")}"
1357
- @@bad_rake = "#{rubybin} #{escape_path(__dir__, "bad_rake.rb")}"
1358
-
1359
- ##
1360
- # Construct a new Gem::Dependency.
1361
-
1362
- def dep(name, *requirements)
1363
- Gem::Dependency.new name, *requirements
1364
- end
1365
-
1366
- ##
1367
- # Constructs a Gem::Resolver::DependencyRequest from a
1368
- # Gem::Dependency +dep+, a +from_name+ and +from_version+ requesting the
1369
- # dependency and a +parent+ DependencyRequest
1370
-
1371
- def dependency_request(dep, from_name, from_version, parent = nil)
1372
- remote = Gem::Source.new @uri
1373
-
1374
- unless parent
1375
- parent_dep = dep from_name, from_version
1376
- parent = Gem::Resolver::DependencyRequest.new parent_dep, nil
1377
- end
1378
-
1379
- spec = Gem::Resolver::IndexSpecification.new \
1380
- nil, from_name, from_version, remote, Gem::Platform::RUBY
1381
- activation = Gem::Resolver::ActivationRequest.new spec, parent
1382
-
1383
- Gem::Resolver::DependencyRequest.new dep, activation
1384
- end
1385
-
1386
- ##
1387
- # Constructs a new Gem::Requirement.
1388
-
1389
- def req(*requirements)
1390
- return requirements.first if Gem::Requirement === requirements.first
1391
- Gem::Requirement.create requirements
1392
- end
1393
-
1394
- ##
1395
- # Constructs a new Gem::Specification.
1396
-
1397
- def spec(name, version, &block)
1398
- Gem::Specification.new name, v(version), &block
1399
- end
1400
-
1401
- ##
1402
- # Creates a SpecFetcher pre-filled with the gems or specs defined in the
1403
- # block.
1404
- #
1405
- # Yields a +fetcher+ object that responds to +spec+ and +gem+. +spec+ adds
1406
- # a specification to the SpecFetcher while +gem+ adds both a specification
1407
- # and the gem data to the RemoteFetcher so the built gem can be downloaded.
1408
- #
1409
- # If only the a-3 gem is supposed to be downloaded you can save setup
1410
- # time by creating only specs for the other versions:
1411
- #
1412
- # spec_fetcher do |fetcher|
1413
- # fetcher.spec 'a', 1
1414
- # fetcher.spec 'a', 2, 'b' => 3 # dependency on b = 3
1415
- # fetcher.gem 'a', 3 do |spec|
1416
- # # spec is a Gem::Specification
1417
- # # ...
1418
- # end
1419
- # end
1420
-
1421
- def spec_fetcher(repository = @gem_repo)
1422
- Gem::TestCase::SpecFetcherSetup.declare self, repository do |spec_fetcher_setup|
1423
- yield spec_fetcher_setup if block_given?
1424
- end
1425
- end
1426
-
1427
- ##
1428
- # Construct a new Gem::Version.
1429
-
1430
- def v(string)
1431
- Gem::Version.create string
1432
- end
1433
-
1434
- ##
1435
- # A vendor_gem is used with a gem dependencies file. The gem created here
1436
- # has no files, just a gem specification for the given +name+ and +version+.
1437
- #
1438
- # Yields the +specification+ to the block, if given
1439
-
1440
- def vendor_gem(name = "a", version = 1)
1441
- directory = File.join "vendor", name
1442
-
1443
- FileUtils.mkdir_p directory
1444
-
1445
- save_gemspec name, version, directory
1446
- end
1447
-
1448
- ##
1449
- # create_gemspec creates gem specification in given +directory+ or '.'
1450
- # for the given +name+ and +version+.
1451
- #
1452
- # Yields the +specification+ to the block, if given
1453
-
1454
- def save_gemspec(name = "a", version = 1, directory = ".")
1455
- vendor_spec = Gem::Specification.new name, version do |specification|
1456
- yield specification if block_given?
1457
- end
1458
-
1459
- File.open File.join(directory, "#{name}.gemspec"), "w" do |io|
1460
- io.write vendor_spec.to_ruby
1461
- end
1462
-
1463
- return name, vendor_spec.version, directory
1464
- end
1465
-
1466
- ##
1467
- # The StaticSet is a static set of gem specifications used for testing only.
1468
- # It is available by requiring Gem::TestCase.
1469
-
1470
- class StaticSet < Gem::Resolver::Set
1471
- ##
1472
- # A StaticSet ignores remote because it has a fixed set of gems.
1473
-
1474
- attr_accessor :remote
1475
-
1476
- ##
1477
- # Creates a new StaticSet for the given +specs+
1478
-
1479
- def initialize(specs)
1480
- super()
1481
-
1482
- @specs = specs
1483
-
1484
- @remote = true
1485
- end
1486
-
1487
- ##
1488
- # Adds +spec+ to this set.
1489
-
1490
- def add(spec)
1491
- @specs << spec
1492
- end
1493
-
1494
- ##
1495
- # Finds +dep+ in this set.
1496
-
1497
- def find_spec(dep)
1498
- @specs.reverse_each do |s|
1499
- return s if dep.matches_spec? s
1500
- end
1501
- end
1502
-
1503
- ##
1504
- # Finds all gems matching +dep+ in this set.
1505
-
1506
- def find_all(dep)
1507
- @specs.find_all {|s| dep.match? s, @prerelease }
1508
- end
1509
-
1510
- ##
1511
- # Loads a Gem::Specification from this set which has the given +name+,
1512
- # version +ver+, +platform+. The +source+ is ignored.
1513
-
1514
- def load_spec(name, ver, platform, source)
1515
- dep = Gem::Dependency.new name, ver
1516
- spec = find_spec dep
1517
-
1518
- Gem::Specification.new spec.name, spec.version do |s|
1519
- s.platform = spec.platform
1520
- end
1521
- end
1522
-
1523
- def prefetch(reqs) # :nodoc:
1524
- end
1525
- end
1526
-
1527
- ##
1528
- # Loads certificate named +cert_name+ from <tt>test/rubygems/</tt>.
1529
-
1530
- def self.load_cert(cert_name)
1531
- cert_file = cert_path cert_name
1532
-
1533
- cert = File.read cert_file
1534
-
1535
- OpenSSL::X509::Certificate.new cert
1536
- end
1537
-
1538
- ##
1539
- # Returns the path to the certificate named +cert_name+ from
1540
- # <tt>test/rubygems/</tt>.
1541
-
1542
- def self.cert_path(cert_name)
1543
- if 32 == begin
1544
- Time.at(2**32)
1545
- rescue StandardError
1546
- 32
1547
- end
1548
- cert_file = "#{__dir__}/#{cert_name}_cert_32.pem"
1549
-
1550
- return cert_file if File.exist? cert_file
1551
- end
1552
-
1553
- "#{__dir__}/#{cert_name}_cert.pem"
1554
- end
1555
-
1556
- ##
1557
- # Loads a private key named +key_name+ with +passphrase+ in <tt>test/rubygems/</tt>
1558
-
1559
- def self.load_key(key_name, passphrase = nil)
1560
- key_file = key_path key_name
1561
-
1562
- key = File.read key_file
1563
-
1564
- OpenSSL::PKey.read key, passphrase
1565
- end
1566
-
1567
- ##
1568
- # Returns the path to the key named +key_name+ from <tt>test/rubygems</tt>
1569
-
1570
- def self.key_path(key_name)
1571
- "#{__dir__}/#{key_name}_key.pem"
1572
- end
1573
-
1574
- # :stopdoc:
1575
- # only available in RubyGems tests
1576
-
1577
- PRIVATE_KEY_PASSPHRASE = "Foo bar"
1578
-
1579
- begin
1580
- PRIVATE_KEY = load_key "private"
1581
- PRIVATE_KEY_PATH = key_path "private"
1582
-
1583
- # 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"
1586
-
1587
- PUBLIC_KEY = PRIVATE_KEY.public_key
1588
-
1589
- PUBLIC_CERT = load_cert "public"
1590
- PUBLIC_CERT_PATH = cert_path "public"
1591
- rescue Errno::ENOENT
1592
- PRIVATE_KEY = nil
1593
- PUBLIC_KEY = nil
1594
- PUBLIC_CERT = nil
1595
- end if Gem::HAVE_OPENSSL
1596
-
1597
- private
1598
-
1599
- def restore_env
1600
- unless Gem.win_platform?
1601
- ENV.replace(@orig_env)
1602
- return
1603
- end
1604
-
1605
- # Fallback logic for Windows below to workaround
1606
- # https://bugs.ruby-lang.org/issues/16798. Can be dropped once all
1607
- # supported rubies include the fix for that.
1608
-
1609
- ENV.clear
1610
-
1611
- @orig_env.each {|k, v| ENV[k] = v }
1612
- end
1613
- end
1614
-
1615
- # https://github.com/seattlerb/minitest/blob/13c48a03d84a2a87855a4de0c959f96800100357/lib/minitest/mock.rb#L192
1616
- class Object
1617
- def stub(name, val_or_callable, *block_args)
1618
- new_name = "__minitest_stub__#{name}"
1619
-
1620
- metaclass = class << self; self; end
1621
-
1622
- if respond_to?(name) && !methods.map(&:to_s).include?(name.to_s)
1623
- metaclass.send :define_method, name do |*args|
1624
- super(*args)
1625
- end
1626
- end
1627
-
1628
- metaclass.send :alias_method, new_name, name
1629
-
1630
- metaclass.send :define_method, name do |*args, &blk|
1631
- if val_or_callable.respond_to? :call
1632
- val_or_callable.call(*args, &blk)
1633
- else
1634
- blk&.call(*block_args)
1635
- val_or_callable
1636
- end
1637
- end
1638
-
1639
- metaclass.send(:ruby2_keywords, name) if metaclass.respond_to?(:ruby2_keywords, true)
1640
-
1641
- yield self
1642
- ensure
1643
- metaclass.send :undef_method, name
1644
- metaclass.send :alias_method, name, new_name
1645
- metaclass.send :undef_method, new_name
1646
- end unless method_defined?(:stub) # lib/resolv/test_dns.rb also has the same method definition
1647
- end
1648
-
1649
- require_relative "utilities"