• Andrew Kolos's avatar
    provide command to `FakeCommand::onRun` (#142206) · 295a9a20
    Andrew Kolos authored
    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);
      },
    )
    ```
    295a9a20
Name
Last commit
Last update
..
analyze_continuously_test.dart Loading commit data...
analyze_suggestion_test.dart Loading commit data...
analyze_test.dart Loading commit data...
android_analyze_test.dart Loading commit data...
assemble_test.dart Loading commit data...
attach_test.dart Loading commit data...
build_aar_test.dart Loading commit data...
build_darwin_framework_test.dart Loading commit data...
build_ios_test.dart Loading commit data...
build_ipa_test.dart Loading commit data...
build_linux_test.dart Loading commit data...
build_macos_test.dart Loading commit data...
build_test.dart Loading commit data...
build_web_test.dart Loading commit data...
build_windows_test.dart Loading commit data...
clean_test.dart Loading commit data...
config_test.dart Loading commit data...
create_usage_test.dart Loading commit data...
custom_devices_test.dart Loading commit data...
daemon_test.dart Loading commit data...
devices_test.dart Loading commit data...
doctor_test.dart Loading commit data...
downgrade_test.dart Loading commit data...
drive_test.dart Loading commit data...
generate_localizations_test.dart Loading commit data...
http_host_validator_test.dart Loading commit data...
ide_config_test.dart Loading commit data...
install_test.dart Loading commit data...
ios_analyze_test.dart Loading commit data...
logs_test.dart Loading commit data...
precache_test.dart Loading commit data...
proxied_devices_test.dart Loading commit data...
proxy_validator_test.dart Loading commit data...
pub_test.dart Loading commit data...
run_test.dart Loading commit data...
screenshot_command_test.dart Loading commit data...
shell_completion_test.dart Loading commit data...
symbolize_test.dart Loading commit data...
test_test.dart Loading commit data...
update_packages_test.dart Loading commit data...
upgrade_test.dart Loading commit data...