Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Set up parallel minitests

  • Loading branch information...
commit 66ec3d403c025db1ef219ad38733c663a7cde3f4 1 parent 1ac5cce
@matschaffer authored
View
3  Gemfile
@@ -7,7 +7,8 @@ end
group :test do
gem 'mocha'
- gem 'minitest', :require => 'minitest/autorun'
+ gem 'parallel'
+ gem 'minitest', :require => false
end
group :development, :test do
View
2  Gemfile.lock
@@ -107,6 +107,7 @@ GEM
systemu (~> 2.2.0)
yajl-ruby
ori (0.1.0)
+ parallel (0.5.14)
polyglot (0.3.3)
rake (0.9.2)
rbx-require-relative (0.0.5)
@@ -153,6 +154,7 @@ DEPENDENCIES
knife-solo!
minitest
mocha
+ parallel
rake
ruby-debug
ruby-debug19
View
9 test/integration_helper.rb
@@ -1,9 +1,8 @@
-require 'rubygems'
-require 'bundler/setup'
-Bundler.require(:default, :test)
-require 'pathname'
+require 'test_helper'
-class IntegrationTest < MiniTest::Unit::TestCase
+MiniTest::Parallel.processor_count = [Dir['test/integration/*_test.rb'].size, 5].min
+
+class IntegrationTest < TestCase
def self.servers
@servers ||= []
end
View
41 test/minitest/parallel.rb
@@ -0,0 +1,41 @@
+# https://github.com/ngauthier/minitest-parallel
+if defined?(MiniTest)
+ raise "Do not require minitest before minitest/parallel\n"
+end
+require 'parallel'
+require 'minitest/unit'
+
+module MiniTest::Parallel
+ def self.included(base)
+ base.class_eval do
+ alias_method :_run_suites_in_series, :_run_suites
+ alias_method :_run_suites, :_run_suites_in_parallel
+ end
+ end
+
+ def self.processor_count=(procs)
+ @processor_count = procs
+ end
+
+ def self.processor_count
+ @processor_count ||= Parallel.processor_count
+ end
+
+ def _run_suites_in_parallel(suites, type)
+ result = Parallel.map(suites, :in_processes => MiniTest::Parallel.processor_count) do |suite|
+ ret = _run_suite(suite, type)
+ {
+ :failures => failures,
+ :errors => errors,
+ :report => report,
+ :run_suite_return => ret
+ }
+ end
+ self.failures = result.inject(0) {|sum, x| sum + x[:failures] }
+ self.errors = result.inject(0) {|sum, x| sum + x[:errors] }
+ self.report = result.inject([]) {|sum, x| sum + x[:report] }
+ result.map {|x| x[:run_suite_return] }
+ end
+end
+
+MiniTest::Unit.send(:include, MiniTest::Parallel)
View
6 test/test_helper.rb
@@ -1,11 +1,13 @@
require 'rubygems'
-require 'test/unit'
require 'bundler'
Bundler.require
Bundler.require(:test)
-class TestCase < Test::Unit::TestCase
+require 'minitest/parallel'
+require 'minitest/autorun'
+
+class TestCase < MiniTest::Unit::TestCase
def default_test
super unless self.class == TestCase
end
Please sign in to comment.
Something went wrong with that request. Please try again.