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} ...@@ -48,18 +48,18 @@ export PROJECT_DIR=${linuxProject.project.directory.path}
// Invoke make. // Invoke make.
final String buildFlag = getNameForBuildMode(buildInfo.mode ?? BuildMode.release); final String buildFlag = getNameForBuildMode(buildInfo.mode ?? BuildMode.release);
final Stopwatch sw = Stopwatch()..start(); 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( final Status status = logger.startProgress(
'Building Linux application...', 'Building Linux application...',
timeout: null, timeout: null,
); );
int result; int result;
try { try {
final Process process = await processManager.start(<String>[
'make',
'-C',
linuxProject.makeFile.parent.path,
'BUILD=$buildFlag',
]);
process.stderr process.stderr
.transform(utf8.decoder) .transform(utf8.decoder)
.transform(const LineSplitter()) .transform(const LineSplitter())
...@@ -69,6 +69,8 @@ export PROJECT_DIR=${linuxProject.project.directory.path} ...@@ -69,6 +69,8 @@ export PROJECT_DIR=${linuxProject.project.directory.path}
.transform(const LineSplitter()) .transform(const LineSplitter())
.listen(printTrace); .listen(printTrace);
result = await process.exitCode; result = await process.exitCode;
} on ArgumentError {
throwToolExit('make not found. Run \'flutter doctor\' for more information.');
} finally { } finally {
status.cancel(); status.cancel();
} }
......
...@@ -117,6 +117,27 @@ void main() { ...@@ -117,6 +117,27 @@ void main() {
FeatureFlags: () => TestFeatureFlags(isLinuxEnabled: true), 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 { testUsingContext('Linux build --debug passes debug mode to make', () async {
final BuildCommand command = BuildCommand(); final BuildCommand command = BuildCommand();
applyMocksToCommand(command); 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