createTestCommand method
Implementation
CommandToRun createTestCommand({
required String projectRoot,
required String relativeProjectRoot,
required DetermineFlutterOrDart tool,
required List<String> flutterArgs,
required List<String> dartArgs,
required List<String> tests,
}) {
if (tests.isEmpty) {
throw Exception('Cannot create a command without tests');
}
final toolArgs = tool.isFlutter ? flutterArgs : dartArgs;
final command = tool.tool();
final script = '$command test ${tests.join(' ')} ${toolArgs.join(' ')}';
logger.detail('Test command: $script');
var label = darkGray.wrap('Running (')!;
label += cyan.wrap(command)!;
if (tool.testType != null) {
label += darkGray.wrap(' | ')!;
label += magenta.wrap(tool.testType!.toUpperCase())!;
}
if (tests.length == 1) {
label += darkGray.wrap(') tests in ')!;
label += yellow.wrap(relativeProjectRoot)!;
} else {
label += darkGray.wrap(') tests for ')!;
label += yellow.wrap(tests.join(', '))!;
}
return CommandToRun(
command: script,
workingDirectory: projectRoot,
keys: ['dart', 'test', ...tests, ...toolArgs],
label: label,
);
}