From 69e0d3e2683d722f0e2a13f514c61fb426af28b4 Mon Sep 17 00:00:00 2001 From: Sergey Chelombitko Date: Mon, 9 Dec 2024 18:21:57 +0000 Subject: [PATCH] Move logging from WorkerRunnable to Marathon class --- .../kotlin/com/malinskiy/marathon/Marathon.kt | 15 ++++++++++----- .../malinskiy/marathon/worker/WorkerRunnable.kt | 6 ------ 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/core/src/main/kotlin/com/malinskiy/marathon/Marathon.kt b/core/src/main/kotlin/com/malinskiy/marathon/Marathon.kt index 615c3238d..8357958ff 100644 --- a/core/src/main/kotlin/com/malinskiy/marathon/Marathon.kt +++ b/core/src/main/kotlin/com/malinskiy/marathon/Marathon.kt @@ -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) @@ -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() @@ -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) diff --git a/marathon-gradle-plugin/src/main/kotlin/com/malinskiy/marathon/worker/WorkerRunnable.kt b/marathon-gradle-plugin/src/main/kotlin/com/malinskiy/marathon/worker/WorkerRunnable.kt index e818c4ffe..003ecf947 100644 --- a/marathon-gradle-plugin/src/main/kotlin/com/malinskiy/marathon/worker/WorkerRunnable.kt +++ b/marathon-gradle-plugin/src/main/kotlin/com/malinskiy/marathon/worker/WorkerRunnable.kt @@ -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 @@ -12,18 +11,13 @@ internal class WorkerRunnable( private val componentsChannel: Channel ) : 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) }