Skip to content

Commit

Permalink
random cleanup (#2232)
Browse files Browse the repository at this point in the history
  • Loading branch information
kevmoo committed Jun 4, 2024
1 parent 18db77c commit 43ad4cd
Show file tree
Hide file tree
Showing 13 changed files with 29 additions and 28 deletions.
2 changes: 1 addition & 1 deletion pkgs/checks/lib/src/checks.dart
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ extension ContextExtension<T> on Subject<T> {
/// 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.
Expand Down
2 changes: 1 addition & 1 deletion pkgs/checks/lib/src/extensions/iterable.dart
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ extension IterableChecks<T> on Subject<Iterable<T>> {
}

/// 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:
Expand Down
2 changes: 1 addition & 1 deletion pkgs/checks/test/extensions/async_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ fake trace''');
queue,
(Subject<StreamQueue<int>> 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);
Expand Down
2 changes: 1 addition & 1 deletion pkgs/checks/test/soft_check_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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)),
Expand Down
5 changes: 3 additions & 2 deletions pkgs/test_core/lib/src/bootstrap/vm.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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');
});
}));
}
2 changes: 1 addition & 1 deletion pkgs/test_core/lib/src/runner/console.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
4 changes: 3 additions & 1 deletion pkgs/test_core/lib/src/runner/engine.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
1 change: 0 additions & 1 deletion pkgs/test_core/lib/src/runner/load_suite.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
18 changes: 9 additions & 9 deletions pkgs/test_core/lib/src/runner/runner_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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<String, dynamic>);
msg['error'] as Map<String, dynamic>);
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':
Expand All @@ -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: () {
Expand Down
6 changes: 3 additions & 3 deletions pkgs/test_core/lib/src/runner/vm/platform.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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();
}));

Expand Down
1 change: 0 additions & 1 deletion pkgs/test_core/lib/src/scaffolding.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down
2 changes: 0 additions & 2 deletions pkgs/test_core/lib/src/util/async.dart
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,3 @@ Stream<T> inCompletionOrder<T>(Iterable<CancelableOperation<T>> operations) {

return controller.stream;
}

void unawaited(Future<void> f) {}
10 changes: 6 additions & 4 deletions pkgs/test_core/lib/src/util/io.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -223,7 +224,8 @@ Future<Uri> 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.
Expand Down

0 comments on commit 43ad4cd

Please sign in to comment.