diff --git a/pkgs/checks/lib/src/checks.dart b/pkgs/checks/lib/src/checks.dart index 5ac2da29c..7103ccaf5 100644 --- a/pkgs/checks/lib/src/checks.dart +++ b/pkgs/checks/lib/src/checks.dart @@ -225,7 +225,7 @@ extension ContextExtension on Subject { /// specific signature varies by operation. /// /// -/// In expectation extension methods calling [expect], [expectAync], or +/// In expectation extension methods calling [expect], [expectAsync], or /// [expectUnawaited], the `predicate` callback can report a [Rejection] if the /// value fails to satisfy the expectation. /// The description will be passed in a "clause" callback. diff --git a/pkgs/checks/lib/src/extensions/iterable.dart b/pkgs/checks/lib/src/extensions/iterable.dart index 352496079..2ab1bfa03 100644 --- a/pkgs/checks/lib/src/extensions/iterable.dart +++ b/pkgs/checks/lib/src/extensions/iterable.dart @@ -70,7 +70,7 @@ extension IterableChecks on Subject> { } /// Expects that the iterable contains a value matching each expected value - /// from [elelements] in the given order, with any extra elements between + /// from [elements] in the given order, with any extra elements between /// them. /// /// For example, the following will succeed: diff --git a/pkgs/checks/test/extensions/async_test.dart b/pkgs/checks/test/extensions/async_test.dart index 43ba5d73c..5bfe55062 100644 --- a/pkgs/checks/test/extensions/async_test.dart +++ b/pkgs/checks/test/extensions/async_test.dart @@ -240,7 +240,7 @@ fake trace'''); queue, (Subject> it) => it.emitsThrough((it) => it.equals(42))); - check(queue).emits((it) => it.equals(0)); + await check(queue).emits((it) => it.equals(0)); }); test('consumes events', () async { final queue = _countingStream(3); diff --git a/pkgs/checks/test/soft_check_test.dart b/pkgs/checks/test/soft_check_test.dart index 87c9b27b8..d919b0db3 100644 --- a/pkgs/checks/test/soft_check_test.dart +++ b/pkgs/checks/test/soft_check_test.dart @@ -19,7 +19,7 @@ void main() { }); group('softCheckAsync', () { test('returns the first failure', () async { - check(Future.value(0)).isRejectedByAsync( + await check(Future.value(0)).isRejectedByAsync( (it) => it ..completes((it) => it.isGreaterThan(1)) ..completes((it) => it.isGreaterThan(2)), diff --git a/pkgs/test_core/lib/src/bootstrap/vm.dart b/pkgs/test_core/lib/src/bootstrap/vm.dart index a2e9f4be9..05604f120 100644 --- a/pkgs/test_core/lib/src/bootstrap/vm.dart +++ b/pkgs/test_core/lib/src/bootstrap/vm.dart @@ -2,6 +2,7 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. +import 'dart:async'; import 'dart:developer'; import 'dart:io'; import 'dart:isolate'; @@ -41,9 +42,9 @@ void internalBootstrapNativeTest( ..pipe(serializeSuite(getMain)); platformChannel.sink.add(testControlChannel.id); - platformChannel.stream.forEach((message) { + unawaited(platformChannel.stream.forEach((message) { assert(message == 'debug'); debugger(message: 'Paused by test runner'); platformChannel.sink.add('done'); - }); + })); } diff --git a/pkgs/test_core/lib/src/runner/console.dart b/pkgs/test_core/lib/src/runner/console.dart index b716aad2c..dc1bba5c1 100644 --- a/pkgs/test_core/lib/src/runner/console.dart +++ b/pkgs/test_core/lib/src/runner/console.dart @@ -111,7 +111,7 @@ class _Command { final String description; /// The callback to run when the command is invoked. - final Function body; + final dynamic Function() body; _Command(this.name, this.description, this.body); } diff --git a/pkgs/test_core/lib/src/runner/engine.dart b/pkgs/test_core/lib/src/runner/engine.dart index 0aa29e604..6a6362761 100644 --- a/pkgs/test_core/lib/src/runner/engine.dart +++ b/pkgs/test_core/lib/src/runner/engine.dart @@ -387,7 +387,9 @@ class Engine { await Future(() {}); if (!_restarted.contains(liveTest)) { - if (_stopOnFirstFailure && liveTest.state.result.isFailing) close(); + if (_stopOnFirstFailure && liveTest.state.result.isFailing) { + unawaited(close()); + } return; } await _runLiveTest(suiteController, liveTest.copy(), diff --git a/pkgs/test_core/lib/src/runner/load_suite.dart b/pkgs/test_core/lib/src/runner/load_suite.dart index d4263ea01..550881e0c 100644 --- a/pkgs/test_core/lib/src/runner/load_suite.dart +++ b/pkgs/test_core/lib/src/runner/load_suite.dart @@ -14,7 +14,6 @@ import 'package:test_api/src/backend/suite.dart'; // ignore: implementation_impo import 'package:test_api/src/backend/suite_platform.dart'; // ignore: implementation_imports import 'package:test_api/src/backend/test.dart'; // ignore: implementation_imports -import '../util/async.dart'; import '../util/io_stub.dart' if (dart.library.io) '../util/io.dart'; import '../util/pair.dart'; import 'load_exception.dart'; diff --git a/pkgs/test_core/lib/src/runner/runner_test.dart b/pkgs/test_core/lib/src/runner/runner_test.dart index f140c0155..2823983e2 100644 --- a/pkgs/test_core/lib/src/runner/runner_test.dart +++ b/pkgs/test_core/lib/src/runner/runner_test.dart @@ -43,23 +43,24 @@ class RunnerTest extends Test { _channel.sink.add({'command': 'run', 'channel': testChannel.id}); testChannel.stream.listen((message) { - switch (message['type'] as String) { + final msg = message as Map; + switch (msg['type'] as String) { case 'error': var asyncError = RemoteException.deserialize( - message['error'] as Map); + msg['error'] as Map); var stackTrace = asyncError.stackTrace; controller.addError(asyncError.error, stackTrace); break; case 'state-change': - controller.setState(State(Status.parse(message['status'] as String), - Result.parse(message['result'] as String))); + controller.setState(State(Status.parse(msg['status'] as String), + Result.parse(msg['result'] as String))); break; case 'message': controller.message(Message( - MessageType.parse(message['message-type'] as String), - message['text'] as String)); + MessageType.parse(msg['message-type'] as String), + msg['text'] as String)); break; case 'complete': @@ -70,9 +71,8 @@ class RunnerTest extends Test { // When we kill the isolate that the test lives in, that will close // this virtual channel and cause the spawned isolate to close as // well. - spawnHybridUri(message['url'] as String, message['message'], suite) - .pipe(testChannel - .virtualChannel((message['channel'] as num).toInt())); + spawnHybridUri(msg['url'] as String, msg['message'], suite).pipe( + testChannel.virtualChannel((msg['channel'] as num).toInt())); break; } }, onDone: () { diff --git a/pkgs/test_core/lib/src/runner/vm/platform.dart b/pkgs/test_core/lib/src/runner/vm/platform.dart index aa4eeb81a..85f691d7a 100644 --- a/pkgs/test_core/lib/src/runner/vm/platform.dart +++ b/pkgs/test_core/lib/src/runner/vm/platform.dart @@ -59,7 +59,7 @@ class VMPlatform extends PlatformPlugin { process = await _spawnExecutable(path, suiteConfig.metadata, serverSocket); } catch (error) { - serverSocket.close(); + unawaited(serverSocket.close()); rethrow; } process.stdout.listen(stdout.add); @@ -100,8 +100,8 @@ class VMPlatform extends PlatformPlugin { for (var fn in cleanupCallbacks) { fn(); } - eventSub?.cancel(); - client?.dispose(); + unawaited(eventSub?.cancel()); + unawaited(client?.dispose()); sink.close(); })); diff --git a/pkgs/test_core/lib/src/scaffolding.dart b/pkgs/test_core/lib/src/scaffolding.dart index b72d9eab3..93343fef1 100644 --- a/pkgs/test_core/lib/src/scaffolding.dart +++ b/pkgs/test_core/lib/src/scaffolding.dart @@ -16,7 +16,6 @@ import 'runner/plugin/environment.dart'; import 'runner/reporter/expanded.dart'; import 'runner/runner_suite.dart'; import 'runner/suite.dart'; -import 'util/async.dart'; import 'util/os.dart'; import 'util/print_sink.dart'; diff --git a/pkgs/test_core/lib/src/util/async.dart b/pkgs/test_core/lib/src/util/async.dart index 422de0e23..036d2b1cf 100644 --- a/pkgs/test_core/lib/src/util/async.dart +++ b/pkgs/test_core/lib/src/util/async.dart @@ -30,5 +30,3 @@ Stream inCompletionOrder(Iterable> operations) { return controller.stream; } - -void unawaited(Future f) {} diff --git a/pkgs/test_core/lib/src/util/io.dart b/pkgs/test_core/lib/src/util/io.dart index d6be8431d..a082dd310 100644 --- a/pkgs/test_core/lib/src/util/io.dart +++ b/pkgs/test_core/lib/src/util/io.dart @@ -44,10 +44,11 @@ final String sdkDir = p.dirname(p.dirname(Platform.resolvedExecutable)); /// The current operating system. final currentOS = OperatingSystem.findByIoName(Platform.operatingSystem); -/// Returns a [SuitePlatform] with the given [runtime], and with [os] and -/// [inGoogle] determined automatically. +/// Returns a [SuitePlatform] with the given [runtime], and with +/// [SuitePlatform.os] and [inGoogle] determined automatically. /// -/// If [runtime] is a browser, this will set [os] to [OperatingSystem.none]. +/// If [runtime] is a browser, this will set [SuitePlatform.os] to +/// [OperatingSystem.none]. // TODO: https://github.com/dart-lang/test/issues/2119 - require compiler SuitePlatform currentPlatform(Runtime runtime, [Compiler? compiler]) => SuitePlatform(runtime, @@ -223,7 +224,8 @@ Future getRemoteDebuggerUrl(Uri base) async { var response = await request.close(); var jsonObject = await json.fuse(utf8).decoder.bind(response).single as List; - return base.resolve(jsonObject.first['devtoolsFrontendUrl'] as String); + return base + .resolve((jsonObject.first as Map)['devtoolsFrontendUrl'] as String); } catch (_) { // If we fail to talk to the remote debugger protocol, give up and return // the raw URL rather than crashing.