1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

srand($seed) at the beginning of each test

To avoid `srand(0)` effect in the other tests, call `srand($seed)`
at the beginning of each test (setup).
[Feature #16655]
This commit is contained in:
Koichi Sasada 2020-02-27 03:47:41 +09:00
parent f9d314245b
commit 14f1790807
2 changed files with 3 additions and 0 deletions

View file

@ -1297,6 +1297,8 @@ module MiniTest
start_time = Time.now
result = ""
srand(runner.options[:seed])
begin
@passed = nil
self.before_setup

View file

@ -47,6 +47,7 @@ class MetaMetaMetaTestCase < MiniTest::Unit::TestCase
srand 42
MiniTest::Unit::TestCase.reset
@tu = MiniTest::Unit.new
@tu.options[:seed] = 42
MiniTest::Unit.runner = nil # protect the outer runner from the inner tests
end