diff options
author | Koichi Sasada <[email protected]> | 2020-02-27 03:47:41 +0900 |
---|---|---|
committer | Koichi Sasada <[email protected]> | 2020-02-27 03:47:41 +0900 |
commit | 14f179080713012251e1faecccefebf2f33ecd86 (patch) | |
tree | 1e88fb58c3cf1cdf123c68febb875bceac6ac8c0 | |
parent | f9d314245b1b088555253f5b653a801031cdc1e6 (diff) |
`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]
-rw-r--r-- | tool/lib/minitest/unit.rb | 2 | ||||
-rw-r--r-- | tool/test/minitest/metametameta.rb | 1 |
2 files changed, 3 insertions, 0 deletions
diff --git a/tool/lib/minitest/unit.rb b/tool/lib/minitest/unit.rb index 8569b2c495..0b0d892436 100644 --- a/tool/lib/minitest/unit.rb +++ b/tool/lib/minitest/unit.rb @@ -1297,6 +1297,8 @@ module MiniTest start_time = Time.now result = "" + srand(runner.options[:seed]) + begin @passed = nil self.before_setup diff --git a/tool/test/minitest/metametameta.rb b/tool/test/minitest/metametameta.rb index a12717c8b1..f7e0f02798 100644 --- a/tool/test/minitest/metametameta.rb +++ b/tool/test/minitest/metametameta.rb @@ -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 |