[前][次][番号順一覧][スレッド一覧]

ruby-changes:33993

From: akr <ko1@a...>
Date: Sat, 24 May 2014 16:09:34 +0900 (JST)
Subject: [ruby-changes:33993] akr:r46074 (trunk): * test/lib/minitest/unit.rb (parallelize_me!): Removed.

akr	2014-05-24 16:09:29 +0900 (Sat, 24 May 2014)

  New Revision: 46074

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=46074

  Log:
    * test/lib/minitest/unit.rb (parallelize_me!): Removed.
      This fixes the line-by-line structure of the test result in verbose
      mode.  [ruby-core:54905]
    
    * test/lib/minitest/parallel_each.rb: Removed.
    
    * test/minitest/test_minitest_mock.rb: Don't call parallelize_me!.
    
    * test/minitest/test_minitest_spec.rb: Ditto.
    
    * test/minitest/test_minitest_unit.rb: Ditto.
      Tests for parallel feature removed.

  Removed files:
    trunk/test/lib/minitest/parallel_each.rb
  Modified files:
    trunk/ChangeLog
    trunk/test/lib/minitest/unit.rb
    trunk/test/minitest/test_minitest_mock.rb
    trunk/test/minitest/test_minitest_spec.rb
    trunk/test/minitest/test_minitest_unit.rb
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 46073)
+++ ChangeLog	(revision 46074)
@@ -1,3 +1,18 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Sat May 24 15:49:39 2014  Tanaka Akira  <akr@f...>
+
+	* test/lib/minitest/unit.rb (parallelize_me!): Removed.
+	  This fixes the line-by-line structure of the test result in verbose
+	  mode.  [ruby-core:54905]
+
+	* test/lib/minitest/parallel_each.rb: Removed.
+
+	* test/minitest/test_minitest_mock.rb: Don't call parallelize_me!.
+
+	* test/minitest/test_minitest_spec.rb: Ditto.
+
+	* test/minitest/test_minitest_unit.rb: Ditto.
+	  Tests for parallel feature removed.
+
 Sat May 24 15:29:10 2014  Tanaka Akira  <akr@f...>
 
 	* test/lib/minitest/hell.rb: Unused file removed.
Index: test/lib/minitest/parallel_each.rb
===================================================================
--- test/lib/minitest/parallel_each.rb	(revision 46073)
+++ test/lib/minitest/parallel_each.rb	(revision 46074)
@@ -1,75 +0,0 @@ https://github.com/ruby/ruby/blob/trunk/test/lib/minitest/parallel_each.rb#L0
-# encoding: utf-8
-
-##
-# Provides a parallel #each that lets you enumerate using N threads.
-# Use environment variable N to customize. Defaults to 2. Enumerable,
-# so all the goodies come along (tho not all are wrapped yet to
-# return another ParallelEach instance).
-
-class ParallelEach
-  require 'thread'
-  include Enumerable
-
-  ##
-  # How many Threads to use for this parallel #each.
-
-  N = (ENV['N'] || 2).to_i
-
-  ##
-  # Create a new ParallelEach instance over +list+.
-
-  def initialize list
-    @queue = Queue.new # *sigh*... the Queue api sucks sooo much...
-
-    list.each { |i| @queue << i }
-    N.times { @queue << nil }
-  end
-
-  def grep pattern # :nodoc:
-    self.class.new super
-  end
-
-  def select(&block) # :nodoc:
-    self.class.new super
-  end
-
-  alias find_all select # :nodoc:
-
-  ##
-  # Starts N threads that yield each element to your block. Joins the
-  # threads at the end.
-
-  def each
-    threads = N.times.map {
-      Thread.new do
-        Thread.current.abort_on_exception = true
-        while job = @queue.pop
-          yield job
-        end
-      end
-    }
-    threads.map(&:join)
-  end
-
-  def count
-    [@queue.size - N, 0].max
-  end
-
-  alias_method :size, :count
-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
Index: test/lib/minitest/unit.rb
===================================================================
--- test/lib/minitest/unit.rb	(revision 46073)
+++ test/lib/minitest/unit.rb	(revision 46074)
@@ -902,8 +902,6 @@ module MiniTest https://github.com/ruby/ruby/blob/trunk/test/lib/minitest/unit.rb#L902
     ##
     # 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
       suites.map { |suite| _run_suite suite, type }
@@ -1346,20 +1344,6 @@ module MiniTest https://github.com/ruby/ruby/blob/trunk/test/lib/minitest/unit.rb#L1344
         end
       end
 
-      ##
-      # Call this at the top of your tests when you want to run your
-      # tests in parallel. In doing so, you're admitting that you rule
-      # 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
-        end
-      end
-
       def self.inherited klass # :nodoc:
         @@test_suites[klass] = true
         super
Index: test/minitest/test_minitest_mock.rb
===================================================================
--- test/minitest/test_minitest_mock.rb	(revision 46073)
+++ test/minitest/test_minitest_mock.rb	(revision 46074)
@@ -3,8 +3,6 @@ https://github.com/ruby/ruby/blob/trunk/test/minitest/test_minitest_mock.rb#L3
 require 'minitest/autorun'
 
 class TestMiniTestMock < MiniTest::Unit::TestCase
-  parallelize_me!
-
   def setup
     @mock = MiniTest::Mock.new.expect(:foo, nil)
     @mock.expect(:meaning_of_life, 42)
@@ -273,8 +271,6 @@ end https://github.com/ruby/ruby/blob/trunk/test/minitest/test_minitest_mock.rb#L271
 require "minitest/metametameta"
 
 class TestMiniTestStub < MiniTest::Unit::TestCase
-  parallelize_me!
-
   def setup
     super
     MiniTest::Unit::TestCase.reset
Index: test/minitest/test_minitest_spec.rb
===================================================================
--- test/minitest/test_minitest_spec.rb	(revision 46073)
+++ test/minitest/test_minitest_spec.rb	(revision 46074)
@@ -593,8 +593,6 @@ class TestMetaStatic < MiniTest::Unit::T https://github.com/ruby/ruby/blob/trunk/test/minitest/test_minitest_spec.rb#L593
 end
 
 class TestMeta < MiniTest::Unit::TestCase
-  parallelize_me!
-
   def util_structure
     x = y = z = nil
     before_list = []
Index: test/minitest/test_minitest_unit.rb
===================================================================
--- test/minitest/test_minitest_unit.rb	(revision 46073)
+++ test/minitest/test_minitest_unit.rb	(revision 46074)
@@ -8,8 +8,6 @@ class AnError < StandardError; include M https://github.com/ruby/ruby/blob/trunk/test/minitest/test_minitest_unit.rb#L8
 class ImmutableString < String; def inspect; super.freeze; end; end
 
 class TestMiniTestUnit < MetaMetaMetaTestCase
-  parallelize_me!
-
   pwd = Pathname.new File.expand_path Dir.pwd
   basedir = Pathname.new(File.expand_path "lib/minitest") + 'mini'
   basedir = basedir.relative_path_from(pwd).to_s
@@ -558,56 +556,6 @@ class TestMiniTestRunner < MetaMetaMetaT https://github.com/ruby/ruby/blob/trunk/test/minitest/test_minitest_unit.rb#L556
       @lock.synchronize { @cv.wait_while { @count > 0 } }
     end
   end
-
-  def test_parallel_each_size
-    assert_equal 0, ParallelEach.new([]).size
-  end
-
-  def test_run_parallel
-    skip "I don't have ParallelEach debugged yet" if maglev?
-
-    test_count = 2
-    test_latch = Latch.new test_count
-    main_latch = Latch.new
-
-    thread = Thread.new {
-      Thread.current.abort_on_exception = true
-
-      # This latch waits until both test latches have been released.  Both
-      # latches can't be released unless done in separate threads because
-      # `main_latch` keeps the test method from finishing.
-      test_latch.await
-      main_latch.release
-    }
-
-    Class.new MiniTest::Unit::TestCase do
-      parallelize_me!
-
-      test_count.times do |i|
-        define_method :"test_wait_on_main_thread_#{i}" do
-          test_latch.release
-
-          # This latch blocks until the "main thread" releases it. The main
-          # thread can't release this latch until both test latches have
-          # been released.  This forces the latches to be released in separate
-          # threads.
-          main_latch.await
-          assert true
-        end
-      end
-    end
-
-    expected = clean <<-EOM
-      ..
-
-      Finished tests in 0.00
-
-      2 tests, 2 assertions, 0 failures, 0 errors, 0 skips
-    EOM
-
-    assert_report expected
-    assert thread.join
-  end
 end
 
 class TestMiniTestUnitOrder < MetaMetaMetaTestCase
@@ -1392,7 +1340,6 @@ class TestMiniTestUnitTestCase < MiniTes https://github.com/ruby/ruby/blob/trunk/test/minitest/test_minitest_unit.rb#L1340
 
   def test_capture_subprocess_io
     @assertion_count = 0
-    skip "Dunno why but the parallel run of this fails"
 
     non_verbose do
       out, err = capture_subprocess_io do
@@ -1756,8 +1703,6 @@ class TestMiniTestUnitTestCase < MiniTes https://github.com/ruby/ruby/blob/trunk/test/minitest/test_minitest_unit.rb#L1703
 end
 
 class TestMiniTestGuard < MiniTest::Unit::TestCase
-  parallelize_me!
-
   def test_mri_eh
     assert self.class.mri? "ruby blah"
     assert self.mri? "ruby blah"

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]