rubygems-update 2.6.0 → 3.4.22

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