Skip to content

Commit 89bcc63

Browse files
deivid-rodriguezk0kubun
authored andcommitted
Revert "Revert ruby/rubygems@d74fa0f"
This reverts commit 7dcfdf1.
1 parent 877ae93 commit 89bcc63

File tree

6 files changed

+62
-87
lines changed

6 files changed

+62
-87
lines changed

spec/bundler/bin/parallel_rspec

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/usr/bin/env ruby
2+
# frozen_string_literal: true
3+
4+
require_relative "../bundler/support/setup"
5+
6+
require "turbo_tests"
7+
TurboTests::CLI.new(ARGV).run

spec/bundler/spec_helper.rb

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,6 @@ def self.ruby=(ruby)
9595

9696
extend(Spec::Builders)
9797

98-
check_test_gems!
99-
10098
build_repo1
10199

102100
reset_paths!
@@ -119,8 +117,4 @@ def self.ruby=(ruby)
119117
ensure
120118
reset!
121119
end
122-
123-
config.after :suite do
124-
FileUtils.rm_r Spec::Path.pristine_system_gem_path
125-
end
126120
end

spec/bundler/support/builders.rb

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -276,14 +276,6 @@ def build_repo(path, **kwargs, &blk)
276276
update_repo(path,**kwargs, &blk)
277277
end
278278

279-
def check_test_gems!
280-
if rake_path.nil?
281-
Spec::Rubygems.install_test_deps
282-
end
283-
284-
Helpers.install_dev_bundler unless pristine_system_gem_path.exist?
285-
end
286-
287279
def update_repo(path, build_compact_index: true)
288280
exempted_caller = Gem.ruby_version >= Gem::Version.new("3.4.0.dev") ? "#{Module.nesting.first}#build_repo" : "build_repo"
289281
if path == gem_repo1 && caller_locations(1, 1).first.label != exempted_caller
@@ -453,6 +445,7 @@ def _build(options = {})
453445
build_path = @context.tmp + full_name
454446
bundler_path = build_path + "#{full_name}.gem"
455447

448+
require "fileutils"
456449
FileUtils.mkdir_p build_path
457450

458451
@context.shipped_files.each do |shipped_file|
@@ -461,7 +454,7 @@ def _build(options = {})
461454
target_shipped_file = build_path + target_shipped_file
462455
target_shipped_dir = File.dirname(target_shipped_file)
463456
FileUtils.mkdir_p target_shipped_dir unless File.directory?(target_shipped_dir)
464-
FileUtils.cp shipped_file, target_shipped_file, preserve: true
457+
FileUtils.cp File.expand_path(shipped_file, @context.source_root), target_shipped_file, preserve: true
465458
end
466459

467460
@context.replace_version_file(@version, dir: build_path)

spec/bundler/support/path.rb

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,8 @@ def relative_gemspec
2525
@relative_gemspec ||= ruby_core? ? "lib/bundler/bundler.gemspec" : "bundler.gemspec"
2626
end
2727

28-
def gemspec_dir
29-
@gemspec_dir ||= gemspec.parent
30-
end
31-
3228
def loaded_gemspec
33-
@loaded_gemspec ||= Gem::Specification.load(gemspec.to_s)
29+
@loaded_gemspec ||= Dir.chdir(source_root) { Gem::Specification.load(gemspec.to_s) }
3430
end
3531

3632
def test_gemfile
@@ -102,11 +98,11 @@ def man_tracked_files
10298
end
10399

104100
def tmp(*path)
105-
tmp_root(scope).join(*path)
101+
tmp_root.join("#{test_env_version}.#{scope}").join(*path)
106102
end
107103

108-
def tmp_root(scope)
109-
source_root.join("tmp", "#{test_env_version}.#{scope}")
104+
def tmp_root
105+
source_root.join("tmp")
110106
end
111107

112108
# Bump this version whenever you make a breaking change to the spec setup
@@ -180,15 +176,15 @@ def base_system_gem_path
180176
end
181177

182178
def base_system_gems
183-
tmp("gems/base")
179+
tmp_root.join("gems/base")
184180
end
185181

186182
def rubocop_gems
187-
tmp("gems/rubocop")
183+
tmp_root.join("gems/rubocop")
188184
end
189185

190186
def standard_gems
191-
tmp("gems/standard")
187+
tmp_root.join("gems/standard")
192188
end
193189

194190
def file_uri_for(path)
@@ -227,7 +223,7 @@ def system_gem_path(*path)
227223
end
228224

229225
def pristine_system_gem_path
230-
tmp("gems/base_system")
226+
tmp_root.join("gems/pristine_system")
231227
end
232228

233229
def local_gem_path(*path, base: bundled_app)
@@ -285,7 +281,7 @@ def git_root
285281
end
286282

287283
def rake_path
288-
Dir["#{base_system_gems}/#{Bundler.ruby_scope}/**/rake*.gem"].first
284+
Dir["#{base_system_gems}/*/*/**/rake*.gem"].first
289285
end
290286

291287
def sinatra_dependency_paths

spec/bundler/support/rubygems_ext.rb

Lines changed: 35 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,6 @@ module Spec
1010
module Rubygems
1111
extend self
1212

13-
def dev_setup
14-
install_gems(dev_gemfile)
15-
end
16-
1713
def gem_load(gem_name, bin_container)
1814
require_relative "switch_rubygems"
1915

@@ -50,41 +46,19 @@ def test_setup
5046
Gem::DefaultUserInteraction.ui = Gem::SilentUI.new
5147
end
5248

53-
def install_parallel_test_deps
54-
Gem.clear_paths
55-
56-
require "parallel"
57-
require "fileutils"
58-
59-
install_test_deps
60-
61-
(2..Parallel.processor_count).each do |n|
62-
source = Path.tmp_root("1")
63-
destination = Path.tmp_root(n.to_s)
64-
65-
FileUtils.cp_r source, destination, remove_destination: true
66-
end
67-
end
68-
6949
def setup_test_paths
70-
Gem.clear_paths
71-
7250
ENV["BUNDLE_PATH"] = nil
73-
ENV["GEM_HOME"] = ENV["GEM_PATH"] = Path.base_system_gem_path.to_s
7451
ENV["PATH"] = [Path.system_gem_path("bin"), ENV["PATH"]].join(File::PATH_SEPARATOR)
7552
ENV["PATH"] = [Path.bindir, ENV["PATH"]].join(File::PATH_SEPARATOR) if Path.ruby_core?
7653
end
7754

7855
def install_test_deps
79-
Gem.clear_paths
80-
81-
install_gems(test_gemfile, Path.base_system_gems.to_s)
82-
install_gems(rubocop_gemfile, Path.rubocop_gems.to_s)
83-
install_gems(standard_gemfile, Path.standard_gems.to_s)
56+
dev_bundle("install", gemfile: test_gemfile, path: Path.base_system_gems.to_s)
57+
dev_bundle("install", gemfile: rubocop_gemfile, path: Path.rubocop_gems.to_s)
58+
dev_bundle("install", gemfile: standard_gemfile, path: Path.standard_gems.to_s)
8459

85-
# For some reason, doing this here crashes on JRuby + Windows. So defer to
86-
# when the test suite is running in that case.
87-
Helpers.install_dev_bundler unless Gem.win_platform? && RUBY_ENGINE == "jruby"
60+
require_relative "helpers"
61+
Helpers.install_dev_bundler
8862
end
8963

9064
def check_source_control_changes(success_message:, error_message:)
@@ -107,6 +81,36 @@ def check_source_control_changes(success_message:, error_message:)
10781
end
10882
end
10983

84+
def dev_bundle(*args, gemfile: dev_gemfile, path: nil)
85+
old_gemfile = ENV["BUNDLE_GEMFILE"]
86+
old_orig_gemfile = ENV["BUNDLER_ORIG_BUNDLE_GEMFILE"]
87+
ENV["BUNDLE_GEMFILE"] = gemfile.to_s
88+
ENV["BUNDLER_ORIG_BUNDLE_GEMFILE"] = nil
89+
90+
if path
91+
old_path = ENV["BUNDLE_PATH"]
92+
ENV["BUNDLE_PATH"] = path
93+
else
94+
old_path__system = ENV["BUNDLE_PATH__SYSTEM"]
95+
ENV["BUNDLE_PATH__SYSTEM"] = "true"
96+
end
97+
98+
require "shellwords"
99+
# We don't use `Open3` here because it does not work on JRuby + Windows
100+
output = `ruby #{File.expand_path("support/bundle.rb", Path.spec_dir)} #{args.shelljoin}`
101+
raise output unless $?.success?
102+
output
103+
ensure
104+
if path
105+
ENV["BUNDLE_PATH"] = old_path
106+
else
107+
ENV["BUNDLE_PATH__SYSTEM"] = old_path__system
108+
end
109+
110+
ENV["BUNDLER_ORIG_BUNDLE_GEMFILE"] = old_orig_gemfile
111+
ENV["BUNDLE_GEMFILE"] = old_gemfile
112+
end
113+
110114
private
111115

112116
def gem_load_and_activate(gem_name, bin_container)
@@ -135,34 +139,6 @@ def gem_activate(gem_name)
135139
gem gem_name, gem_requirement
136140
end
137141

138-
def install_gems(gemfile, path = nil)
139-
old_gemfile = ENV["BUNDLE_GEMFILE"]
140-
old_orig_gemfile = ENV["BUNDLER_ORIG_BUNDLE_GEMFILE"]
141-
ENV["BUNDLE_GEMFILE"] = gemfile.to_s
142-
ENV["BUNDLER_ORIG_BUNDLE_GEMFILE"] = nil
143-
144-
if path
145-
old_path = ENV["BUNDLE_PATH"]
146-
ENV["BUNDLE_PATH"] = path
147-
else
148-
old_path__system = ENV["BUNDLE_PATH__SYSTEM"]
149-
ENV["BUNDLE_PATH__SYSTEM"] = "true"
150-
end
151-
152-
# We don't use `Open3` here because it does not work on JRuby + Windows
153-
output = `#{Gem.ruby} #{File.expand_path("support/bundle.rb", Path.spec_dir)} install`
154-
raise output unless $?.success?
155-
ensure
156-
if path
157-
ENV["BUNDLE_PATH"] = old_path
158-
else
159-
ENV["BUNDLE_PATH__SYSTEM"] = old_path__system
160-
end
161-
162-
ENV["BUNDLER_ORIG_BUNDLE_GEMFILE"] = old_orig_gemfile
163-
ENV["BUNDLE_GEMFILE"] = old_gemfile
164-
end
165-
166142
def test_gemfile
167143
Path.test_gemfile
168144
end

spec/bundler/support/setup.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# frozen_string_literal: true
2+
3+
require_relative "switch_rubygems"
4+
5+
require_relative "rubygems_ext"
6+
Spec::Rubygems.install_test_deps
7+
8+
require_relative "path"
9+
$LOAD_PATH.unshift(File.expand_path("../../lib", __dir__)) if Spec::Path.ruby_core?

0 commit comments

Comments
 (0)