Roll engine to 76cb311d9c33720dcd19274228b39ecdbad8d9af (with rolled dart) (#16518)

* Handle error count reported by frontend.

Extend compilation result from single string to a structure(string filename and integer error count).

* Use ?.

* Include engine roll with dart sdk roll.

* parse(onError) -> tryParse

* Make '?? throw' more readable and avoid issue with analyzer

* Fix test so it mocks compiler output including errors count
This commit is contained in:
Alexander Aprelev
2018-04-12 16:28:01 -07:00
committed by Siva
parent c73b8a7cf6
commit e0cd42e4ad
13 changed files with 75 additions and 48 deletions

View File

@@ -43,15 +43,15 @@ void main() {
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'
'result abc\nline1\nline2\nabc /path/to/main.dart.dill 0'
))
));
final String output = await compile(sdkRoot: '/path/to/sdkroot',
final CompilerOutput 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('/path/to/main.dart.dill'));
expect(output.outputFilename, equals('/path/to/main.dart.dill'));
}, overrides: <Type, Generator>{
ProcessManager: () => mockProcessManager,
});
@@ -66,7 +66,7 @@ void main() {
))
));
final String output = await compile(sdkRoot: '/path/to/sdkroot',
final CompilerOutput output = await compile(sdkRoot: '/path/to/sdkroot',
mainPath: '/path/to/main.dart'
);
expect(mockFrontendServerStdIn.getAndClear(), isEmpty);
@@ -88,7 +88,7 @@ void main() {
))
));
final String output = await compile(sdkRoot: '/path/to/sdkroot',
final CompilerOutput output = await compile(sdkRoot: '/path/to/sdkroot',
mainPath: '/path/to/main.dart'
);
expect(mockFrontendServerStdIn.getAndClear(), isEmpty);
@@ -137,17 +137,17 @@ void main() {
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'
'result abc\nline1\nline2\nabc /path/to/main.dart.dill 0'
))
));
final String output = await generator.recompile(
final CompilerOutput output = await generator.recompile(
'/path/to/main.dart', null /* invalidatedFiles */
);
expect(mockFrontendServerStdIn.getAndClear(), 'compile /path/to/main.dart\n');
verifyNoMoreInteractions(mockFrontendServerStdIn);
expect(logger.errorText, equals('compiler message: line1\ncompiler message: line2\n'));
expect(output, equals('/path/to/main.dart.dill'));
expect(output.outputFilename, equals('/path/to/main.dart.dill'));
}, overrides: <Type, Generator>{
ProcessManager: () => mockProcessManager,
});
@@ -157,7 +157,7 @@ void main() {
.thenAnswer((Invocation invocation) => const Stream<List<int>>.empty()
);
final String output = await generator.recompile(
final CompilerOutput output = await generator.recompile(
'/path/to/main.dart', null /* invalidatedFiles */
);
expect(output, equals(null));
@@ -171,12 +171,12 @@ void main() {
final StreamController<List<int>> streamController = new StreamController<List<int>>();
when(mockFrontendServer.stdout)
.thenAnswer((Invocation invocation) => streamController.stream);
streamController.add(utf8.encode('result abc\nline0\nline1\nabc /path/to/main.dart.dill\n'));
streamController.add(utf8.encode('result abc\nline0\nline1\nabc /path/to/main.dart.dill 0\n'));
await generator.recompile('/path/to/main.dart', null /* invalidatedFiles */);
expect(mockFrontendServerStdIn.getAndClear(), 'compile /path/to/main.dart\n');
await _recompile(streamController, generator, mockFrontendServerStdIn,
'result abc\nline1\nline2\nabc /path/to/main.dart.dill\n');
'result abc\nline1\nline2\nabc /path/to/main.dart.dill 0\n');
verifyNoMoreInteractions(mockFrontendServerStdIn);
expect(mockFrontendServerStdIn.getAndClear(), isEmpty);
@@ -195,15 +195,15 @@ void main() {
when(mockFrontendServer.stdout)
.thenAnswer((Invocation invocation) => streamController.stream);
streamController.add(utf8.encode(
'result abc\nline0\nline1\nabc /path/to/main.dart.dill\n'
'result abc\nline0\nline1\nabc /path/to/main.dart.dill 0\n'
));
await generator.recompile('/path/to/main.dart', null /* invalidatedFiles */);
expect(mockFrontendServerStdIn.getAndClear(), 'compile /path/to/main.dart\n');
await _recompile(streamController, generator, mockFrontendServerStdIn,
'result abc\nline1\nline2\nabc /path/to/main.dart.dill\n');
'result abc\nline1\nline2\nabc /path/to/main.dart.dill 0\n');
await _recompile(streamController, generator, mockFrontendServerStdIn,
'result abc\nline2\nline3\nabc /path/to/main.dart.dill\n');
'result abc\nline2\nline3\nabc /path/to/main.dart.dill 0\n');
verifyNoMoreInteractions(mockFrontendServerStdIn);
expect(mockFrontendServerStdIn.getAndClear(), isEmpty);
@@ -226,8 +226,8 @@ Future<Null> _recompile(StreamController<List<int>> streamController,
new Future<List<int>>(() {
streamController.add(utf8.encode(mockCompilerOutput));
});
final String output = await generator.recompile(null /* mainPath */, <String>['/path/to/main.dart']);
expect(output, equals('/path/to/main.dart.dill'));
final CompilerOutput output = await generator.recompile(null /* mainPath */, <String>['/path/to/main.dart']);
expect(output.outputFilename, equals('/path/to/main.dart.dill'));
final String commands = mockFrontendServerStdIn.getAndClear();
final RegExp re = new RegExp('^recompile (.*)\\n/path/to/main.dart\\n(.*)\\n\$');
expect(commands, matches(re));