Skip to content

Commit

Permalink
+ Removed minor optimization removing empty suites before run.
Browse files Browse the repository at this point in the history
+ Simplified test randomization (test order will change even with fixed seed).

[git-p4: depot-paths = "//src/minitest/dev/": change = 13422]
  • Loading branch information
zenspider committed Jun 5, 2022
1 parent ed224bc commit 9cdb2c6
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 14 deletions.
2 changes: 1 addition & 1 deletion lib/minitest.rb
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ def self.run args = []
# sub-classes to run.

def self.__run reporter, options
suites = Runnable.runnables.reject { |s| s.runnable_methods.empty? }.shuffle
suites = Runnable.runnables.shuffle
parallel, serial = suites.partition { |s| s.test_order == :parallel }

# If we run the parallel tests before the serial tests, the parallel tests
Expand Down
3 changes: 1 addition & 2 deletions lib/minitest/test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,7 @@ def self.runnable_methods

case self.test_order
when :random, :parallel then
max = methods.size
methods.sort.sort_by { rand max }
methods.sort.shuffle
when :alpha, :sorted then
methods.sort
else
Expand Down
22 changes: 11 additions & 11 deletions test/minitest/test_minitest_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -99,20 +99,20 @@ def test_this_is_non_ascii_failure_message
end

expected = clean <<-EOM
EF
FE
Finished in 0.00
1) Error:
FakeNamedTestXX#test_this_is_non_ascii_failure_message:
RuntimeError: ЁЁЁ
FILE:LINE:in `test_this_is_non_ascii_failure_message'
2) Failure:
1) Failure:
FakeNamedTestXX#test_this_is_not_ascii_assertion [FILE:LINE]:
Expected: \"ЁЁЁ\"
Actual: \"ёёё\"
2) Error:
FakeNamedTestXX#test_this_is_non_ascii_failure_message:
RuntimeError: ЁЁЁ
FILE:LINE:in `test_this_is_non_ascii_failure_message'
2 runs, 1 assertions, 1 failures, 1 errors, 0 skips
EOM

Expand Down Expand Up @@ -260,7 +260,7 @@ def test_error
end

expected = clean <<-EOM
E.
.E
Finished in 0.00
Expand Down Expand Up @@ -307,7 +307,7 @@ def test_run_failing
setup_basic_tu

expected = clean <<-EOM
F.
.F
Finished in 0.00
Expand Down Expand Up @@ -491,7 +491,7 @@ def test_skip
end

expected = clean <<-EOM
S.
.S
Finished in 0.00
Expand All @@ -518,8 +518,8 @@ def test_skip
end

expected = clean <<-EOM
FakeNamedTestXX#test_skip = 0.00 s = S
FakeNamedTestXX#test_something = 0.00 s = .
FakeNamedTestXX#test_skip = 0.00 s = S
Finished in 0.00
Expand Down

0 comments on commit 9cdb2c6

Please sign in to comment.