madsim-rs / madsim

Magical Deterministic Simulator for distributed systems in Rust.
Apache License 2.0
618 stars 41 forks source link

Allow toggling off the new-thread-spawned detector #210

Closed tomasol closed 1 month ago

tomasol commented 1 month ago

When a test spawns a new thread, madsim will panic with "attempt to spawn a system thread in simulation.", which is good for catching one specific kind of determinism breakage. However I still see benefits of using madsim's seeded RNG with regular tests, as it helps narrowing down the possible causes of a failure, especially for property-based testing. I would like to propose adding a new environment variable that would disable the said check.

I am currently testing with the check removed, I also had to insert a sleep if going == false in the block_on loop.

tomasol commented 1 month ago

Thanks for the quick fix again :heart: , there is just one more thing that I mentioned on the last line that enables awaiting on events triggered by the thread.

wangrunji0408 commented 1 month ago

Oh sorry I missed the last part. Thanks for your PR!