flutter/dev/conductor/core/test
Andrew Kolos 295a9a2031
provide command to FakeCommand::onRun (#142206)
Part of work on [#101077](https://github.com/flutter/flutter/pull/141194). This is done as a separate PR to avoid a massive diff.

## Context
1. The `FakeCommand` class accepts a list of patterns that's used to match a command given to its `FakeProcessManager`. Since `FakeCommand` can match a list of patterns, not just specifically strings, it can be used to match commands where the exact value of some arguments can't (easily) known ahead of time. For example, a part of the tool may invoke a command with an argument that is the path of a temporarily file that has a randomly-generated basename.
2. The `FakeCommand` class provides on `onRun` parameter, which is a callback that is run when the `FakeProcessManager` runs a command that matches the `FakeCommand` in question.

## Issue
In the event that a `FakeCommand` is constructed using patterns, the test code can't know the exact values used for arguments in the command. This PR proposes changing the type of `onRun` from `VoidCallback?` to `void Function(List<String>)?`. When run, the value `List<String>` parameter will be the full command that the `FakeCommand` matched.

Example:
```dart
FakeCommand(
  command: <Pattern>[
    artifacts.getArtifactPath(Artifact.engineDartBinary),
    'run',
    'vector_graphics_compiler',
    RegExp(r'--input=/.*\.temp'),
    RegExp(r'--output=/.*\.temp'),
  ],
  onRun: (List<String> command) {
    final outputPath = (() { 
      // code to parse `--output` from `command`
    })();
    testFileSystem.file(outputPath).createSync(recursive: true);
  },
)
```
2024-01-25 07:51:25 +00:00
..
candidates_test.dart [flutter_conductor] implement UI scaffold (#90621) 2021-09-24 15:30:09 -07:00
clean_test.dart added cleanContext (#93264) 2021-11-08 17:34:03 -05:00
common.dart re-enable "Linux packages_autoroller" (#130088) 2023-07-10 19:32:56 +00:00
globals_test.dart [conductor] Remove PublishChannel and use MPA command (#135884) 2023-10-09 21:13:55 +00:00
next_test.dart provide command to FakeCommand::onRun (#142206) 2024-01-25 07:51:25 +00:00
packages_autoroller_test.dart Enable strict-inference (#135043) 2023-09-20 19:59:08 +00:00
repository_test.dart provide command to FakeCommand::onRun (#142206) 2024-01-25 07:51:25 +00:00
start_test.dart provide command to FakeCommand::onRun (#142206) 2024-01-25 07:51:25 +00:00
state_test.dart [conductor] Remove PublishChannel and use MPA command (#135884) 2023-10-09 21:13:55 +00:00
version_test.dart [flutter_conductor] deprecate increment (#99189) 2022-03-01 12:11:22 -08:00