Handle abnormal termination of frontend compiler. (#13982)

* Check frontend_server exit code.

When frontend_server completes abnormally, flutter tools has to stop and let user know.

* Add tests
This commit is contained in:
Alexander Aprelev
2018-01-10 17:51:08 -08:00
committed by GitHub
parent 5c88f8f295
commit 9534082fc0
4 changed files with 54 additions and 3 deletions

View File

@@ -342,6 +342,10 @@ Future<String> _buildAotSnapshot(
aot : true,
strongMode: strongMode,
);
if (mainPath == null) {
printError('Compiler terminated unexpectedly.');
return null;
}
}
genSnapshotCmd.add(mainPath);

View File

@@ -110,8 +110,8 @@ Future<String> compile(
.transform(UTF8.decoder)
.transform(const LineSplitter())
.listen(stdoutHandler.handler);
await server.exitCode;
return stdoutHandler.outputFilename.future;
final int exitCode = await server.exitCode;
return exitCode == 0 ? stdoutHandler.outputFilename.future : null;
}
/// Wrapper around incremental frontend server compiler, that communicates with
@@ -175,7 +175,8 @@ class ResidentCompiler {
_server.stdin.writeln('compile $scriptFilename');
return stdoutHandler.outputFilename.future;
final int exitCode = await _server.exitCode;
return exitCode == 0 ? stdoutHandler.outputFilename.future : null;
}

View File

@@ -76,6 +76,9 @@ Future<Null> build({
mainPath: fs.file(mainPath).absolute.path,
strongMode: strongMode
);
if (kernelBinaryFilename == null) {
throwToolExit('Compiler terminated unexpectedly on $mainPath');
}
kernelContent = new DevFSFileContent(fs.file(kernelBinaryFilename));
}