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

@@ -74,6 +74,28 @@ void main() {
}, overrides: <Type, Generator>{
ProcessManager: () => mockProcessManager,
});
testUsingContext('single dart abnormal compiler termination', () async {
when(mockFrontendServer.exitCode).thenReturn(255);
final BufferLogger logger = context[Logger];
when(mockFrontendServer.stdout)
.thenAnswer((Invocation invocation) => new Stream<List<int>>.fromFuture(
new Future<List<int>>.value(UTF8.encode(
'result abc\nline1\nline2\nabc'
))
));
final String output = await compile(sdkRoot: '/path/to/sdkroot',
mainPath: '/path/to/main.dart'
);
expect(mockFrontendServerStdIn.getAndClear(), isEmpty);
expect(logger.errorText, equals('compiler message: line1\ncompiler message: line2\n'));
expect(output, equals(null));
}, overrides: <Type, Generator>{
ProcessManager: () => mockProcessManager,
});
});
group('incremental compile', () {
@@ -125,6 +147,27 @@ void main() {
ProcessManager: () => mockProcessManager,
});
testUsingContext('single dart compile abnormally terminates', () async {
when(mockFrontendServer.exitCode).thenReturn(255);
final BufferLogger logger = context[Logger];
when(mockFrontendServer.stdout)
.thenAnswer((Invocation invocation) => new Stream<List<int>>.fromFuture(
new Future<List<int>>.value(UTF8.encode(
'result abc\nline1\nline2\nabc /path/to/main.dart.dill'
))
));
final String output = await generator.recompile(
'/path/to/main.dart', null /* invalidatedFiles */
);
expect(logger.errorText, equals('compiler message: line1\ncompiler message: line2\n'));
expect(output, equals(null));
}, overrides: <Type, Generator>{
ProcessManager: () => mockProcessManager,
});
testUsingContext('compile and recompile', () async {
final BufferLogger logger = context[Logger];