mirror of
https://github.com/flutter/flutter.git
synced 2026-02-05 11:19:18 +08:00
explicitly catch ArgumentError, and add tests (#52757)
This commit is contained in:
parent
a4d30c1607
commit
071d4eb2c8
@ -542,6 +542,9 @@ class _DefaultProcessUtils implements ProcessUtils {
|
||||
} on Exception catch (error) {
|
||||
_logger.printTrace('$cli failed with $error');
|
||||
return false;
|
||||
} on ArgumentError catch (error) {
|
||||
_logger.printTrace('$cli failed with $error');
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@ -556,6 +559,9 @@ class _DefaultProcessUtils implements ProcessUtils {
|
||||
} on Exception catch (error) {
|
||||
_logger.printTrace('$cli failed with $error');
|
||||
return false;
|
||||
} on ArgumentError catch (error) {
|
||||
_logger.printTrace('$cli failed with $error');
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -360,6 +360,20 @@ void main() {
|
||||
);
|
||||
expect(processUtils.exitsHappySync(<String>['boohoo']), isFalse);
|
||||
});
|
||||
|
||||
testWithoutContext('catches Exception and returns false', () {
|
||||
when(mockProcessManager.runSync(<String>['boohoo'])).thenThrow(
|
||||
const ProcessException('Process failed', <String>[]),
|
||||
);
|
||||
expect(processUtils.exitsHappySync(<String>['boohoo']), isFalse);
|
||||
});
|
||||
|
||||
testWithoutContext('catches ArgumentError and returns false', () {
|
||||
when(mockProcessManager.runSync(<String>['nonesuch'])).thenThrow(
|
||||
ArgumentError('Invalid argument(s): Cannot find executable for nonesuch')
|
||||
);
|
||||
expect(processUtils.exitsHappySync(<String>['nonesuch']), isFalse);
|
||||
});
|
||||
});
|
||||
|
||||
group('exitsHappy', () {
|
||||
@ -387,6 +401,20 @@ void main() {
|
||||
});
|
||||
expect(await processUtils.exitsHappy(<String>['boohoo']), isFalse);
|
||||
});
|
||||
|
||||
testWithoutContext('catches Exception and returns false', () async {
|
||||
when(mockProcessManager.run(<String>['boohoo'])).thenThrow(
|
||||
const ProcessException('Process failed', <String>[]),
|
||||
);
|
||||
expect(await processUtils.exitsHappy(<String>['boohoo']), isFalse);
|
||||
});
|
||||
|
||||
testWithoutContext('catches ArgumentError and returns false', () async {
|
||||
when(mockProcessManager.run(<String>['nonesuch'])).thenThrow(
|
||||
ArgumentError('Invalid argument(s): Cannot find executable for nonesuch'),
|
||||
);
|
||||
expect(await processUtils.exitsHappy(<String>['nonesuch']), isFalse);
|
||||
});
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user