Unverified Commit 14c1c211 authored by Jonah Williams's avatar Jonah Williams Committed by GitHub

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

parent fde26751
......@@ -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();
}
......
......@@ -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);
......
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