-
Notifications
You must be signed in to change notification settings - Fork 167
Description
Question rather than an issue --
I'm informally responsible for unit tests of SuperCollider's LinkClock. Most of the tests are fine.
We have one test called test_newLinkClock_shouldNotChangeLinkTempo.
- Create a LinkClock at 150 bpm.
- Wait 500 ms for the Link session to stabilize.
- Create a second LinkClock at 60 bpm.
- This should sync clock2's tempo (and phase etc., but tempo is what we're testing). On the SC side, this causes a
\temponotification to be broadcast, which signals the test to move ahead. - Then we check if clock1's tempo is still 150 bpm: true = pass.
- Both clocks (peers) are then destroyed at the same time.
On my machine, if I run this test in isolation, it passes.
In our github CI, the test sporadically fails.
I can also reproduce the failure if I run the test multiple times in quick succession. When it fails, it looks like clock2 controls the Link session's tempo, despite being created later. But, if I increase the delay after creating the first clock, the failures disappear.
So there's a conflict between Link requiring some time to ensure that the session is created correctly vs the desire to minimize hardcoded delays in a unit testing suite that already takes longer to run than we might like.
So the question is how best to handle this.
Is there a recommendation for how long to wait for the first Link peer to stabilize the session, so that we can be sure of its state?
Or (better) does the Link API emit some signal when the session is ready to be trusted? Above, for instance, the second peer gets a tempo-change notification if, at connection time, its tempo disagrees with the session's established tempo. But the first peer, AFAICS, gets nothing. So, on our side, I don't know how to be sure that the clock has actually synced up with the session. Understood that, under normal use, you'd create the peer and probably start playing up to several minutes later -- but for testing purposes, it would really help not to have to hardcode long wait times.
Any advice welcome -- thanks.