This testcase runs slowly due to 3.2s of sleeps = 2 + 1 + 0.2s.
After this patch it has 0.55s only.
Reduced by:
- observed that the last test was bogus: we were sleeping until the queue was idle, effectively just a second copy of the first test. This avoids 1s sleep.
- when waiting for debounce, sleep only until test passes, not for enough time to be safe (in practice was 2x debounce time, now 1x debounce time)
- scaling delays down by a factor of 2 (note: factor of 10 caused bot failures)
This is potentially a race in the test that we did not have before, right?
There is probably much less work in the main test thread, but we probably can still see the failure if we are unlucky with how the OS schedules us.
My stance is it's better to have no tests for certain behaviours than flaky tests.
But if you find it useful let's try to run it and see whether my suspicions are unfounded, don't want to block the change on it.