rubygems-update 3.2.17 → 3.2.18

Sign up to get free protection for your applications and to get access to all the features.
Files changed (152) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +7 -0
  3. data/Manifest.txt +2 -0
  4. data/Rakefile +1 -6
  5. data/bundler/CHANGELOG.md +16 -0
  6. data/bundler/bundler.gemspec +2 -3
  7. data/bundler/lib/bundler.rb +1 -0
  8. data/bundler/lib/bundler/build_metadata.rb +2 -2
  9. data/bundler/lib/bundler/cli.rb +13 -33
  10. data/bundler/lib/bundler/cli/outdated.rb +7 -10
  11. data/bundler/lib/bundler/definition.rb +14 -75
  12. data/bundler/lib/bundler/feature_flag.rb +0 -1
  13. data/bundler/lib/bundler/friendly_errors.rb +1 -1
  14. data/bundler/lib/bundler/index.rb +1 -2
  15. data/bundler/lib/bundler/man/bundle-add.1 +1 -1
  16. data/bundler/lib/bundler/man/bundle-binstubs.1 +1 -1
  17. data/bundler/lib/bundler/man/bundle-cache.1 +1 -1
  18. data/bundler/lib/bundler/man/bundle-check.1 +1 -1
  19. data/bundler/lib/bundler/man/bundle-clean.1 +1 -1
  20. data/bundler/lib/bundler/man/bundle-config.1 +1 -7
  21. data/bundler/lib/bundler/man/bundle-config.1.ronn +0 -8
  22. data/bundler/lib/bundler/man/bundle-doctor.1 +1 -1
  23. data/bundler/lib/bundler/man/bundle-exec.1 +1 -1
  24. data/bundler/lib/bundler/man/bundle-gem.1 +1 -1
  25. data/bundler/lib/bundler/man/bundle-info.1 +1 -1
  26. data/bundler/lib/bundler/man/bundle-init.1 +1 -1
  27. data/bundler/lib/bundler/man/bundle-inject.1 +1 -1
  28. data/bundler/lib/bundler/man/bundle-install.1 +1 -1
  29. data/bundler/lib/bundler/man/bundle-list.1 +1 -1
  30. data/bundler/lib/bundler/man/bundle-lock.1 +1 -1
  31. data/bundler/lib/bundler/man/bundle-open.1 +1 -1
  32. data/bundler/lib/bundler/man/bundle-outdated.1 +1 -1
  33. data/bundler/lib/bundler/man/bundle-platform.1 +1 -1
  34. data/bundler/lib/bundler/man/bundle-pristine.1 +1 -1
  35. data/bundler/lib/bundler/man/bundle-remove.1 +1 -1
  36. data/bundler/lib/bundler/man/bundle-show.1 +1 -1
  37. data/bundler/lib/bundler/man/bundle-update.1 +1 -1
  38. data/bundler/lib/bundler/man/bundle-viz.1 +1 -1
  39. data/bundler/lib/bundler/man/bundle.1 +1 -1
  40. data/bundler/lib/bundler/man/gemfile.5 +1 -1
  41. data/bundler/lib/bundler/plugin/api/source.rb +14 -0
  42. data/bundler/lib/bundler/resolver.rb +13 -96
  43. data/bundler/lib/bundler/resolver/spec_group.rb +0 -24
  44. data/bundler/lib/bundler/rubygems_ext.rb +2 -2
  45. data/bundler/lib/bundler/settings.rb +0 -1
  46. data/bundler/lib/bundler/source.rb +9 -0
  47. data/bundler/lib/bundler/source/rubygems.rb +15 -4
  48. data/bundler/lib/bundler/source/rubygems_aggregate.rb +64 -0
  49. data/bundler/lib/bundler/source_list.rb +29 -10
  50. data/bundler/lib/bundler/source_map.rb +58 -0
  51. data/bundler/lib/bundler/templates/newgem/newgem.gemspec.tt +1 -1
  52. data/bundler/lib/bundler/version.rb +1 -1
  53. data/lib/rubygems.rb +1 -1
  54. data/lib/rubygems/ext/ext_conf_builder.rb +4 -4
  55. data/lib/rubygems/specification.rb +0 -2
  56. data/lib/rubygems/test_case.rb +102 -18
  57. data/rubygems-update.gemspec +1 -1
  58. data/test/rubygems/test_bundled_ca.rb +2 -2
  59. data/test/rubygems/test_deprecate.rb +3 -3
  60. data/test/rubygems/test_gem.rb +33 -31
  61. data/test/rubygems/test_gem_bundler_version_finder.rb +2 -2
  62. data/test/rubygems/test_gem_command.rb +1 -1
  63. data/test/rubygems/test_gem_command_manager.rb +5 -5
  64. data/test/rubygems/test_gem_commands_build_command.rb +10 -10
  65. data/test/rubygems/test_gem_commands_cert_command.rb +36 -36
  66. data/test/rubygems/test_gem_commands_check_command.rb +5 -5
  67. data/test/rubygems/test_gem_commands_cleanup_command.rb +24 -24
  68. data/test/rubygems/test_gem_commands_contents_command.rb +3 -3
  69. data/test/rubygems/test_gem_commands_dependency_command.rb +2 -2
  70. data/test/rubygems/test_gem_commands_environment_command.rb +1 -1
  71. data/test/rubygems/test_gem_commands_fetch_command.rb +9 -9
  72. data/test/rubygems/test_gem_commands_help_command.rb +1 -1
  73. data/test/rubygems/test_gem_commands_install_command.rb +60 -60
  74. data/test/rubygems/test_gem_commands_list_command.rb +1 -1
  75. data/test/rubygems/test_gem_commands_lock_command.rb +1 -1
  76. data/test/rubygems/test_gem_commands_open_command.rb +8 -9
  77. data/test/rubygems/test_gem_commands_owner_command.rb +3 -3
  78. data/test/rubygems/test_gem_commands_pristine_command.rb +14 -14
  79. data/test/rubygems/test_gem_commands_push_command.rb +6 -6
  80. data/test/rubygems/test_gem_commands_query_command.rb +7 -7
  81. data/test/rubygems/test_gem_commands_server_command.rb +2 -2
  82. data/test/rubygems/test_gem_commands_setup_command.rb +21 -21
  83. data/test/rubygems/test_gem_commands_signin_command.rb +6 -6
  84. data/test/rubygems/test_gem_commands_sources_command.rb +5 -5
  85. data/test/rubygems/test_gem_commands_specification_command.rb +6 -6
  86. data/test/rubygems/test_gem_commands_uninstall_command.rb +4 -4
  87. data/test/rubygems/test_gem_commands_unpack_command.rb +2 -2
  88. data/test/rubygems/test_gem_commands_update_command.rb +10 -10
  89. data/test/rubygems/test_gem_commands_which_command.rb +3 -3
  90. data/test/rubygems/test_gem_commands_yank_command.rb +1 -1
  91. data/test/rubygems/test_gem_config_file.rb +9 -9
  92. data/test/rubygems/test_gem_dependency.rb +6 -6
  93. data/test/rubygems/test_gem_dependency_installer.rb +4 -4
  94. data/test/rubygems/test_gem_doctor.rb +30 -30
  95. data/test/rubygems/test_gem_ext_builder.rb +20 -20
  96. data/test/rubygems/test_gem_ext_cmake_builder.rb +4 -4
  97. data/test/rubygems/test_gem_ext_configure_builder.rb +4 -4
  98. data/test/rubygems/test_gem_ext_ext_conf_builder.rb +14 -13
  99. data/test/rubygems/test_gem_ext_rake_builder.rb +1 -1
  100. data/test/rubygems/test_gem_gemcutter_utilities.rb +8 -8
  101. data/test/rubygems/test_gem_install_update_options.rb +9 -9
  102. data/test/rubygems/test_gem_installer.rb +142 -140
  103. data/test/rubygems/test_gem_local_remote_options.rb +1 -1
  104. data/test/rubygems/test_gem_package.rb +48 -48
  105. data/test/rubygems/test_gem_package_old.rb +9 -9
  106. data/test/rubygems/test_gem_package_tar_header.rb +5 -5
  107. data/test/rubygems/test_gem_package_tar_reader_entry.rb +8 -8
  108. data/test/rubygems/test_gem_package_tar_writer.rb +18 -20
  109. data/test/rubygems/test_gem_package_task.rb +2 -2
  110. data/test/rubygems/test_gem_path_support.rb +1 -1
  111. data/test/rubygems/test_gem_rdoc.rb +9 -9
  112. data/test/rubygems/test_gem_remote_fetcher.rb +17 -18
  113. data/test/rubygems/test_gem_request.rb +2 -2
  114. data/test/rubygems/test_gem_request_connection_pools.rb +1 -1
  115. data/test/rubygems/test_gem_request_set.rb +15 -14
  116. data/test/rubygems/test_gem_request_set_gem_dependency_api.rb +16 -16
  117. data/test/rubygems/test_gem_request_set_lockfile.rb +3 -3
  118. data/test/rubygems/test_gem_request_set_lockfile_parser.rb +3 -3
  119. data/test/rubygems/test_gem_request_set_lockfile_tokenizer.rb +4 -4
  120. data/test/rubygems/test_gem_requirement.rb +13 -13
  121. data/test/rubygems/test_gem_resolver.rb +11 -11
  122. data/test/rubygems/test_gem_resolver_best_set.rb +1 -1
  123. data/test/rubygems/test_gem_resolver_git_set.rb +1 -1
  124. data/test/rubygems/test_gem_resolver_git_specification.rb +2 -2
  125. data/test/rubygems/test_gem_resolver_index_specification.rb +1 -1
  126. data/test/rubygems/test_gem_resolver_installer_set.rb +4 -4
  127. data/test/rubygems/test_gem_resolver_local_specification.rb +1 -1
  128. data/test/rubygems/test_gem_resolver_specification.rb +1 -1
  129. data/test/rubygems/test_gem_resolver_vendor_set.rb +2 -2
  130. data/test/rubygems/test_gem_security.rb +5 -5
  131. data/test/rubygems/test_gem_security_policy.rb +27 -27
  132. data/test/rubygems/test_gem_security_signer.rb +7 -7
  133. data/test/rubygems/test_gem_security_trust_dir.rb +4 -4
  134. data/test/rubygems/test_gem_server.rb +2 -2
  135. data/test/rubygems/test_gem_silent_ui.rb +9 -9
  136. data/test/rubygems/test_gem_source.rb +2 -2
  137. data/test/rubygems/test_gem_source_fetch_problem.rb +1 -1
  138. data/test/rubygems/test_gem_source_git.rb +11 -11
  139. data/test/rubygems/test_gem_source_specific_file.rb +1 -1
  140. data/test/rubygems/test_gem_spec_fetcher.rb +1 -1
  141. data/test/rubygems/test_gem_specification.rb +83 -103
  142. data/test/rubygems/test_gem_stream_ui.rb +1 -1
  143. data/test/rubygems/test_gem_stub_specification.rb +4 -4
  144. data/test/rubygems/test_gem_uninstaller.rb +16 -16
  145. data/test/rubygems/test_gem_util.rb +8 -6
  146. data/test/rubygems/test_gem_version.rb +4 -13
  147. data/test/rubygems/test_kernel.rb +4 -4
  148. data/test/rubygems/test_project_sanity.rb +1 -1
  149. data/test/rubygems/test_remote_fetch_error.rb +1 -1
  150. data/test/rubygems/test_require.rb +13 -13
  151. data/test/test_changelog_generator.rb +1 -2
  152. metadata +5 -3
@@ -105,7 +105,7 @@ module Gem
105
105
  end
106
106
 
107
107
  class Dependency
108
- attr_accessor :source, :groups, :all_sources
108
+ attr_accessor :source, :groups
109
109
 
110
110
  alias_method :eql?, :==
111
111
 
@@ -116,7 +116,7 @@ module Gem
116
116
  end
117
117
 
118
118
  def to_yaml_properties
119
- instance_variables.reject {|p| ["@source", "@groups", "@all_sources"].include?(p.to_s) }
119
+ instance_variables.reject {|p| ["@source", "@groups"].include?(p.to_s) }
120
120
  end
121
121
 
122
122
  def to_lock
@@ -21,7 +21,6 @@ module Bundler
21
21
  disable_exec_load
22
22
  disable_local_branch_check
23
23
  disable_local_revision_check
24
- disable_multisource
25
24
  disable_shared_gems
26
25
  disable_version_check
27
26
  force_ruby_platform
@@ -7,6 +7,7 @@ module Bundler
7
7
  autoload :Metadata, File.expand_path("source/metadata", __dir__)
8
8
  autoload :Path, File.expand_path("source/path", __dir__)
9
9
  autoload :Rubygems, File.expand_path("source/rubygems", __dir__)
10
+ autoload :RubygemsAggregate, File.expand_path("source/rubygems_aggregate", __dir__)
10
11
 
11
12
  attr_accessor :dependency_names
12
13
 
@@ -39,6 +40,10 @@ module Bundler
39
40
 
40
41
  def remote!; end
41
42
 
43
+ def add_dependency_names(names)
44
+ @dependency_names = Array(dependency_names) | Array(names)
45
+ end
46
+
42
47
  # it's possible that gems from one source depend on gems from some
43
48
  # other source, so now we download gemspecs and iterate over those
44
49
  # dependencies, looking for gems we don't have info on yet.
@@ -48,6 +53,10 @@ module Bundler
48
53
  specs.dependency_names
49
54
  end
50
55
 
56
+ def spec_names
57
+ specs.spec_names
58
+ end
59
+
51
60
  def include?(other)
52
61
  other == self
53
62
  end
@@ -259,8 +259,16 @@ module Bundler
259
259
  !equivalent
260
260
  end
261
261
 
262
+ def spec_names
263
+ if @allow_remote && dependency_api_available?
264
+ remote_specs.spec_names
265
+ else
266
+ []
267
+ end
268
+ end
269
+
262
270
  def unmet_deps
263
- if @allow_remote && api_fetchers.any?
271
+ if @allow_remote && dependency_api_available?
264
272
  remote_specs.unmet_dependency_names
265
273
  else
266
274
  []
@@ -276,7 +284,7 @@ module Bundler
276
284
 
277
285
  def double_check_for(unmet_dependency_names)
278
286
  return unless @allow_remote
279
- return unless api_fetchers.any?
287
+ return unless dependency_api_available?
280
288
 
281
289
  unmet_dependency_names = unmet_dependency_names.call
282
290
  unless unmet_dependency_names.nil?
@@ -298,17 +306,20 @@ module Bundler
298
306
  remote_specs.each do |spec|
299
307
  case spec
300
308
  when EndpointSpecification, Gem::Specification, StubSpecification, LazySpecification
301
- names.concat(spec.runtime_dependencies)
309
+ names.concat(spec.runtime_dependencies.map(&:name))
302
310
  when RemoteSpecification # from the full index
303
311
  return nil
304
312
  else
305
313
  raise "unhandled spec type (#{spec.inspect})"
306
314
  end
307
315
  end
308
- names.map!(&:name) if names
309
316
  names
310
317
  end
311
318
 
319
+ def dependency_api_available?
320
+ api_fetchers.any?
321
+ end
322
+
312
323
  protected
313
324
 
314
325
  def credless_remotes
@@ -0,0 +1,64 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Bundler
4
+ class Source
5
+ class RubygemsAggregate
6
+ attr_reader :source_map, :sources
7
+
8
+ def initialize(sources, source_map)
9
+ @sources = sources
10
+ @source_map = source_map
11
+
12
+ @index = build_index
13
+ end
14
+
15
+ def specs
16
+ @index
17
+ end
18
+
19
+ def to_s
20
+ "any of the sources"
21
+ end
22
+
23
+ private
24
+
25
+ def build_index
26
+ Index.build do |idx|
27
+ dependency_names = source_map.pinned_spec_names
28
+
29
+ sources.all_sources.each do |source|
30
+ source.dependency_names = dependency_names - source_map.pinned_spec_names(source)
31
+ idx.add_source source.specs
32
+ dependency_names.concat(source.unmet_deps).uniq!
33
+ end
34
+
35
+ double_check_for_index(idx, dependency_names)
36
+ end
37
+ end
38
+
39
+ # Suppose the gem Foo depends on the gem Bar. Foo exists in Source A. Bar has some versions that exist in both
40
+ # sources A and B. At this point, the API request will have found all the versions of Bar in source A,
41
+ # but will not have found any versions of Bar from source B, which is a problem if the requested version
42
+ # of Foo specifically depends on a version of Bar that is only found in source B. This ensures that for
43
+ # each spec we found, we add all possible versions from all sources to the index.
44
+ def double_check_for_index(idx, dependency_names)
45
+ pinned_names = source_map.pinned_spec_names
46
+
47
+ names = :names # do this so we only have to traverse to get dependency_names from the index once
48
+ unmet_dependency_names = lambda do
49
+ return names unless names == :names
50
+ new_names = sources.all_sources.map(&:dependency_names_to_double_check)
51
+ return names = nil if new_names.compact!
52
+ names = new_names.flatten(1).concat(dependency_names)
53
+ names.uniq!
54
+ names -= pinned_names
55
+ names
56
+ end
57
+
58
+ sources.all_sources.each do |source|
59
+ source.double_check_for(unmet_dependency_names)
60
+ end
61
+ end
62
+ end
63
+ end
64
+ end
@@ -21,15 +21,19 @@ module Bundler
21
21
  @rubygems_sources = []
22
22
  @metadata_source = Source::Metadata.new
23
23
 
24
- @disable_multisource = true
24
+ @merged_gem_lockfile_sections = false
25
25
  end
26
26
 
27
- def disable_multisource?
28
- @disable_multisource
27
+ def merged_gem_lockfile_sections?
28
+ @merged_gem_lockfile_sections
29
29
  end
30
30
 
31
31
  def merged_gem_lockfile_sections!
32
- @disable_multisource = false
32
+ @merged_gem_lockfile_sections = true
33
+ end
34
+
35
+ def no_aggregate_global_source?
36
+ global_rubygems_source.remotes.size <= 1
33
37
  end
34
38
 
35
39
  def add_path_source(options = {})
@@ -70,7 +74,11 @@ module Bundler
70
74
  end
71
75
 
72
76
  def rubygems_sources
73
- @rubygems_sources + [global_rubygems_source]
77
+ non_global_rubygems_sources + [global_rubygems_source]
78
+ end
79
+
80
+ def non_global_rubygems_sources
81
+ @rubygems_sources
74
82
  end
75
83
 
76
84
  def rubygems_remotes
@@ -81,16 +89,27 @@ module Bundler
81
89
  path_sources + git_sources + plugin_sources + rubygems_sources + [metadata_source]
82
90
  end
83
91
 
92
+ def non_default_explicit_sources
93
+ all_sources - [default_source, metadata_source]
94
+ end
95
+
84
96
  def get(source)
85
97
  source_list_for(source).find {|s| equal_source?(source, s) || equivalent_source?(source, s) }
86
98
  end
87
99
 
88
100
  def lock_sources
89
- lock_sources = (path_sources + git_sources + plugin_sources).sort_by(&:to_s)
90
- if disable_multisource?
91
- lock_sources + rubygems_sources.sort_by(&:to_s).uniq
101
+ lock_other_sources + lock_rubygems_sources
102
+ end
103
+
104
+ def lock_other_sources
105
+ (path_sources + git_sources + plugin_sources).sort_by(&:to_s)
106
+ end
107
+
108
+ def lock_rubygems_sources
109
+ if merged_gem_lockfile_sections?
110
+ [combine_rubygems_sources]
92
111
  else
93
- lock_sources << combine_rubygems_sources
112
+ rubygems_sources.sort_by(&:to_s).uniq
94
113
  end
95
114
  end
96
115
 
@@ -104,7 +123,7 @@ module Bundler
104
123
  end
105
124
  end
106
125
 
107
- replacement_rubygems = !disable_multisource? &&
126
+ replacement_rubygems = merged_gem_lockfile_sections? &&
108
127
  replacement_sources.detect {|s| s.is_a?(Source::Rubygems) }
109
128
  @global_rubygems_source = replacement_rubygems if replacement_rubygems
110
129
 
@@ -0,0 +1,58 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Bundler
4
+ class SourceMap
5
+ attr_reader :sources, :dependencies
6
+
7
+ def initialize(sources, dependencies)
8
+ @sources = sources
9
+ @dependencies = dependencies
10
+ end
11
+
12
+ def pinned_spec_names(skip = nil)
13
+ direct_requirements.reject {|_, source| source == skip }.keys
14
+ end
15
+
16
+ def all_requirements
17
+ requirements = direct_requirements.dup
18
+
19
+ unmet_deps = sources.non_default_explicit_sources.map do |source|
20
+ (source.spec_names - pinned_spec_names).each do |indirect_dependency_name|
21
+ previous_source = requirements[indirect_dependency_name]
22
+ if previous_source.nil?
23
+ requirements[indirect_dependency_name] = source
24
+ else
25
+ no_ambiguous_sources = Bundler.feature_flag.bundler_3_mode?
26
+
27
+ msg = ["The gem '#{indirect_dependency_name}' was found in multiple relevant sources."]
28
+ msg.concat [previous_source, source].map {|s| " * #{s}" }.sort
29
+ msg << "You #{no_ambiguous_sources ? :must : :should} add this gem to the source block for the source you wish it to be installed from."
30
+ msg = msg.join("\n")
31
+
32
+ raise SecurityError, msg if no_ambiguous_sources
33
+ Bundler.ui.warn "Warning: #{msg}"
34
+ end
35
+ end
36
+
37
+ source.unmet_deps
38
+ end
39
+
40
+ sources.default_source.add_dependency_names(unmet_deps.flatten - requirements.keys)
41
+
42
+ requirements
43
+ end
44
+
45
+ def direct_requirements
46
+ @direct_requirements ||= begin
47
+ requirements = {}
48
+ default = sources.default_source
49
+ dependencies.each do |dep|
50
+ dep_source = dep.source || default
51
+ dep_source.add_dependency_names(dep.name)
52
+ requirements[dep.name] = dep_source
53
+ end
54
+ requirements
55
+ end
56
+ end
57
+ end
58
+ end
@@ -14,7 +14,7 @@ Gem::Specification.new do |spec|
14
14
  <%- if config[:mit] -%>
15
15
  spec.license = "MIT"
16
16
  <%- end -%>
17
- spec.required_ruby_version = Gem::Requirement.new(">= <%= config[:required_ruby_version] %>")
17
+ spec.required_ruby_version = ">= <%= config[:required_ruby_version] %>"
18
18
 
19
19
  spec.metadata["allowed_push_host"] = "TODO: Set to 'http://mygemserver.com'"
20
20
 
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: false
2
2
 
3
3
  module Bundler
4
- VERSION = "2.2.17".freeze
4
+ VERSION = "2.2.18".freeze
5
5
 
6
6
  def self.bundler_major_version
7
7
  @bundler_major_version ||= VERSION.split(".").first.to_i
data/lib/rubygems.rb CHANGED
@@ -8,7 +8,7 @@
8
8
  require 'rbconfig'
9
9
 
10
10
  module Gem
11
- VERSION = "3.2.17".freeze
11
+ VERSION = "3.2.18".freeze
12
12
  end
13
13
 
14
14
  # Must be first since it unloads the prelude from 1.9.2
@@ -23,11 +23,11 @@ class Gem::Ext::ExtConfBuilder < Gem::Ext::Builder
23
23
  # spaces do not work.
24
24
  #
25
25
  # Details: https://github.com/rubygems/rubygems/issues/977#issuecomment-171544940
26
- tmp_dest = get_relative_path(tmp_dest, extension_dir)
26
+ tmp_dest_relative = get_relative_path(tmp_dest.clone, extension_dir)
27
27
 
28
28
  Tempfile.open %w[siteconf .rb], extension_dir do |siteconf|
29
29
  siteconf.puts "require 'rbconfig'"
30
- siteconf.puts "dest_path = #{tmp_dest.dump}"
30
+ siteconf.puts "dest_path = #{tmp_dest_relative.dump}"
31
31
  %w[sitearchdir sitelibdir].each do |dir|
32
32
  siteconf.puts "RbConfig::MAKEFILE_CONFIG['#{dir}'] = dest_path"
33
33
  siteconf.puts "RbConfig::CONFIG['#{dir}'] = dest_path"
@@ -63,8 +63,8 @@ class Gem::Ext::ExtConfBuilder < Gem::Ext::Builder
63
63
 
64
64
  make dest_path, results, extension_dir
65
65
 
66
- if tmp_dest
67
- full_tmp_dest = File.join(extension_dir, tmp_dest)
66
+ if tmp_dest_relative
67
+ full_tmp_dest = File.join(extension_dir, tmp_dest_relative)
68
68
 
69
69
  # TODO remove in RubyGems 3
70
70
  if Gem.install_extension_in_lib and lib_dir
@@ -1558,7 +1558,6 @@ class Gem::Specification < Gem::BasicSpecification
1558
1558
  def build_extensions # :nodoc:
1559
1559
  return if default_gem?
1560
1560
  return if extensions.empty?
1561
- return if installed_by_version < Gem::Version.new('2.2.0.preview.2')
1562
1561
  return if File.exist? gem_build_complete_path
1563
1562
  return if !File.writable?(base_dir)
1564
1563
  return if !File.exist?(File.join(base_dir, 'extensions'))
@@ -2129,7 +2128,6 @@ class Gem::Specification < Gem::BasicSpecification
2129
2128
  def missing_extensions?
2130
2129
  return false if default_gem?
2131
2130
  return false if extensions.empty?
2132
- return false if installed_by_version < Gem::Version.new('2.2.0.preview.2')
2133
2131
  return false if File.exist? gem_build_complete_path
2134
2132
 
2135
2133
  true
@@ -12,7 +12,7 @@ if File.exist?(bundler_gemspec)
12
12
  end
13
13
 
14
14
  begin
15
- gem 'minitest', '~> 5.13'
15
+ gem 'test-unit', '~> 3.0'
16
16
  rescue Gem::LoadError
17
17
  end
18
18
 
@@ -32,16 +32,7 @@ else
32
32
  require 'bundler'
33
33
  end
34
34
 
35
- # Enable server plugin needed for bisection
36
- if ENV["RG_BISECT_SERVER_PLUGIN"]
37
- require ENV["RG_BISECT_SERVER_PLUGIN"]
38
-
39
- Minitest.extensions << "server"
40
- end
41
-
42
- ENV["MT_NO_PLUGINS"] = "true"
43
-
44
- require 'minitest/autorun'
35
+ require 'test/unit'
45
36
 
46
37
  ENV["JARS_SKIP"] = "true" if Gem.java_platform? # avoid unnecessary and noisy `jar-dependencies` post install hook
47
38
 
@@ -111,7 +102,7 @@ end
111
102
  # and uninstall gems, fetch remote gems through a stub fetcher and be assured
112
103
  # your normal set of gems is not affected.
113
104
 
114
- class Gem::TestCase < Minitest::Test
105
+ class Gem::TestCase < Test::Unit::TestCase
115
106
  extend Gem::Deprecate
116
107
 
117
108
  attr_accessor :fetcher # :nodoc:
@@ -140,11 +131,48 @@ class Gem::TestCase < Minitest::Test
140
131
  end
141
132
 
142
133
  def assert_directory_exists(path, msg = nil)
143
- msg = message(msg) { "Expected path '#{path}' to be a directory" }
144
- assert_path_exists path
134
+ msg = build_message(msg, "Expected path '#{path}' to be a directory")
135
+ assert_path_exist path
145
136
  assert File.directory?(path), msg
146
137
  end
147
138
 
139
+ # https://github.com/seattlerb/minitest/blob/21d9e804b63c619f602f3f4ece6c71b48974707a/lib/minitest/assertions.rb#L188
140
+ def _synchronize
141
+ yield
142
+ end
143
+
144
+ # https://github.com/seattlerb/minitest/blob/21d9e804b63c619f602f3f4ece6c71b48974707a/lib/minitest/assertions.rb#L546
145
+ def capture_subprocess_io
146
+ _synchronize do
147
+ begin
148
+ require "tempfile"
149
+
150
+ captured_stdout, captured_stderr = Tempfile.new("out"), Tempfile.new("err")
151
+
152
+ orig_stdout, orig_stderr = $stdout.dup, $stderr.dup
153
+ $stdout.reopen captured_stdout
154
+ $stderr.reopen captured_stderr
155
+
156
+ yield
157
+
158
+ $stdout.rewind
159
+ $stderr.rewind
160
+
161
+ return captured_stdout.read, captured_stderr.read
162
+ ensure
163
+ captured_stdout.unlink
164
+ captured_stderr.unlink
165
+ $stdout.reopen orig_stdout
166
+ $stderr.reopen orig_stderr
167
+
168
+ orig_stdout.close
169
+ orig_stderr.close
170
+ captured_stdout.close
171
+ captured_stderr.close
172
+ end
173
+ end
174
+ end
175
+
148
176
  ##
149
177
  # Sets the ENABLE_SHARED entry in RbConfig::CONFIG to +value+ and restores
150
178
  # the original value when the block ends
@@ -262,19 +290,19 @@ class Gem::TestCase < Minitest::Test
262
290
 
263
291
  def assert_contains_make_command(target, output, msg = nil)
264
292
  if output.match(/\n/)
265
- msg = message(msg) do
293
+ msg = build_message(msg,
266
294
  "Expected output containing make command \"%s\", but was \n\nBEGIN_OF_OUTPUT\n%sEND_OF_OUTPUT" % [
267
295
  ('%s %s' % [make_command, target]).rstrip,
268
296
  output,
269
297
  ]
270
- end
298
+ )
271
299
  else
272
- msg = message(msg) do
300
+ msg = build_message(msg,
273
301
  'Expected make command "%s": %s' % [
274
302
  ('%s %s' % [make_command, target]).rstrip,
275
303
  output,
276
304
  ]
277
- end
305
+ )
278
306
  end
279
307
 
280
308
  assert scan_make_command_lines(output).any? {|line|
@@ -664,6 +692,28 @@ class Gem::TestCase < Minitest::Test
664
692
  path
665
693
  end
666
694
 
695
+ ##
696
+ # Load a YAML string, the psych 3 way
697
+
698
+ def load_yaml(yaml)
699
+ if YAML.respond_to?(:unsafe_load)
700
+ YAML.unsafe_load(yaml)
701
+ else
702
+ YAML.load(yaml)
703
+ end
704
+ end
705
+
706
+ ##
707
+ # Load a YAML file, the psych 3 way
708
+
709
+ def load_yaml_file(file)
710
+ if YAML.respond_to?(:unsafe_load_file)
711
+ YAML.unsafe_load_file(file)
712
+ else
713
+ YAML.load_file(file)
714
+ end
715
+ end
716
+
667
717
  def all_spec_names
668
718
  Gem::Specification.map(&:full_name)
669
719
  end
@@ -1519,4 +1569,38 @@ Also, a list:
1519
1569
  end if Gem::HAVE_OPENSSL
1520
1570
  end
1521
1571
 
1572
+ # https://github.com/seattlerb/minitest/blob/13c48a03d84a2a87855a4de0c959f96800100357/lib/minitest/mock.rb#L192
1573
+ class Object
1574
+ def stub(name, val_or_callable, *block_args)
1575
+ new_name = "__minitest_stub__#{name}"
1576
+
1577
+ metaclass = class << self; self; end
1578
+
1579
+ if respond_to? name and not methods.map(&:to_s).include? name.to_s
1580
+ metaclass.send :define_method, name do |*args|
1581
+ super(*args)
1582
+ end
1583
+ end
1584
+
1585
+ metaclass.send :alias_method, new_name, name
1586
+
1587
+ metaclass.send :define_method, name do |*args, &blk|
1588
+ if val_or_callable.respond_to? :call
1589
+ val_or_callable.call(*args, &blk)
1590
+ else
1591
+ blk.call(*block_args) if blk
1592
+ val_or_callable
1593
+ end
1594
+ end
1595
+
1596
+ metaclass.send(:ruby2_keywords, name) if metaclass.respond_to?(:ruby2_keywords, true)
1597
+
1598
+ yield self
1599
+ ensure
1600
+ metaclass.send :undef_method, name
1601
+ metaclass.send :alias_method, name, new_name
1602
+ metaclass.send :undef_method, new_name
1603
+ end
1604
+ end
1605
+
1522
1606
  require 'rubygems/test_utilities'