@@ -18,7 +18,6 @@ import com.malinskiy.marathon.execution.StrictRunProcessor
18
18
import com.malinskiy.marathon.execution.TestParser
19
19
import com.malinskiy.marathon.execution.TestShard
20
20
import com.malinskiy.marathon.execution.progress.ProgressReporter
21
- import com.malinskiy.marathon.log.MarathonLogConfigurator
22
21
import com.malinskiy.marathon.log.MarathonLogging
23
22
import com.malinskiy.marathon.report.logs.LogsProvider
24
23
import com.malinskiy.marathon.test.Test
@@ -38,13 +37,12 @@ class Marathon(
38
37
private val cachedTestsReporter : CacheTestReporter ,
39
38
private val progressReporter : ProgressReporter ,
40
39
private val strictRunChecker : StrictRunChecker ,
41
- private val logConfigurator : MarathonLogConfigurator ,
42
40
private val logsProvider : LogsProvider ,
43
41
private val track : Track ,
44
42
private val timer : Timer
45
43
) : MarathonRunner {
46
44
47
- private val logger = MarathonLogging .logger( " Marathon" )
45
+ private val logger = MarathonLogging .getLogger( Marathon :: class .java )
48
46
49
47
private val configurationValidator = LogicalConfigurationValidator ()
50
48
private val strictRunProcessor = StrictRunProcessor (configuration.strictRunConfiguration)
@@ -54,14 +52,18 @@ class Marathon(
54
52
override suspend fun start () {
55
53
logger.debug(" Starting Marathon" )
56
54
57
- MarathonLogging .debug = configuration.debug
58
- logConfigurator.configure()
55
+ configurationValidator.validate(configuration)
59
56
57
+ logger.debug(" Initializing device provider" )
60
58
deviceProvider.initialize()
61
- logger.debug(" Finished loading device provider" )
62
59
63
- configurationValidator.validate(configuration)
60
+ if (configuration.outputDir.exists()) {
61
+ logger.info(" Cleaning output directory ${configuration.outputDir} " )
62
+ configuration.outputDir.deleteRecursively()
63
+ }
64
+ configuration.outputDir.mkdirs()
64
65
66
+ logger.debug(" Initializing scheduler" )
65
67
val currentCoroutineContext = coroutineContext
66
68
scheduler = Scheduler (
67
69
deviceProvider,
@@ -77,38 +79,29 @@ class Marathon(
77
79
timer,
78
80
currentCoroutineContext
79
81
)
80
-
81
- logger.debug(" Created scheduler" )
82
-
83
- if (configuration.outputDir.exists()) {
84
- logger.info(" Output directory ${configuration.outputDir} already exists" )
85
- configuration.outputDir.deleteRecursively()
86
- }
87
- configuration.outputDir.mkdirs()
88
-
89
82
scheduler.initialize()
90
83
}
91
84
92
85
override suspend fun scheduleTests (componentInfo : ComponentInfo ) {
93
86
val parsedTests = testParser.extract(componentInfo)
94
87
val tests = applyTestFilters(parsedTests)
95
88
96
- logger.info(" Scheduling ${tests.size } tests for $componentInfo " )
89
+ logger.info(" Scheduling { } tests for {} " , tests.size, componentInfo )
97
90
logger.debug(tests.joinToString(" , " ) { it.toTestName() })
98
91
99
92
val shard = prepareTestShard(tests, analytics)
100
93
scheduler.addTests(shard)
101
94
}
102
95
103
96
override suspend fun stopAndWaitForCompletion (): Boolean {
104
- logger.debug(" Waiting for completion " )
97
+ logger.debug(" Waiting for test run to complete " )
105
98
106
99
try {
107
100
scheduler.stopAndWaitForCompletion()
108
101
onFinish()
109
102
} catch (@Suppress(" TooGenericExceptionCaught" ) e: Throwable ) {
110
103
// We don't want to catch these. If an exception was thrown, we should fail the execution
111
- logger.error(" Error occurred while finishing tests run" , e)
104
+ logger.error(" An error occurred while finishing test run" , e)
112
105
throw e
113
106
}
114
107
return progressReporter.aggregateResult()
@@ -125,7 +118,7 @@ class Marathon(
125
118
try {
126
119
tracker.finish()
127
120
} catch (@Suppress(" TooGenericExceptionCaught" ) e: Throwable ) {
128
- throw ReportGenerationException (" Failed to generate test run report with exception " , e)
121
+ throw ReportGenerationException (" Failed to generate test run report" , e)
129
122
}
130
123
}
131
124
0 commit comments