rubygems-update 3.2.32 → 3.3.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (177) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +154 -4
  3. data/CONTRIBUTING.md +40 -10
  4. data/Manifest.txt +11 -5
  5. data/POLICIES.md +22 -8
  6. data/README.md +9 -7
  7. data/UPGRADING.md +5 -81
  8. data/bin/gem +1 -6
  9. data/bundler/CHANGELOG.md +70 -0
  10. data/bundler/exe/bundle +7 -8
  11. data/bundler/lib/bundler/.document +1 -0
  12. data/bundler/lib/bundler/build_metadata.rb +2 -2
  13. data/bundler/lib/bundler/cli/doctor.rb +3 -2
  14. data/bundler/lib/bundler/cli/gem.rb +2 -1
  15. data/bundler/lib/bundler/cli/info.rb +6 -1
  16. data/bundler/lib/bundler/cli/install.rb +2 -0
  17. data/bundler/lib/bundler/cli/update.rb +2 -2
  18. data/bundler/lib/bundler/cli.rb +6 -0
  19. data/bundler/lib/bundler/compact_index_client/updater.rb +0 -5
  20. data/bundler/lib/bundler/definition.rb +29 -53
  21. data/bundler/lib/bundler/dependency.rb +5 -7
  22. data/bundler/lib/bundler/dsl.rb +18 -30
  23. data/bundler/lib/bundler/endpoint_specification.rb +0 -8
  24. data/bundler/lib/bundler/environment_preserver.rb +4 -1
  25. data/bundler/lib/bundler/fetcher/compact_index.rb +9 -4
  26. data/bundler/lib/bundler/fetcher.rb +2 -5
  27. data/bundler/lib/bundler/injector.rb +10 -1
  28. data/bundler/lib/bundler/installer/gem_installer.rb +1 -6
  29. data/bundler/lib/bundler/installer.rb +1 -4
  30. data/bundler/lib/bundler/lazy_specification.rb +17 -1
  31. data/bundler/lib/bundler/lockfile_parser.rb +10 -13
  32. data/bundler/lib/bundler/man/bundle-add.1 +10 -2
  33. data/bundler/lib/bundler/man/bundle-add.1.ronn +7 -1
  34. data/bundler/lib/bundler/man/bundle-binstubs.1 +1 -1
  35. data/bundler/lib/bundler/man/bundle-cache.1 +1 -1
  36. data/bundler/lib/bundler/man/bundle-check.1 +1 -1
  37. data/bundler/lib/bundler/man/bundle-clean.1 +1 -1
  38. data/bundler/lib/bundler/man/bundle-config.1 +3 -3
  39. data/bundler/lib/bundler/man/bundle-config.1.ronn +3 -3
  40. data/bundler/lib/bundler/man/bundle-doctor.1 +1 -1
  41. data/bundler/lib/bundler/man/bundle-exec.1 +1 -1
  42. data/bundler/lib/bundler/man/bundle-gem.1 +1 -1
  43. data/bundler/lib/bundler/man/bundle-info.1 +1 -1
  44. data/bundler/lib/bundler/man/bundle-init.1 +1 -1
  45. data/bundler/lib/bundler/man/bundle-inject.1 +1 -1
  46. data/bundler/lib/bundler/man/bundle-install.1 +2 -2
  47. data/bundler/lib/bundler/man/bundle-install.1.ronn +2 -2
  48. data/bundler/lib/bundler/man/bundle-list.1 +1 -1
  49. data/bundler/lib/bundler/man/bundle-lock.1 +1 -1
  50. data/bundler/lib/bundler/man/bundle-open.1 +1 -1
  51. data/bundler/lib/bundler/man/bundle-outdated.1 +1 -1
  52. data/bundler/lib/bundler/man/bundle-platform.1 +1 -1
  53. data/bundler/lib/bundler/man/bundle-pristine.1 +1 -1
  54. data/bundler/lib/bundler/man/bundle-remove.1 +1 -1
  55. data/bundler/lib/bundler/man/bundle-show.1 +1 -1
  56. data/bundler/lib/bundler/man/bundle-update.1 +2 -2
  57. data/bundler/lib/bundler/man/bundle-update.1.ronn +2 -1
  58. data/bundler/lib/bundler/man/bundle-viz.1 +1 -1
  59. data/bundler/lib/bundler/man/bundle.1 +1 -1
  60. data/bundler/lib/bundler/man/gemfile.5 +28 -2
  61. data/bundler/lib/bundler/man/gemfile.5.ronn +9 -1
  62. data/bundler/lib/bundler/plugin/api/source.rb +1 -0
  63. data/bundler/lib/bundler/plugin/installer.rb +1 -1
  64. data/bundler/lib/bundler/process_lock.rb +1 -1
  65. data/bundler/lib/bundler/psyched_yaml.rb +1 -13
  66. data/bundler/lib/bundler/resolver.rb +34 -31
  67. data/bundler/lib/bundler/rubygems_ext.rb +2 -0
  68. data/bundler/lib/bundler/rubygems_gem_installer.rb +1 -1
  69. data/bundler/lib/bundler/rubygems_integration.rb +11 -48
  70. data/bundler/lib/bundler/self_manager.rb +76 -0
  71. data/bundler/lib/bundler/shared_helpers.rb +4 -12
  72. data/bundler/lib/bundler/source/git/git_proxy.rb +2 -2
  73. data/bundler/lib/bundler/source/metadata.rb +1 -1
  74. data/bundler/lib/bundler/source/rubygems.rb +16 -12
  75. data/bundler/lib/bundler/source/rubygems_aggregate.rb +1 -1
  76. data/bundler/lib/bundler/source.rb +1 -1
  77. data/bundler/lib/bundler/source_list.rb +7 -29
  78. data/bundler/lib/bundler/templates/Executable.bundler +1 -1
  79. data/bundler/lib/bundler/templates/Gemfile +0 -2
  80. data/bundler/lib/bundler/templates/gems.rb +0 -3
  81. data/bundler/lib/bundler/templates/newgem/Rakefile.tt +10 -1
  82. data/bundler/lib/bundler/templates/newgem/github/workflows/main.yml.tt +2 -2
  83. data/bundler/lib/bundler/templates/newgem/newgem.gemspec.tt +1 -1
  84. data/bundler/lib/bundler/templates/newgem/sig/newgem.rbs.tt +8 -0
  85. data/bundler/lib/bundler/templates/newgem/test/minitest/{newgem_test.rb.tt → test_newgem.rb.tt} +1 -1
  86. data/bundler/lib/bundler/ui/shell.rb +1 -1
  87. data/bundler/lib/bundler/vendor/.document +1 -0
  88. data/bundler/lib/bundler/vendor/thor/lib/thor/actions/file_manipulation.rb +6 -6
  89. data/bundler/lib/bundler/vendor/thor/lib/thor/actions/inject_into_file.rb +5 -3
  90. data/bundler/lib/bundler/vendor/thor/lib/thor/actions.rb +6 -2
  91. data/bundler/lib/bundler/vendor/thor/lib/thor/core_ext/hash_with_indifferent_access.rb +6 -0
  92. data/bundler/lib/bundler/vendor/thor/lib/thor/error.rb +9 -4
  93. data/bundler/lib/bundler/vendor/thor/lib/thor/parser/options.rb +19 -1
  94. data/bundler/lib/bundler/vendor/thor/lib/thor/shell/basic.rb +22 -4
  95. data/bundler/lib/bundler/vendor/thor/lib/thor/shell.rb +1 -1
  96. data/bundler/lib/bundler/vendor/thor/lib/thor/util.rb +1 -1
  97. data/bundler/lib/bundler/vendor/uri/lib/uri/common.rb +17 -80
  98. data/bundler/lib/bundler/vendor/uri/lib/uri/ftp.rb +0 -1
  99. data/bundler/lib/bundler/vendor/uri/lib/uri/generic.rb +5 -6
  100. data/bundler/lib/bundler/vendor/uri/lib/uri/http.rb +0 -1
  101. data/bundler/lib/bundler/vendor/uri/lib/uri/https.rb +0 -1
  102. data/bundler/lib/bundler/vendor/uri/lib/uri/ldap.rb +1 -1
  103. data/bundler/lib/bundler/vendor/uri/lib/uri/mailto.rb +0 -1
  104. data/bundler/lib/bundler/vendor/uri/lib/uri/rfc2396_parser.rb +1 -14
  105. data/bundler/lib/bundler/vendor/uri/lib/uri/rfc3986_parser.rb +1 -12
  106. data/bundler/lib/bundler/vendor/uri/lib/uri/version.rb +1 -1
  107. data/bundler/lib/bundler/vendor/uri/lib/uri/ws.rb +84 -0
  108. data/bundler/lib/bundler/vendor/uri/lib/uri/wss.rb +22 -0
  109. data/bundler/lib/bundler/vendor/uri/lib/uri.rb +0 -1
  110. data/bundler/lib/bundler/version.rb +1 -1
  111. data/bundler/lib/bundler.rb +9 -3
  112. data/hide_lib_for_update/note.txt +0 -4
  113. data/lib/rubygems/bundler_version_finder.rb +10 -42
  114. data/lib/rubygems/command_manager.rb +4 -2
  115. data/lib/rubygems/commands/install_command.rb +5 -2
  116. data/lib/rubygems/commands/pristine_command.rb +8 -2
  117. data/lib/rubygems/commands/server_command.rb +14 -77
  118. data/lib/rubygems/commands/setup_command.rb +21 -22
  119. data/lib/rubygems/commands/update_command.rb +9 -4
  120. data/lib/rubygems/defaults.rb +2 -20
  121. data/lib/rubygems/dependency.rb +7 -7
  122. data/lib/rubygems/deprecate.rb +53 -6
  123. data/lib/rubygems/errors.rb +0 -3
  124. data/lib/rubygems/exceptions.rb +31 -1
  125. data/lib/rubygems/ext/builder.rb +5 -3
  126. data/lib/rubygems/install_update_options.rb +11 -2
  127. data/lib/rubygems/installer.rb +14 -12
  128. data/lib/rubygems/name_tuple.rb +2 -3
  129. data/lib/rubygems/optparse/.document +1 -0
  130. data/lib/rubygems/path_support.rb +1 -6
  131. data/lib/rubygems/platform.rb +4 -0
  132. data/lib/rubygems/remote_fetcher.rb +1 -1
  133. data/lib/rubygems/requirement.rb +1 -1
  134. data/lib/rubygems/resolver/installer_set.rb +1 -1
  135. data/lib/rubygems/security/policy.rb +1 -3
  136. data/lib/rubygems/security.rb +14 -7
  137. data/lib/rubygems/source.rb +3 -1
  138. data/lib/rubygems/spec_fetcher.rb +1 -1
  139. data/lib/rubygems/specification.rb +21 -21
  140. data/lib/rubygems/stub_specification.rb +1 -1
  141. data/lib/rubygems/text.rb +21 -20
  142. data/lib/rubygems/tsort/.document +1 -0
  143. data/lib/rubygems/uninstaller.rb +4 -1
  144. data/lib/rubygems/unknown_command_spell_checker.rb +21 -0
  145. data/lib/rubygems/version.rb +2 -0
  146. data/lib/rubygems.rb +48 -56
  147. data/rubygems-update.gemspec +1 -1
  148. data/setup.rb +1 -6
  149. data/test/rubygems/helper.rb +20 -6
  150. data/test/rubygems/test_config.rb +2 -2
  151. data/test/rubygems/test_exit.rb +11 -0
  152. data/test/rubygems/test_gem.rb +46 -76
  153. data/test/rubygems/test_gem_bundler_version_finder.rb +22 -43
  154. data/test/rubygems/test_gem_command_manager.rb +28 -2
  155. data/test/rubygems/test_gem_commands_install_command.rb +33 -0
  156. data/test/rubygems/test_gem_commands_open_command.rb +1 -1
  157. data/test/rubygems/test_gem_commands_server_command.rb +4 -46
  158. data/test/rubygems/test_gem_commands_setup_command.rb +17 -0
  159. data/test/rubygems/test_gem_commands_update_command.rb +2 -2
  160. data/test/rubygems/test_gem_dependency.rb +4 -8
  161. data/test/rubygems/test_gem_installer.rb +10 -5
  162. data/test/rubygems/test_gem_path_support.rb +2 -6
  163. data/test/rubygems/test_gem_remote_fetcher.rb +15 -0
  164. data/test/rubygems/test_gem_requirement.rb +0 -1
  165. data/test/rubygems/test_gem_security.rb +1 -1
  166. data/test/rubygems/test_gem_specification.rb +16 -25
  167. data/test/rubygems/test_gem_stream_ui.rb +1 -1
  168. data/test/rubygems/test_gem_text.rb +6 -0
  169. data/test/rubygems/test_kernel.rb +1 -13
  170. data/test/rubygems/test_project_sanity.rb +1 -1
  171. data/test/rubygems/test_require.rb +4 -58
  172. data/test/rubygems/test_rubygems.rb +23 -0
  173. metadata +14 -8
  174. data/bundler/lib/bundler/gemdeps.rb +0 -29
  175. data/lib/rubygems/server.rb +0 -882
  176. data/test/rubygems/bogussources.rb +0 -9
  177. data/test/rubygems/test_gem_server.rb +0 -608
data/lib/rubygems.rb CHANGED
@@ -8,7 +8,7 @@
8
8
  require 'rbconfig'
9
9
 
10
10
  module Gem
11
- VERSION = "3.2.32".freeze
11
+ VERSION = "3.3.2".freeze
12
12
  end
13
13
 
14
14
  # Must be first since it unloads the prelude from 1.9.2
@@ -163,16 +163,6 @@ module Gem
163
163
  specifications/default
164
164
  ].freeze
165
165
 
166
- ##
167
- # Exception classes used in a Gem.read_binary +rescue+ statement
168
-
169
- READ_BINARY_ERRORS = [Errno::EACCES, Errno::EROFS, Errno::ENOSYS, Errno::ENOTSUP].freeze
170
-
171
- ##
172
- # Exception classes used in Gem.write_binary +rescue+ statement
173
-
174
- WRITE_BINARY_ERRORS = [Errno::ENOSYS, Errno::ENOTSUP].freeze
175
-
176
166
  @@win_platform = nil
177
167
 
178
168
  @configuration = nil
@@ -272,9 +262,6 @@ module Gem
272
262
 
273
263
  unless spec = specs.first
274
264
  msg = "can't find gem #{dep} with executable #{exec_name}"
275
- if dep.filters_bundler? && bundler_message = Gem::BundlerVersionFinder.missing_version_message
276
- msg = bundler_message
277
- end
278
265
  raise Gem::GemNotFoundException, msg
279
266
  end
280
267
 
@@ -779,40 +766,42 @@ An Array (#{env.inspect}) was passed in from #{caller[3]}
779
766
  # Safely read a file in binary mode on all platforms.
780
767
 
781
768
  def self.read_binary(path)
782
- File.open path, 'rb+' do |f|
783
- f.flock(File::LOCK_EX)
784
- f.read
769
+ open_with_flock(path, 'rb+') do |io|
770
+ io.read
785
771
  end
786
- rescue *READ_BINARY_ERRORS
787
- File.open path, 'rb' do |f|
788
- f.read
789
- end
790
- rescue Errno::ENOLCK # NFS
791
- if Thread.main != Thread.current
792
- raise
793
- else
794
- File.open path, 'rb' do |f|
795
- f.read
796
- end
772
+ rescue Errno::EACCES, Errno::EROFS
773
+ open_with_flock(path, 'rb') do |io|
774
+ io.read
797
775
  end
798
776
  end
799
777
 
800
778
  ##
801
779
  # Safely write a file in binary mode on all platforms.
802
780
  def self.write_binary(path, data)
803
- File.open(path, 'wb') do |io|
804
- begin
805
- io.flock(File::LOCK_EX)
806
- rescue *WRITE_BINARY_ERRORS
807
- end
781
+ open_with_flock(path, 'wb') do |io|
808
782
  io.write data
809
783
  end
784
+ end
785
+
786
+ ##
787
+ # Open a file with given flags, and protect access with flock
788
+
789
+ def self.open_with_flock(path, flags, &block)
790
+ File.open(path, flags) do |io|
791
+ unless java_platform?
792
+ begin
793
+ io.flock(File::LOCK_EX)
794
+ rescue Errno::ENOSYS, Errno::ENOTSUP
795
+ end
796
+ end
797
+ yield io
798
+ end
810
799
  rescue Errno::ENOLCK # NFS
811
800
  if Thread.main != Thread.current
812
801
  raise
813
802
  else
814
- File.open(path, 'wb') do |io|
815
- io.write data
803
+ File.open(path, flags) do |io|
804
+ yield io
816
805
  end
817
806
  end
818
807
  end
@@ -854,7 +843,7 @@ An Array (#{env.inspect}) was passed in from #{caller[3]}
854
843
  fetcher = Gem::SpecFetcher.fetcher
855
844
  spec_tuples, = fetcher.spec_for_dependency dependency
856
845
 
857
- spec, = spec_tuples.first
846
+ spec, = spec_tuples.last
858
847
 
859
848
  spec
860
849
  end
@@ -1293,7 +1282,12 @@ An Array (#{env.inspect}) was passed in from #{caller[3]}
1293
1282
  end
1294
1283
 
1295
1284
  def default_gem_load_paths
1296
- @default_gem_load_paths ||= $LOAD_PATH[load_path_insert_index..-1]
1285
+ @default_gem_load_paths ||= $LOAD_PATH[load_path_insert_index..-1].map do |lp|
1286
+ expanded = File.expand_path(lp)
1287
+ next expanded unless File.exist?(expanded)
1288
+
1289
+ File.realpath(expanded)
1290
+ end
1297
1291
  end
1298
1292
  end
1299
1293
 
@@ -1310,37 +1304,19 @@ An Array (#{env.inspect}) was passed in from #{caller[3]}
1310
1304
  autoload :Licenses, File.expand_path('rubygems/util/licenses', __dir__)
1311
1305
  autoload :NameTuple, File.expand_path('rubygems/name_tuple', __dir__)
1312
1306
  autoload :PathSupport, File.expand_path('rubygems/path_support', __dir__)
1313
- autoload :Platform, File.expand_path('rubygems/platform', __dir__)
1314
1307
  autoload :RequestSet, File.expand_path('rubygems/request_set', __dir__)
1315
- autoload :Requirement, File.expand_path('rubygems/requirement', __dir__)
1316
1308
  autoload :Resolver, File.expand_path('rubygems/resolver', __dir__)
1317
1309
  autoload :Source, File.expand_path('rubygems/source', __dir__)
1318
1310
  autoload :SourceList, File.expand_path('rubygems/source_list', __dir__)
1319
1311
  autoload :SpecFetcher, File.expand_path('rubygems/spec_fetcher', __dir__)
1320
- autoload :Specification, File.expand_path('rubygems/specification', __dir__)
1321
1312
  autoload :Util, File.expand_path('rubygems/util', __dir__)
1322
1313
  autoload :Version, File.expand_path('rubygems/version', __dir__)
1323
1314
  end
1324
1315
 
1325
1316
  require_relative 'rubygems/exceptions'
1317
+ require_relative 'rubygems/specification'
1326
1318
 
1327
1319
  # REFACTOR: This should be pulled out into some kind of hacks file.
1328
- begin
1329
- ##
1330
- # Defaults the Ruby implementation wants to provide for RubyGems
1331
-
1332
- require "rubygems/defaults/#{RUBY_ENGINE}"
1333
- rescue LoadError
1334
- end
1335
-
1336
- ##
1337
- # Loads the default specs.
1338
- Gem::Specification.load_defaults
1339
-
1340
- require_relative 'rubygems/core_ext/kernel_gem'
1341
- require_relative 'rubygems/core_ext/kernel_require'
1342
- require_relative 'rubygems/core_ext/kernel_warn'
1343
-
1344
1320
  begin
1345
1321
  ##
1346
1322
  # Defaults the operating system (or packager) wants to provide for RubyGems.
@@ -1356,3 +1332,19 @@ rescue StandardError => e
1356
1332
  "the problem and ask for help."
1357
1333
  raise e.class, msg
1358
1334
  end
1335
+
1336
+ begin
1337
+ ##
1338
+ # Defaults the Ruby implementation wants to provide for RubyGems
1339
+
1340
+ require "rubygems/defaults/#{RUBY_ENGINE}"
1341
+ rescue LoadError
1342
+ end
1343
+
1344
+ ##
1345
+ # Loads the default specs.
1346
+ Gem::Specification.load_defaults
1347
+
1348
+ require_relative 'rubygems/core_ext/kernel_gem'
1349
+ require_relative 'rubygems/core_ext/kernel_require'
1350
+ require_relative 'rubygems/core_ext/kernel_warn'
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = "rubygems-update"
5
- s.version = "3.2.32"
5
+ s.version = "3.3.2"
6
6
  s.authors = ["Jim Weirich", "Chad Fowler", "Eric Hodel", "Luis Lavena", "Aaron Patterson", "Samuel Giddins", "André Arko", "Evan Phoenix", "Hiroshi SHIBATA"]
7
7
  s.email = ["", "", "drbrain@segment7.net", "luislavena@gmail.com", "aaron@tenderlovemaking.com", "segiddins@segiddins.me", "andre@arko.net", "evan@phx.io", "hsbt@ruby-lang.org"]
8
8
 
data/setup.rb CHANGED
@@ -21,7 +21,6 @@ Dir.chdir File.dirname(__FILE__)
21
21
  $:.unshift File.expand_path('lib')
22
22
  require 'rubygems'
23
23
  require 'rubygems/gem_runner'
24
- require 'rubygems/exceptions'
25
24
 
26
25
  Gem::CommandManager.instance.register_command :setup
27
26
 
@@ -31,8 +30,4 @@ if ENV["GEM_PREV_VER"]
31
30
  end
32
31
  args.unshift 'setup'
33
32
 
34
- begin
35
- Gem::GemRunner.new.run args
36
- rescue Gem::SystemExitException => e
37
- exit e.exit_code
38
- end
33
+ Gem::GemRunner.new.run args
@@ -143,15 +143,13 @@ class Gem::TestCase < Test::Unit::TestCase
143
143
 
144
144
  return captured_stdout.read, captured_stderr.read
145
145
  ensure
146
- captured_stdout.unlink
147
- captured_stderr.unlink
148
146
  $stdout.reopen orig_stdout
149
147
  $stderr.reopen orig_stderr
150
148
 
151
149
  orig_stdout.close
152
150
  orig_stderr.close
153
- captured_stdout.close
154
- captured_stderr.close
151
+ captured_stdout.close!
152
+ captured_stderr.close!
155
153
  end
156
154
  end
157
155
  end
@@ -591,7 +589,7 @@ class Gem::TestCase < Test::Unit::TestCase
591
589
  def have_git?
592
590
  return if in_path? @git
593
591
 
594
- skip 'cannot find git executable, use GIT environment variable to set'
592
+ pend 'cannot find git executable, use GIT environment variable to set'
595
593
  end
596
594
 
597
595
  def in_path?(executable) # :nodoc:
@@ -1302,6 +1300,22 @@ Also, a list:
1302
1300
  Gem.instance_variable_set :@ruby, orig_ruby
1303
1301
  end
1304
1302
 
1303
+ def with_internal_encoding(encoding)
1304
+ int_enc = Encoding.default_internal
1305
+ silence_warnings { Encoding.default_internal = encoding }
1306
+
1307
+ yield
1308
+ ensure
1309
+ silence_warnings { Encoding.default_internal = int_enc }
1310
+ end
1311
+
1312
+ def silence_warnings
1313
+ old_verbose, $VERBOSE = $VERBOSE, false
1314
+ yield
1315
+ ensure
1316
+ $VERBOSE = old_verbose
1317
+ end
1318
+
1305
1319
  class << self
1306
1320
  # :nodoc:
1307
1321
  ##
@@ -1589,7 +1603,7 @@ class Object
1589
1603
  metaclass.send :undef_method, name
1590
1604
  metaclass.send :alias_method, name, new_name
1591
1605
  metaclass.send :undef_method, new_name
1592
- end
1606
+ end unless method_defined?(:stub) # lib/resolv/test_dns.rb also has the same method definition
1593
1607
  end
1594
1608
 
1595
1609
  require_relative 'utilities'
@@ -12,14 +12,14 @@ class TestConfig < Gem::TestCase
12
12
  end
13
13
 
14
14
  def test_good_rake_path_is_escaped
15
- path = Gem::TestCase.class_eval('@@good_rake')
15
+ path = Gem::TestCase.class_variable_get(:@@good_rake)
16
16
  ruby, rake = path.shellsplit
17
17
  assert_equal(Gem.ruby, ruby)
18
18
  assert_match(/\/good_rake.rb\z/, rake)
19
19
  end
20
20
 
21
21
  def test_bad_rake_path_is_escaped
22
- path = Gem::TestCase.class_eval('@@bad_rake')
22
+ path = Gem::TestCase.class_variable_get(:@@bad_rake)
23
23
  ruby, rake = path.shellsplit
24
24
  assert_equal(Gem.ruby, ruby)
25
25
  assert_match(/\/bad_rake.rb\z/, rake)
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'helper'
4
+ require 'rubygems'
5
+
6
+ class TestExit < Gem::TestCase
7
+ def test_exit
8
+ system(*ruby_with_rubygems_in_load_path, "-e", "raise Gem::SystemExitException.new(2)")
9
+ assert_equal 2, $?.exitstatus
10
+ end
11
+ end
@@ -354,41 +354,6 @@ class TestGem < Gem::TestCase
354
354
  assert status.success?, output
355
355
  end
356
356
 
357
- def test_activate_bin_path_gives_proper_error_for_bundler
358
- bundler = util_spec 'bundler', '2' do |s|
359
- s.executables = ['bundle']
360
- end
361
-
362
- install_specs bundler
363
-
364
- File.open("Gemfile.lock", "w") do |f|
365
- f.write <<-L.gsub(/ {8}/, "")
366
- GEM
367
- remote: https://rubygems.org/
368
- specs:
369
-
370
- PLATFORMS
371
- ruby
372
-
373
- DEPENDENCIES
374
-
375
- BUNDLED WITH
376
- 9999
377
- L
378
- end
379
-
380
- File.open("Gemfile", "w") {|f| f.puts('source "https://rubygems.org"') }
381
-
382
- e = assert_raise Gem::GemNotFoundException do
383
- load Gem.activate_bin_path("bundler", "bundle", ">= 0.a")
384
- end
385
-
386
- assert_includes e.message, "Could not find 'bundler' (9999) required by your #{File.expand_path("Gemfile.lock")}."
387
- assert_includes e.message, "To update to the latest version installed on your system, run `bundle update --bundler`."
388
- assert_includes e.message, "To install the missing version, run `gem install bundler:9999`"
389
- refute_includes e.message, "can't find gem bundler (>= 0.a) with executable bundle"
390
- end
391
-
392
357
  def test_activate_bin_path_selects_exact_bundler_version_if_present
393
358
  bundler_latest = util_spec 'bundler', '2.0.1' do |s|
394
359
  s.executables = ['bundle']
@@ -888,6 +853,27 @@ class TestGem < Gem::TestCase
888
853
  assert_equal gems['a-2'], spec
889
854
  end
890
855
 
856
+ def test_self_latest_spec_for_multiple_sources
857
+ uri = 'https://example.sample.com/'
858
+ source = Gem::Source.new(uri)
859
+ source_list = Gem::SourceList.new
860
+ source_list << Gem::Source.new(@uri)
861
+ source_list << source
862
+ Gem.sources.replace source_list
863
+
864
+ spec_fetcher(uri) do |fetcher|
865
+ fetcher.spec 'a', 1.1
866
+ end
867
+
868
+ gems = spec_fetcher do |fetcher|
869
+ fetcher.spec 'a', 1
870
+ fetcher.spec 'a', '3.a'
871
+ fetcher.spec 'a', 2
872
+ end
873
+ spec = Gem.latest_spec_for 'a'
874
+ assert_equal gems['a-2'], spec
875
+ end
876
+
891
877
  def test_self_latest_rubygems_version
892
878
  spec_fetcher do |fetcher|
893
879
  fetcher.spec 'rubygems-update', '1.8.23'
@@ -912,6 +898,29 @@ class TestGem < Gem::TestCase
912
898
  assert_equal Gem::Version.new(2), version
913
899
  end
914
900
 
901
+ def test_self_latest_version_for_multiple_sources
902
+ uri = 'https://example.sample.com/'
903
+ source = Gem::Source.new(uri)
904
+ source_list = Gem::SourceList.new
905
+ source_list << Gem::Source.new(@uri)
906
+ source_list << source
907
+ Gem.sources.replace source_list
908
+
909
+ spec_fetcher(uri) do |fetcher|
910
+ fetcher.spec 'a', 1.1
911
+ end
912
+
913
+ spec_fetcher do |fetcher|
914
+ fetcher.spec 'a', 1
915
+ fetcher.spec 'a', 2
916
+ fetcher.spec 'a', '3.a'
917
+ end
918
+
919
+ version = Gem.latest_version_for 'a'
920
+
921
+ assert_equal Gem::Version.new(2), version
922
+ end
923
+
915
924
  def test_self_loaded_specs
916
925
  foo = util_spec 'foo'
917
926
  install_gem foo
@@ -921,56 +930,17 @@ class TestGem < Gem::TestCase
921
930
  assert_equal true, Gem.loaded_specs.keys.include?('foo')
922
931
  end
923
932
 
924
- def util_path
925
- ENV.delete "GEM_HOME"
926
- ENV.delete "GEM_PATH"
927
- end
928
-
929
933
  def test_self_path
930
934
  assert_equal [Gem.dir], Gem.path
931
935
  end
932
936
 
933
937
  def test_self_path_default
934
- util_path
935
-
936
- if defined?(APPLE_GEM_HOME)
937
- orig_APPLE_GEM_HOME = APPLE_GEM_HOME
938
- Object.send :remove_const, :APPLE_GEM_HOME
939
- end
938
+ ENV.delete "GEM_HOME"
939
+ ENV.delete "GEM_PATH"
940
940
 
941
941
  Gem.instance_variable_set :@paths, nil
942
942
 
943
943
  assert_equal [Gem.default_path, Gem.dir].flatten.uniq, Gem.path
944
- ensure
945
- Object.const_set :APPLE_GEM_HOME, orig_APPLE_GEM_HOME if orig_APPLE_GEM_HOME
946
- end
947
-
948
- unless win_platform?
949
- def test_self_path_APPLE_GEM_HOME
950
- util_path
951
-
952
- Gem.clear_paths
953
- apple_gem_home = File.join @tempdir, 'apple_gem_home'
954
-
955
- old, $-w = $-w, nil
956
- Object.const_set :APPLE_GEM_HOME, apple_gem_home
957
- $-w = old
958
-
959
- assert_includes Gem.path, apple_gem_home
960
- ensure
961
- Object.send :remove_const, :APPLE_GEM_HOME
962
- end
963
-
964
- def test_self_path_APPLE_GEM_HOME_GEM_PATH
965
- Gem.clear_paths
966
- ENV['GEM_PATH'] = @gemhome
967
- apple_gem_home = File.join @tempdir, 'apple_gem_home'
968
- Gem.const_set :APPLE_GEM_HOME, apple_gem_home
969
-
970
- refute Gem.path.include?(apple_gem_home)
971
- ensure
972
- Gem.send :remove_const, :APPLE_GEM_HOME
973
- end
974
944
  end
975
945
 
976
946
  def test_self_path_ENV_PATH
@@ -48,30 +48,31 @@ class TestGemBundlerVersionFinder < Gem::TestCase
48
48
  end
49
49
 
50
50
  def test_bundler_version_with_lockfile
51
- bvf.stub(:lockfile_contents, [nil, ""]) do
51
+ bvf.stub(:lockfile_contents, "") do
52
52
  assert_nil bvf.bundler_version
53
53
  end
54
- bvf.stub(:lockfile_contents, [nil, "\n\nBUNDLED WITH\n 1.1.1.1\n"]) do
54
+ bvf.stub(:lockfile_contents, "\n\nBUNDLED WITH\n 1.1.1.1\n") do
55
55
  assert_equal v("1.1.1.1"), bvf.bundler_version
56
56
  end
57
- bvf.stub(:lockfile_contents, [nil, "\n\nBUNDLED WITH\n fjdkslfjdkslfjsldk\n"]) do
57
+ bvf.stub(:lockfile_contents, "\n\nBUNDLED WITH\n fjdkslfjdkslfjsldk\n") do
58
58
  assert_nil bvf.bundler_version
59
59
  end
60
60
  end
61
61
 
62
- def test_bundler_version_with_reason
63
- assert_nil bvf.bundler_version_with_reason
64
- bvf.stub(:lockfile_contents, [nil, "\n\nBUNDLED WITH\n 1.1.1.1\n"]) do
65
- assert_equal ["1.1.1.1", "your lockfile"], bvf.bundler_version_with_reason
62
+ def test_bundler_version
63
+ assert_nil bvf.bundler_version
64
+ bvf.stub(:lockfile_contents, "\n\nBUNDLED WITH\n 1.1.1.1\n") do
65
+ assert_equal "1.1.1.1", bvf.bundler_version.to_s
66
66
 
67
67
  $0 = "bundle"
68
68
  ARGV.replace %w[update --bundler]
69
- assert_nil bvf.bundler_version_with_reason
69
+ assert_nil bvf.bundler_version
70
+
70
71
  ARGV.replace %w[update --bundler=1.1.1.2]
71
- assert_equal ["1.1.1.2", "`bundle update --bundler`"], bvf.bundler_version_with_reason
72
+ assert_equal "1.1.1.2", bvf.bundler_version.to_s
72
73
 
73
74
  ENV["BUNDLER_VERSION"] = "1.1.1.3"
74
- assert_equal ["1.1.1.3", "`$BUNDLER_VERSION`"], bvf.bundler_version_with_reason
75
+ assert_equal "1.1.1.3", bvf.bundler_version.to_s
75
76
  end
76
77
  end
77
78
 
@@ -90,57 +91,35 @@ class TestGemBundlerVersionFinder < Gem::TestCase
90
91
  Dir.chdir(orig_dir)
91
92
  end
92
93
 
93
- assert_nil bvf.bundler_version_with_reason
94
- end
95
-
96
- def test_compatible
97
- assert bvf.compatible?(util_spec("foo"))
98
- assert bvf.compatible?(util_spec("bundler", 1.1))
99
-
100
- bvf.stub(:bundler_version, v("1.1.1.1")) do
101
- assert bvf.compatible?(util_spec("foo"))
102
- assert bvf.compatible?(util_spec("bundler", "1.1.1.1"))
103
- assert bvf.compatible?(util_spec("bundler", "1.1.1.a"))
104
- assert bvf.compatible?(util_spec("bundler", "1.999"))
105
- refute bvf.compatible?(util_spec("bundler", "2.999"))
106
- end
107
-
108
- bvf.stub(:bundler_version, v("2.1.1.1")) do
109
- assert bvf.compatible?(util_spec("foo"))
110
- assert bvf.compatible?(util_spec("bundler", "2.1.1.1"))
111
- assert bvf.compatible?(util_spec("bundler", "2.1.1.a"))
112
- assert bvf.compatible?(util_spec("bundler", "2.999"))
113
- refute bvf.compatible?(util_spec("bundler", "1.999"))
114
- refute bvf.compatible?(util_spec("bundler", "3.0.0"))
115
- end
94
+ assert_nil bvf.bundler_version
116
95
  end
117
96
 
118
- def test_filter
97
+ def test_prioritize
119
98
  versions = %w[1 1.0 1.0.1.1 2 2.a 2.0 2.1.1 3 3.a 3.0 3.1.1]
120
99
  specs = versions.map {|v| util_spec("bundler", v) }
121
100
 
122
- assert_equal %w[1 1.0 1.0.1.1 2 2.a 2.0 2.1.1 3 3.a 3.0 3.1.1], util_filter_specs(specs).map(&:version).map(&:to_s)
101
+ assert_equal %w[1 1.0 1.0.1.1 2 2.a 2.0 2.1.1 3 3.a 3.0 3.1.1], util_prioritize_specs(specs)
123
102
 
124
103
  bvf.stub(:bundler_version, v("2.1.1.1")) do
125
- assert_equal %w[2 2.a 2.0 2.1.1], util_filter_specs(specs).map(&:version).map(&:to_s)
104
+ assert_equal %w[1 1.0 1.0.1.1 2 2.a 2.0 2.1.1 3 3.a 3.0 3.1.1], util_prioritize_specs(specs)
126
105
  end
127
106
  bvf.stub(:bundler_version, v("1.1.1.1")) do
128
- assert_equal %w[1 1.0 1.0.1.1], util_filter_specs(specs).map(&:version).map(&:to_s)
107
+ assert_equal %w[1 1.0 1.0.1.1 2 2.a 2.0 2.1.1 3 3.a 3.0 3.1.1], util_prioritize_specs(specs)
129
108
  end
130
109
  bvf.stub(:bundler_version, v("1")) do
131
- assert_equal %w[1 1.0 1.0.1.1], util_filter_specs(specs).map(&:version).map(&:to_s)
110
+ assert_equal %w[1 1.0 1.0.1.1 2 2.a 2.0 2.1.1 3 3.a 3.0 3.1.1], util_prioritize_specs(specs)
132
111
  end
133
112
  bvf.stub(:bundler_version, v("2.a")) do
134
- assert_equal %w[2.a 2 2.0 2.1.1], util_filter_specs(specs).map(&:version).map(&:to_s)
113
+ assert_equal %w[2.a 1 1.0 1.0.1.1 2 2.0 2.1.1 3 3.a 3.0 3.1.1], util_prioritize_specs(specs)
135
114
  end
136
115
  bvf.stub(:bundler_version, v("3")) do
137
- assert_equal %w[3 3.a 3.0 3.1.1], util_filter_specs(specs).map(&:version).map(&:to_s)
116
+ assert_equal %w[3 1 1.0 1.0.1.1 2 2.a 2.0 2.1.1 3.a 3.0 3.1.1], util_prioritize_specs(specs)
138
117
  end
139
118
  end
140
119
 
141
- def util_filter_specs(specs)
120
+ def util_prioritize_specs(specs)
142
121
  specs = specs.dup
143
- bvf.filter!(specs)
144
- specs
122
+ bvf.prioritize!(specs)
123
+ specs.map(&:version).map(&:to_s)
145
124
  end
146
125
  end
@@ -36,6 +36,18 @@ class TestGemCommandManager < Gem::TestCase
36
36
  assert_kind_of Gem::Commands::InstallCommand, command
37
37
  end
38
38
 
39
+ def test_find_login_alias_command
40
+ command = @command_manager.find_command 'login'
41
+
42
+ assert_kind_of Gem::Commands::SigninCommand, command
43
+ end
44
+
45
+ def test_find_logout_alias_comamnd
46
+ command = @command_manager.find_command 'logout'
47
+
48
+ assert_kind_of Gem::Commands::SignoutCommand, command
49
+ end
50
+
39
51
  def test_find_command_ambiguous_exact
40
52
  ins_command = Class.new
41
53
  Gem::Commands.send :const_set, :InsCommand, ins_command
@@ -50,13 +62,27 @@ class TestGemCommandManager < Gem::TestCase
50
62
  end
51
63
 
52
64
  def test_find_command_unknown
53
- e = assert_raise Gem::CommandLineError do
65
+ e = assert_raise Gem::UnknownCommandError do
54
66
  @command_manager.find_command 'xyz'
55
67
  end
56
68
 
57
69
  assert_equal 'Unknown command xyz', e.message
58
70
  end
59
71
 
72
+ def test_find_command_unknown_suggestions
73
+ e = assert_raise Gem::UnknownCommandError do
74
+ @command_manager.find_command 'pish'
75
+ end
76
+
77
+ message = 'Unknown command pish'.dup
78
+
79
+ if RUBY_VERSION >= "2.4" && defined?(DidYouMean::SPELL_CHECKERS) && defined?(DidYouMean::Correctable)
80
+ message << "\nDid you mean? \"push\""
81
+ end
82
+
83
+ assert_equal message, e.message
84
+ end
85
+
60
86
  def test_run_interrupt
61
87
  old_load_path = $:.dup
62
88
  $: << File.expand_path("test/rubygems", PROJECT_DIR)
@@ -265,7 +291,7 @@ class TestGemCommandManager < Gem::TestCase
265
291
 
266
292
  #check defaults
267
293
  @command_manager.process_args %w[update]
268
- assert_includes check_options[:document], 'rdoc'
294
+ assert_includes check_options[:document], 'ri'
269
295
 
270
296
  #check settings
271
297
  check_options = nil
@@ -782,6 +782,39 @@ ERROR: Possible alternatives: non_existent_with_hint
782
782
  assert_match "1 gem installed", @ui.output
783
783
  end
784
784
 
785
+ def test_execute_remote_truncates_existing_gemspecs
786
+ spec_fetcher do |fetcher|
787
+ fetcher.gem 'a', 1
788
+ end
789
+
790
+ @cmd.options[:domain] = :remote
791
+
792
+ @cmd.options[:args] = %w[a]
793
+
794
+ use_ui @ui do
795
+ assert_raise Gem::MockGemUi::SystemExitException, @ui.error do
796
+ @cmd.execute
797
+ end
798
+ end
799
+
800
+ assert_equal %w[a-1], @cmd.installed_specs.map {|spec| spec.full_name }
801
+ assert_match "1 gem installed", @ui.output
802
+
803
+ a1_gemspec = File.join(@gemhome, 'specifications', "a-1.gemspec")
804
+
805
+ initial_a1_gemspec_content = File.read(a1_gemspec)
806
+ modified_a1_gemspec_content = initial_a1_gemspec_content + "\n # AAAAAAA\n"
807
+ File.write(a1_gemspec, modified_a1_gemspec_content)
808
+
809
+ use_ui @ui do
810
+ assert_raise Gem::MockGemUi::SystemExitException, @ui.error do
811
+ @cmd.execute
812
+ end
813
+ end
814
+
815
+ assert_equal initial_a1_gemspec_content, File.read(a1_gemspec)
816
+ end
817
+
785
818
  def test_execute_remote_ignores_files
786
819
  specs = spec_fetcher do |fetcher|
787
820
  fetcher.gem 'a', 1
@@ -21,7 +21,7 @@ class TestGemCommandsOpenCommand < Gem::TestCase
21
21
 
22
22
  def test_execute
23
23
  @cmd.options[:args] = %w[foo]
24
- @cmd.options[:editor] = "#{Gem.ruby} -e0 --"
24
+ @cmd.options[:editor] = "#{ruby_with_rubygems_in_load_path} -eexit --"
25
25
 
26
26
  gem 'foo', '1.0.0'
27
27
  spec = gem 'foo', '1.0.1'