mirror of
https://github.com/flutter/flutter.git
synced 2025-06-03 00:51:18 +00:00
Catch argument error from Make when it isn't installed (#42252)
This commit is contained in:
parent
fde267516b
commit
14c1c211d5
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user