[前][次][番号順一覧][スレッド一覧]

ruby-changes:60209

From: Koichi <ko1@a...>
Date: Thu, 27 Feb 2020 03:48:23 +0900 (JST)
Subject: [ruby-changes:60209] 14f1790807 (master): `srand($seed)` at the beginning of each test

https://git.ruby-lang.org/ruby.git/commit/?id=14f1790807

From 14f179080713012251e1faecccefebf2f33ecd86 Mon Sep 17 00:00:00 2001
From: Koichi Sasada <ko1@a...>
Date: Thu, 27 Feb 2020 03:47:41 +0900
Subject: `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]

diff --git a/tool/lib/minitest/unit.rb b/tool/lib/minitest/unit.rb
index 8569b2c..0b0d892 100644
--- a/tool/lib/minitest/unit.rb
+++ b/tool/lib/minitest/unit.rb
@@ -1297,6 +1297,8 @@ module MiniTest https://github.com/ruby/ruby/blob/trunk/tool/lib/minitest/unit.rb#L1297
         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 a12717c..f7e0f02 100644
--- a/tool/test/minitest/metametameta.rb
+++ b/tool/test/minitest/metametameta.rb
@@ -47,6 +47,7 @@ class MetaMetaMetaTestCase < MiniTest::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/tool/test/minitest/metametameta.rb#L47
     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
-- 
cgit v0.10.2


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]