summaryrefslogtreecommitdiff
path: root/spec/support/rubygems_ext.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/support/rubygems_ext.rb')
-rw-r--r--spec/support/rubygems_ext.rb52
1 files changed, 30 insertions, 22 deletions
diff --git a/spec/support/rubygems_ext.rb b/spec/support/rubygems_ext.rb
index ee9c750a52..b177fc690a 100644
--- a/spec/support/rubygems_ext.rb
+++ b/spec/support/rubygems_ext.rb
@@ -15,7 +15,7 @@ module Spec
}.freeze
DEPS = {
- "rack" => "~> 2.0",
+ "rack" => "2.0.8",
"rack-test" => "~> 1.1",
"artifice" => "~> 0.6.0",
"compact_index" => "~> 0.11.0",
@@ -51,24 +51,9 @@ module Spec
end
def setup
- require "fileutils"
-
- Gem.clear_paths
-
- ENV["BUNDLE_PATH"] = nil
- ENV["GEM_HOME"] = ENV["GEM_PATH"] = Path.base_system_gems.to_s
- ENV["PATH"] = [Path.bindir, Path.system_gem_path.join("bin"), ENV["PATH"]].join(File::PATH_SEPARATOR)
+ install_test_deps
- manifest = DEPS.to_a.sort_by(&:first).map {|k, v| "#{k} => #{v}\n" }
- manifest_path = Path.base_system_gems.join("manifest.txt")
- # it's OK if there are extra gems
- if !manifest_path.file? || !(manifest - manifest_path.readlines).empty?
- FileUtils.rm_rf(Path.base_system_gems)
- FileUtils.mkdir_p(Path.base_system_gems)
- puts "installing gems for the tests to use..."
- install_gems(DEPS)
- manifest_path.open("wb") {|f| f << manifest.join }
- end
+ require "fileutils"
FileUtils.mkdir_p(Path.home)
FileUtils.mkdir_p(Path.tmpdir)
@@ -80,6 +65,32 @@ module Spec
Gem::DefaultUserInteraction.ui = Gem::SilentUI.new
end
+ def install_parallel_test_deps
+ require "parallel"
+
+ prev_env_test_number = ENV["TEST_ENV_NUMBER"]
+
+ begin
+ Parallel.processor_count.times do |n|
+ ENV["TEST_ENV_NUMBER"] = (n + 1).to_s
+
+ install_test_deps
+ end
+ ensure
+ ENV["TEST_ENV_NUMBER"] = prev_env_test_number
+ end
+ end
+
+ def install_test_deps
+ Gem.clear_paths
+
+ ENV["BUNDLE_PATH"] = nil
+ ENV["GEM_HOME"] = ENV["GEM_PATH"] = Path.base_system_gems.to_s
+ ENV["PATH"] = [Path.bindir, Path.system_gem_path.join("bin"), ENV["PATH"]].join(File::PATH_SEPARATOR)
+
+ install_gems(DEPS)
+ end
+
private
def gem_load_and_activate(gem_name, bin_container)
@@ -95,10 +106,7 @@ module Spec
end
def install_gems(gems)
- reqs, no_reqs = gems.partition {|_, req| !req.nil? && !req.split(" ").empty? }
- no_reqs.map!(&:first)
- reqs.map! {|name, req| "'#{name}:#{req}'" }
- deps = reqs.concat(no_reqs).join(" ")
+ deps = gems.map {|name, req| "'#{name}:#{req}'" }.join(" ")
gem = ENV["GEM_COMMAND"] || "#{Gem.ruby} -S gem --backtrace"
cmd = "#{gem} install #{deps} --no-document --conservative"
system(cmd) || raise("Installing gems #{deps} for the tests to use failed!")