gpt4 book ai didi

rspec - RSpec 种子在不同的机器上运行是否相同?

转载 作者:行者123 更新时间:2023-12-04 15:52:27 26 4
gpt4 key购买 nike

我正在尝试使用 Travis 设置 CI。但是我遇到了在 Travis 上失败但在本地没有的测试,甚至提供了相同的种子。

我认为种子运行相同,但现在我不确定,并想弄清楚它是否存在,所以我现在在哪里看。

最佳答案

看看this RSpec 功能页面:

In Ruby, randomness is seeded by calling srand and passing it the seed that you want to use. By doing this, subsequent calls to rand, shuffle, sample, etc. will all be randomized the same way given the same seed is passed to srand.



所以简而言之,是的,它会在其他机器上以相同的顺序运行。

ruby 的 srand确实保证使用相同 Ruby 版本的机器之间的数字相同。请参阅此 SO 问题和结果答案: Does seed generate same random sequence across different Rubys?

关于rspec - RSpec 种子在不同的机器上运行是否相同?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43615656/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com