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

ruby-changes:60219

From: Koichi <ko1@a...>
Date: Fri, 28 Feb 2020 17:44:45 +0900 (JST)
Subject: [ruby-changes:60219] 28399e4e0f (master): respect --test-order=random

https://git.ruby-lang.org/ruby.git/commit/?id=28399e4e0f

From 28399e4e0f8036b03d7e626b0071de0f59ac7bc0 Mon Sep 17 00:00:00 2001
From: Koichi Sasada <ko1@a...>
Date: Thu, 27 Feb 2020 10:49:14 +0900
Subject: respect --test-order=random

Now --test-order=random is simply ignored. This patch respect
this option.

diff --git a/tool/lib/minitest/unit.rb b/tool/lib/minitest/unit.rb
index f4e5e4e..3d1b796 100644
--- a/tool/lib/minitest/unit.rb
+++ b/tool/lib/minitest/unit.rb
@@ -1387,11 +1387,16 @@ module MiniTest https://github.com/ruby/ruby/blob/trunk/tool/lib/minitest/unit.rb#L1387
       end
 
       def self.test_order # :nodoc:
-        :random
+        :sorted
       end
 
       def self.test_suites # :nodoc:
-        @@test_suites.keys.sort_by { |ts| ts.name.to_s }
+        case self.test_order
+        when :random
+          @@test_suites.keys.shuffle
+        else
+          @@test_suites.keys.sort_by { |ts| ts.name.to_s }
+        end
       end
 
       def self.test_methods # :nodoc:
diff --git a/tool/lib/test/unit.rb b/tool/lib/test/unit.rb
index ad053cf..130fcf0 100644
--- a/tool/lib/test/unit.rb
+++ b/tool/lib/test/unit.rb
@@ -474,6 +474,14 @@ module Test https://github.com/ruby/ruby/blob/trunk/tool/lib/test/unit.rb#L474
         # Require needed thing for parallel running
         require 'timeout'
         @tasks = @files.dup # Array of filenames.
+
+        case MiniTest::Unit::TestCase.test_order
+        when :random
+          @tasks.shuffle!
+        else
+          # sorted
+        end
+
         @need_quit = false
         @dead_workers = []  # Array of dead workers.
         @warnings = []
diff --git a/tool/lib/test/unit/testcase.rb b/tool/lib/test/unit/testcase.rb
index 58cfbca..68149a4 100644
--- a/tool/lib/test/unit/testcase.rb
+++ b/tool/lib/test/unit/testcase.rb
@@ -18,10 +18,6 @@ module Test https://github.com/ruby/ruby/blob/trunk/tool/lib/test/unit/testcase.rb#L18
         super runner
       end
 
-      def self.test_order
-        :sorted
-      end
-
       def self.method_added(name)
         super
         return unless name.to_s.start_with?("test_")
-- 
cgit v0.10.2


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

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