@@ -86,6 +86,12 @@ class TestCommand : Callable<Int> {
86
86
)
87
87
private var shards: Int = 1
88
88
89
+ @Option(
90
+ names = [" -b" , " --broadcast" ],
91
+ description = [" Broadcasts all the tests across all running devices" ]
92
+ )
93
+ private var broadcast: Boolean = false
94
+
89
95
@Option(names = [" -c" , " --continuous" ])
90
96
private var continuous: Boolean = false
91
97
@@ -178,7 +184,6 @@ class TestCommand : Callable<Int> {
178
184
}
179
185
180
186
private fun handleSessions (debugOutputPath : Path , plan : ExecutionPlan ): Int = runBlocking(Dispatchers .IO ) {
181
- val sharded = shards > 1
182
187
183
188
runCatching {
184
189
val deviceIds = (if (isWebFlow())
@@ -194,10 +199,16 @@ class TestCommand : Callable<Int> {
194
199
initialActiveDevices.addAll(DeviceService .listConnectedDevices().map {
195
200
it.instanceId
196
201
}.toMutableSet())
197
- val effectiveShards = shards.coerceAtMost(plan.flowsToRun.size)
198
- val chunkPlans = plan.flowsToRun
202
+
203
+ val availableDevices = if (deviceIds.isNotEmpty()) deviceIds.size else initialActiveDevices.size
204
+ val effectiveShards = if (broadcast) availableDevices else shards.coerceAtMost(plan.flowsToRun.size)
205
+ val sharded = effectiveShards > 1
206
+
207
+ val chunkPlans =
208
+ if (broadcast) (0 until availableDevices).map { ExecutionPlan (plan.flowsToRun, plan.sequence) }
209
+ else plan.flowsToRun
199
210
.withIndex()
200
- .groupBy { it.index % shards }
211
+ .groupBy { it.index % effectiveShards }
201
212
.map { (shardIndex, files) ->
202
213
ExecutionPlan (
203
214
files.map { it.value },
@@ -209,12 +220,12 @@ class TestCommand : Callable<Int> {
209
220
}
210
221
211
222
// Collect device configurations for missing shards, if any
212
- val missing = effectiveShards - if (deviceIds.isNotEmpty()) deviceIds.size else initialActiveDevices.size
213
- val allDeviceConfigs = (0 until missing).map { shardIndex ->
223
+ val missing = effectiveShards - availableDevices
224
+ val allDeviceConfigs = if ( ! broadcast) (0 until missing).map { shardIndex ->
214
225
PrintUtils .message(" ------------------ Shard ${shardIndex + 1 } ------------------" )
215
226
// Collect device configurations here, one per shard
216
227
PickDeviceView .requestDeviceOptions()
217
- }.toMutableList()
228
+ }.toMutableList() else mutableListOf ()
218
229
219
230
val barrier = CountDownLatch (effectiveShards)
220
231
0 commit comments