summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorDavid Rodríguez <deivid.rodriguez@riseup.net>2020-01-06 23:16:10 +0100
committerDavid Rodríguez <deivid.rodriguez@riseup.net>2020-01-07 01:56:12 +0100
commit0df849428348df13c3af94b427c388bc0689e368 (patch)
treed1d5cd42e4e1a210421c916dc8dc1d250bcaa287 /spec
parentf17341d13c7b9a7462bebaabc084eb96f584657e (diff)
downloadbundler-0df849428348df13c3af94b427c388bc0689e368.tar.gz
Split test gem installation to a separate task
We run into a race condition when testing in parallel when all processors install test gems to their test folder (due to shared gem cache). So I figure we can instead run this setup sequentially beforehand.
Diffstat (limited to 'spec')
-rw-r--r--spec/support/rubygems_ext.rb36
1 files changed, 28 insertions, 8 deletions
diff --git a/spec/support/rubygems_ext.rb b/spec/support/rubygems_ext.rb
index d41ee64bec..b9bbfde2b3 100644
--- a/spec/support/rubygems_ext.rb
+++ b/spec/support/rubygems_ext.rb
@@ -51,15 +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
- install_gems(DEPS)
+ require "fileutils"
FileUtils.mkdir_p(Path.home)
FileUtils.mkdir_p(Path.tmpdir)
@@ -71,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)