Fixing flaky tests in combov2.comboctl.PumpIOTest. cmdCMDReadErrorWarningStatus and checkCMDHistoryDeltaRetrieval failed about 20% of time (run with @RepeatedTest(100)) since pumpIO.disconnect was send before processing last command was done.

This commit is contained in:
robertbuessow 2023-08-29 16:23:54 +02:00 committed by Milos Kozak
parent 946ea0bf33
commit 5c34184723

View file

@ -24,7 +24,8 @@ class TestBluetoothDevice(private val testComboIO: ComboIO) : BluetoothDevice(Di
}
override fun disconnect() {
frameParser.reset()
// Synchronized rest so we don't interfere with pushing/parsing data into the frameParser.
synchronized(frameParser) { frameParser.reset() }
runBlocking {
innerJob.cancelAndJoin()
}
@ -38,8 +39,10 @@ class TestBluetoothDevice(private val testComboIO: ComboIO) : BluetoothDevice(Di
}
override fun blockingSend(dataToSend: List<Byte>) {
frameParser.pushData(dataToSend)
frameParser.parseFrame()?.let {
synchronized(frameParser) {
frameParser.pushData(dataToSend)
frameParser.parseFrame()
}?.let {
runBlocking {
innerScope.async {
testComboIO.send(it)