Catch argument error from Make when it isn't installed (#42252)

This commit is contained in:
Jonah Williams 2019-10-08 14:53:55 -07:00 committed by GitHub
parent fde267516b
commit 14c1c211d5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 29 additions and 6 deletions

View File

@ -48,18 +48,18 @@ export PROJECT_DIR=${linuxProject.project.directory.path}
// Invoke make.
final String buildFlag = getNameForBuildMode(buildInfo.mode ?? BuildMode.release);
final Stopwatch sw = Stopwatch()..start();
final Process process = await processManager.start(<String>[
'make',
'-C',
linuxProject.makeFile.parent.path,
'BUILD=$buildFlag',
]);
final Status status = logger.startProgress(
'Building Linux application...',
timeout: null,
);
int result;
try {
final Process process = await processManager.start(<String>[
'make',
'-C',
linuxProject.makeFile.parent.path,
'BUILD=$buildFlag',
]);
process.stderr
.transform(utf8.decoder)
.transform(const LineSplitter())
@ -69,6 +69,8 @@ export PROJECT_DIR=${linuxProject.project.directory.path}
.transform(const LineSplitter())
.listen(printTrace);
result = await process.exitCode;
} on ArgumentError {
throwToolExit('make not found. Run \'flutter doctor\' for more information.');
} finally {
status.cancel();
}

View File

@ -117,6 +117,27 @@ void main() {
FeatureFlags: () => TestFeatureFlags(isLinuxEnabled: true),
});
testUsingContext('Handles argument error from missing make', () async {
final BuildCommand command = BuildCommand();
applyMocksToCommand(command);
setUpMockProjectFilesForBuild();
when(mockProcessManager.start(<String>[
'make',
'-C',
'/linux',
'BUILD=release',
])).thenThrow(ArgumentError());
expect(createTestCommandRunner(command).run(
const <String>['build', 'linux']
), throwsToolExit(message: 'make not found. Run \'flutter doctor\' for more information.'));
}, overrides: <Type, Generator>{
FileSystem: () => MemoryFileSystem(),
ProcessManager: () => mockProcessManager,
Platform: () => linuxPlatform,
FeatureFlags: () => TestFeatureFlags(isLinuxEnabled: true),
});
testUsingContext('Linux build --debug passes debug mode to make', () async {
final BuildCommand command = BuildCommand();
applyMocksToCommand(command);