Skip to content

Commit

Permalink
Remove hard exit hack (#1280)
Browse files Browse the repository at this point in the history
Closes #599

Close `ReceivePort` instances that are passed to spawned isolated.
This resolves at least one cause of the test runner hanging.

Drop support for and usage of the `FORCE_TEST_EXIT` environment.
  • Loading branch information
natebosch authored Jun 23, 2021
1 parent b8bac52 commit d8a0918
Show file tree
Hide file tree
Showing 10 changed files with 13 additions and 14 deletions.
1 change: 0 additions & 1 deletion .github/workflows/dart.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ defaults:
shell: bash
env:
PUB_ENVIRONMENT: bot.github
FORCE_TEST_EXIT: true

jobs:
job_001:
Expand Down
2 changes: 0 additions & 2 deletions mono_repo.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
self_validate: analyze_and_format

github:
env:
FORCE_TEST_EXIT: true
# Setting just `cron` keeps the defaults for `push` and `pull_request`
cron: '0 0 * * 0' # “At 00:00 (UTC) on Sunday.”
on_completion:
Expand Down
2 changes: 2 additions & 0 deletions pkgs/test/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
## 1.17.10-dev

## 1.17.9

* Fix a bug where a tag level configuration would cause test suites with that
Expand Down
4 changes: 2 additions & 2 deletions pkgs/test/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: test
version: 1.17.9
version: 1.17.10-dev
description: >-
A full featured library for writing and running Dart tests across platforms.
repository: https://github.com/dart-lang/test/blob/master/pkgs/test
Expand Down Expand Up @@ -34,7 +34,7 @@ dependencies:
yaml: ^3.0.0
# Use an exact version until the test_api and test_core package are stable.
test_api: 0.4.1
test_core: 0.3.29
test_core: 0.3.30

dev_dependencies:
fake_async: ^1.0.0
Expand Down
3 changes: 1 addition & 2 deletions pkgs/test/test/runner/runner_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -714,8 +714,7 @@ void main(List<String> args) async {
test.completeShutdown();
}''').create();
var test = await runDart(['runner.dart', '--no-color', '--', 'test.dart'],
description: 'dart runner.dart -- test.dart',
environment: {'FORCE_TEST_EXIT': 'false'});
description: 'dart runner.dart -- test.dart');
expect(
test.stdout,
emitsThrough(containsInOrder([
Expand Down
4 changes: 4 additions & 0 deletions pkgs/test_core/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.3.30-dev

* Remove support for `FORCE_TEST_EXIT`.

## 0.3.29

* Fix a bug where a tag level configuration would cause test suites with that
Expand Down
6 changes: 0 additions & 6 deletions pkgs/test_core/lib/src/executable.dart
Original file line number Diff line number Diff line change
Expand Up @@ -166,12 +166,6 @@ Future<void> _execute(List<String> args) async {
await runner?.close();
}

// TODO(grouma) - figure out why the executable can hang in the travis
// environment. https://github.com/dart-lang/test/issues/599
if (Platform.environment['FORCE_TEST_EXIT'] == 'true') {
exit(exitCode);
}

return;
}

Expand Down
2 changes: 2 additions & 0 deletions pkgs/test_core/lib/src/runner/spawn_hybrid.dart
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ StreamChannel spawnHybridUri(String url, Object? message, Suite suite) {
var disconnector = Disconnector();
onExitPort.listen((_) {
disconnector.disconnect();
port.close();
onExitPort.close();
});

Expand All @@ -62,6 +63,7 @@ StreamChannel spawnHybridUri(String url, Object? message, Suite suite) {
.transformSink(StreamSinkTransformer.fromHandlers(handleDone: (sink) {
// If the user closes the stream channel, kill the isolate.
isolate.kill();
port.close();
onExitPort.close();
sink.close();
}));
Expand Down
1 change: 1 addition & 0 deletions pkgs/test_core/lib/src/runner/vm/platform.dart
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ class VMPlatform extends PlatformPlugin {
StreamSubscription<Event>? eventSub;
var channel = IsolateChannel.connectReceive(receivePort)
.transformStream(StreamTransformer.fromHandlers(handleDone: (sink) {
receivePort.close();
isolate!.kill();
eventSub?.cancel();
client?.dispose();
Expand Down
2 changes: 1 addition & 1 deletion pkgs/test_core/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: test_core
version: 0.3.29
version: 0.3.30-dev
description: A basic library for writing tests and running them on the VM.
homepage: https://github.com/dart-lang/test/blob/master/pkgs/test_core

Expand Down

0 comments on commit d8a0918

Please sign in to comment.