Unverified Commit 9fe55670 authored by Jenn Magder's avatar Jenn Magder Committed by GitHub

Print sub process that failed to run in tool (#120999)

parent f7851368
...@@ -667,7 +667,10 @@ class ErrorHandlingProcessManager extends ProcessManager { ...@@ -667,7 +667,10 @@ class ErrorHandlingProcessManager extends ProcessManager {
stdoutEncoding: stdoutEncoding, stdoutEncoding: stdoutEncoding,
stderrEncoding: stderrEncoding, stderrEncoding: stderrEncoding,
); );
}, platform: _platform); },
platform: _platform,
failureMessage: 'Flutter failed to run "${command.join(' ')}"',
);
} }
@override @override
...@@ -688,7 +691,10 @@ class ErrorHandlingProcessManager extends ProcessManager { ...@@ -688,7 +691,10 @@ class ErrorHandlingProcessManager extends ProcessManager {
runInShell: runInShell, runInShell: runInShell,
mode: mode, mode: mode,
); );
}, platform: _platform); },
platform: _platform,
failureMessage: 'Flutter failed to run "${command.join(' ')}"',
);
} }
@override @override
...@@ -711,7 +717,10 @@ class ErrorHandlingProcessManager extends ProcessManager { ...@@ -711,7 +717,10 @@ class ErrorHandlingProcessManager extends ProcessManager {
stdoutEncoding: stdoutEncoding, stdoutEncoding: stdoutEncoding,
stderrEncoding: stderrEncoding, stderrEncoding: stderrEncoding,
); );
}, platform: _platform); },
platform: _platform,
failureMessage: 'Flutter failed to run "${command.join(' ')}"',
);
} }
} }
...@@ -759,9 +768,11 @@ void _handleMacOSException(Exception e, String? message, int errorCode, String? ...@@ -759,9 +768,11 @@ void _handleMacOSException(Exception e, String? message, int errorCode, String?
const int ebadarch = 86; const int ebadarch = 86;
if (errorCode == ebadarch) { if (errorCode == ebadarch) {
final StringBuffer errorBuffer = StringBuffer(); final StringBuffer errorBuffer = StringBuffer();
errorBuffer.writeln(message); if (message != null) {
errorBuffer.writeln('This binary was built with the incorrect architecture to run on this machine.'); errorBuffer.writeln('$message.');
errorBuffer.writeln('Flutter requires the Rosetta translation environment. If you are on an ARM Mac, try running:'); }
errorBuffer.writeln('The binary was built with the incorrect architecture to run on this machine.');
errorBuffer.writeln('If you are on an ARM Apple Silicon Mac, Flutter requires the Rosetta translation environment. Try running:');
errorBuffer.writeln(' sudo softwareupdate --install-rosetta --agree-to-license'); errorBuffer.writeln(' sudo softwareupdate --install-rosetta --agree-to-license');
_throwFileSystemException(errorBuffer.toString()); _throwFileSystemException(errorBuffer.toString());
} }
......
...@@ -963,7 +963,8 @@ void main() { ...@@ -963,7 +963,8 @@ void main() {
platform: windowsPlatform, platform: windowsPlatform,
); );
const String expectedMessage = 'The flutter tool cannot access the file'; const String expectedMessage = 'Flutter failed to run "foo". The flutter tool cannot access the file or directory.\n'
'Please ensure that the SDK and/or project is installed in a location that has read/write permissions for the current user.';
expect(() async => processManager.start(<String>['foo']), expect(() async => processManager.start(<String>['foo']),
throwsToolExit(message: expectedMessage)); throwsToolExit(message: expectedMessage));
expect(() async => processManager.run(<String>['foo']), expect(() async => processManager.run(<String>['foo']),
...@@ -1021,7 +1022,8 @@ void main() { ...@@ -1021,7 +1022,8 @@ void main() {
platform: linuxPlatform, platform: linuxPlatform,
); );
const String expectedMessage = 'The flutter tool cannot access the file'; const String expectedMessage = 'Flutter failed to run "foo".\n'
'Please ensure that the SDK and/or project is installed in a location that has read/write permissions for the current user.';
expect(() async => processManager.start(<String>['foo']), expect(() async => processManager.start(<String>['foo']),
throwsToolExit(message: expectedMessage)); throwsToolExit(message: expectedMessage));
...@@ -1085,7 +1087,8 @@ void main() { ...@@ -1085,7 +1087,8 @@ void main() {
platform: macOSPlatform, platform: macOSPlatform,
); );
const String expectedMessage = 'The flutter tool cannot access the file'; const String expectedMessage = 'Flutter failed to run "foo".\n'
'Please ensure that the SDK and/or project is installed in a location that has read/write permissions for the current user.';
expect(() async => processManager.start(<String>['foo']), expect(() async => processManager.start(<String>['foo']),
throwsToolExit(message: expectedMessage)); throwsToolExit(message: expectedMessage));
...@@ -1113,9 +1116,9 @@ void main() { ...@@ -1113,9 +1116,9 @@ void main() {
testWithoutContext('when bad CPU type', () async { testWithoutContext('when bad CPU type', () async {
final FakeProcessManager fakeProcessManager = FakeProcessManager.list(<FakeCommand>[ final FakeProcessManager fakeProcessManager = FakeProcessManager.list(<FakeCommand>[
const FakeCommand(command: <String>['foo'], exception: ProcessException('', <String>[], '', ebadarch)), const FakeCommand(command: <String>['foo', '--bar'], exception: ProcessException('', <String>[], '', ebadarch)),
const FakeCommand(command: <String>['foo'], exception: ProcessException('', <String>[], '', ebadarch)), const FakeCommand(command: <String>['foo', '--bar'], exception: ProcessException('', <String>[], '', ebadarch)),
const FakeCommand(command: <String>['foo'], exception: ProcessException('', <String>[], '', ebadarch)), const FakeCommand(command: <String>['foo', '--bar'], exception: ProcessException('', <String>[], '', ebadarch)),
]); ]);
final ProcessManager processManager = ErrorHandlingProcessManager( final ProcessManager processManager = ErrorHandlingProcessManager(
...@@ -1123,13 +1126,14 @@ void main() { ...@@ -1123,13 +1126,14 @@ void main() {
platform: macOSPlatform, platform: macOSPlatform,
); );
const String expectedMessage = 'Flutter requires the Rosetta translation environment'; const String expectedMessage = 'Flutter failed to run "foo --bar".\n'
'The binary was built with the incorrect architecture to run on this machine.';
expect(() async => processManager.start(<String>['foo']), expect(() async => processManager.start(<String>['foo', '--bar']),
throwsToolExit(message: expectedMessage)); throwsToolExit(message: expectedMessage));
expect(() async => processManager.run(<String>['foo']), expect(() async => processManager.run(<String>['foo', '--bar']),
throwsToolExit(message: expectedMessage)); throwsToolExit(message: expectedMessage));
expect(() => processManager.runSync(<String>['foo']), expect(() => processManager.runSync(<String>['foo', '--bar']),
throwsToolExit(message: expectedMessage)); throwsToolExit(message: expectedMessage));
}); });
}); });
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment