summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBundlerbot <bot@bundler.io>2019-08-20 07:46:35 +0000
committerBundlerbot <bot@bundler.io>2019-08-20 07:46:35 +0000
commitd63efd91dc2cf075a5a047dfb2fa18555a58536d (patch)
treea72c616ad4e69fcc06525e000e7c3eba052e23cd
parent870a43d4319c54f70540fb4f5c19ea784aa83b54 (diff)
parentb5be57dcdcb47e47497e635e673bb95b9ffc32b3 (diff)
downloadbundler-d63efd91dc2cf075a5a047dfb2fa18555a58536d.tar.gz
Merge #7317
7317: Parallelize test suite (Take 2) r=hsbt a=hsbt ### What was the end-user problem that led to this PR? This branch reduced test time of bundler. ### What was your diagnosis of the problem? #7232 has a conflict with the current master branch. ### What is your fix for the problem, implemented in this PR? I picked a commit for parallelized tests from #7232 ### Why did you choose this fix out of the possible options? Fixed https://github.com/bundler/bundler/pull/7232 Co-authored-by: David Rodríguez <deivid.rodriguez@riseup.net> Co-authored-by: Hiroshi SHIBATA <hsbt@ruby-lang.org>
-rw-r--r--.rspec_parallel4
-rw-r--r--Rakefile10
-rwxr-xr-xbin/parallel_rspec12
-rw-r--r--spec/bundler/source_spec.rb15
-rw-r--r--spec/runtime/load_spec.rb2
-rw-r--r--spec/support/parallel.rb5
-rw-r--r--spec/support/path.rb9
-rw-r--r--spec/support/rubygems_ext.rb1
8 files changed, 49 insertions, 9 deletions
diff --git a/.rspec_parallel b/.rspec_parallel
new file mode 100644
index 0000000000..6989221a44
--- /dev/null
+++ b/.rspec_parallel
@@ -0,0 +1,4 @@
+--format progress
+--format ParallelTests::RSpec::RuntimeLogger --out tmp/parallel_runtime_rspec.log
+--require spec_helper
+--require support/parallel.rb
diff --git a/Rakefile b/Rakefile
index 6655af7d8d..f02a552ff8 100644
--- a/Rakefile
+++ b/Rakefile
@@ -92,6 +92,10 @@ namespace :spec do
releases = %w[v2.5.2 v2.6.14 v2.7.10 v3.0.6]
(branches + releases).each do |rg|
desc "Run specs with RubyGems #{rg}"
+ task "parallel_#{rg}" do
+ sh("bin/parallel_rspec spec/")
+ end
+
task rg do
sh("bin/rspec --format progress")
end
@@ -112,7 +116,7 @@ namespace :spec do
desc "Run specs under a RubyGems checkout (set RGV=path)"
task "co" do
- sh("bin/rspec --format progress")
+ sh("bin/parallel_rspec spec/")
end
namespace "co" do
@@ -142,9 +146,7 @@ namespace :spec do
ENV["BUNDLER_SPEC_PRE_RECORDED"] = "TRUE"
puts "\n\e[1;33m[Travis CI] Running bundler specs against RubyGems #{rg}\e[m\n\n"
- specs = safe_task { Rake::Task["spec:rubygems:#{rg}"].invoke }
-
- Rake::Task["spec:rubygems:#{rg}"].reenable
+ specs = safe_task { Rake::Task["spec:rubygems:parallel_#{rg}"].invoke }
puts "\n\e[1;33m[Travis CI] Running bundler sudo specs against RubyGems #{rg}\e[m\n\n"
sudos = system("sudo -E rake spec:rubygems:#{rg}:sudo")
diff --git a/bin/parallel_rspec b/bin/parallel_rspec
new file mode 100755
index 0000000000..26402aee7c
--- /dev/null
+++ b/bin/parallel_rspec
@@ -0,0 +1,12 @@
+#!/usr/bin/env ruby
+# frozen_string_literal: true
+
+load File.expand_path("../with_rubygems", __FILE__) if ENV["RGV"]
+
+require_relative "../spec/support/rubygems_ext"
+
+begin
+ Spec::Rubygems.gem_load("parallel_tests", "parallel_rspec")
+rescue Gem::LoadError => e
+ warn "We couln't activate parallel_tests (#{e.requirement}). Run `gem install parallel_tests:'#{e.requirement}'`"
+end
diff --git a/spec/bundler/source_spec.rb b/spec/bundler/source_spec.rb
index 46d86937da..5b11503d23 100644
--- a/spec/bundler/source_spec.rb
+++ b/spec/bundler/source_spec.rb
@@ -57,7 +57,10 @@ RSpec.describe Bundler::Source do
let(:locked_gem) { double(:locked_gem, :name => "nokogiri", :version => "< 1.5") }
context "with color", :no_color_tty do
- before { Bundler.ui = Bundler::UI::Shell.new }
+ before do
+ allow($stdout).to receive(:tty?).and_return(true)
+ Bundler.ui = Bundler::UI::Shell.new
+ end
it "should return a string with the spec name and version and locked spec version" do
expect(subject.version_message(spec)).to eq("nokogiri >= 1.6\e[32m (was < 1.5)\e[0m")
@@ -78,7 +81,10 @@ RSpec.describe Bundler::Source do
let(:locked_gem) { double(:locked_gem, :name => "nokogiri", :version => "1.7.0") }
context "with color", :no_color_tty do
- before { Bundler.ui = Bundler::UI::Shell.new }
+ before do
+ allow($stdout).to receive(:tty?).and_return(true)
+ Bundler.ui = Bundler::UI::Shell.new
+ end
it "should return a string with the locked spec version in yellow" do
expect(subject.version_message(spec)).to eq("nokogiri 1.6.1\e[33m (was 1.7.0)\e[0m")
@@ -99,7 +105,10 @@ RSpec.describe Bundler::Source do
let(:locked_gem) { double(:locked_gem, :name => "nokogiri", :version => "1.7.0") }
context "with color", :no_color_tty do
- before { Bundler.ui = Bundler::UI::Shell.new }
+ before do
+ allow($stdout).to receive(:tty?).and_return(true)
+ Bundler.ui = Bundler::UI::Shell.new
+ end
it "should return a string with the locked spec version in green" do
expect(subject.version_message(spec)).to eq("nokogiri 1.7.1\e[32m (was 1.7.0)\e[0m")
diff --git a/spec/runtime/load_spec.rb b/spec/runtime/load_spec.rb
index b7dc509f6f..acefc1a583 100644
--- a/spec/runtime/load_spec.rb
+++ b/spec/runtime/load_spec.rb
@@ -58,7 +58,7 @@ RSpec.describe "Bundler.load" do
end
it "does not find a Gemfile above the testing directory" do
- bundler_gemfile = tmp.join("../Gemfile")
+ bundler_gemfile = Pathname.new(__dir__).join("../../Gemfile")
unless File.exist?(bundler_gemfile)
FileUtils.touch(bundler_gemfile)
@remove_bundler_gemfile = true
diff --git a/spec/support/parallel.rb b/spec/support/parallel.rb
new file mode 100644
index 0000000000..8763cb9ec4
--- /dev/null
+++ b/spec/support/parallel.rb
@@ -0,0 +1,5 @@
+# frozen_string_literal: true
+
+RSpec.configure do |config|
+ config.silence_filter_announcements = true
+end
diff --git a/spec/support/path.rb b/spec/support/path.rb
index 14c1514291..061385168f 100644
--- a/spec/support/path.rb
+++ b/spec/support/path.rb
@@ -38,7 +38,14 @@ module Spec
end
def tmp(*path)
- root.join("tmp", *path)
+ root.join("tmp", scope, *path)
+ end
+
+ def scope
+ test_number = ENV["TEST_ENV_NUMBER"]
+ return "1" if test_number.nil?
+
+ test_number.empty? ? "1" : test_number
end
def home(*path)
diff --git a/spec/support/rubygems_ext.rb b/spec/support/rubygems_ext.rb
index aa04c3d00e..faa474a917 100644
--- a/spec/support/rubygems_ext.rb
+++ b/spec/support/rubygems_ext.rb
@@ -8,6 +8,7 @@ module Spec
module Rubygems
DEV_DEPS = {
"automatiek" => "~> 0.2.0",
+ "parallel_tests" => "~> 2.29",
"rake" => "~> 12.0",
"ronn" => "~> 0.7.3",
"rspec" => "~> 3.8",