@@ -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
0 commit comments