Skip to content

Commit

Permalink
Add timeout to cds loader tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kunyavskiy committed Aug 30, 2023
1 parent 13f40e3 commit e451f37
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions src/cds/src/test/kotlin/org/icpclive/cds/CdsLoadersTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package org.icpclive.cds

import kotlinx.coroutines.flow.first
import kotlinx.coroutines.runBlocking
import kotlinx.coroutines.withTimeout
import kotlinx.serialization.encodeToString
import kotlinx.serialization.json.Json
import org.approvaltests.Approvals
Expand All @@ -16,6 +17,7 @@ import org.icpclive.cds.common.ContestParseResult
import org.icpclive.cds.settings.*
import kotlin.test.Test
import kotlin.text.Regex
import kotlin.time.Duration.Companion.minutes

class CdsLoadersTest {
@Test
Expand Down Expand Up @@ -103,12 +105,14 @@ class CdsLoadersTest {
private fun loaderTest(args: CDSSettings, advanced: AdvancedProperties? = null) {
val loader = args.toFlow(emptyMap())
val result = runBlocking {
val result = loader.contestState().first { it.infoAfterEvent?.status == ContestStatus.FINALIZED }.let {
ContestParseResult(
it.infoAfterEvent!!,
it.runs.values.toList(),
it.analyticsMessages.values.toList()
)
val result = withTimeout(1.minutes) {
loader.contestState().first { it.infoAfterEvent?.status == ContestStatus.FINALIZED }.let {
ContestParseResult(
it.infoAfterEvent!!,
it.runs.values.toList(),
it.analyticsMessages.values.toList()
)
}
}
if (advanced != null) {
result.copy(
Expand Down

0 comments on commit e451f37

Please sign in to comment.