createTestCommand method

CommandToRun createTestCommand({
  1. required String projectRoot,
  2. required DetermineFlutterOrDart tool,
  3. required String relativeProjectRoot,
  4. required List<String> flutterArgs,
  5. required List<String> dartArgs,
  6. required List<String> tests,
})

Implementation

CommandToRun createTestCommand({
  required String projectRoot,
  required DetermineFlutterOrDart tool,
  required String relativeProjectRoot,
  required List<String> flutterArgs,
  required List<String> dartArgs,
  required List<String> tests,
}) {
  final toolArgs = tool.isFlutter ? flutterArgs : dartArgs;

  final command = tool.tool();

  final script = [
    '$command test',
    if (tests.isNotEmpty) tests.join(' '),
    if (toolArgs.isNotEmpty) toolArgs.join(' '),
  ].join(' ');

  logger.detail('Test command: $script');

  var label = darkGray.wrap('Running (')!;
  label += cyan.wrap(command)!;
  label += darkGray.wrap(') tests in ')!;
  label += yellow.wrap(relativeProjectRoot)!;

  return CommandToRun(
    command: script,
    workingDirectory: projectRoot,
    keys: ['dart', 'test', ...tests, ...toolArgs],
    label: label,
  );
}