The way the tests are currently set up is each test brings up a Wayland server and runs the tested code in the second thread, while the main thread sleeps and dispatches messages on the server side the required number of times:
https://github.com/YaLTeR/wl-clipboard-rs/blob/b29b92416496677494ad7ddde6a0c6dde437e6ef/src/tests/paste.rs#L180-L188
This is not very robust because depending on the thread scheduling the (arbitrarily chosen) 100 ms delay might not be enough for the second thread to do its chunk of work and send data over the Wayland socket.
The way the tests are currently set up is each test brings up a Wayland server and runs the tested code in the second thread, while the main thread sleeps and dispatches messages on the server side the required number of times: https://github.com/YaLTeR/wl-clipboard-rs/blob/b29b92416496677494ad7ddde6a0c6dde437e6ef/src/tests/paste.rs#L180-L188 This is not very robust because depending on the thread scheduling the (arbitrarily chosen) 100 ms delay might not be enough for the second thread to do its chunk of work and send data over the Wayland socket.
It should be possible to change this to be predictable. Most of the crate code (except the last loop in
copy()
) currently does its communication viaEventQueue::sync_roundtrip()
which might help here too. For the reference, see how the testroundtrip()
function is set up in thewayland-rs
tests: https://github.com/Smithay/wayland-rs/blob/11c8875a7b59aa24020eff48b0de82abba705af1/tests/helpers/mod.rs#L84-L113