Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

! Rearranged minitest/unit.rb so NO parallelization code is loaded/us…

…ed until you opt-in.

[git-p4: depot-paths = "//src/minitest/dev/": change = 8134]
  • Loading branch information...
commit 728054b615425e5d8d6291143195dd6552112219 1 parent 8272a02
@zenspider zenspider authored
View
2  lib/minitest/hell.rb
@@ -1,3 +1,5 @@
+require "minitest/parallel_each"
+
class Minitest::Unit::TestCase # :nodoc:
class << self
alias :old_test_order :test_order
View
16 lib/minitest/parallel_each.rb
@@ -48,3 +48,19 @@ def each
end
end
end
+
+class MiniTest::Unit
+ alias _old_run_suites _run_suites
+
+ ##
+ # Runs all the +suites+ for a given +type+. Runs suites declaring
+ # a test_order of +:parallel+ in parallel, and everything else
+ # serial.
+
+ def _run_suites suites, type
+ parallel, serial = suites.partition { |s| s.test_order == :parallel }
+
+ ParallelEach.new(parallel).map { |suite| _run_suite suite, type } +
+ serial.map { |suite| _run_suite suite, type }
+ end
+end
View
28 lib/minitest/unit.rb
@@ -1,7 +1,5 @@
-require 'optparse'
-require 'rbconfig'
-require 'thread' # required for 1.8
-require 'minitest/parallel_each'
+require "optparse"
+require "rbconfig"
##
# Minimal (mostly drop-in) replacement for test-unit.
@@ -891,15 +889,13 @@ def _run_anything type
end
##
- # Runs all the +suites+ for a given +type+. Runs suites declaring
- # a test_order of +:parallel+ in parallel, and everything else
- # serial.
+ # Runs all the +suites+ for a given +type+.
+ #
+ # NOTE: this method is redefined in parallel_each.rb, which is
+ # loaded if a test-suite calls parallelize_me!.
def _run_suites suites, type
- parallel, serial = suites.partition { |s| s.test_order == :parallel }
-
- ParallelEach.new(parallel).map { |suite| _run_suite suite, type } +
- serial.map { |suite| _run_suite suite, type }
+ suites.map { |suite| _run_suite suite, type }
end
##
@@ -981,11 +977,15 @@ def initialize # :nodoc:
@report = []
@errors = @failures = @skips = 0
@verbose = false
- @mutex = Mutex.new
+ @mutex = Mutex.new if defined?(Mutex)
end
def synchronize # :nodoc:
- @mutex.synchronize { yield }
+ if @mutex then
+ @mutex.synchronize { yield }
+ else
+ yield
+ end
end
def process_args args = [] # :nodoc:
@@ -1405,6 +1405,8 @@ def self.make_my_diffs_pretty!
# and your tests are awesome.
def self.parallelize_me!
+ require "minitest/parallel_each"
+
class << self
undef_method :test_order if method_defined? :test_order
define_method :test_order do :parallel end
Please sign in to comment.
Something went wrong with that request. Please try again.