You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In 1.66.1 and previous, RUST_TEST_THREADS=1 (or --test-threads=1) used a single thread to run the tests. After that point the behaviour changed. Cargo now apparently uses multiple threads but with a lock to ensure that only one thread runs at a time. This change of behaviour has broken some of my tests for https://crates.io/crates/stakker.
Stakker can run multi-threaded, but as a single-threaded optimisation I allow a single thread to effectively become "special". If Stakker is started on that thread, then it can safely use global variables internally as an optimisation. However if Stakker is then started on any other thread, it panics. This is fine when the app is structured as a main thread plus auxiliary threads. However, with the new behaviour my single-threaded tests are panicking.
This is a valid use-case. The code is sound. It would be preferable to use cargo test to test it and not to have to resort to any other kind of tooling.
Whilst I can continue to run the other tests fine (cargo test runs the multi-threaded tests by default), I do need to also test the single-threaded functionality. So I will have to improvise something for now. I'll see if I can use --list and run them one by one. But it would be helpful if the --test-threads=1 option went back to doing as the name suggests.
Steps
Checkout Stakker on Linux (or something with a bash shell)
Execute ./run-test-all which executes all tests, including single-threaded ones
On 1.68.1, you will see lots of assertion failures due to the thread-id being different to expected.
Problem
In 1.66.1 and previous, RUST_TEST_THREADS=1 (or --test-threads=1) used a single thread to run the tests. After that point the behaviour changed. Cargo now apparently uses multiple threads but with a lock to ensure that only one thread runs at a time. This change of behaviour has broken some of my tests for https://crates.io/crates/stakker.
Stakker can run multi-threaded, but as a single-threaded optimisation I allow a single thread to effectively become "special". If Stakker is started on that thread, then it can safely use global variables internally as an optimisation. However if Stakker is then started on any other thread, it panics. This is fine when the app is structured as a main thread plus auxiliary threads. However, with the new behaviour my single-threaded tests are panicking.
This is a valid use-case. The code is sound. It would be preferable to use
cargo test
to test it and not to have to resort to any other kind of tooling.Whilst I can continue to run the other tests fine (
cargo test
runs the multi-threaded tests by default), I do need to also test the single-threaded functionality. So I will have to improvise something for now. I'll see if I can use--list
and run them one by one. But it would be helpful if the --test-threads=1 option went back to doing as the name suggests.Steps
./run-test-all
which executes all tests, including single-threaded onesOn 1.68.1, you will see lots of assertion failures due to the thread-id being different to expected.
Possible Solution(s)
Revert whatever change introduced this?
Notes
No response
Version
The text was updated successfully, but these errors were encountered: