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

This commit is contained in:
Jenn Magder 2023-02-17 14:02:51 -08:00 committed by GitHub
parent f785136852
commit 9fe556705b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 31 additions and 16 deletions

View File

@ -667,7 +667,10 @@ class ErrorHandlingProcessManager extends ProcessManager {
stdoutEncoding: stdoutEncoding,
stderrEncoding: stderrEncoding,
);
}, platform: _platform);
},
platform: _platform,
failureMessage: 'Flutter failed to run "${command.join(' ')}"',
);
}
@override
@ -688,7 +691,10 @@ class ErrorHandlingProcessManager extends ProcessManager {
runInShell: runInShell,
mode: mode,
);
}, platform: _platform);
},
platform: _platform,
failureMessage: 'Flutter failed to run "${command.join(' ')}"',
);
}
@override
@ -711,7 +717,10 @@ class ErrorHandlingProcessManager extends ProcessManager {
stdoutEncoding: stdoutEncoding,
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?
const int ebadarch = 86;
if (errorCode == ebadarch) {
final StringBuffer errorBuffer = StringBuffer();
errorBuffer.writeln(message);
errorBuffer.writeln('This binary was built with the incorrect architecture to run on this machine.');
errorBuffer.writeln('Flutter requires the Rosetta translation environment. If you are on an ARM Mac, try running:');
if (message != null) {
errorBuffer.writeln('$message.');
}
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');
_throwFileSystemException(errorBuffer.toString());
}

View File

@ -963,7 +963,8 @@ void main() {
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']),
throwsToolExit(message: expectedMessage));
expect(() async => processManager.run(<String>['foo']),
@ -1021,7 +1022,8 @@ void main() {
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']),
throwsToolExit(message: expectedMessage));
@ -1085,7 +1087,8 @@ void main() {
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']),
throwsToolExit(message: expectedMessage));
@ -1113,9 +1116,9 @@ void main() {
testWithoutContext('when bad CPU type', () async {
final FakeProcessManager fakeProcessManager = FakeProcessManager.list(<FakeCommand>[
const FakeCommand(command: <String>['foo'], exception: ProcessException('', <String>[], '', ebadarch)),
const FakeCommand(command: <String>['foo'], 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', '--bar'], exception: ProcessException('', <String>[], '', ebadarch)),
const FakeCommand(command: <String>['foo', '--bar'], exception: ProcessException('', <String>[], '', ebadarch)),
]);
final ProcessManager processManager = ErrorHandlingProcessManager(
@ -1123,13 +1126,14 @@ void main() {
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));
expect(() async => processManager.run(<String>['foo']),
expect(() async => processManager.run(<String>['foo', '--bar']),
throwsToolExit(message: expectedMessage));
expect(() => processManager.runSync(<String>['foo']),
expect(() => processManager.runSync(<String>['foo', '--bar']),
throwsToolExit(message: expectedMessage));
});
});