Skip to content

Commit

Permalink
Move logging from WorkerRunnable to Marathon class
Browse files Browse the repository at this point in the history
  • Loading branch information
Sergey Chelombitko committed Dec 9, 2024
1 parent 555017d commit 69e0d3e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
15 changes: 10 additions & 5 deletions core/src/main/kotlin/com/malinskiy/marathon/Marathon.kt
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,12 @@ class Marathon(
}

override suspend fun start() {
logger.debug("Starting Marathon")

configureLogging(configuration.vendorConfiguration)

deviceProvider.initialize(configuration.vendorConfiguration)
logger.debug { "Finished loading device provider" }
logger.debug("Finished loading device provider")

configurationValidator.validate(configuration)

Expand All @@ -87,10 +89,10 @@ class Marathon(
currentCoroutineContext
)

logger.debug { "Created scheduler" }
logger.debug("Created scheduler")

if (configuration.outputDir.exists()) {
logger.info { "Output ${configuration.outputDir} already exists" }
logger.info("Output directory ${configuration.outputDir} already exists")
configuration.outputDir.deleteRecursively()
}
configuration.outputDir.mkdirs()
Expand All @@ -103,14 +105,17 @@ class Marathon(
override suspend fun scheduleTests(componentInfo: ComponentInfo) {
val parsedTests = testParser.extract(componentInfo)
val tests = applyTestFilters(parsedTests)
val shard = prepareTestShard(tests, analytics)

logger.info("Scheduling ${tests.size} tests")
logger.info("Scheduling ${tests.size} tests for $componentInfo")
logger.debug(tests.joinToString(", ") { it.toTestName() })

val shard = prepareTestShard(tests, analytics)
scheduler.addTests(shard)
}

override suspend fun stopAndWaitForCompletion(): Boolean {
logger.debug("Waiting for completion")

try {
scheduler.stopAndWaitForCompletion()
onFinish(analytics, deviceProvider, attachmentManager)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package com.malinskiy.marathon.worker

import com.malinskiy.marathon.Marathon
import com.malinskiy.marathon.execution.ComponentInfo
import com.malinskiy.marathon.log.MarathonLogging
import kotlinx.coroutines.channels.Channel
import kotlinx.coroutines.runBlocking
import org.gradle.api.GradleException
Expand All @@ -12,18 +11,13 @@ internal class WorkerRunnable(
private val componentsChannel: Channel<ComponentInfo>
) : Runnable {

private val log = MarathonLogging.logger {}

override fun run() = runBlocking {
log.debug("Starting Marathon worker")
marathon.start()

for (component in componentsChannel) {
log.debug("Scheduling tests for $component")
marathon.scheduleTests(component)
}

log.debug("Waiting for completion")
stopAndWaitForCompletion(marathon)
}

Expand Down

0 comments on commit 69e0d3e

Please # to comment.