buildFlutterTestArgs function
List<String>
buildFlutterTestArgs(
- List<
String> arguments, { - required String suiteEncryptionKey,
- required String? reportMode,
- required String? reportFile,
- required int? timeoutSeconds,
- required bool verbose,
- List<
String> shardPaths = const [], - List<
String> shardIds = const [], - int? workerIndex,
- String? progressFile,
- String? appLogPath,
- String? appLogDisplayPath,
- String? artifactRoot,
- Map<
String, dynamic> ? serviceOverrides, - String artifactDisplayRoot = 'build/ensemble_test_runner',
- String testEntryRelativePath = TestAppPatcher.testEntryRelativePath,
- FlutterDevice? physicalDevice,
- bool hostOwnsServices = false,
- String? testsAssetPrefix,
- bool useRuntimeWorkerConfig = false,
Builds the complete, deterministic command line passed to flutter test.
Keeping command construction separate from process orchestration makes the worker boundary explicit and lets callers validate it without launching a Flutter process.
Implementation
List<String> buildFlutterTestArgs(
List<String> arguments, {
required String suiteEncryptionKey,
required String? reportMode,
required String? reportFile,
required int? timeoutSeconds,
required bool verbose,
List<String> shardPaths = const [],
List<String> shardIds = const [],
int? workerIndex,
String? progressFile,
String? appLogPath,
String? appLogDisplayPath,
String? artifactRoot,
Map<String, dynamic>? serviceOverrides,
String artifactDisplayRoot = 'build/ensemble_test_runner',
String testEntryRelativePath = TestAppPatcher.testEntryRelativePath,
FlutterDevice? physicalDevice,
bool hostOwnsServices = false,
String? testsAssetPrefix,
bool useRuntimeWorkerConfig = false,
}) {
final planBatchFile = planBatchFileFromArguments(arguments);
final runtimeWorkerConfig = useRuntimeWorkerConfig && physicalDevice == null;
return [
'test',
testEntryRelativePath,
'--no-pub',
if (physicalDevice != null) ...['-d', physicalDevice.id],
if (hostOwnsServices) '--dart-define=ensembleTestHostOwnsServices=true',
if (testsAssetPrefix != null)
'--dart-define=ensembleTestTestsAssetPrefix=${testsAssetPrefix.endsWith('/') ? testsAssetPrefix : '$testsAssetPrefix/'}',
if (physicalDevice != null)
'--dart-define=ensembleTestExecutionMode=integration',
if (arguments.contains('--reset-device-storage'))
'--dart-define=ensembleTestResetDeviceStorage=true',
if (arguments.contains('--allow-device-storage-mutation'))
'--dart-define=ensembleTestAllowDeviceStorageMutation=true',
if (physicalDevice != null && !physicalDevice.isVirtual)
'--dart-define=ensembleTestDeviceIsPhysical=true',
if (!runtimeWorkerConfig)
'--dart-define=ensembleTestEncryptionKey=$suiteEncryptionKey',
if (physicalDevice != null) ...[
'--dart-define=ensembleTestPhysicalDeviceId=${physicalDevice.id}',
'--dart-define=ensembleTestPhysicalPlatform=${physicalDevice.platform}',
'--dart-define=ensembleTestPhysicalDeviceName=${physicalDevice.name}',
],
if (!runtimeWorkerConfig && reportMode != null)
'--dart-define=ensembleTestReport=$reportMode',
'--dart-define=ensembleTestEmitJsonReport=true',
if (!runtimeWorkerConfig && reportFile != null)
'--dart-define=ensembleTestReportFile=$reportFile',
if (!runtimeWorkerConfig && timeoutSeconds != null)
'--dart-define=ensembleTestTimeoutSeconds=$timeoutSeconds',
if (!runtimeWorkerConfig && workerIndex != null) ...[
'--dart-define=ensembleTestWorkerIndex=$workerIndex',
'--dart-define=ensembleTestWorkerSuffix=worker${workerIndex + 1}',
],
if (!runtimeWorkerConfig && progressFile != null)
'--dart-define=ensembleTestProgressFile=$progressFile',
if (!runtimeWorkerConfig && appLogPath != null)
'--dart-define=ensembleTestAppLogFile=$appLogPath',
if (!runtimeWorkerConfig && appLogDisplayPath != null)
'--dart-define=ensembleTestAppLogDisplayFile=$appLogDisplayPath',
if (!runtimeWorkerConfig && artifactRoot != null)
'--dart-define=ensembleTestArtifactRoot=$artifactRoot',
if (!runtimeWorkerConfig &&
serviceOverrides != null &&
serviceOverrides.isNotEmpty)
'--dart-define=ensembleTestServiceOverrides=${json.encode(serviceOverrides)}',
if (!runtimeWorkerConfig)
'--dart-define=ensembleTestArtifactDisplayRoot=$artifactDisplayRoot',
if (!runtimeWorkerConfig) ..._inputDartDefines(arguments),
if (!runtimeWorkerConfig) ..._selectionDartDefines(arguments),
if (!runtimeWorkerConfig && shardPaths.isNotEmpty)
'--dart-define=ensembleTestShardPath=${shardPaths.join(',')}',
if (!runtimeWorkerConfig && shardIds.isNotEmpty)
'--dart-define=ensembleTestShardId=${shardIds.join(',')}',
if (!runtimeWorkerConfig && planBatchFile != null)
'--dart-define=ensembleTestPlanBatchFile=$planBatchFile',
'--reporter',
verbose ? 'expanded' : 'silent',
...flutterTestArguments(arguments),
];
}