[flutter_tools] consume package:process exceptions (#79657)
This commit is contained in:
@@ -684,25 +684,47 @@ void main() {
|
||||
});
|
||||
});
|
||||
|
||||
test('skipCommandLookup invokes Process calls directly', () async {
|
||||
final ErrorHandlingProcessManager processManager = ErrorHandlingProcessManager(
|
||||
delegate: const LocalProcessManager(),
|
||||
platform: windowsPlatform,
|
||||
);
|
||||
|
||||
// Throws process exception because the executable does not exist.
|
||||
await ErrorHandlingProcessManager.skipCommandLookup<void>(() async {
|
||||
expect(() => processManager.runSync(<String>['foo']), throwsA(isA<ProcessException>()));
|
||||
expect(() => processManager.run(<String>['foo']), throwsA(isA<ProcessException>()));
|
||||
expect(() => processManager.start(<String>['foo']), throwsA(isA<ProcessException>()));
|
||||
});
|
||||
});
|
||||
|
||||
group('ProcessManager on windows throws tool exit', () {
|
||||
const int kDeviceFull = 112;
|
||||
const int kUserMappedSectionOpened = 1224;
|
||||
const int kUserPermissionDenied = 5;
|
||||
|
||||
test('when PackageProcess throws an exception containg non-executable bits', () {
|
||||
final FakeProcessManager fakeProcessManager = FakeProcessManager.list(<FakeCommand>[
|
||||
const FakeCommand(command: <String>['foo'], exception: ProcessPackageExecutableNotFoundException('', candidates: <String>['not-empty'])),
|
||||
const FakeCommand(command: <String>['foo'], exception: ProcessPackageExecutableNotFoundException('', candidates: <String>['not-empty'])),
|
||||
]);
|
||||
|
||||
final ProcessManager processManager = ErrorHandlingProcessManager(
|
||||
delegate: fakeProcessManager,
|
||||
platform: windowsPlatform,
|
||||
);
|
||||
|
||||
const String expectedMessage = 'The Flutter tool could not locate an executable with suitable permissions';
|
||||
|
||||
expect(() async => processManager.start(<String>['foo']),
|
||||
throwsToolExit(message: expectedMessage));
|
||||
expect(() async => processManager.runSync(<String>['foo']),
|
||||
throwsToolExit(message: expectedMessage));
|
||||
});
|
||||
|
||||
test('when PackageProcess throws an exception without containing non-executable bits', () {
|
||||
final FakeProcessManager fakeProcessManager = FakeProcessManager.list(<FakeCommand>[
|
||||
const FakeCommand(command: <String>['foo'], exception: ProcessPackageExecutableNotFoundException('', candidates: <String>[])),
|
||||
const FakeCommand(command: <String>['foo'], exception: ProcessPackageExecutableNotFoundException('', candidates: <String>[])),
|
||||
]);
|
||||
|
||||
final ProcessManager processManager = ErrorHandlingProcessManager(
|
||||
delegate: fakeProcessManager,
|
||||
platform: windowsPlatform,
|
||||
);
|
||||
|
||||
// If there were no located executables treat this as a programming error and rethrow the original
|
||||
// exception.
|
||||
expect(() async => processManager.start(<String>['foo']), throwsProcessException());
|
||||
expect(() async => processManager.runSync(<String>['foo']), throwsProcessException());
|
||||
});
|
||||
|
||||
test('when the device is full', () {
|
||||
final FakeProcessManager fakeProcessManager = FakeProcessManager.list(<FakeCommand>[
|
||||
const FakeCommand(command: <String>['foo'], exception: ProcessException('', <String>[], '', kDeviceFull)),
|
||||
|
||||
Reference in New Issue
Block a user