From 968d6df49f5f59eb2898d27399ad6d49b723216d Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Sun, 17 May 2020 16:33:56 +0900 Subject: [PATCH] Added --test-order=nosort option Run tests in the order given in the command line. --- tool/lib/minitest/unit.rb | 9 +++++++-- tool/lib/test/unit.rb | 2 +- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/tool/lib/minitest/unit.rb b/tool/lib/minitest/unit.rb index 5d24d0e30d..707dcfbf4f 100644 --- a/tool/lib/minitest/unit.rb +++ b/tool/lib/minitest/unit.rb @@ -1404,11 +1404,14 @@ module MiniTest end def self.test_suites # :nodoc: + suites = @@test_suites.keys case self.test_order when :random - @@test_suites.keys.shuffle + suites.shuffle + when :nosort + suites else - @@test_suites.keys.sort_by { |ts| ts.name.to_s } + suites.sort_by { |ts| ts.name.to_s } end end @@ -1424,6 +1427,8 @@ module MiniTest methods.sort.sort_by { rand max } when :alpha, :sorted then methods.sort + when :nosort + methods else raise "Unknown test_order: #{self.test_order.inspect}" end diff --git a/tool/lib/test/unit.rb b/tool/lib/test/unit.rb index a2ee464ff1..0cba377db2 100644 --- a/tool/lib/test/unit.rb +++ b/tool/lib/test/unit.rb @@ -102,7 +102,7 @@ module Test (options[:filter] ||= []) << a end - opts.on '--test-order=random|alpha|sorted', [:random, :alpha, :sorted] do |a| + opts.on '--test-order=random|alpha|sorted|nosort', [:random, :alpha, :sorted, :nosort] do |a| MiniTest::Unit::TestCase.test_order = a end end