[tool] Update to Dart 3 (#6030)

Updates the repo tooling to Dart 3, now that the N-2 version has Dart 3, which allows us to use Dart 3 features (e.g., records) going forward.

To allow the update:
- Removes `break` commands from `switch`es (all done automatically with `dart fix --apply`)
- Replaces mocking of `ProcessResult` with just creating an actual `ProcessResult` since it's a `final` data class and thus can't (but also doesn't need to be) mocked.
This commit is contained in:
stuartmorgan
2024-02-06 11:31:48 -08:00
committed by GitHub
parent 9382257ce7
commit 7403992f15
15 changed files with 70 additions and 99 deletions

View File

@ -394,8 +394,9 @@ void main() {
platformIOS: const PlatformDetails(PlatformSupport.inline)
});
final Iterable<Directory> exampleDirs = plugin.getExamples().map(
(RepositoryPackage example) => example.directory);
final Iterable<Directory> exampleDirs = plugin
.getExamples()
.map((RepositoryPackage example) => example.directory);
final List<String> output = await runCapturingPrint(
runner, <String>['fetch-deps', '--no-dart', '--ios']);
@ -432,10 +433,11 @@ void main() {
});
processRunner
.mockProcessesForExecutable[getFlutterCommand(mockPlatform)] =
<FakeProcessInfo>[
.mockProcessesForExecutable[getFlutterCommand(mockPlatform)] =
<FakeProcessInfo>[
FakeProcessInfo(MockProcess(), <String>['precache']),
FakeProcessInfo(MockProcess(exitCode: 1), <String>['build', 'ios', '--config-only']),
FakeProcessInfo(MockProcess(exitCode: 1),
<String>['build', 'ios', '--config-only']),
];
Error? commandError;
@ -499,8 +501,9 @@ void main() {
platformMacOS: const PlatformDetails(PlatformSupport.inline)
});
final Iterable<Directory> exampleDirs = plugin.getExamples().map(
(RepositoryPackage example) => example.directory);
final Iterable<Directory> exampleDirs = plugin
.getExamples()
.map((RepositoryPackage example) => example.directory);
final List<String> output = await runCapturingPrint(
runner, <String>['fetch-deps', '--no-dart', '--macos']);
@ -537,18 +540,19 @@ void main() {
});
processRunner
.mockProcessesForExecutable[getFlutterCommand(mockPlatform)] =
<FakeProcessInfo>[
.mockProcessesForExecutable[getFlutterCommand(mockPlatform)] =
<FakeProcessInfo>[
FakeProcessInfo(MockProcess(), <String>['precache']),
FakeProcessInfo(MockProcess(exitCode: 1), <String>['build', 'macos', '--config-only']),
FakeProcessInfo(MockProcess(exitCode: 1),
<String>['build', 'macos', '--config-only']),
];
Error? commandError;
final List<String> output = await runCapturingPrint(
runner, <String>['fetch-deps', '--no-dart', '--macos'],
errorHandler: (Error e) {
commandError = e;
});
commandError = e;
});
expect(commandError, isA<ToolExit>());
expect(