From 63226cc4973b78cdf35a88e92320eff9ac9cc889 Mon Sep 17 00:00:00 2001 From: Sergey Chelombitko Date: Mon, 22 Jul 2024 13:01:41 +0100 Subject: [PATCH 1/3] Remove paths to APKs from Configuration model --- .../marathon/scenario/CacheScenarios.kt | 1 + .../kotlin/com/malinskiy/marathon/Marathon.kt | 32 --------------- .../com/malinskiy/marathon/di/Modules.kt | 2 +- .../execution/ComponentInfoExtractor.kt | 5 --- .../scenario/DeviceFilteringScenario.kt | 1 + .../scenario/DisconnectingScenarios.kt | 1 + .../scenario/InvalidConfigScenarios.kt | 1 + .../marathon/scenario/SuccessScenarios.kt | 1 + .../marathon/scenario/UncompletedScenarios.kt | 1 + .../marathon/ConfigurationFactory.kt | 16 +------- .../marathon/android/AndroidConfiguration.kt | 2 - .../malinskiy/marathon/android/di/Modules.kt | 3 -- .../executor/AndroidComponentInfoExtractor.kt | 20 --------- .../marathon/android/AndroidTestParserSpek.kt | 41 +++---------------- .../android/AndroidDeviceTestRunnerSpek.kt | 12 ++++-- .../test/StubComponentInfoExtractor.kt | 13 ------ .../marathon/test/TestBodyExtensions.kt | 9 +++- .../marathon/test/TestVendorConfiguration.kt | 2 - 18 files changed, 30 insertions(+), 133 deletions(-) delete mode 100644 core/src/main/kotlin/com/malinskiy/marathon/execution/ComponentInfoExtractor.kt delete mode 100644 vendor/vendor-android/base/src/main/kotlin/com/malinskiy/marathon/android/executor/AndroidComponentInfoExtractor.kt delete mode 100644 vendor/vendor-test/src/main/kotlin/com/malinskiy/marathon/test/StubComponentInfoExtractor.kt diff --git a/core/src/integrationTest/kotlin/com/malinskiy/marathon/scenario/CacheScenarios.kt b/core/src/integrationTest/kotlin/com/malinskiy/marathon/scenario/CacheScenarios.kt index 9b6fadd71..9bdce04be 100644 --- a/core/src/integrationTest/kotlin/com/malinskiy/marathon/scenario/CacheScenarios.kt +++ b/core/src/integrationTest/kotlin/com/malinskiy/marathon/scenario/CacheScenarios.kt @@ -10,6 +10,7 @@ import com.malinskiy.marathon.execution.TestStatus import com.malinskiy.marathon.test.StubDevice import com.malinskiy.marathon.test.Test import com.malinskiy.marathon.test.TestComponentInfo +import com.malinskiy.marathon.test.runAsync import com.malinskiy.marathon.test.setupMarathon import kotlinx.coroutines.delay import kotlinx.coroutines.runBlocking diff --git a/core/src/main/kotlin/com/malinskiy/marathon/Marathon.kt b/core/src/main/kotlin/com/malinskiy/marathon/Marathon.kt index c5e1177d6..5fa8f58d2 100644 --- a/core/src/main/kotlin/com/malinskiy/marathon/Marathon.kt +++ b/core/src/main/kotlin/com/malinskiy/marathon/Marathon.kt @@ -8,10 +8,8 @@ import com.malinskiy.marathon.cache.test.TestCacheLoader import com.malinskiy.marathon.cache.test.TestCacheSaver import com.malinskiy.marathon.config.LogicalConfigurationValidator import com.malinskiy.marathon.device.DeviceProvider -import com.malinskiy.marathon.exceptions.NoDevicesException import com.malinskiy.marathon.exceptions.ReportGenerationException import com.malinskiy.marathon.execution.ComponentInfo -import com.malinskiy.marathon.execution.ComponentInfoExtractor import com.malinskiy.marathon.execution.Configuration import com.malinskiy.marathon.execution.Scheduler import com.malinskiy.marathon.execution.StrictRunChecker @@ -35,7 +33,6 @@ private val log = MarathonLogging.logger {} class Marathon( val configuration: Configuration, - private val componentInfoExtractor: ComponentInfoExtractor, private val deviceProvider: DeviceProvider, private val tracker: TrackerInternal, private val analytics: Analytics, @@ -66,35 +63,6 @@ class Marathon( logConfigurator.configure(vendorConfiguration) } - fun run() = runBlocking { - try { - val isSuccess = runAsync() - when { - configuration.ignoreFailures -> true - else -> isSuccess - } - } catch (th: Throwable) { - log.error(th.toString()) - - when (th) { - is NoDevicesException -> { - log.warn { "No devices found" } - false - } - else -> false - } - } - } - - suspend fun runAsync(): Boolean { - start() - - val componentInfo = componentInfoExtractor.extract(configuration) - scheduleTests(componentInfo) - - return stopAndWaitForCompletion() - } - override suspend fun start() { configureLogging(configuration.vendorConfiguration) diff --git a/core/src/main/kotlin/com/malinskiy/marathon/di/Modules.kt b/core/src/main/kotlin/com/malinskiy/marathon/di/Modules.kt index a6ce4572c..6f6220b36 100644 --- a/core/src/main/kotlin/com/malinskiy/marathon/di/Modules.kt +++ b/core/src/main/kotlin/com/malinskiy/marathon/di/Modules.kt @@ -68,7 +68,7 @@ fun coreModule(timer: Timer?) = module { single { timer ?: SystemTimer(get()) } single { ProgressReporter(get()) } single { ConfigurationStrictRunChecker(get()) } - single { Marathon(get(), get(), get(), get(), get(), get(), get(), get(), get(), get(), get(), get(), get(), get(), get(), get()) } + single { Marathon(get(), get(), get(), get(), get(), get(), get(), get(), get(), get(), get(), get(), get(), get(), get()) } } fun KoinApplication.marathonConfiguration(configuration: Configuration): KoinApplication { diff --git a/core/src/main/kotlin/com/malinskiy/marathon/execution/ComponentInfoExtractor.kt b/core/src/main/kotlin/com/malinskiy/marathon/execution/ComponentInfoExtractor.kt deleted file mode 100644 index b2e0ea227..000000000 --- a/core/src/main/kotlin/com/malinskiy/marathon/execution/ComponentInfoExtractor.kt +++ /dev/null @@ -1,5 +0,0 @@ -package com.malinskiy.marathon.execution - -interface ComponentInfoExtractor { - fun extract(configuration: Configuration): ComponentInfo -} diff --git a/core/src/test/kotlin/com/malinskiy/marathon/scenario/DeviceFilteringScenario.kt b/core/src/test/kotlin/com/malinskiy/marathon/scenario/DeviceFilteringScenario.kt index 3fede0d4c..f44cbfbca 100644 --- a/core/src/test/kotlin/com/malinskiy/marathon/scenario/DeviceFilteringScenario.kt +++ b/core/src/test/kotlin/com/malinskiy/marathon/scenario/DeviceFilteringScenario.kt @@ -6,6 +6,7 @@ import com.malinskiy.marathon.test.StubDevice import com.malinskiy.marathon.test.Test import com.malinskiy.marathon.test.TestComponentInfo import com.malinskiy.marathon.test.assert.shouldBeEqualToAsJson +import com.malinskiy.marathon.test.runAsync import com.malinskiy.marathon.test.setupMarathon import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.delay diff --git a/core/src/test/kotlin/com/malinskiy/marathon/scenario/DisconnectingScenarios.kt b/core/src/test/kotlin/com/malinskiy/marathon/scenario/DisconnectingScenarios.kt index 2b1251be5..3ce1b434f 100644 --- a/core/src/test/kotlin/com/malinskiy/marathon/scenario/DisconnectingScenarios.kt +++ b/core/src/test/kotlin/com/malinskiy/marathon/scenario/DisconnectingScenarios.kt @@ -6,6 +6,7 @@ import com.malinskiy.marathon.test.StubDevice import com.malinskiy.marathon.test.Test import com.malinskiy.marathon.test.TestComponentInfo import com.malinskiy.marathon.test.assert.shouldBeEqualToAsJson +import com.malinskiy.marathon.test.runAsync import com.malinskiy.marathon.test.setupMarathon import com.malinskiy.marathon.time.Timer import kotlinx.coroutines.ExperimentalCoroutinesApi diff --git a/core/src/test/kotlin/com/malinskiy/marathon/scenario/InvalidConfigScenarios.kt b/core/src/test/kotlin/com/malinskiy/marathon/scenario/InvalidConfigScenarios.kt index e5f954788..800fe5fe4 100644 --- a/core/src/test/kotlin/com/malinskiy/marathon/scenario/InvalidConfigScenarios.kt +++ b/core/src/test/kotlin/com/malinskiy/marathon/scenario/InvalidConfigScenarios.kt @@ -8,6 +8,7 @@ import com.malinskiy.marathon.execution.strategy.impl.sharding.CountShardingStra import com.malinskiy.marathon.test.StubDevice import com.malinskiy.marathon.test.Test import com.malinskiy.marathon.test.TestComponentInfo +import com.malinskiy.marathon.test.runAsync import com.malinskiy.marathon.test.setupMarathon import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.delay diff --git a/core/src/test/kotlin/com/malinskiy/marathon/scenario/SuccessScenarios.kt b/core/src/test/kotlin/com/malinskiy/marathon/scenario/SuccessScenarios.kt index b7552492a..86af6f0ff 100644 --- a/core/src/test/kotlin/com/malinskiy/marathon/scenario/SuccessScenarios.kt +++ b/core/src/test/kotlin/com/malinskiy/marathon/scenario/SuccessScenarios.kt @@ -6,6 +6,7 @@ import com.malinskiy.marathon.test.StubDevice import com.malinskiy.marathon.test.Test import com.malinskiy.marathon.test.TestComponentInfo import com.malinskiy.marathon.test.assert.shouldBeEqualToAsJson +import com.malinskiy.marathon.test.runAsync import com.malinskiy.marathon.test.setupMarathon import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.delay diff --git a/core/src/test/kotlin/com/malinskiy/marathon/scenario/UncompletedScenarios.kt b/core/src/test/kotlin/com/malinskiy/marathon/scenario/UncompletedScenarios.kt index 8a40588d0..d13749944 100644 --- a/core/src/test/kotlin/com/malinskiy/marathon/scenario/UncompletedScenarios.kt +++ b/core/src/test/kotlin/com/malinskiy/marathon/scenario/UncompletedScenarios.kt @@ -7,6 +7,7 @@ import com.malinskiy.marathon.test.StubDevice import com.malinskiy.marathon.test.Test import com.malinskiy.marathon.test.TestComponentInfo import com.malinskiy.marathon.test.assert.shouldBeEqualToAsJson +import com.malinskiy.marathon.test.runAsync import com.malinskiy.marathon.test.setupMarathon import com.malinskiy.marathon.time.Timer import kotlinx.coroutines.ExperimentalCoroutinesApi diff --git a/marathon-gradle-plugin/src/main/kotlin/com/malinskiy/marathon/ConfigurationFactory.kt b/marathon-gradle-plugin/src/main/kotlin/com/malinskiy/marathon/ConfigurationFactory.kt index e468f8c99..0374a04db 100644 --- a/marathon-gradle-plugin/src/main/kotlin/com/malinskiy/marathon/ConfigurationFactory.kt +++ b/marathon-gradle-plugin/src/main/kotlin/com/malinskiy/marathon/ConfigurationFactory.kt @@ -18,13 +18,10 @@ internal fun createCommonConfiguration( sdkDirectory: File ): Configuration { val output = getOutputDirectory(project, marathonConfig) - val fakeApk = File(".") val fakeName = "marathon-common" return createConfiguration( extensionConfig = marathonConfig, - applicationApk = null, - instrumentationApk = fakeApk, sdkDirectory = sdkDirectory, name = fakeName, output = output @@ -33,8 +30,6 @@ internal fun createCommonConfiguration( private fun createConfiguration( extensionConfig: MarathonExtension, - applicationApk: File?, - instrumentationApk: File, sdkDirectory: File, name: String, output: File @@ -66,19 +61,14 @@ private fun createConfiguration( testOutputTimeoutMillis = extensionConfig.testOutputTimeoutMillis, noDevicesTimeoutMillis = extensionConfig.noDevicesTimeoutMillis, debug = extensionConfig.debug, - vendorConfiguration = createAndroidConfiguration(extensionConfig, applicationApk, instrumentationApk, sdkDirectory) + vendorConfiguration = createAndroidConfiguration(extensionConfig, sdkDirectory) ) private fun getOutputDirectory(project: Project, extensionConfig: MarathonExtension): File = extensionConfig.baseOutputDir?.let { File(it) } ?: project.layout.buildDirectory.dir("reports/marathon").get().asFile -private fun createAndroidConfiguration( - extension: MarathonExtension, - applicationApk: File?, - instrumentationApk: File, - sdkDirectory: File -): AndroidConfiguration { +private fun createAndroidConfiguration(extension: MarathonExtension, sdkDirectory: File): AndroidConfiguration { val autoGrantPermission = extension.autoGrantPermission ?: DEFAULT_AUTO_GRANT_PERMISSION val instrumentationArgs = extension.instrumentationArgs val applicationPmClear = extension.applicationPmClear ?: DEFAULT_APPLICATION_PM_CLEAR @@ -101,8 +91,6 @@ private fun createAndroidConfiguration( return AndroidConfiguration( sdkDirectory, - applicationApk, - instrumentationApk, listOf(ddmlibModule), autoGrantPermission, instrumentationArgs, diff --git a/vendor/vendor-android/base/src/main/kotlin/com/malinskiy/marathon/android/AndroidConfiguration.kt b/vendor/vendor-android/base/src/main/kotlin/com/malinskiy/marathon/android/AndroidConfiguration.kt index fc84c2217..4cc08d4b4 100644 --- a/vendor/vendor-android/base/src/main/kotlin/com/malinskiy/marathon/android/AndroidConfiguration.kt +++ b/vendor/vendor-android/base/src/main/kotlin/com/malinskiy/marathon/android/AndroidConfiguration.kt @@ -17,8 +17,6 @@ const val DEFAULT_USED_STORAGE_THRESHOLD_PERCENTS = 85 data class AndroidConfiguration( val androidSdk: File, - val applicationOutput: File?, - val testApplicationOutput: File, val implementationModules: List, val autoGrantPermission: Boolean = DEFAULT_AUTO_GRANT_PERMISSION, val instrumentationArgs: Map = emptyMap(), diff --git a/vendor/vendor-android/base/src/main/kotlin/com/malinskiy/marathon/android/di/Modules.kt b/vendor/vendor-android/base/src/main/kotlin/com/malinskiy/marathon/android/di/Modules.kt index fce26c750..5a322b006 100644 --- a/vendor/vendor-android/base/src/main/kotlin/com/malinskiy/marathon/android/di/Modules.kt +++ b/vendor/vendor-android/base/src/main/kotlin/com/malinskiy/marathon/android/di/Modules.kt @@ -1,7 +1,6 @@ package com.malinskiy.marathon.android.di import com.malinskiy.marathon.android.AndroidComponentCacheKeyProvider -import com.malinskiy.marathon.android.AndroidComponentInfoExtractor import com.malinskiy.marathon.android.AndroidLogConfigurator import com.malinskiy.marathon.android.AndroidTestParser import com.malinskiy.marathon.android.executor.logcat.LogcatCollector @@ -9,7 +8,6 @@ import com.malinskiy.marathon.android.executor.logcat.LogcatListener import com.malinskiy.marathon.android.executor.logcat.parse.LogcatEventsAdapter import com.malinskiy.marathon.android.executor.logcat.parse.LogcatEventsListener import com.malinskiy.marathon.cache.test.key.ComponentCacheKeyProvider -import com.malinskiy.marathon.execution.ComponentInfoExtractor import com.malinskiy.marathon.execution.TestParser import com.malinskiy.marathon.log.MarathonLogConfigurator import com.malinskiy.marathon.report.logs.LogsProvider @@ -17,7 +15,6 @@ import org.koin.dsl.module val androidModule = module { single { AndroidTestParser() } - single { AndroidComponentInfoExtractor() } single { AndroidComponentCacheKeyProvider(get()) } single { LogcatCollector() } single { get() } diff --git a/vendor/vendor-android/base/src/main/kotlin/com/malinskiy/marathon/android/executor/AndroidComponentInfoExtractor.kt b/vendor/vendor-android/base/src/main/kotlin/com/malinskiy/marathon/android/executor/AndroidComponentInfoExtractor.kt deleted file mode 100644 index abc0f3805..000000000 --- a/vendor/vendor-android/base/src/main/kotlin/com/malinskiy/marathon/android/executor/AndroidComponentInfoExtractor.kt +++ /dev/null @@ -1,20 +0,0 @@ -package com.malinskiy.marathon.android - -import com.malinskiy.marathon.execution.ComponentInfo -import com.malinskiy.marathon.execution.ComponentInfoExtractor -import com.malinskiy.marathon.execution.Configuration - -class AndroidComponentInfoExtractor : ComponentInfoExtractor { - - override fun extract(configuration: Configuration): ComponentInfo { - val androidConfiguration = configuration.vendorConfiguration as AndroidConfiguration - - return AndroidComponentInfo( - name = configuration.name, - applicationId = "", - testApplicationId = "", - applicationOutput = androidConfiguration.applicationOutput, - testApplicationOutput = androidConfiguration.testApplicationOutput - ) - } -} diff --git a/vendor/vendor-android/base/src/test/kotlin/com/malinskiy/marathon/android/AndroidTestParserSpek.kt b/vendor/vendor-android/base/src/test/kotlin/com/malinskiy/marathon/android/AndroidTestParserSpek.kt index e04117430..e8ef21a8f 100644 --- a/vendor/vendor-android/base/src/test/kotlin/com/malinskiy/marathon/android/AndroidTestParserSpek.kt +++ b/vendor/vendor-android/base/src/test/kotlin/com/malinskiy/marathon/android/AndroidTestParserSpek.kt @@ -1,6 +1,5 @@ package com.malinskiy.marathon.android -import com.malinskiy.marathon.execution.Configuration import com.malinskiy.marathon.test.MetaProperty import com.malinskiy.marathon.test.Test import kotlinx.coroutines.runBlocking @@ -17,42 +16,13 @@ class AndroidTestParserSpek : Spek( group("android test apk") { val apkFile = File(javaClass.classLoader.getResource("android_test_1.apk").file) - val configuration = Configuration( + val componentInfo = AndroidComponentInfo( name = "", - outputDir = File(""), - customAnalyticsTracker = null, - poolingStrategy = null, - shardingStrategy = null, - sortingStrategy = null, - batchingStrategy = null, - flakinessStrategy = null, - retryStrategy = null, - filteringConfiguration = null, - strictRunFilterConfiguration = null, - cache = null, - ignoreFailures = null, - isCodeCoverageEnabled = null, - fallbackToScreenshots = null, - strictMode = null, - listener = null, - uncompletedTestRetryQuota = null, - testClassRegexes = null, - includeSerialRegexes = null, - excludeSerialRegexes = null, - ignoreFailureRegexes = null, - failFastFailureRegexes = null, - testBatchTimeoutMillis = null, - testOutputTimeoutMillis = null, - noDevicesTimeoutMillis = null, - debug = null, - vendorConfiguration = AndroidConfiguration( - implementationModules = emptyList(), - androidSdk = File(""), - applicationOutput = File(""), - testApplicationOutput = apkFile - ) + applicationId = null, + testApplicationId = "com.example.test", + applicationOutput = null, + testApplicationOutput = apkFile ) - val componentInfo = AndroidComponentInfoExtractor().extract(configuration) it("should return proper list of test methods") { val extractedTests = runBlocking { parser.extract(componentInfo) } @@ -71,4 +41,3 @@ class AndroidTestParserSpek : Spek( } } }) - diff --git a/vendor/vendor-android/ddmlib/src/test/kotlin/com/malinskiy/marathon/android/AndroidDeviceTestRunnerSpek.kt b/vendor/vendor-android/ddmlib/src/test/kotlin/com/malinskiy/marathon/android/AndroidDeviceTestRunnerSpek.kt index 35b51d748..71c7c03d2 100644 --- a/vendor/vendor-android/ddmlib/src/test/kotlin/com/malinskiy/marathon/android/AndroidDeviceTestRunnerSpek.kt +++ b/vendor/vendor-android/ddmlib/src/test/kotlin/com/malinskiy/marathon/android/AndroidDeviceTestRunnerSpek.kt @@ -77,13 +77,17 @@ class AndroidDeviceTestRunnerSpek : Spek( noDevicesTimeoutMillis = null, debug = null, vendorConfiguration = AndroidConfiguration( - File(""), - applicationOutput = File(""), - testApplicationOutput = apkFile, + androidSdk = File(""), implementationModules = emptyList() ) ) - val componentInfo = AndroidComponentInfoExtractor().extract(configuration) + val componentInfo = AndroidComponentInfo( + name = "", + applicationId = null, + testApplicationId = "com.example.test", + applicationOutput = File(""), + testApplicationOutput = apkFile, + ) val ignoredTest = Test("ignored", "ignored", "ignored", listOf(MetaProperty("org.junit.Ignore")), componentInfo) val identifier = ignoredTest.toTestIdentifier() diff --git a/vendor/vendor-test/src/main/kotlin/com/malinskiy/marathon/test/StubComponentInfoExtractor.kt b/vendor/vendor-test/src/main/kotlin/com/malinskiy/marathon/test/StubComponentInfoExtractor.kt deleted file mode 100644 index e9f15de99..000000000 --- a/vendor/vendor-test/src/main/kotlin/com/malinskiy/marathon/test/StubComponentInfoExtractor.kt +++ /dev/null @@ -1,13 +0,0 @@ -package com.malinskiy.marathon.test - -import com.malinskiy.marathon.execution.ComponentInfo -import com.malinskiy.marathon.execution.ComponentInfoExtractor -import com.malinskiy.marathon.execution.Configuration - -class StubComponentInfoExtractor : ComponentInfoExtractor { - - override fun extract(configuration: Configuration): ComponentInfo { - return TestComponentInfo("test", configuration.name) - } - -} diff --git a/vendor/vendor-test/src/main/kotlin/com/malinskiy/marathon/test/TestBodyExtensions.kt b/vendor/vendor-test/src/main/kotlin/com/malinskiy/marathon/test/TestBodyExtensions.kt index 683b7a713..07df0139e 100644 --- a/vendor/vendor-test/src/main/kotlin/com/malinskiy/marathon/test/TestBodyExtensions.kt +++ b/vendor/vendor-test/src/main/kotlin/com/malinskiy/marathon/test/TestBodyExtensions.kt @@ -1,10 +1,17 @@ package com.malinskiy.marathon.test import com.malinskiy.marathon.Marathon +import com.malinskiy.marathon.execution.ComponentInfo import com.malinskiy.marathon.test.factory.MarathonFactory import org.jetbrains.spek.api.dsl.TestBody fun TestBody.setupMarathon(f: MarathonFactory.() -> Unit): Marathon { val marathonFactory = MarathonFactory() return marathonFactory.apply(f).build() -} \ No newline at end of file +} + +suspend fun Marathon.runAsync(componentInfo: ComponentInfo = TestComponentInfo()): Boolean { + start() + scheduleTests(componentInfo) + return stopAndWaitForCompletion() +} diff --git a/vendor/vendor-test/src/main/kotlin/com/malinskiy/marathon/test/TestVendorConfiguration.kt b/vendor/vendor-test/src/main/kotlin/com/malinskiy/marathon/test/TestVendorConfiguration.kt index b1abb97a5..f81d3418b 100644 --- a/vendor/vendor-test/src/main/kotlin/com/malinskiy/marathon/test/TestVendorConfiguration.kt +++ b/vendor/vendor-test/src/main/kotlin/com/malinskiy/marathon/test/TestVendorConfiguration.kt @@ -3,7 +3,6 @@ package com.malinskiy.marathon.test import com.malinskiy.marathon.cache.test.key.ComponentCacheKeyProvider import com.malinskiy.marathon.device.DeviceFeature import com.malinskiy.marathon.device.DeviceProvider -import com.malinskiy.marathon.execution.ComponentInfoExtractor import com.malinskiy.marathon.execution.TestParser import com.malinskiy.marathon.log.MarathonLogConfigurator import com.malinskiy.marathon.report.logs.LogsProvider @@ -17,7 +16,6 @@ class TestVendorConfiguration : VendorConfiguration { private val testModule = module { single { StubComponentCacheKeyProvider() } - single { StubComponentInfoExtractor() } single { deviceProvider } single { StubLogsProvider() } single { testParser } From 338e64ff503ab1beb4d07fee4e73e75b985d67b1 Mon Sep 17 00:00:00 2001 From: Sergey Chelombitko Date: Mon, 22 Jul 2024 13:03:50 +0100 Subject: [PATCH 2/3] Remove name from Configuration model --- .../kotlin/com/malinskiy/marathon/analytics/TrackerFactory.kt | 2 +- .../kotlin/com/malinskiy/marathon/execution/Configuration.kt | 4 ---- .../com/malinskiy/marathon/report/html/HtmlSummaryReporter.kt | 3 --- .../kotlin/com/malinskiy/marathon/ConfigurationFactory.kt | 4 ---- .../main/kotlin/com/malinskiy/marathon/report/HtmlIndex.kt | 1 - .../malinskiy/marathon/android/AndroidDeviceTestRunnerSpek.kt | 1 - .../malinskiy/marathon/test/factory/ConfigurationFactory.kt | 2 -- 7 files changed, 1 insertion(+), 16 deletions(-) diff --git a/core/src/main/kotlin/com/malinskiy/marathon/analytics/TrackerFactory.kt b/core/src/main/kotlin/com/malinskiy/marathon/analytics/TrackerFactory.kt index c5bc4c0d4..826a67908 100644 --- a/core/src/main/kotlin/com/malinskiy/marathon/analytics/TrackerFactory.kt +++ b/core/src/main/kotlin/com/malinskiy/marathon/analytics/TrackerFactory.kt @@ -76,7 +76,7 @@ internal class TrackerFactory( RawJsonReporter(fileManager, gson), TestJsonReporter(fileManager, gson), AllureReporter(configuration, File(configuration.outputDir, "allure-results"), testResultDescriptionFactory), - HtmlSummaryReporter(gson, configuration.outputDir, configuration, testResultDescriptionFactory), + HtmlSummaryReporter(gson, configuration.outputDir, testResultDescriptionFactory), StdoutReporter(timer), configuration.listener?.let { ListenerReporter(it) } ), diff --git a/core/src/main/kotlin/com/malinskiy/marathon/execution/Configuration.kt b/core/src/main/kotlin/com/malinskiy/marathon/execution/Configuration.kt index 85f4af172..f1569817e 100644 --- a/core/src/main/kotlin/com/malinskiy/marathon/execution/Configuration.kt +++ b/core/src/main/kotlin/com/malinskiy/marathon/execution/Configuration.kt @@ -21,7 +21,6 @@ private const val DEFAULT_NO_DEVICES_TIMEOUT_MILLIS: Long = 300_000 private const val DEFAULT_OUTPUT_TIMEOUT_MILLIS: Long = 60_000 data class Configuration constructor( - val name: String, val outputDir: File, val customAnalyticsTracker: Tracker?, @@ -57,7 +56,6 @@ data class Configuration constructor( ) { constructor( - name: String, outputDir: File, customAnalyticsTracker: Tracker?, @@ -93,7 +91,6 @@ data class Configuration constructor( ) : this( - name = name, outputDir = outputDir, customAnalyticsTracker = customAnalyticsTracker, poolingStrategy = poolingStrategy ?: OmniPoolingStrategy(), @@ -125,7 +122,6 @@ data class Configuration constructor( fun toMap() = mapOf( - "name" to name, "outputDir" to outputDir.absolutePath, "pooling" to poolingStrategy.toString(), "sharding" to shardingStrategy.toString(), diff --git a/core/src/main/kotlin/com/malinskiy/marathon/report/html/HtmlSummaryReporter.kt b/core/src/main/kotlin/com/malinskiy/marathon/report/html/HtmlSummaryReporter.kt index 19352e16e..477258950 100644 --- a/core/src/main/kotlin/com/malinskiy/marathon/report/html/HtmlSummaryReporter.kt +++ b/core/src/main/kotlin/com/malinskiy/marathon/report/html/HtmlSummaryReporter.kt @@ -8,7 +8,6 @@ import com.malinskiy.marathon.device.DeviceFeature import com.malinskiy.marathon.device.DeviceInfo import com.malinskiy.marathon.execution.Attachment import com.malinskiy.marathon.execution.AttachmentType -import com.malinskiy.marathon.execution.Configuration import com.malinskiy.marathon.execution.TestResult import com.malinskiy.marathon.execution.TestStatus import com.malinskiy.marathon.extension.relativePathTo @@ -34,7 +33,6 @@ import kotlin.math.roundToLong class HtmlSummaryReporter( private val gson: Gson, private val rootOutput: File, - private val configuration: Configuration, private val testSummaryFormatter: TestSummaryFormatter ) : Reporter { @@ -233,7 +231,6 @@ class HtmlSummaryReporter( private fun Summary.toHtmlIndex() = HtmlIndex( - title = configuration.name, totalFailed = pools.sumOf { it.failed.size }, totalIgnored = pools.sumOf { it.ignored.size }, totalPassed = pools.sumOf { it.passed.size }, diff --git a/marathon-gradle-plugin/src/main/kotlin/com/malinskiy/marathon/ConfigurationFactory.kt b/marathon-gradle-plugin/src/main/kotlin/com/malinskiy/marathon/ConfigurationFactory.kt index 0374a04db..bc21b20a1 100644 --- a/marathon-gradle-plugin/src/main/kotlin/com/malinskiy/marathon/ConfigurationFactory.kt +++ b/marathon-gradle-plugin/src/main/kotlin/com/malinskiy/marathon/ConfigurationFactory.kt @@ -18,12 +18,10 @@ internal fun createCommonConfiguration( sdkDirectory: File ): Configuration { val output = getOutputDirectory(project, marathonConfig) - val fakeName = "marathon-common" return createConfiguration( extensionConfig = marathonConfig, sdkDirectory = sdkDirectory, - name = fakeName, output = output ) } @@ -31,10 +29,8 @@ internal fun createCommonConfiguration( private fun createConfiguration( extensionConfig: MarathonExtension, sdkDirectory: File, - name: String, output: File ): Configuration = Configuration( - name = name, outputDir = output, customAnalyticsTracker = extensionConfig.customAnalyticsTracker, poolingStrategy = extensionConfig.poolingStrategy?.toStrategy(), diff --git a/report/html-report/src/main/kotlin/com/malinskiy/marathon/report/HtmlIndex.kt b/report/html-report/src/main/kotlin/com/malinskiy/marathon/report/HtmlIndex.kt index 3a709c4b7..3c4ddf82b 100644 --- a/report/html-report/src/main/kotlin/com/malinskiy/marathon/report/HtmlIndex.kt +++ b/report/html-report/src/main/kotlin/com/malinskiy/marathon/report/HtmlIndex.kt @@ -3,7 +3,6 @@ package com.malinskiy.marathon.report import com.google.gson.annotations.SerializedName data class HtmlIndex( - @SerializedName("title") val title: String, @SerializedName("total_failed") val totalFailed: Int, @SerializedName("total_flaky") val totalFlaky: Int, @SerializedName("total_ignored") val totalIgnored: Int, diff --git a/vendor/vendor-android/ddmlib/src/test/kotlin/com/malinskiy/marathon/android/AndroidDeviceTestRunnerSpek.kt b/vendor/vendor-android/ddmlib/src/test/kotlin/com/malinskiy/marathon/android/AndroidDeviceTestRunnerSpek.kt index 71c7c03d2..1644ea3f1 100644 --- a/vendor/vendor-android/ddmlib/src/test/kotlin/com/malinskiy/marathon/android/AndroidDeviceTestRunnerSpek.kt +++ b/vendor/vendor-android/ddmlib/src/test/kotlin/com/malinskiy/marathon/android/AndroidDeviceTestRunnerSpek.kt @@ -49,7 +49,6 @@ class AndroidDeviceTestRunnerSpek : Spek( val apkFile = File(javaClass.classLoader.getResource("android_test_1.apk").file) val output = File("") val configuration = Configuration( - name = "", outputDir = output, customAnalyticsTracker = null, poolingStrategy = null, diff --git a/vendor/vendor-test/src/main/kotlin/com/malinskiy/marathon/test/factory/ConfigurationFactory.kt b/vendor/vendor-test/src/main/kotlin/com/malinskiy/marathon/test/factory/ConfigurationFactory.kt index 32dc1001a..8768cd9f2 100644 --- a/vendor/vendor-test/src/main/kotlin/com/malinskiy/marathon/test/factory/ConfigurationFactory.kt +++ b/vendor/vendor-test/src/main/kotlin/com/malinskiy/marathon/test/factory/ConfigurationFactory.kt @@ -21,7 +21,6 @@ import java.nio.file.Files fun configuration(block: ConfigurationFactory.() -> Unit = {}) = ConfigurationFactory().apply(block).build() class ConfigurationFactory { - var name = "DEFAULT_TEST_CONFIG" var outputDir = Files.createTempDirectory("test-run").toFile() var vendorConfiguration = TestVendorConfiguration() var debug: Boolean? = null @@ -62,7 +61,6 @@ class ConfigurationFactory { fun build(): Configuration = Configuration( - name = name, outputDir = outputDir, customAnalyticsTracker = customAnalyticsTracker, poolingStrategy = poolingStrategy, From bbd2b6f0b43e45aeb078476d99b057740dc4082b Mon Sep 17 00:00:00 2001 From: Sergey Chelombitko Date: Mon, 22 Jul 2024 13:12:47 +0100 Subject: [PATCH 3/3] Remove baseOutputDir --- .../marathon/ConfigurationFactory.kt | 24 +++---------------- .../malinskiy/marathon/MarathonExtension.kt | 2 -- 2 files changed, 3 insertions(+), 23 deletions(-) diff --git a/marathon-gradle-plugin/src/main/kotlin/com/malinskiy/marathon/ConfigurationFactory.kt b/marathon-gradle-plugin/src/main/kotlin/com/malinskiy/marathon/ConfigurationFactory.kt index bc21b20a1..ef0e3e2f1 100644 --- a/marathon-gradle-plugin/src/main/kotlin/com/malinskiy/marathon/ConfigurationFactory.kt +++ b/marathon-gradle-plugin/src/main/kotlin/com/malinskiy/marathon/ConfigurationFactory.kt @@ -14,24 +14,10 @@ import java.io.File internal fun createCommonConfiguration( project: Project, - marathonConfig: MarathonExtension, - sdkDirectory: File -): Configuration { - val output = getOutputDirectory(project, marathonConfig) - - return createConfiguration( - extensionConfig = marathonConfig, - sdkDirectory = sdkDirectory, - output = output - ) -} - -private fun createConfiguration( extensionConfig: MarathonExtension, - sdkDirectory: File, - output: File + sdkDirectory: File ): Configuration = Configuration( - outputDir = output, + outputDir = project.layout.buildDirectory.dir("reports/marathon").get().asFile, customAnalyticsTracker = extensionConfig.customAnalyticsTracker, poolingStrategy = extensionConfig.poolingStrategy?.toStrategy(), shardingStrategy = extensionConfig.shardingStrategy?.toStrategy(), @@ -57,13 +43,9 @@ private fun createConfiguration( testOutputTimeoutMillis = extensionConfig.testOutputTimeoutMillis, noDevicesTimeoutMillis = extensionConfig.noDevicesTimeoutMillis, debug = extensionConfig.debug, - vendorConfiguration = createAndroidConfiguration(extensionConfig, sdkDirectory) + vendorConfiguration = createAndroidConfiguration(extension = extensionConfig, sdkDirectory = sdkDirectory) ) -private fun getOutputDirectory(project: Project, extensionConfig: MarathonExtension): File = - extensionConfig.baseOutputDir?.let { File(it) } - ?: project.layout.buildDirectory.dir("reports/marathon").get().asFile - private fun createAndroidConfiguration(extension: MarathonExtension, sdkDirectory: File): AndroidConfiguration { val autoGrantPermission = extension.autoGrantPermission ?: DEFAULT_AUTO_GRANT_PERMISSION val instrumentationArgs = extension.instrumentationArgs diff --git a/marathon-gradle-plugin/src/main/kotlin/com/malinskiy/marathon/MarathonExtension.kt b/marathon-gradle-plugin/src/main/kotlin/com/malinskiy/marathon/MarathonExtension.kt index ed76e32a5..b44151769 100644 --- a/marathon-gradle-plugin/src/main/kotlin/com/malinskiy/marathon/MarathonExtension.kt +++ b/marathon-gradle-plugin/src/main/kotlin/com/malinskiy/marathon/MarathonExtension.kt @@ -18,8 +18,6 @@ open class MarathonExtension { var strictRunFilterConfiguration: StrictRunFilterPluginConfiguration? = null var listener: MarathonListener? = null - var baseOutputDir: String? = null - var cache: CachePluginConfiguration? = null var ignoreFailures: Boolean? = null var isCodeCoverageEnabled: Boolean? = null