mirror of
https://github.com/flutter/packages.git
synced 2025-08-06 00:42:13 +08:00
[flutter_plugin_tools] Remove most exitOnError:true usage (#4130)
The intent of package-looping commands is that we always want to run them for all the targeted packages, accumulating failures, and then report them all at the end, so we don't end up with the problem of only finding errors one at a time. However, some of them were using `exitOnError: true` for the underlying commands, causing the first error to be fatal to the test. This PR: - Removes all use of `exitOnError: true` from the package-looping commands. (It's still used in `format`, but fixing that is a larger issue, and less important due to the way `format` is currently structured.) - Fixes the mock process runner used in our tests to correctly simulate `exitOrError: true`; the fact that it didn't was hiding this problem in test (e.g., `drive-examples` had a test that asserted that all failures were summarized correctly, which passed because in tests it was behaving as if `exitOnError` were false) - Adjusts the mock process runner to allow setting a list of mock result for a specific executable instead of one result for all calls to anything, in order to fix some tests that were broken by the two changes above and unfixable without this (e.g., a test of a command that had been calling one executable with `exitOnError: true` then another with ``exitOnError: false`, where the test was asserting things about the second call failing, which only worked because the first call's failure wasn't actually checked). To limit the scope of the PR, the old method of setting a single result for all calls is still supported for now as a fallback. - Fixes the fact that the mock `run` and `runAndStream` had opposite default exit code behavior when no mock process was set (since that caused me a lot of confusion while fixing the above until I figured it out).
This commit is contained in:
@ -33,10 +33,12 @@ void main() {
|
||||
runner.addCommand(command);
|
||||
});
|
||||
|
||||
test('retries gcloud set', () async {
|
||||
test('fails if gcloud auth fails', () async {
|
||||
final MockProcess mockProcess = MockProcess();
|
||||
mockProcess.exitCodeCompleter.complete(1);
|
||||
processRunner.processToReturn = mockProcess;
|
||||
processRunner.mockProcessesForExecutable['gcloud'] = <Process>[
|
||||
mockProcess
|
||||
];
|
||||
createFakePlugin('plugin', packagesDir, extraFiles: <String>[
|
||||
'example/integration_test/foo_test.dart',
|
||||
'example/android/gradlew',
|
||||
@ -50,6 +52,31 @@ void main() {
|
||||
});
|
||||
|
||||
expect(commandError, isA<ToolExit>());
|
||||
expect(
|
||||
output,
|
||||
containsAllInOrder(<Matcher>[
|
||||
contains('Unable to activate gcloud account.'),
|
||||
]));
|
||||
});
|
||||
|
||||
test('retries gcloud set', () async {
|
||||
final MockProcess mockAuthProcess = MockProcess();
|
||||
mockAuthProcess.exitCodeCompleter.complete(0);
|
||||
final MockProcess mockConfigProcess = MockProcess();
|
||||
mockConfigProcess.exitCodeCompleter.complete(1);
|
||||
processRunner.mockProcessesForExecutable['gcloud'] = <Process>[
|
||||
mockAuthProcess,
|
||||
mockConfigProcess,
|
||||
];
|
||||
createFakePlugin('plugin', packagesDir, extraFiles: <String>[
|
||||
'example/integration_test/foo_test.dart',
|
||||
'example/android/gradlew',
|
||||
'example/android/app/src/androidTest/MainActivityTest.java',
|
||||
]);
|
||||
|
||||
final List<String> output =
|
||||
await runCapturingPrint(runner, <String>['firebase-test-lab']);
|
||||
|
||||
expect(
|
||||
output,
|
||||
containsAllInOrder(<Matcher>[
|
||||
|
Reference in New Issue
Block a user