diff --git a/vendor/vendor-ios/src/main/kotlin/com/malinskiy/marathon/ios/AppleDeviceTestRunner.kt b/vendor/vendor-ios/src/main/kotlin/com/malinskiy/marathon/ios/AppleDeviceTestRunner.kt index e2fe955f9..f7ee17561 100644 --- a/vendor/vendor-ios/src/main/kotlin/com/malinskiy/marathon/ios/AppleDeviceTestRunner.kt +++ b/vendor/vendor-ios/src/main/kotlin/com/malinskiy/marathon/ios/AppleDeviceTestRunner.kt @@ -3,6 +3,7 @@ package com.malinskiy.marathon.ios import com.malinskiy.marathon.config.Configuration import com.malinskiy.marathon.config.vendor.VendorConfiguration import com.malinskiy.marathon.ios.executor.listener.AppleTestRunListener +import com.malinskiy.marathon.ios.extensions.testBundle import com.malinskiy.marathon.ios.test.TestEvent import com.malinskiy.marathon.ios.test.TestPassed import com.malinskiy.marathon.ios.test.TestFailed @@ -40,6 +41,7 @@ class AppleDeviceTestRunner(private val device: AppleSimulatorDevice, private va tests = rawTestBatch.tests, xcresult = remoteXcresultPath, coverage = configuration.isCodeCoverageEnabled, + testTargetName = vendorConfiguration.testBundle().testBundleId, ) var channel: ReceiveChannel>? = null try { diff --git a/vendor/vendor-ios/src/main/kotlin/com/malinskiy/marathon/ios/AppleSimulatorDevice.kt b/vendor/vendor-ios/src/main/kotlin/com/malinskiy/marathon/ios/AppleSimulatorDevice.kt index 4b09fb293..254c95630 100644 --- a/vendor/vendor-ios/src/main/kotlin/com/malinskiy/marathon/ios/AppleSimulatorDevice.kt +++ b/vendor/vendor-ios/src/main/kotlin/com/malinskiy/marathon/ios/AppleSimulatorDevice.kt @@ -35,7 +35,6 @@ import com.malinskiy.marathon.ios.executor.listener.TestResultsListener import com.malinskiy.marathon.ios.executor.listener.TestRunListenerAdapter import com.malinskiy.marathon.ios.executor.listener.screenshot.ScreenCapturerTestRunListener import com.malinskiy.marathon.ios.logparser.XctestEventProducer -import com.malinskiy.marathon.ios.logparser.formatter.NoopPackageNameFormatter import com.malinskiy.marathon.ios.logparser.parser.DebugLogPrinter import com.malinskiy.marathon.ios.logparser.parser.DeviceFailureException import com.malinskiy.marathon.ios.logparser.parser.DiagnosticLogsPathFinder @@ -349,7 +348,7 @@ class AppleSimulatorDevice( withContext(Dispatchers.IO) { val deferredStdout = supervisorScope { async { - val testEventProducer = XctestEventProducer(NoopPackageNameFormatter, timer) + val testEventProducer = XctestEventProducer(request.testTargetName ?: "", timer) for (line in session.stdout) { testEventProducer.process(line)?.let { send(it) diff --git a/vendor/vendor-ios/src/main/kotlin/com/malinskiy/marathon/ios/XCTestParser.kt b/vendor/vendor-ios/src/main/kotlin/com/malinskiy/marathon/ios/XCTestParser.kt index 2473569f4..3f5d8e629 100644 --- a/vendor/vendor-ios/src/main/kotlin/com/malinskiy/marathon/ios/XCTestParser.kt +++ b/vendor/vendor-ios/src/main/kotlin/com/malinskiy/marathon/ios/XCTestParser.kt @@ -7,6 +7,7 @@ import com.malinskiy.marathon.device.Device import com.malinskiy.marathon.exceptions.TestParsingException import com.malinskiy.marathon.execution.RemoteTestParser import com.malinskiy.marathon.execution.withRetry +import com.malinskiy.marathon.ios.extensions.testBundle import com.malinskiy.marathon.ios.model.AppleTestBundle import com.malinskiy.marathon.ios.test.TestEvent import com.malinskiy.marathon.ios.test.TestRequest @@ -77,7 +78,9 @@ class XCTestParser( for (event in events) { when (event) { is TestStarted -> { - tests.add(event.id) + //Target name is never printed via xcodebuild. We create it using the bundle id in com.malinskiy.marathon.ios.xctestrun.TestRootFactory + val testWithTargetName = event.id.copy(pkg = vendorConfiguration.testBundle().testBundleId) + tests.add(testWithTargetName) } else -> Unit } diff --git a/vendor/vendor-ios/src/main/kotlin/com/malinskiy/marathon/ios/logparser/XctestEventProducer.kt b/vendor/vendor-ios/src/main/kotlin/com/malinskiy/marathon/ios/logparser/XctestEventProducer.kt index b68c8fde1..db57f5144 100644 --- a/vendor/vendor-ios/src/main/kotlin/com/malinskiy/marathon/ios/logparser/XctestEventProducer.kt +++ b/vendor/vendor-ios/src/main/kotlin/com/malinskiy/marathon/ios/logparser/XctestEventProducer.kt @@ -1,6 +1,5 @@ package com.malinskiy.marathon.ios.logparser -import com.malinskiy.marathon.ios.logparser.formatter.PackageNameFormatter import com.malinskiy.marathon.ios.logparser.parser.DeviceFailureParser import com.malinskiy.marathon.ios.logparser.parser.TestRunProgressParser import com.malinskiy.marathon.ios.test.TestEvent @@ -8,10 +7,13 @@ import com.malinskiy.marathon.time.Timer /** * Currently doesn't provide any guarantee on the methods that should be called even once + * + * @param targetName target name (or blueprint name) is not printed by xcodebuild output, we have to augment the results to still have + * 'target/class_name/test_name' structure mapped properly to marathon's package.class.method */ -class XctestEventProducer(packageNameFormatter: PackageNameFormatter, timer: Timer) : TestEventProducer { +class XctestEventProducer(targetName: String, timer: Timer) : TestEventProducer { private val failureParser = DeviceFailureParser() - private val testRunListener = TestRunProgressParser(timer, packageNameFormatter) + private val testRunListener = TestRunProgressParser(timer, targetName) override fun process(line: String): List? { return failureParser.process(line) ?: testRunListener.process(line) diff --git a/vendor/vendor-ios/src/main/kotlin/com/malinskiy/marathon/ios/logparser/formatter/NoopPackageNameFormatter.kt b/vendor/vendor-ios/src/main/kotlin/com/malinskiy/marathon/ios/logparser/formatter/NoopPackageNameFormatter.kt deleted file mode 100644 index 6739a34ec..000000000 --- a/vendor/vendor-ios/src/main/kotlin/com/malinskiy/marathon/ios/logparser/formatter/NoopPackageNameFormatter.kt +++ /dev/null @@ -1,5 +0,0 @@ -package com.malinskiy.marathon.ios.logparser.formatter - -object NoopPackageNameFormatter : PackageNameFormatter { - override fun format(name: String?) = name -} diff --git a/vendor/vendor-ios/src/main/kotlin/com/malinskiy/marathon/ios/logparser/formatter/PackageNameFormatter.kt b/vendor/vendor-ios/src/main/kotlin/com/malinskiy/marathon/ios/logparser/formatter/PackageNameFormatter.kt deleted file mode 100644 index 918134d0c..000000000 --- a/vendor/vendor-ios/src/main/kotlin/com/malinskiy/marathon/ios/logparser/formatter/PackageNameFormatter.kt +++ /dev/null @@ -1,5 +0,0 @@ -package com.malinskiy.marathon.ios.logparser.formatter - -interface PackageNameFormatter { - fun format(name: String?): String? -} diff --git a/vendor/vendor-ios/src/main/kotlin/com/malinskiy/marathon/ios/logparser/formatter/TestLogPackageNameFormatter.kt b/vendor/vendor-ios/src/main/kotlin/com/malinskiy/marathon/ios/logparser/formatter/TestLogPackageNameFormatter.kt deleted file mode 100644 index 24582d3c9..000000000 --- a/vendor/vendor-ios/src/main/kotlin/com/malinskiy/marathon/ios/logparser/formatter/TestLogPackageNameFormatter.kt +++ /dev/null @@ -1,14 +0,0 @@ -package com.malinskiy.marathon.ios.logparser.formatter - -/** - * When applied, replaces module name reported in xcodebuild log with testing target name in order - * to unify test representation. - */ -class TestLogPackageNameFormatter( - private val productModuleName: String, - private val targetName: String -) : PackageNameFormatter { - override fun format(name: String?): String? { - return name?.replace(productModuleName, targetName) - } -} diff --git a/vendor/vendor-ios/src/main/kotlin/com/malinskiy/marathon/ios/logparser/parser/TestRunProgressParser.kt b/vendor/vendor-ios/src/main/kotlin/com/malinskiy/marathon/ios/logparser/parser/TestRunProgressParser.kt index d532de90c..2eca10842 100644 --- a/vendor/vendor-ios/src/main/kotlin/com/malinskiy/marathon/ios/logparser/parser/TestRunProgressParser.kt +++ b/vendor/vendor-ios/src/main/kotlin/com/malinskiy/marathon/ios/logparser/parser/TestRunProgressParser.kt @@ -1,7 +1,6 @@ package com.malinskiy.marathon.ios.logparser.parser import com.malinskiy.marathon.ios.logparser.TestEventProducer -import com.malinskiy.marathon.ios.logparser.formatter.PackageNameFormatter import com.malinskiy.marathon.ios.test.TestEvent import com.malinskiy.marathon.ios.test.TestFailed import com.malinskiy.marathon.ios.test.TestIgnored @@ -14,14 +13,14 @@ import kotlin.math.roundToInt class TestRunProgressParser( private val timer: Timer, - private val packageNameFormatter: PackageNameFormatter, + private val targetName: String, ) : TestEventProducer { val logger = MarathonLogging.logger(TestRunProgressParser::class.java.simpleName) - val TEST_CASE_STARTED = """Test Case '-\[([a-zA-Z0-9_.]+) ([a-zA-Z0-9_]+)]' started\.""".toRegex() + val TEST_CASE_STARTED = """Test Case '-\[([a-zA-Z0-9_.]+) ([a-zA-Z0-9_ ]+)]' started\.""".toRegex() val TEST_CASE_FINISHED = - """Test Case '-\[([a-zA-Z0-9_.]+) ([a-zA-Z0-9_]+)]' (passed|failed|skipped) \(([\d\.]+) seconds\)\.""".toRegex() + """Test Case '-\[([a-zA-Z0-9_.]+) ([a-zA-Z0-9_ ]+)]' (passed|failed|skipped) \(([\d\.]+) seconds\)\.""".toRegex() /** * $1 = file @@ -65,8 +64,13 @@ class TestRunProgressParser( var pkg: String? = null var clazz: String? = null if (pkgWithClass != null) { - pkg = packageNameFormatter.format(pkgWithClass.substringBeforeLast('.', missingDelimiterValue = "")) - clazz = pkgWithClass.substringAfter('.', missingDelimiterValue = pkgWithClass) + if (pkgWithClass.contains('.')) { + pkg = pkgWithClass.substringBeforeLast('.', missingDelimiterValue = "") + clazz = pkgWithClass.substringAfter('.', missingDelimiterValue = pkgWithClass) + } else { + pkg = targetName + clazz = pkgWithClass + } } val method = matchResult?.groups?.get(2)?.value @@ -111,8 +115,13 @@ class TestRunProgressParser( var pkg: String? = null var clazz: String? = null if (pkgWithClass != null) { - pkg = packageNameFormatter.format(pkgWithClass.substringBeforeLast('.', missingDelimiterValue = "")) - clazz = pkgWithClass.substringAfter('.', missingDelimiterValue = pkgWithClass) + if (pkgWithClass.contains('.')) { + pkg = pkgWithClass.substringBeforeLast('.', missingDelimiterValue = "") + clazz = pkgWithClass.substringAfter('.', missingDelimiterValue = pkgWithClass) + } else { + pkg = targetName + clazz = pkgWithClass + } } val method = matchResult?.groups?.get(2)?.value diff --git a/vendor/vendor-ios/src/main/kotlin/com/malinskiy/marathon/ios/test/TestRequest.kt b/vendor/vendor-ios/src/main/kotlin/com/malinskiy/marathon/ios/test/TestRequest.kt index 1144347c1..04c472975 100644 --- a/vendor/vendor-ios/src/main/kotlin/com/malinskiy/marathon/ios/test/TestRequest.kt +++ b/vendor/vendor-ios/src/main/kotlin/com/malinskiy/marathon/ios/test/TestRequest.kt @@ -9,6 +9,7 @@ data class TestRequest( val coverage: Boolean, val tests: List? = null, val xcresult: String? = null, + val testTargetName: String? = null, ) { fun toXcodebuildTestFilter(): Array { return tests?.map { "'-only-testing:${it.toTestName(packageSeparator = '/', methodSeparator = '/')}'" }?.toTypedArray() ?: emptyArray()