From 6dcacb8d7fb531e6140edcb0fdb93f54c1c54f58 Mon Sep 17 00:00:00 2001 From: Nicolas Bouilleaud Date: Wed, 29 Apr 2020 00:10:36 +0200 Subject: [PATCH] WIP: Enable parallel_spec wip: * [ ] Update README setup: * bundle * rake parallel:create (to setup test databases) usage: RAILS_ENV=test rake parallel:spec (without spring) bin/parallel_rspec spec (with spring) timing on my slow macbook: > rake spec Finished in 55.08 seconds (files took 6.85 seconds to load) > RAILS_ENV=test rake parallel:spec Took 47 seconds --- .rspec_parallel | 2 ++ Gemfile | 2 ++ Gemfile.lock | 6 ++++++ bin/parallel_rspec | 8 ++++++++ bin/spring | 4 ++-- 5 files changed, 20 insertions(+), 2 deletions(-) create mode 100644 .rspec_parallel create mode 100755 bin/parallel_rspec diff --git a/.rspec_parallel b/.rspec_parallel new file mode 100644 index 0000000000..aaff198a32 --- /dev/null +++ b/.rspec_parallel @@ -0,0 +1,2 @@ +--format progress +--format ParallelTests::RSpec::RuntimeLogger --out tmp/parallel_runtime_rspec.log diff --git a/Gemfile b/Gemfile index 0eb0c3bdfd..31aa955081 100644 --- a/Gemfile +++ b/Gemfile @@ -83,6 +83,8 @@ group :development, :test do gem 'faker' gem 'rspec-rails' gem 'rspec_junit_formatter', require: false + gem 'parallel_tests' + gem 'spring-commands-parallel-tests' gem "dotenv-rails" gem "debase" end diff --git a/Gemfile.lock b/Gemfile.lock index e4c088c61a..43cc998012 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -304,6 +304,8 @@ GEM mini_portile2 (~> 2.4.0) orm_adapter (0.5.0) parallel (1.19.1) + parallel_tests (2.32.0) + parallel parser (2.7.1.0) ast (~> 2.4.0) pg (1.2.3) @@ -447,6 +449,8 @@ GEM shoulda-matchers (4.3.0) activesupport (>= 4.2.0) spring (2.1.0) + spring-commands-parallel-tests (1.0.1) + spring (>= 0.9.1) spring-commands-rspec (1.0.4) spring (>= 0.9.1) spring-watcher-listen (2.0.1) @@ -545,6 +549,7 @@ DEPENDENCIES listen mailjet metamagic + parallel_tests pg premailer-rails puma @@ -567,6 +572,7 @@ DEPENDENCIES sentry-raven shoulda-matchers spring + spring-commands-parallel-tests spring-commands-rspec spring-watcher-listen therubyracer diff --git a/bin/parallel_rspec b/bin/parallel_rspec new file mode 100755 index 0000000000..b12215a3ae --- /dev/null +++ b/bin/parallel_rspec @@ -0,0 +1,8 @@ +#!/usr/bin/env ruby +begin + load File.expand_path('spring', __dir__) +rescue LoadError => e + raise unless e.message.include?('spring') +end +require 'bundler/setup' +load Gem.bin_path('parallel_tests', 'parallel_rspec') diff --git a/bin/spring b/bin/spring index fb2ec2ebb4..d89ee495fa 100755 --- a/bin/spring +++ b/bin/spring @@ -1,6 +1,6 @@ #!/usr/bin/env ruby -# This file loads spring without using Bundler, in order to be fast. +# This file loads Spring without using Bundler, in order to be fast. # It gets overwritten when you run the `spring binstub` command. unless defined?(Spring) @@ -8,7 +8,7 @@ unless defined?(Spring) require 'bundler' lockfile = Bundler::LockfileParser.new(Bundler.default_lockfile.read) - spring = lockfile.specs.detect { |spec| spec.name == "spring" } + spring = lockfile.specs.detect { |spec| spec.name == 'spring' } if spring Gem.use_paths Gem.dir, Bundler.bundle_path.to_s, *Gem.path gem 'spring', spring.version