Unverified Commit 4bcf8fb4 authored by Jenn Magder's avatar Jenn Magder Committed by GitHub

Migrate compile to null safety (#83153)

parent ade6e1f9
This diff is collapsed.
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// @dart = 2.8
import 'dart:async'; import 'dart:async';
import 'package:file/memory.dart'; import 'package:file/memory.dart';
...@@ -24,10 +22,10 @@ void main() { ...@@ -24,10 +22,10 @@ void main() {
stdoutHandler.reset(); stdoutHandler.reset();
'result abc\nline1\nline2\nabc\nabc /path/to/main.dart.dill 0'.split('\n').forEach(stdoutHandler.handler); 'result abc\nline1\nline2\nabc\nabc /path/to/main.dart.dill 0'.split('\n').forEach(stdoutHandler.handler);
final CompilerOutput output = await stdoutHandler.compilerOutput.future; final CompilerOutput? output = await stdoutHandler.compilerOutput?.future;
expect(logger.errorText, equals('line1\nline2\n')); expect(logger.errorText, equals('line1\nline2\n'));
expect(output.outputFilename, equals('/path/to/main.dart.dill')); expect(output?.outputFilename, equals('/path/to/main.dart.dill'));
}); });
testWithoutContext('StdoutHandler can parse output for failed batch compilation', () async { testWithoutContext('StdoutHandler can parse output for failed batch compilation', () async {
...@@ -36,7 +34,7 @@ void main() { ...@@ -36,7 +34,7 @@ void main() {
stdoutHandler.reset(); stdoutHandler.reset();
'result abc\nline1\nline2\nabc\nabc'.split('\n').forEach(stdoutHandler.handler); 'result abc\nline1\nline2\nabc\nabc'.split('\n').forEach(stdoutHandler.handler);
final CompilerOutput output = await stdoutHandler.compilerOutput.future; final CompilerOutput? output = await stdoutHandler.compilerOutput?.future;
expect(logger.errorText, equals('line1\nline2\n')); expect(logger.errorText, equals('line1\nline2\n'));
expect(output, equals(null)); expect(output, equals(null));
...@@ -73,7 +71,7 @@ void main() { ...@@ -73,7 +71,7 @@ void main() {
]), ]),
stdoutHandler: stdoutHandler, stdoutHandler: stdoutHandler,
); );
final Future<CompilerOutput> output = kernelCompiler.compile(sdkRoot: '/path/to/sdkroot', final Future<CompilerOutput?> output = kernelCompiler.compile(sdkRoot: '/path/to/sdkroot',
mainPath: '/path/to/main.dart', mainPath: '/path/to/main.dart',
buildMode: BuildMode.debug, buildMode: BuildMode.debug,
trackWidgetCreation: false, trackWidgetCreation: false,
...@@ -81,10 +79,10 @@ void main() { ...@@ -81,10 +79,10 @@ void main() {
packageConfig: PackageConfig.empty, packageConfig: PackageConfig.empty,
packagesPath: '.packages', packagesPath: '.packages',
); );
stdoutHandler.compilerOutput.complete(const CompilerOutput('', 0, <Uri>[])); stdoutHandler.compilerOutput?.complete(const CompilerOutput('', 0, <Uri>[]));
completer.complete(); completer.complete();
expect((await output).outputFilename, ''); expect((await output)?.outputFilename, '');
}); });
testWithoutContext('KernelCompiler returns null if StdoutHandler returns null', () async { testWithoutContext('KernelCompiler returns null if StdoutHandler returns null', () async {
...@@ -118,7 +116,7 @@ void main() { ...@@ -118,7 +116,7 @@ void main() {
]), ]),
stdoutHandler: stdoutHandler, stdoutHandler: stdoutHandler,
); );
final Future<CompilerOutput> output = kernelCompiler.compile(sdkRoot: '/path/to/sdkroot', final Future<CompilerOutput?> output = kernelCompiler.compile(sdkRoot: '/path/to/sdkroot',
mainPath: '/path/to/main.dart', mainPath: '/path/to/main.dart',
buildMode: BuildMode.debug, buildMode: BuildMode.debug,
trackWidgetCreation: false, trackWidgetCreation: false,
...@@ -126,7 +124,7 @@ void main() { ...@@ -126,7 +124,7 @@ void main() {
packageConfig: PackageConfig.empty, packageConfig: PackageConfig.empty,
packagesPath: '.packages', packagesPath: '.packages',
); );
stdoutHandler.compilerOutput.complete(null); stdoutHandler.compilerOutput?.complete(null);
completer.complete(); completer.complete();
expect(await output, null); expect(await output, null);
...@@ -163,7 +161,7 @@ void main() { ...@@ -163,7 +161,7 @@ void main() {
]), ]),
stdoutHandler: stdoutHandler, stdoutHandler: stdoutHandler,
); );
final Future<CompilerOutput> output = kernelCompiler.compile(sdkRoot: '/path/to/sdkroot', final Future<CompilerOutput?> output = kernelCompiler.compile(sdkRoot: '/path/to/sdkroot',
mainPath: '/path/to/main.dart', mainPath: '/path/to/main.dart',
buildMode: BuildMode.debug, buildMode: BuildMode.debug,
trackWidgetCreation: false, trackWidgetCreation: false,
...@@ -171,7 +169,7 @@ void main() { ...@@ -171,7 +169,7 @@ void main() {
packageConfig: PackageConfig.empty, packageConfig: PackageConfig.empty,
packagesPath: '.packages', packagesPath: '.packages',
); );
stdoutHandler.compilerOutput.complete(const CompilerOutput('', 0, <Uri>[])); stdoutHandler.compilerOutput?.complete(const CompilerOutput('', 0, <Uri>[]));
completer.complete(); completer.complete();
expect(await output, null); expect(await output, null);
...@@ -209,7 +207,7 @@ void main() { ...@@ -209,7 +207,7 @@ void main() {
]), ]),
stdoutHandler: stdoutHandler, stdoutHandler: stdoutHandler,
); );
final Future<CompilerOutput> output = kernelCompiler.compile(sdkRoot: '/path/to/sdkroot', final Future<CompilerOutput?> output = kernelCompiler.compile(sdkRoot: '/path/to/sdkroot',
mainPath: '/path/to/main.dart', mainPath: '/path/to/main.dart',
buildMode: BuildMode.profile, buildMode: BuildMode.profile,
trackWidgetCreation: false, trackWidgetCreation: false,
...@@ -218,10 +216,10 @@ void main() { ...@@ -218,10 +216,10 @@ void main() {
packageConfig: PackageConfig.empty, packageConfig: PackageConfig.empty,
packagesPath: '.packages', packagesPath: '.packages',
); );
stdoutHandler.compilerOutput.complete(const CompilerOutput('', 0, <Uri>[])); stdoutHandler.compilerOutput?.complete(const CompilerOutput('', 0, <Uri>[]));
completer.complete(); completer.complete();
expect((await output).outputFilename, ''); expect((await output)?.outputFilename, '');
}); });
testWithoutContext('passes correct AOT config to kernel compiler in aot/release mode', () async { testWithoutContext('passes correct AOT config to kernel compiler in aot/release mode', () async {
...@@ -256,7 +254,7 @@ void main() { ...@@ -256,7 +254,7 @@ void main() {
]), ]),
stdoutHandler: stdoutHandler, stdoutHandler: stdoutHandler,
); );
final Future<CompilerOutput> output = kernelCompiler.compile(sdkRoot: '/path/to/sdkroot', final Future<CompilerOutput?> output = kernelCompiler.compile(sdkRoot: '/path/to/sdkroot',
mainPath: '/path/to/main.dart', mainPath: '/path/to/main.dart',
buildMode: BuildMode.release, buildMode: BuildMode.release,
trackWidgetCreation: false, trackWidgetCreation: false,
...@@ -265,10 +263,10 @@ void main() { ...@@ -265,10 +263,10 @@ void main() {
packageConfig: PackageConfig.empty, packageConfig: PackageConfig.empty,
packagesPath: '.packages', packagesPath: '.packages',
); );
stdoutHandler.compilerOutput.complete(const CompilerOutput('', 0, <Uri>[])); stdoutHandler.compilerOutput?.complete(const CompilerOutput('', 0, <Uri>[]));
completer.complete(); completer.complete();
expect((await output).outputFilename, ''); expect((await output)?.outputFilename, '');
}); });
testWithoutContext('KernelCompiler passes dartDefines to the frontend_server', () async { testWithoutContext('KernelCompiler passes dartDefines to the frontend_server', () async {
...@@ -305,7 +303,7 @@ void main() { ...@@ -305,7 +303,7 @@ void main() {
stdoutHandler: stdoutHandler, stdoutHandler: stdoutHandler,
); );
final Future<CompilerOutput> output = kernelCompiler.compile(sdkRoot: '/path/to/sdkroot', final Future<CompilerOutput?> output = kernelCompiler.compile(sdkRoot: '/path/to/sdkroot',
mainPath: '/path/to/main.dart', mainPath: '/path/to/main.dart',
buildMode: BuildMode.debug, buildMode: BuildMode.debug,
trackWidgetCreation: false, trackWidgetCreation: false,
...@@ -314,10 +312,10 @@ void main() { ...@@ -314,10 +312,10 @@ void main() {
packagesPath: '.packages', packagesPath: '.packages',
); );
stdoutHandler.compilerOutput.complete(const CompilerOutput('', 0, <Uri>[])); stdoutHandler.compilerOutput?.complete(const CompilerOutput('', 0, <Uri>[]));
completer.complete(); completer.complete();
expect((await output).outputFilename, ''); expect((await output)?.outputFilename, '');
}); });
testWithoutContext('KernelCompiler maps a file to a multi-root scheme if provided', () async { testWithoutContext('KernelCompiler maps a file to a multi-root scheme if provided', () async {
...@@ -354,7 +352,7 @@ void main() { ...@@ -354,7 +352,7 @@ void main() {
stdoutHandler: stdoutHandler, stdoutHandler: stdoutHandler,
); );
final Future<CompilerOutput> output = kernelCompiler.compile(sdkRoot: '/path/to/sdkroot', final Future<CompilerOutput?> output = kernelCompiler.compile(sdkRoot: '/path/to/sdkroot',
mainPath: '/foo/bar/fizz/main.dart', mainPath: '/foo/bar/fizz/main.dart',
buildMode: BuildMode.debug, buildMode: BuildMode.debug,
trackWidgetCreation: false, trackWidgetCreation: false,
...@@ -363,10 +361,10 @@ void main() { ...@@ -363,10 +361,10 @@ void main() {
packagesPath: '.packages', packagesPath: '.packages',
); );
stdoutHandler.compilerOutput.complete(const CompilerOutput('', 0, <Uri>[])); stdoutHandler.compilerOutput?.complete(const CompilerOutput('', 0, <Uri>[]));
completer.complete(); completer.complete();
expect((await output).outputFilename, ''); expect((await output)?.outputFilename, '');
}); });
testWithoutContext('KernelCompiler uses generated entrypoint', () async { testWithoutContext('KernelCompiler uses generated entrypoint', () async {
...@@ -409,7 +407,7 @@ void main() { ...@@ -409,7 +407,7 @@ void main() {
buildDir.parent.childFile('generated_main.dart').createSync(recursive: true); buildDir.parent.childFile('generated_main.dart').createSync(recursive: true);
final Future<CompilerOutput> output = kernelCompiler.compile(sdkRoot: '/path/to/sdkroot', final Future<CompilerOutput?> output = kernelCompiler.compile(sdkRoot: '/path/to/sdkroot',
mainPath: '/foo/bar/fizz/main.dart', mainPath: '/foo/bar/fizz/main.dart',
buildMode: BuildMode.debug, buildMode: BuildMode.debug,
trackWidgetCreation: false, trackWidgetCreation: false,
...@@ -420,7 +418,7 @@ void main() { ...@@ -420,7 +418,7 @@ void main() {
checkDartPluginRegistry: true, checkDartPluginRegistry: true,
); );
stdoutHandler.compilerOutput.complete(const CompilerOutput('', 0, <Uri>[])); stdoutHandler.compilerOutput?.complete(const CompilerOutput('', 0, <Uri>[]));
completer.complete(); completer.complete();
await output; await output;
}); });
......
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// @dart = 2.8
import 'dart:async'; import 'dart:async';
import 'package:file/memory.dart'; import 'package:file/memory.dart';
...@@ -24,12 +22,12 @@ import '../src/fake_process_manager.dart'; ...@@ -24,12 +22,12 @@ import '../src/fake_process_manager.dart';
import '../src/fakes.dart'; import '../src/fakes.dart';
void main() { void main() {
FakeProcessManager processManager; late FakeProcessManager processManager;
ResidentCompiler generator; late ResidentCompiler generator;
MemoryIOSink frontendServerStdIn; late MemoryIOSink frontendServerStdIn;
StreamController<String> stdErrStreamController; late StreamController<String> stdErrStreamController;
BufferLogger testLogger; late BufferLogger testLogger;
MemoryFileSystem fileSystem; late MemoryFileSystem fileSystem;
setUp(() { setUp(() {
testLogger = BufferLogger.test(); testLogger = BufferLogger.test();
...@@ -52,7 +50,7 @@ void main() { ...@@ -52,7 +50,7 @@ void main() {
}); });
testWithoutContext('compile expression fails if not previously compiled', () async { testWithoutContext('compile expression fails if not previously compiled', () async {
final CompilerOutput result = await generator.compileExpression( final CompilerOutput? result = await generator.compileExpression(
'2+2', null, null, null, null, false); '2+2', null, null, null, null, false);
expect(result, isNull); expect(result, isNull);
...@@ -82,12 +80,12 @@ void main() { ...@@ -82,12 +80,12 @@ void main() {
packageConfig: PackageConfig.empty, packageConfig: PackageConfig.empty,
projectRootPath: '', projectRootPath: '',
fs: fileSystem, fs: fileSystem,
).then((CompilerOutput output) { ).then((CompilerOutput? output) {
expect(frontendServerStdIn.getAndClear(), expect(frontendServerStdIn.getAndClear(),
'compile file:///path/to/main.dart\n'); 'compile file:///path/to/main.dart\n');
expect(testLogger.errorText, expect(testLogger.errorText,
equals('line1\nline2\n')); equals('line1\nline2\n'));
expect(output.outputFilename, equals('/path/to/main.dart.dill')); expect(output!.outputFilename, equals('/path/to/main.dart.dill'));
compileExpressionResponseCompleter.complete( compileExpressionResponseCompleter.complete(
Future<List<int>>.value(utf8.encode( Future<List<int>>.value(utf8.encode(
...@@ -95,9 +93,9 @@ void main() { ...@@ -95,9 +93,9 @@ void main() {
))); )));
generator.compileExpression( generator.compileExpression(
'2+2', null, null, null, null, false).then( '2+2', null, null, null, null, false).then(
(CompilerOutput outputExpression) { (CompilerOutput? outputExpression) {
expect(outputExpression, isNotNull); expect(outputExpression, isNotNull);
expect(outputExpression.expressionData, <int>[1, 2, 3, 4]); expect(outputExpression!.expressionData, <int>[1, 2, 3, 4]);
} }
); );
}); });
...@@ -126,10 +124,10 @@ void main() { ...@@ -126,10 +124,10 @@ void main() {
packageConfig: PackageConfig.empty, packageConfig: PackageConfig.empty,
projectRootPath: '', projectRootPath: '',
fs: MemoryFileSystem(), fs: MemoryFileSystem(),
).then((CompilerOutput outputCompile) { ).then((CompilerOutput? outputCompile) {
expect(testLogger.errorText, expect(testLogger.errorText,
equals('line1\nline2\n')); equals('line1\nline2\n'));
expect(outputCompile.outputFilename, equals('/path/to/main.dart.dill')); expect(outputCompile!.outputFilename, equals('/path/to/main.dart.dill'));
fileSystem.file('/path/to/main.dart.dill.incremental') fileSystem.file('/path/to/main.dart.dill.incremental')
..createSync(recursive: true) ..createSync(recursive: true)
...@@ -144,9 +142,9 @@ void main() { ...@@ -144,9 +142,9 @@ void main() {
final Completer<bool> lastExpressionCompleted = Completer<bool>(); final Completer<bool> lastExpressionCompleted = Completer<bool>();
unawaited( unawaited(
generator.compileExpression('0+1', null, null, null, null, false).then( generator.compileExpression('0+1', null, null, null, null, false).then(
(CompilerOutput outputExpression) { (CompilerOutput? outputExpression) {
expect(outputExpression, isNotNull); expect(outputExpression, isNotNull);
expect(outputExpression.expressionData, <int>[0, 1, 2, 3]); expect(outputExpression!.expressionData, <int>[0, 1, 2, 3]);
fileSystem.file('/path/to/main.dart.dill.incremental') fileSystem.file('/path/to/main.dart.dill.incremental')
..createSync(recursive: true) ..createSync(recursive: true)
...@@ -161,9 +159,9 @@ void main() { ...@@ -161,9 +159,9 @@ void main() {
// The test manages timing via completers. // The test manages timing via completers.
unawaited( unawaited(
generator.compileExpression('1+1', null, null, null, null, false).then( generator.compileExpression('1+1', null, null, null, null, false).then(
(CompilerOutput outputExpression) { (CompilerOutput? outputExpression) {
expect(outputExpression, isNotNull); expect(outputExpression, isNotNull);
expect(outputExpression.expressionData, <int>[4, 5, 6, 7]); expect(outputExpression!.expressionData, <int>[4, 5, 6, 7]);
lastExpressionCompleted.complete(true); lastExpressionCompleted.complete(true);
}, },
), ),
...@@ -179,13 +177,13 @@ void main() { ...@@ -179,13 +177,13 @@ void main() {
class FakeProcess extends Fake implements Process { class FakeProcess extends Fake implements Process {
@override @override
Stream<List<int>> stdout; Stream<List<int>> stdout = const Stream<List<int>>.empty();
@override @override
Stream<List<int>> stderr; Stream<List<int>> stderr = const Stream<List<int>>.empty();
@override @override
IOSink stdin; IOSink stdin = IOSink(StreamController<List<int>>().sink);
@override @override
Future<int> get exitCode => Completer<int>().future; Future<int> get exitCode => Completer<int>().future;
...@@ -195,12 +193,12 @@ class FakeProcessManager extends Fake implements ProcessManager { ...@@ -195,12 +193,12 @@ class FakeProcessManager extends Fake implements ProcessManager {
final FakeProcess process = FakeProcess(); final FakeProcess process = FakeProcess();
@override @override
bool canRun(dynamic executable, {String workingDirectory}) { bool canRun(dynamic executable, {String? workingDirectory}) {
return true; return true;
} }
@override @override
Future<Process> start(List<Object> command, {String workingDirectory, Map<String, String> environment, bool includeParentEnvironment = true, bool runInShell = false, ProcessStartMode mode = ProcessStartMode.normal}) async { Future<Process> start(List<Object> command, {String? workingDirectory, Map<String, String>? environment, bool includeParentEnvironment = true, bool runInShell = false, ProcessStartMode mode = ProcessStartMode.normal}) async {
return process; return process;
} }
} }
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// @dart = 2.8
import 'dart:async'; import 'dart:async';
import 'package:file/memory.dart'; import 'package:file/memory.dart';
...@@ -21,13 +19,13 @@ import '../src/fake_process_manager.dart'; ...@@ -21,13 +19,13 @@ import '../src/fake_process_manager.dart';
import '../src/fakes.dart'; import '../src/fakes.dart';
void main() { void main() {
ResidentCompiler generator; late ResidentCompiler generator;
ResidentCompiler generatorWithScheme; late ResidentCompiler generatorWithScheme;
MemoryIOSink frontendServerStdIn; late MemoryIOSink frontendServerStdIn;
BufferLogger testLogger; late BufferLogger testLogger;
StdoutHandler generatorStdoutHandler; late StdoutHandler generatorStdoutHandler;
StdoutHandler generatorWithSchemeStdoutHandler; late StdoutHandler generatorWithSchemeStdoutHandler;
FakeProcessManager fakeProcessManager; late FakeProcessManager fakeProcessManager;
const List<String> frontendServerCommand = <String>[ const List<String> frontendServerCommand = <String>[
'HostArtifact.engineDartBinary', 'HostArtifact.engineDartBinary',
...@@ -87,7 +85,7 @@ void main() { ...@@ -87,7 +85,7 @@ void main() {
stdin: frontendServerStdIn, stdin: frontendServerStdIn,
)); ));
final CompilerOutput output = await generator.recompile( final CompilerOutput? output = await generator.recompile(
Uri.parse('/path/to/main.dart'), Uri.parse('/path/to/main.dart'),
null /* invalidatedFiles */, null /* invalidatedFiles */,
outputPath: '/build/', outputPath: '/build/',
...@@ -97,7 +95,7 @@ void main() { ...@@ -97,7 +95,7 @@ void main() {
); );
expect(frontendServerStdIn.getAndClear(), 'compile /path/to/main.dart\n'); expect(frontendServerStdIn.getAndClear(), 'compile /path/to/main.dart\n');
expect(testLogger.errorText, equals('line1\nline2\n')); expect(testLogger.errorText, equals('line1\nline2\n'));
expect(output.outputFilename, equals('/path/to/main.dart.dill')); expect(output?.outputFilename, equals('/path/to/main.dart.dill'));
expect(fakeProcessManager, hasNoRemainingExpectations); expect(fakeProcessManager, hasNoRemainingExpectations);
}); });
...@@ -114,7 +112,7 @@ void main() { ...@@ -114,7 +112,7 @@ void main() {
stdin: frontendServerStdIn, stdin: frontendServerStdIn,
)); ));
final CompilerOutput output = await generatorWithScheme.recompile( final CompilerOutput? output = await generatorWithScheme.recompile(
Uri.parse('file:///foo/bar/fizz/main.dart'), Uri.parse('file:///foo/bar/fizz/main.dart'),
null /* invalidatedFiles */, null /* invalidatedFiles */,
outputPath: '/build/', outputPath: '/build/',
...@@ -124,7 +122,7 @@ void main() { ...@@ -124,7 +122,7 @@ void main() {
); );
expect(frontendServerStdIn.getAndClear(), 'compile scheme:///main.dart\n'); expect(frontendServerStdIn.getAndClear(), 'compile scheme:///main.dart\n');
expect(testLogger.errorText, equals('line1\nline2\n')); expect(testLogger.errorText, equals('line1\nline2\n'));
expect(output.outputFilename, equals('/path/to/main.dart.dill')); expect(output?.outputFilename, equals('/path/to/main.dart.dill'));
expect(fakeProcessManager, hasNoRemainingExpectations); expect(fakeProcessManager, hasNoRemainingExpectations);
}); });
...@@ -401,16 +399,16 @@ Future<void> _recompile( ...@@ -401,16 +399,16 @@ Future<void> _recompile(
MemoryIOSink frontendServerStdIn, MemoryIOSink frontendServerStdIn,
String mockCompilerOutput, { String mockCompilerOutput, {
bool suppressErrors = false, bool suppressErrors = false,
Uri mainUri, Uri? mainUri,
String expectedMainUri = '/path/to/main.dart', String expectedMainUri = '/path/to/main.dart',
List<Uri> updatedUris, List<Uri>? updatedUris,
List<String> expectedUpdatedUris, List<String>? expectedUpdatedUris,
}) async { }) async {
mainUri ??= Uri.parse('/path/to/main.dart'); mainUri ??= Uri.parse('/path/to/main.dart');
updatedUris ??= <Uri>[mainUri]; updatedUris ??= <Uri>[mainUri];
expectedUpdatedUris ??= <String>[expectedMainUri]; expectedUpdatedUris ??= <String>[expectedMainUri];
final Future<CompilerOutput> recompileFuture = generator.recompile( final Future<CompilerOutput?> recompileFuture = generator.recompile(
mainUri, mainUri,
updatedUris, updatedUris,
outputPath: '/build/', outputPath: '/build/',
...@@ -425,8 +423,8 @@ Future<void> _recompile( ...@@ -425,8 +423,8 @@ Future<void> _recompile(
scheduleMicrotask(() { scheduleMicrotask(() {
LineSplitter.split(mockCompilerOutput).forEach(stdoutHandler.handler); LineSplitter.split(mockCompilerOutput).forEach(stdoutHandler.handler);
}); });
final CompilerOutput output = await recompileFuture; final CompilerOutput? output = await recompileFuture;
expect(output.outputFilename, equals('/path/to/main.dart.dill')); expect(output?.outputFilename, equals('/path/to/main.dart.dill'));
final String commands = frontendServerStdIn.getAndClear(); final String commands = frontendServerStdIn.getAndClear();
final RegExp whitespace = RegExp(r'\s+'); final RegExp whitespace = RegExp(r'\s+');
final List<String> parts = commands.split(whitespace); final List<String> parts = commands.split(whitespace);
...@@ -459,11 +457,11 @@ Future<void> _reject( ...@@ -459,11 +457,11 @@ Future<void> _reject(
) async { ) async {
// Put content into the output stream after generator.recompile gets // Put content into the output stream after generator.recompile gets
// going few lines below, resets completer. // going few lines below, resets completer.
final Future<CompilerOutput> rejectFuture = generator.reject(); final Future<CompilerOutput?> rejectFuture = generator.reject();
scheduleMicrotask(() { scheduleMicrotask(() {
LineSplitter.split(mockCompilerOutput).forEach(stdoutHandler.handler); LineSplitter.split(mockCompilerOutput).forEach(stdoutHandler.handler);
}); });
final CompilerOutput output = await rejectFuture; final CompilerOutput? output = await rejectFuture;
expect(output, isNull); expect(output, isNull);
final String commands = frontendServerStdIn.getAndClear(); final String commands = frontendServerStdIn.getAndClear();
......
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// @dart = 2.8
import 'package:file/file.dart'; import 'package:file/file.dart';
import 'package:file/memory.dart'; import 'package:file/memory.dart';
import 'package:flutter_tools/src/base/logger.dart'; import 'package:flutter_tools/src/base/logger.dart';
...@@ -19,10 +17,10 @@ void main() { ...@@ -19,10 +17,10 @@ void main() {
expect(stdoutHandler.boundaryKey, '12345'); expect(stdoutHandler.boundaryKey, '12345');
stdoutHandler.handler('12345'); stdoutHandler.handler('12345');
stdoutHandler.handler('12345 message 0'); stdoutHandler.handler('12345 message 0');
final CompilerOutput output = await stdoutHandler.compilerOutput.future; final CompilerOutput? output = await stdoutHandler.compilerOutput?.future;
expect(output.errorCount, 0); expect(output?.errorCount, 0);
expect(output.outputFilename, 'message'); expect(output?.outputFilename, 'message');
expect(output.expressionData, null); expect(output?.expressionData, null);
}); });
testWithoutContext('StdoutHandler can read output bytes', () async { testWithoutContext('StdoutHandler can read output bytes', () async {
...@@ -35,11 +33,11 @@ void main() { ...@@ -35,11 +33,11 @@ void main() {
expect(stdoutHandler.boundaryKey, '12345'); expect(stdoutHandler.boundaryKey, '12345');
stdoutHandler.handler('12345'); stdoutHandler.handler('12345');
stdoutHandler.handler('12345 message 0'); stdoutHandler.handler('12345 message 0');
final CompilerOutput output = await stdoutHandler.compilerOutput.future; final CompilerOutput? output = await stdoutHandler.compilerOutput?.future;
expect(output.errorCount, 0); expect(output?.errorCount, 0);
expect(output.outputFilename, 'message'); expect(output?.outputFilename, 'message');
expect(output.expressionData, <int>[1, 2, 3, 4]); expect(output?.expressionData, <int>[1, 2, 3, 4]);
}); });
testWithoutContext('StdoutHandler reads output bytes if errorCount > 0', () async { testWithoutContext('StdoutHandler reads output bytes if errorCount > 0', () async {
...@@ -52,11 +50,11 @@ void main() { ...@@ -52,11 +50,11 @@ void main() {
expect(stdoutHandler.boundaryKey, '12345'); expect(stdoutHandler.boundaryKey, '12345');
stdoutHandler.handler('12345'); stdoutHandler.handler('12345');
stdoutHandler.handler('12345 message 1'); stdoutHandler.handler('12345 message 1');
final CompilerOutput output = await stdoutHandler.compilerOutput.future; final CompilerOutput? output = await stdoutHandler.compilerOutput?.future;
expect(output.errorCount, 1); expect(output?.errorCount, 1);
expect(output.outputFilename, 'message'); expect(output?.outputFilename, 'message');
expect(output.expressionData, <int>[1, 2, 3, 4]); expect(output?.expressionData, <int>[1, 2, 3, 4]);
}); });
testWithoutContext('TargetModel values', () { testWithoutContext('TargetModel values', () {
...@@ -72,7 +70,7 @@ void main() { ...@@ -72,7 +70,7 @@ void main() {
expect(TargetModel('dartdevc'), TargetModel.dartdevc); expect(TargetModel('dartdevc'), TargetModel.dartdevc);
expect(TargetModel.dartdevc.toString(), 'dartdevc'); expect(TargetModel.dartdevc.toString(), 'dartdevc');
expect(() => TargetModel('foobar'), throwsAssertionError); expect(() => TargetModel('foobar'), throwsException);
}); });
testWithoutContext('toMultiRootPath maps different URIs', () async { testWithoutContext('toMultiRootPath maps different URIs', () async {
......
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