Skip to content

Commit

Permalink
Reformat code and optimize imports
Browse files Browse the repository at this point in the history
  • Loading branch information
Sergey Chelombitko committed Aug 2, 2024
1 parent 95ea0ab commit d267561
Show file tree
Hide file tree
Showing 129 changed files with 167 additions and 260 deletions.
36 changes: 18 additions & 18 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
[*]
charset=utf-8
end_of_line=lf
insert_final_newline=true
indent_style=space
indent_size=4
charset = utf-8
end_of_line = lf
insert_final_newline = true
indent_style = space
indent_size = 4
max_line_length = 160

[{*.sht,*.html,*.shtm,*.shtml,*.htm}]
indent_style=space
indent_size=2
indent_style = space
indent_size = 2

[{*.mod,*.dtd,*.ent,*.elt}]
indent_style=space
indent_size=2
indent_style = space
indent_size = 2

[{*.jhm,*.xslt,*.xul,*.tagx,*.rng,*.xsl,*.xsd,*.ant,*.tld,*.fxml,*.jrxml,*.jspx,*.xml,*.jnlp,*.wsdl,*.pom}]
indent_style=space
indent_size=2
indent_style = space
indent_size = 2

[*.json]
indent_style=space
indent_size=2
indent_style = space
indent_size = 2

[*.svg]
indent_style=space
indent_size=2
indent_style = space
indent_size = 2

[{*.yml,*.yaml}]
indent_style=space
indent_size=2

indent_style = space
indent_size = 2
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import org.testcontainers.containers.GenericContainer
import org.testcontainers.containers.wait.strategy.Wait
import java.time.Duration

class GradleCacheContainer constructor(image: String = "$DEFAULT_IMAGE_NAME:$DEFAULT_TAG") :
class GradleCacheContainer(image: String = "$DEFAULT_IMAGE_NAME:$DEFAULT_TAG") :
GenericContainer<GradleCacheContainer>(image) {

init {
Expand Down
1 change: 0 additions & 1 deletion core/src/main/kotlin/com/malinskiy/marathon/Marathon.kt
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import com.malinskiy.marathon.test.toTestName
import com.malinskiy.marathon.time.Timer
import com.malinskiy.marathon.vendor.VendorConfiguration
import kotlinx.coroutines.runBlocking
import java.util.*
import kotlin.coroutines.coroutineContext

private val log = MarathonLogging.logger {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

package com.malinskiy.marathon.actor


import java.util.*
import java.util.ArrayList
import java.util.LinkedHashMap
import java.util.concurrent.atomic.AtomicReference

class StateMachine<STATE : Any, EVENT : Any, SIDE_EFFECT : Any> private constructor(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ fun <T> unboundedChannel() = Channel<T>(Channel.UNLIMITED)
suspend fun <T> SendChannel<T>.safeSend(element: T) {
if (isClosedForSend) return
send(element)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ class Track : Tracker {
override fun deviceConnected(poolId: DevicePoolId, device: DeviceInfo) {
delegates.get().forEach { it.deviceConnected(poolId, device) }
}

override fun test(poolId: DevicePoolId, device: DeviceInfo, testResult: TestResult, final: Boolean) {
delegates.get().forEach { it.test(poolId, device, testResult, final) }
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ class DelegatingTrackerInternal(private val trackers: List<TrackerInternal>) : T
override fun track(event: Event) = trackers.forEach { it.track(event) }

override fun close() = trackers.forEach { it.close() }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ data class ExecutionReport(
return summaries
}


private fun compilePoolSummary(poolId: DevicePoolId): PoolSummary {
val devices = deviceConnectedEvents.filter { it.poolId == poolId }.map { it.device }.distinctBy { it.serialNumber }

Expand All @@ -93,9 +92,8 @@ data class ExecutionReport(
.toSet()

val ignored = tests
.filter { it.status == TestStatus.IGNORED
|| it.status == TestStatus.ASSUMPTION_FAILURE
}.map { it.test.toTestName() }
.filter { it.status == TestStatus.IGNORED || it.status == TestStatus.ASSUMPTION_FAILURE }
.map { it.test.toTestName() }
.toSet()

val failed = tests
Expand All @@ -107,9 +105,8 @@ data class ExecutionReport(
.toSet()

val fromCache = tests
.filter {
it.isFromCache
}.map { it.test.toTestName() }
.filter { it.isFromCache }
.map { it.test.toTestName() }
.toSet()

val duration = tests.map { it.durationMillis() }.sum()
Expand All @@ -121,9 +118,8 @@ data class ExecutionReport(
.map { it.test.toTestName() }

val rawIgnored = rawTests
.filter { it.status == TestStatus.IGNORED
|| it.status == TestStatus.ASSUMPTION_FAILURE
}.map { it.test.toTestName() }
.filter { it.status == TestStatus.IGNORED || it.status == TestStatus.ASSUMPTION_FAILURE }
.map { it.test.toTestName() }

val rawFailed = rawTests
.filter { it.status == TestStatus.FAILURE }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
package com.malinskiy.marathon.analytics.internal.sub

import com.malinskiy.marathon.report.Reporter
import java.util.*
import java.util.Collections
import java.util.LinkedList

class ExecutionReportGenerator(
private val reporters: List<Reporter>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ package com.malinskiy.marathon.analytics.internal.sub
interface TrackerInternal {
fun track(event: Event)
fun close()
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.malinskiy.marathon.cache

import io.ktor.utils.io.*
import io.ktor.utils.io.ByteReadChannel

interface CacheEntryReader {
suspend fun readFrom(input: ByteReadChannel)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import com.malinskiy.marathon.cache.config.LocalCacheConfiguration
import com.malinskiy.marathon.cache.config.RemoteCacheConfiguration
import com.malinskiy.marathon.cache.gradle.GradleHttpCacheService
import com.malinskiy.marathon.execution.Configuration
import java.lang.IllegalArgumentException

class CacheServiceFactory(private val configuration: Configuration) {

Expand All @@ -16,5 +15,4 @@ class CacheServiceFactory(private val configuration: Configuration) {
is RemoteCacheConfiguration.Disabled -> NoOpCacheService()
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,4 @@ sealed class LocalCacheConfiguration {
) : LocalCacheConfiguration()

object Disabled : LocalCacheConfiguration()

}
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,4 @@ sealed class RemoteCacheConfiguration {
) : RemoteCacheConfiguration()

object Disabled : RemoteCacheConfiguration()

}
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,18 @@ import com.malinskiy.marathon.cache.CacheKey
import com.malinskiy.marathon.cache.CacheService
import com.malinskiy.marathon.cache.config.RemoteCacheConfiguration
import com.malinskiy.marathon.log.MarathonLogging
import io.ktor.client.*
import io.ktor.client.engine.apache.*
import io.ktor.client.plugins.auth.*
import io.ktor.client.plugins.auth.providers.*
import io.ktor.client.request.*
import io.ktor.client.statement.*
import io.ktor.content.*
import io.ktor.http.*
import io.ktor.client.HttpClient
import io.ktor.client.engine.apache.Apache
import io.ktor.client.plugins.auth.Auth
import io.ktor.client.plugins.auth.providers.BasicAuthCredentials
import io.ktor.client.plugins.auth.providers.basic
import io.ktor.client.request.get
import io.ktor.client.request.put
import io.ktor.client.request.setBody
import io.ktor.client.statement.bodyAsChannel
import io.ktor.content.ByteArrayContent
import io.ktor.http.HttpStatusCode
import io.ktor.http.isSuccess
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext
import java.io.ByteArrayOutputStream
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,4 @@ sealed class CacheResult {
val pool: DevicePoolId,
val testShard: TestShard
) : CacheResult()

}
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,4 @@ class CacheTestReporter(
TestStatus.IGNORED, TestStatus.ASSUMPTION_FAILURE -> progressReporter.testIgnored(poolId, testResult.device, testResult.test)
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,4 @@ class TestCacheKey(
}

override fun hashCode(): Int = key.hashCode()

}
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@ import com.malinskiy.marathon.execution.TestStatus
import com.malinskiy.marathon.io.AttachmentManager
import com.malinskiy.marathon.io.FileType
import com.malinskiy.marathon.test.Test
import io.ktor.utils.io.*
import io.ktor.utils.io.streams.*
import io.ktor.utils.io.ByteReadChannel
import io.ktor.utils.io.streams.readerUTF8
import io.ktor.utils.io.streams.writePacket
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext
import java.io.File
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ import com.malinskiy.marathon.cache.CacheEntryWriter
import com.malinskiy.marathon.device.DeviceInfo
import com.malinskiy.marathon.execution.Attachment
import com.malinskiy.marathon.execution.TestResult
import io.ktor.utils.io.core.*
import io.ktor.utils.io.streams.*
import io.ktor.utils.io.core.buildPacket
import io.ktor.utils.io.core.writeText
import io.ktor.utils.io.streams.writePacket
import java.io.DataOutputStream
import java.io.File
import java.io.OutputStream
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ import com.malinskiy.marathon.execution.Configuration

interface ConfigurationValidator {
fun validate(configuration: Configuration)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,16 @@ class LogicalConfigurationValidator : ConfigurationValidator {
override fun validate(configuration: Configuration) {
when {
configuration.flakinessStrategy !is IgnoreFlakinessStrategy &&
configuration.shardingStrategy !is ParallelShardingStrategy -> {
configuration.shardingStrategy !is ParallelShardingStrategy -> {
throw ConfigurationException(
"Configuration is invalid: " +
"can't use complex sharding and complex flakiness strategy at the same time. " +
"See: https://github.com/Malinskiy/marathon/issues/197"
"can't use complex sharding and complex flakiness strategy at the same time. " +
"See: https://github.com/Malinskiy/marathon/issues/197"
)
}

configuration.flakinessStrategy !is IgnoreFlakinessStrategy &&
configuration.cache.isEnabled -> {
configuration.cache.isEnabled -> {
throw ConfigurationException("Complex flakiness strategy and caching is not supported yet")
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ package com.malinskiy.marathon.exceptions
*/
class DeviceLostException : RuntimeException {
constructor(cause: Throwable) : super(cause)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,4 @@ data class CacheConfiguration(

val isEnabled: Boolean
get() = local !is LocalCacheConfiguration.Disabled || remote !is RemoteCacheConfiguration.Disabled

}
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ class CompositionFilter(
}.toList()
}


private fun filterWithSubtractOperation(tests: List<Test>): List<Test> {
return filters.fold(tests.toSet()) { acc, f ->
acc.subtract(f.filter(tests))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import java.io.File
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(
data class Configuration(
val outputDir: File,

val customAnalyticsTracker: Tracker?,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import com.malinskiy.marathon.test.Test

interface StrictRunChecker {
fun isStrictRun(test: Test): Boolean
fun hasFailFastFailures(stackTrace: String? = null) : Boolean
fun hasFailFastFailures(stackTrace: String? = null): Boolean
}

class ConfigurationStrictRunChecker(private val configuration: Configuration) : StrictRunChecker {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,7 @@ class DeviceActor(
}
return@onTransition
}
val sideEffect = validTransition.sideEffect
when (sideEffect) {
when (val sideEffect = validTransition.sideEffect) {
DeviceAction.Initialize -> {
initialize()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ import com.malinskiy.marathon.time.Timer
import kotlinx.coroutines.CompletableDeferred
import kotlinx.coroutines.Job
import kotlinx.coroutines.channels.SendChannel
import java.util.*
import java.util.PriorityQueue
import java.util.Queue
import kotlin.coroutines.CoroutineContext

class QueueActor(
Expand Down Expand Up @@ -316,7 +317,6 @@ class QueueActor(
}
}


private suspend fun onRequestBatch(device: DeviceInfo) {
logger.debug { "request next batch for device ${device.serialNumber}" }
val queueIsEmpty = queue.isEmpty()
Expand Down Expand Up @@ -352,7 +352,6 @@ class QueueActor(
}
}


sealed class QueueMessage {
data class AddShard(val shard: TestShard) : QueueMessage()
data class RequestBatch(val device: DeviceInfo) : QueueMessage()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package com.malinskiy.marathon.execution.strategy
import com.malinskiy.marathon.analytics.external.Analytics
import com.malinskiy.marathon.test.Test
import com.malinskiy.marathon.test.TestBatch
import java.util.*
import java.util.Queue

interface BatchingStrategy {
fun process(queue: Queue<Test>, analytics: Analytics): TestBatch
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package com.malinskiy.marathon.execution.strategy

import com.malinskiy.marathon.device.DevicePoolId
import com.malinskiy.marathon.execution.TestResult
import com.malinskiy.marathon.execution.TestShard
import com.malinskiy.marathon.test.Test

interface RetryStrategy {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import com.malinskiy.marathon.execution.strategy.BatchingStrategy
import com.malinskiy.marathon.test.Test
import com.malinskiy.marathon.test.TestBatch
import java.time.Instant
import java.util.*
import java.util.Queue

class FixedSizeBatchingStrategy(
private val size: Int,
Expand Down Expand Up @@ -90,5 +90,4 @@ class FixedSizeBatchingStrategy(
override fun toString(): String {
return "FixedSizeBatchingStrategy(size=$size, durationMillis=$durationMillis, percentile=$percentile, timeLimit=$timeLimit, lastMileLength=$lastMileLength)"
}

}
Loading

0 comments on commit d267561

Please sign in to comment.