Skip to content

Commit

Permalink
Adding withTimeout to see if it can allow the coroutine to run upto t…
Browse files Browse the repository at this point in the history
…he timeout
  • Loading branch information
Rd4dev committed Jun 30, 2024
1 parent 0e99588 commit 67e5fb9
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package org.oppia.android.scripts.coverage
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Deferred
import kotlinx.coroutines.async
import kotlinx.coroutines.withTimeout
import org.oppia.android.scripts.common.BazelClient
import org.oppia.android.scripts.common.CommandExecutor
import org.oppia.android.scripts.common.ScriptBackgroundCoroutineDispatcher
Expand Down Expand Up @@ -38,10 +39,12 @@ class CoverageRunner(
bazelTestTarget: String
): Deferred<CoverageReport> {
return CoroutineScope(scriptBgDispatcher).async {
val coverageResult = retrieveCoverageResult(bazelTestTarget)
?: error("Failed to retrieve coverage result for $bazelTestTarget")
withTimeout(600_000) {
val coverageResult = retrieveCoverageResult(bazelTestTarget)
?: error("Failed to retrieve coverage result for $bazelTestTarget")

coverageDataFileLines(coverageResult, bazelTestTarget)
coverageDataFileLines(coverageResult, bazelTestTarget)
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,6 @@ class MavenDependenciesRetriever(
finalDependenciesList: List<MavenListDependency>
): Deferred<MavenDependencyList> {
return CoroutineScope(scriptBgDispatcher).async {
println("delaying...")
delay(400000)
val candidates = finalDependenciesList.map { MavenListDependencyPomCandidate(it) }
val undoneCandidates = candidates.filterTo(mutableSetOf()) { it.latestPomFileText == null }
var attemptCount = 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,6 @@ class RunCoverageTest {
assertThat(outputReportText).isEqualTo(expectedResult)
}

@Test(timeout = 400000)
fun testRunCoverage_sampleTestsMarkdownFormat_returnsCoverageData() {
testBazelWorkspace.initEmptyWorkspace()

Expand All @@ -370,6 +369,16 @@ class RunCoverageTest {
fun sumNumbers(a: Int, b: Int): Any {
return if (a == 0 && b == 0) {
"Both numbers are zero"
} else if (a == 245) {
"Big number than 244"
} else if (a == 1) {
1 + b
} else if (a == 2) {
2 + b
} else if (b == 1) {
a + 1
} else if (b == 2) {
a + 2
} else {
a + b
}
Expand Down

0 comments on commit 67e5fb9

Please sign in to comment.