From 28399e4e0f8036b03d7e626b0071de0f59ac7bc0 Mon Sep 17 00:00:00 2001 From: Koichi Sasada Date: Thu, 27 Feb 2020 10:49:14 +0900 Subject: [PATCH] respect --test-order=random Now --test-order=random is simply ignored. This patch respect this option. --- tool/lib/minitest/unit.rb | 9 +++++++-- tool/lib/test/unit.rb | 8 ++++++++ tool/lib/test/unit/testcase.rb | 4 ---- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/tool/lib/minitest/unit.rb b/tool/lib/minitest/unit.rb index f4e5e4ec8b..3d1b796fdf 100644 --- a/tool/lib/minitest/unit.rb +++ b/tool/lib/minitest/unit.rb @@ -1387,11 +1387,16 @@ module MiniTest 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 ad053cffdd..130fcf07e1 100644 --- a/tool/lib/test/unit.rb +++ b/tool/lib/test/unit.rb @@ -474,6 +474,14 @@ module Test # 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 58cfbcab99..68149a4880 100644 --- a/tool/lib/test/unit/testcase.rb +++ b/tool/lib/test/unit/testcase.rb @@ -18,10 +18,6 @@ module Test super runner end - def self.test_order - :sorted - end - def self.method_added(name) super return unless name.to_s.start_with?("test_")