Turn on unawaited_futures in flutter_tools (#21048)
This commit is contained in:
@@ -43,8 +43,8 @@ void main() {
|
||||
expect(response['id'], 0);
|
||||
expect(response['result'], isNotEmpty);
|
||||
expect(response['result'] is String, true);
|
||||
responses.close();
|
||||
commands.close();
|
||||
await responses.close();
|
||||
await commands.close();
|
||||
});
|
||||
|
||||
testUsingContext('printError should send daemon.logMessage event', () async {
|
||||
@@ -64,8 +64,8 @@ void main() {
|
||||
final Map<String, String> logMessage = response['params'].cast<String, String>();
|
||||
expect(logMessage['level'], 'error');
|
||||
expect(logMessage['message'], 'daemon.logMessage test');
|
||||
responses.close();
|
||||
commands.close();
|
||||
await responses.close();
|
||||
await commands.close();
|
||||
}, overrides: <Type, Generator>{
|
||||
Logger: () => notifyingLogger,
|
||||
});
|
||||
@@ -103,9 +103,8 @@ void main() {
|
||||
notifyingLogger: notifyingLogger
|
||||
);
|
||||
commands.add(<String, dynamic>{'id': 0, 'method': 'daemon.shutdown'});
|
||||
return daemon.onExit.then<Null>((int code) {
|
||||
responses.close();
|
||||
commands.close();
|
||||
return daemon.onExit.then<Null>((int code) async {
|
||||
await commands.close();
|
||||
expect(code, 0);
|
||||
});
|
||||
});
|
||||
@@ -127,8 +126,8 @@ void main() {
|
||||
final Map<String, dynamic> response = await responses.stream.firstWhere(_notEvent);
|
||||
expect(response['id'], 0);
|
||||
expect(response['error'], contains('appId is required'));
|
||||
responses.close();
|
||||
commands.close();
|
||||
await responses.close();
|
||||
await commands.close();
|
||||
});
|
||||
|
||||
testUsingContext('ext.flutter.debugPaint via service extension without an appId should report an error', () async {
|
||||
@@ -154,8 +153,8 @@ void main() {
|
||||
final Map<String, dynamic> response = await responses.stream.firstWhere(_notEvent);
|
||||
expect(response['id'], 0);
|
||||
expect(response['error'], contains('appId is required'));
|
||||
responses.close();
|
||||
commands.close();
|
||||
await responses.close();
|
||||
await commands.close();
|
||||
});
|
||||
|
||||
testUsingContext('app.stop without appId should report an error', () async {
|
||||
@@ -175,8 +174,8 @@ void main() {
|
||||
final Map<String, dynamic> response = await responses.stream.firstWhere(_notEvent);
|
||||
expect(response['id'], 0);
|
||||
expect(response['error'], contains('appId is required'));
|
||||
responses.close();
|
||||
commands.close();
|
||||
await responses.close();
|
||||
await commands.close();
|
||||
});
|
||||
|
||||
testUsingContext('daemon should send showMessage on startup if no Android devices are available', () async {
|
||||
@@ -212,11 +211,11 @@ void main() {
|
||||
final Map<String, dynamic> response = await responses.stream.firstWhere(_notEvent);
|
||||
expect(response['id'], 0);
|
||||
expect(response['result'], isList);
|
||||
responses.close();
|
||||
commands.close();
|
||||
await responses.close();
|
||||
await commands.close();
|
||||
});
|
||||
|
||||
testUsingContext('should send device.added event when device is discovered', () {
|
||||
testUsingContext('should send device.added event when device is discovered', () async {
|
||||
final StreamController<Map<String, dynamic>> commands = new StreamController<Map<String, dynamic>>();
|
||||
final StreamController<Map<String, dynamic>> responses = new StreamController<Map<String, dynamic>>();
|
||||
daemon = new Daemon(
|
||||
@@ -229,15 +228,15 @@ void main() {
|
||||
daemon.deviceDomain.addDeviceDiscoverer(discoverer);
|
||||
discoverer.addDevice(new MockAndroidDevice());
|
||||
|
||||
return responses.stream.skipWhile(_isConnectedEvent).first.then((Map<String, dynamic> response) {
|
||||
return await responses.stream.skipWhile(_isConnectedEvent).first.then((Map<String, dynamic> response) async {
|
||||
expect(response['event'], 'device.added');
|
||||
expect(response['params'], isMap);
|
||||
|
||||
final Map<String, dynamic> params = response['params'];
|
||||
expect(params['platform'], isNotEmpty); // the mock device has a platform of 'android-arm'
|
||||
|
||||
responses.close();
|
||||
commands.close();
|
||||
await responses.close();
|
||||
await commands.close();
|
||||
});
|
||||
}, overrides: <Type, Generator>{
|
||||
AndroidWorkflow: () => new MockAndroidWorkflow(),
|
||||
@@ -261,8 +260,8 @@ void main() {
|
||||
final Map<String, dynamic> response = await responses.stream.firstWhere(_notEvent);
|
||||
expect(response['id'], 0);
|
||||
expect(response['error'], contains('emulatorId is required'));
|
||||
responses.close();
|
||||
commands.close();
|
||||
await responses.close();
|
||||
await commands.close();
|
||||
});
|
||||
|
||||
testUsingContext('emulator.getEmulators should respond with list', () async {
|
||||
@@ -277,8 +276,8 @@ void main() {
|
||||
final Map<String, dynamic> response = await responses.stream.firstWhere(_notEvent);
|
||||
expect(response['id'], 0);
|
||||
expect(response['result'], isList);
|
||||
responses.close();
|
||||
commands.close();
|
||||
await responses.close();
|
||||
await commands.close();
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -276,7 +276,7 @@ void main() {
|
||||
'result abc\nline1\nline2\nabc /path/to/main.dart.dill 0\n'
|
||||
)));
|
||||
|
||||
generator.recompile(
|
||||
await generator.recompile(
|
||||
'/path/to/main.dart', null /* invalidatedFiles */
|
||||
).then((CompilerOutput output) {
|
||||
expect(mockFrontendServerStdIn.getAndClear(),
|
||||
@@ -320,7 +320,8 @@ void main() {
|
||||
compileExpressionResponseCompleter2.future,
|
||||
]));
|
||||
|
||||
generator.recompile(
|
||||
// The test manages timing via completers.
|
||||
generator.recompile( // ignore: unawaited_futures
|
||||
'/path/to/main.dart', null /* invalidatedFiles */
|
||||
).then((CompilerOutput outputCompile) {
|
||||
expect(logger.errorText,
|
||||
@@ -332,8 +333,9 @@ void main() {
|
||||
)));
|
||||
});
|
||||
|
||||
// The test manages timing via completers.
|
||||
final Completer<bool> lastExpressionCompleted = new Completer<bool>();
|
||||
generator.compileExpression('0+1', null, null, null, null, false).then(
|
||||
generator.compileExpression('0+1', null, null, null, null, false).then( // ignore: unawaited_futures
|
||||
(CompilerOutput outputExpression) {
|
||||
expect(outputExpression, isNotNull);
|
||||
expect(outputExpression.outputFilename,
|
||||
@@ -344,7 +346,8 @@ void main() {
|
||||
)));
|
||||
});
|
||||
|
||||
generator.compileExpression('1+1', null, null, null, null, false).then(
|
||||
// The test manages timing via completers.
|
||||
generator.compileExpression('1+1', null, null, null, null, false).then( // ignore: unawaited_futures
|
||||
(CompilerOutput outputExpression) {
|
||||
expect(outputExpression, isNotNull);
|
||||
expect(outputExpression.outputFilename,
|
||||
|
||||
@@ -28,12 +28,12 @@ void main() {
|
||||
Future<Null> expectDevice(String id, List<Device> expected) async {
|
||||
expect(await deviceManager.getDevicesById(id).toList(), expected);
|
||||
}
|
||||
expectDevice('01abfc49119c410e', <Device>[device2]);
|
||||
expectDevice('Nexus 5X', <Device>[device2]);
|
||||
expectDevice('0553790d0a4e726f', <Device>[device1]);
|
||||
expectDevice('Nexus 5', <Device>[device1]);
|
||||
expectDevice('0553790', <Device>[device1]);
|
||||
expectDevice('Nexus', <Device>[device1, device2]);
|
||||
await expectDevice('01abfc49119c410e', <Device>[device2]);
|
||||
await expectDevice('Nexus 5X', <Device>[device2]);
|
||||
await expectDevice('0553790d0a4e726f', <Device>[device1]);
|
||||
await expectDevice('Nexus 5', <Device>[device1]);
|
||||
await expectDevice('0553790', <Device>[device1]);
|
||||
await expectDevice('Nexus', <Device>[device1, device2]);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -62,12 +62,12 @@ void main() {
|
||||
expect(await testEmulatorManager.getEmulatorsMatching(id), expected);
|
||||
}
|
||||
|
||||
expectEmulator('Nexus_5', <Emulator>[emulator1]);
|
||||
expectEmulator('Nexus_5X', <Emulator>[emulator2]);
|
||||
expectEmulator('Nexus_5X_API_27_x86', <Emulator>[emulator2]);
|
||||
expectEmulator('Nexus', <Emulator>[emulator1, emulator2]);
|
||||
expectEmulator('iOS Simulator', <Emulator>[emulator3]);
|
||||
expectEmulator('ios', <Emulator>[emulator3]);
|
||||
await expectEmulator('Nexus_5', <Emulator>[emulator1]);
|
||||
await expectEmulator('Nexus_5X', <Emulator>[emulator2]);
|
||||
await expectEmulator('Nexus_5X_API_27_x86', <Emulator>[emulator2]);
|
||||
await expectEmulator('Nexus', <Emulator>[emulator1, emulator2]);
|
||||
await expectEmulator('iOS Simulator', <Emulator>[emulator3]);
|
||||
await expectEmulator('ios', <Emulator>[emulator3]);
|
||||
});
|
||||
|
||||
testUsingContext('create emulator with an empty name does not fail',
|
||||
|
||||
@@ -89,7 +89,9 @@ class FlutterTestDriver {
|
||||
workingDirectory: _projectFolder.path,
|
||||
environment: <String, String>{'FLUTTER_TEST': 'true'});
|
||||
|
||||
_proc.exitCode.then((int code) {
|
||||
// This class doesn't use the result of the future. It's made available
|
||||
// via a getter for external uses.
|
||||
_proc.exitCode.then((int code) { // ignore: unawaited_futures
|
||||
_debugPrint('Process exited ($code)');
|
||||
_hasExited = true;
|
||||
});
|
||||
|
||||
@@ -97,7 +97,7 @@ void main() {
|
||||
testInMemory('exits on already materialized module', () async {
|
||||
final FlutterProject project = await aModuleProject();
|
||||
await project.android.materialize();
|
||||
expectToolExitLater(project.android.materialize(), contains('already materialized'));
|
||||
return expectToolExitLater(project.android.materialize(), contains('already materialized'));
|
||||
});
|
||||
testInMemory('creates android/app folder in place of .android/app', () async {
|
||||
final FlutterProject project = await aModuleProject();
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
|
||||
// Copyright 2016 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
@@ -134,7 +135,7 @@ void main() {
|
||||
expect(uri.port, 99);
|
||||
expect('$uri', 'http://127.0.0.1:99/PTwjm8Ii8qg=/');
|
||||
|
||||
discoverer.cancel();
|
||||
await discoverer.cancel();
|
||||
logReader.dispose();
|
||||
});
|
||||
|
||||
@@ -153,7 +154,7 @@ void main() {
|
||||
expect(uri.port, 1243);
|
||||
expect('$uri', 'http://127.0.0.1:1243/PTwjm8Ii8qg=/');
|
||||
|
||||
discoverer.cancel();
|
||||
await discoverer.cancel();
|
||||
logReader.dispose();
|
||||
});
|
||||
|
||||
@@ -172,7 +173,7 @@ void main() {
|
||||
expect(uri.port, 99);
|
||||
expect('$uri', 'http://127.0.0.1:99/PTwjm8Ii8qg=/');
|
||||
|
||||
discoverer.cancel();
|
||||
await discoverer.cancel();
|
||||
logReader.dispose();
|
||||
});
|
||||
|
||||
@@ -192,7 +193,7 @@ void main() {
|
||||
expect(uri.port, 54777);
|
||||
expect('$uri', 'http://[::1]:54777/PTwjm8Ii8qg=/');
|
||||
|
||||
discoverer.cancel();
|
||||
await discoverer.cancel();
|
||||
logReader.dispose();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user