diff options
author | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2021-09-18 16:05:26 +0900 |
---|---|---|
committer | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2021-10-04 20:46:47 +0900 |
commit | c4570acc86837fefa542a678dfdaba73cdd1fd03 (patch) | |
tree | 3727981f05a359b1fca4fb9df050b26f5c46ddf0 /tool/lib/test/unit/testcase.rb | |
parent | 44b2e32fb670e5e704f5721cf973cdc77d54a315 (diff) |
Refactor ordering of tests
* Split the sorting types into classes.
* Apply the same sorting to method sorting under the parallel
test.
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/4862
Diffstat (limited to 'tool/lib/test/unit/testcase.rb')
-rw-r--r-- | tool/lib/test/unit/testcase.rb | 40 |
1 files changed, 2 insertions, 38 deletions
diff --git a/tool/lib/test/unit/testcase.rb b/tool/lib/test/unit/testcase.rb index 241421d6d9..4cc1aae3e4 100644 --- a/tool/lib/test/unit/testcase.rb +++ b/tool/lib/test/unit/testcase.rb @@ -159,7 +159,6 @@ module Test start_time = Time.now result = "" - srand(runner.options[:seed]) begin @passed = nil @@ -267,46 +266,11 @@ module Test end def self.test_suites # :nodoc: - suites = @@test_suites.keys - - case self.test_order - when :random - # shuffle test suites based on CRC32 of their names - salt = "\n" + rand(1 << 32).to_s - crc_tbl = (0..255).map do |i| - (0..7).inject(i) {|c,| (c & 1 == 1) ? (0xEDB88320 ^ (c >> 1)) : (c >> 1) } - end - suites = suites.sort_by do |suite| - crc32 = 0xffffffff - "#{suite.name}#{salt}".each_byte do |data| - crc32 = crc_tbl[(crc32 ^ data) & 0xff] ^ (crc32 >> 8) - end - crc32 ^ 0xffffffff - end - when :nosort - suites - else - suites.sort_by { |ts| ts.name.to_s } - end + @@test_suites.keys end def self.test_methods # :nodoc: - methods = public_instance_methods(true).grep(/^test/).map { |m| m.to_s } - - case self.test_order - when :parallel - max = methods.size - ParallelEach.new methods.sort.sort_by { rand max } - when :random then - max = methods.size - 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 + public_instance_methods(true).grep(/^test/) end ## |