@@ -151,34 +151,36 @@ class TestCommand : Callable<Int> {
151151 }
152152
153153 override fun call (): Int {
154+ TestDebugReporter .install(
155+ debugOutputPathAsString = debugOutput,
156+ flattenDebugOutput = flattenDebugOutput,
157+ printToConsole = parent?.verbose == true ,
158+ )
159+
154160 if (parent?.platform != null ) {
155161 throw CliError (" --platform option was deprecated. You can remove it to run your test." )
156162 }
157163
158164 val executionPlan = try {
159165 WorkspaceExecutionPlanner .plan(
160- flowFile.toPath().toAbsolutePath(),
161- includeTags,
162- excludeTags
166+ input = flowFile.toPath().toAbsolutePath(),
167+ includeTags = includeTags ,
168+ excludeTags = excludeTags,
163169 )
164170 } catch (e: ValidationError ) {
165171 throw CliError (e.message)
166172 }
167173
168174 env = env.withInjectedShellEnvVars()
169175
170- TestDebugReporter .install(
171- debugOutputPathAsString = debugOutput,
172- flattenDebugOutput = flattenDebugOutput,
173- printToConsole = parent?.verbose == true ,
174- )
175176 val debugOutputPath = TestDebugReporter .getDebugOutputPath()
176177
177178 return handleSessions(debugOutputPath, executionPlan)
178179 }
179180
180181 private fun handleSessions (debugOutputPath : Path , plan : ExecutionPlan ): Int = runBlocking(Dispatchers .IO ) {
181182 val sharded = shards > 1
183+ val onlySequenceFlows = plan.sequence.flows.isNotEmpty() && plan.flowsToRun.isEmpty() // An edge case
182184
183185 runCatching {
184186 val deviceIds = (if (isWebFlow())
@@ -195,23 +197,32 @@ class TestCommand : Callable<Int> {
195197 it.instanceId
196198 }.toMutableSet())
197199
198- if (shards > 1 && plan.sequence? .flows? .isNotEmpty() == true ) {
200+ if (sharded && plan.sequence.flows.isNotEmpty()) {
199201 error(" Cannot run sharded tests with sequential execution" )
200202 }
201203
202- val effectiveShards = shards.coerceAtMost(plan.flowsToRun.size)
203- val chunkPlans = plan.flowsToRun
204- .withIndex()
205- .groupBy { it.index % shards }
206- .map { (shardIndex, files) ->
207- ExecutionPlan (
208- files.map { it.value },
209- plan.sequence.also {
210- if (it?.flows?.isNotEmpty() == true && sharded)
211- error(" Cannot run sharded tests with sequential execution." )
212- }
213- )
214- }
204+ if (sharded) {
205+ PrintUtils .info(" Requested to run ${plan.flowsToRun.size} flows in $shards shard(s)" )
206+ }
207+
208+ val effectiveShards = if (onlySequenceFlows) 1 else shards.coerceAtMost(plan.flowsToRun.size)
209+ val chunkPlans: List <ExecutionPlan > = if (onlySequenceFlows) {
210+ // Handle an edge case
211+ // We only want to run sequential flows in this case.
212+ listOf (plan)
213+ } else {
214+ plan.flowsToRun
215+ .withIndex()
216+ .groupBy { it.index % shards }
217+ .map { (shardIndex, files) ->
218+ ExecutionPlan (
219+ flowsToRun = files.map { it.value },
220+ sequence = plan.sequence,
221+ )
222+ }
223+ }
224+
225+ PrintUtils .info(" Will run ${if (onlySequenceFlows) plan.sequence.flows.size else plan.flowsToRun.size} flows in $effectiveShards shard(s)" )
215226
216227 // Collect device configurations for missing shards, if any
217228 val missing = effectiveShards - if (deviceIds.isNotEmpty()) deviceIds.size else initialActiveDevices.size
0 commit comments