flutter/packages/flutter_tools/test/general.shard/base
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
..
analyze_size_test.dart Unified analytics migration for CodeSizeAnalysis (#138351) 2023-11-14 20:23:40 +00:00
async_guard_test.dart fixes to anticipate next Dart linter release (#127211) 2023-05-19 21:27:24 +00:00
bot_detector_test.dart
build_test.dart Set template and migrate apps to iOS 12 minimum (#140823) 2024-01-03 00:47:40 +00:00
command_help_test.dart Support disabling animations in the CLI (#132239) 2023-08-23 03:35:22 +00:00
common_test.dart
context_test.dart
deferred_component_test.dart [reland] Support conditional bundling of assets based on --flavor (#139834) 2023-12-14 05:30:10 +00:00
error_handling_io_test.dart [flutter_tools] handle FileSystemException trying to delete temp directory from core_devices.dart (#140415) 2023-12-20 00:08:54 +00:00
file_system_test.dart Add spaces after flow control statements (#126320) 2023-05-15 11:07:30 +02:00
fingerprint_test.dart
io_test.dart
logger_test.dart Reduce animations further when --no-cli-animations is set. (#133598) 2023-11-16 21:05:22 +00:00
multi_root_file_system_test.dart
net_test.dart
os_test.dart provide command to FakeCommand::onRun (#142206) 2024-01-25 07:51:25 +00:00
os_utils_test.dart Flutter preview device (#135639) 2023-10-18 00:27:54 +00:00
platform_test.dart
process_test.dart [flutter_tools] ensure processUtils reports exit code in ProcessExceptions (#136672) 2023-10-30 19:51:26 +00:00
signals_test.dart [flutter_tools] Run ShutdownHooks when handling signals (#134590) 2023-09-13 13:05:29 -07:00
task_queue_test.dart [flutter_tools] Replace Future.catchError() with Future.then(onError: ...) (#120637) 2023-02-15 19:03:00 +00:00
terminal_test.dart [flutter_tools] catch StdinException when setting terminal to SingleCharMode (#136283) 2023-10-10 23:10:29 +00:00
user_messages_test.dart Fix the message strings for xcodeMissing and xcodeIncomplete (#117922) 2023-01-04 02:48:00 +00:00