[tool] Move changed file detection to base command class (#8730)

Consolidates the code to find all changed file paths into the `PackageLoopingCommand` class that is the base of almost all of the repo tooling commands. This in a preparatory PR for a future change to allow each command to define a list of files or file patterns that definitively *don't* affect that test, so that CI can be smarter about what tests to run (e.g., not running expensive integration tests for README changes).

A side effect of this change is that tests of almost all commands now need a mock `GitDir` instance. This would add a lot of copy/pasted boilerplate to the test setup, and there is already too much of that, so instead this refactors common test setup:
- Creating a memory file system
- Populating it with a packages directory
- Creating a RecordingProcessRunner to mock out process calls
- Creating a mock GitDir that forwards to a RecordingProcessRunner

into a helper method (using records and destructuring to easily return multiple values). While some tests don't need all of these steps, those that don't can easily ignore parts of it, and it will make it much easier to update tests in the future if they need them, and it makes the setup much more consistent which makes it easier to reason about test setup in general.

Prep for https://github.com/flutter/flutter/issues/136394
This commit is contained in:
stuartmorgan
2025-03-25 14:29:17 -07:00
committed by GitHub
parent c254ecab9c
commit 8c287e99d6
65 changed files with 587 additions and 633 deletions

View File

@ -16,6 +16,7 @@ class XcodeAnalyzeCommand extends PackageLoopingCommand {
super.packagesDir, {
super.processRunner,
super.platform,
super.gitDir,
}) : _xcode = Xcode(processRunner: processRunner, log: true) {
argParser.addFlag(platformIOS, help: 'Analyze iOS');
argParser.addFlag(platformMacOS, help: 'Analyze macOS');