[flutter_tools] ensure processUtils reports exit code in ProcessExceptions (#136672)
Help to debug situations like: https://github.com/flutter/flutter/issues/135982
This commit is contained in:
committed by
GitHub
parent
2c102175f2
commit
f830e4be4d
@@ -277,7 +277,7 @@ class _DefaultProcessUtils implements ProcessUtils {
|
||||
_logger.printTrace(runResult.toString());
|
||||
if (throwOnError && runResult.exitCode != 0 &&
|
||||
(allowedFailures == null || !allowedFailures(runResult.exitCode))) {
|
||||
runResult.throwException('Process exited abnormally:\n$runResult');
|
||||
runResult.throwException('Process exited abnormally with exit code ${runResult.exitCode}:\n$runResult');
|
||||
}
|
||||
return runResult;
|
||||
}
|
||||
@@ -341,7 +341,7 @@ class _DefaultProcessUtils implements ProcessUtils {
|
||||
_logger.printTrace(runResult.toString());
|
||||
if (throwOnError && runResult.exitCode != 0 &&
|
||||
(allowedFailures == null || !allowedFailures(exitCode))) {
|
||||
runResult.throwException('Process exited abnormally:\n$runResult');
|
||||
runResult.throwException('Process exited abnormally with exit code $exitCode:\n$runResult');
|
||||
}
|
||||
return runResult;
|
||||
}
|
||||
@@ -407,7 +407,7 @@ class _DefaultProcessUtils implements ProcessUtils {
|
||||
}
|
||||
|
||||
if (failedExitCode && throwOnError) {
|
||||
String message = 'The command failed';
|
||||
String message = 'The command failed with exit code ${runResult.exitCode}';
|
||||
if (verboseExceptions) {
|
||||
message = 'The command failed\nStdout:\n${runResult.stdout}\n'
|
||||
'Stderr:\n${runResult.stderr}';
|
||||
|
||||
@@ -33,7 +33,10 @@ void main() {
|
||||
exitCode: 1,
|
||||
));
|
||||
|
||||
expect(() async => processUtils.run(<String>['false'], throwOnError: true), throwsProcessException());
|
||||
expect(
|
||||
() async => processUtils.run(<String>['false'], throwOnError: true),
|
||||
throwsProcessException(message: 'Process exited abnormally with exit code 1'),
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -123,7 +123,7 @@ void main() {
|
||||
expect(logger.statusText, contains('Property List error: Unexpected character \x01 at line 1 / '
|
||||
'JSON error: JSON text did not start with array or object and option to allow fragments not '
|
||||
'set. around line 1, column 0.\n'));
|
||||
expect(logger.errorText, 'ProcessException: The command failed\n'
|
||||
expect(logger.errorText, 'ProcessException: The command failed with exit code 1\n'
|
||||
' Command: /usr/bin/plutil -convert xml1 -o - ${file.absolute.path}\n');
|
||||
}, skip: !platform.isMacOS); // [intended] requires macos tool chain.
|
||||
|
||||
@@ -185,7 +185,7 @@ void main() {
|
||||
expect(logger.statusText, contains('foo.plist: Property List error: Unexpected character \x01 '
|
||||
'at line 1 / JSON error: JSON text did not start with array or object and option to allow '
|
||||
'fragments not set. around line 1, column 0.\n'));
|
||||
expect(logger.errorText, equals('ProcessException: The command failed\n'
|
||||
expect(logger.errorText, equals('ProcessException: The command failed with exit code 1\n'
|
||||
' Command: /usr/bin/plutil -replace CFBundleIdentifier -string dev.flutter.fake foo.plist\n'));
|
||||
}, skip: !platform.isMacOS); // [intended] requires macos tool chain.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user