From 29bd5d39c73bde3fd211f4ad58db2cec795c87a6 Mon Sep 17 00:00:00 2001 From: Nate Bosch Date: Wed, 18 Jun 2025 04:37:28 +0000 Subject: [PATCH 1/3] Add the platform level channel to zone values We make a test channel available in the zones running tests to enable features like spawning VM isolates but it's not available in the zone that runs `main`. Add a new zone variable that holds the test channel. --- pkgs/test/CHANGELOG.md | 2 ++ pkgs/test/pubspec.yaml | 6 +++--- pkgs/test_api/CHANGELOG.md | 2 ++ pkgs/test_api/lib/src/backend/declarer.dart | 4 ++-- pkgs/test_api/lib/src/backend/remote_listener.dart | 3 ++- pkgs/test_api/lib/src/scaffolding/spawn_hybrid.dart | 2 +- pkgs/test_api/pubspec.yaml | 2 +- pkgs/test_core/CHANGELOG.md | 2 ++ pkgs/test_core/pubspec.yaml | 4 ++-- 9 files changed, 17 insertions(+), 10 deletions(-) diff --git a/pkgs/test/CHANGELOG.md b/pkgs/test/CHANGELOG.md index 606d0d3ba..298345927 100644 --- a/pkgs/test/CHANGELOG.md +++ b/pkgs/test/CHANGELOG.md @@ -1,3 +1,5 @@ +## 1.26.3-WIP + ## 1.26.2 * Graduate native assets from experiment to preview. diff --git a/pkgs/test/pubspec.yaml b/pkgs/test/pubspec.yaml index a62ae0e2f..eb30f0d55 100644 --- a/pkgs/test/pubspec.yaml +++ b/pkgs/test/pubspec.yaml @@ -1,5 +1,5 @@ name: test -version: 1.26.2 +version: 1.26.3-WIP description: >- A full featured library for writing and running Dart tests across platforms. repository: https://github.com/dart-lang/test/tree/master/pkgs/test @@ -36,8 +36,8 @@ dependencies: stream_channel: ^2.1.0 # Use an exact version until the test_api and test_core package are stable. - test_api: 0.7.6 - test_core: 0.6.11 + test_api: 0.7.7 + test_core: 0.6.12 typed_data: ^1.3.0 web_socket_channel: '>=2.0.0 <4.0.0' diff --git a/pkgs/test_api/CHANGELOG.md b/pkgs/test_api/CHANGELOG.md index ac26b156d..8687263d7 100644 --- a/pkgs/test_api/CHANGELOG.md +++ b/pkgs/test_api/CHANGELOG.md @@ -1,3 +1,5 @@ +## 0.7.7-WIP + ## 0.7.6 * Fix an assertion failure when using `setUpAll` or `tearDownAll` and running diff --git a/pkgs/test_api/lib/src/backend/declarer.dart b/pkgs/test_api/lib/src/backend/declarer.dart index 4e9818d1e..52d05b9f7 100644 --- a/pkgs/test_api/lib/src/backend/declarer.dart +++ b/pkgs/test_api/lib/src/backend/declarer.dart @@ -191,8 +191,8 @@ class Declarer { /// Runs [body] with this declarer as [Declarer.current]. /// /// Returns the return value of [body]. - T declare(T Function() body) => - runZoned(body, zoneValues: {#test.declarer: this}); + T declare(T Function() body, {Map? zoneValues}) => + runZoned(body, zoneValues: {#test.declarer: this, ...?zoneValues}); /// Defines a test case with the given name and body. void test(String name, dynamic Function() body, diff --git a/pkgs/test_api/lib/src/backend/remote_listener.dart b/pkgs/test_api/lib/src/backend/remote_listener.dart index 757720904..d2baac8a1 100644 --- a/pkgs/test_api/lib/src/backend/remote_listener.dart +++ b/pkgs/test_api/lib/src/backend/remote_listener.dart @@ -117,7 +117,8 @@ final class RemoteListener { await beforeLoad(suiteChannelManager.connectOut); } - await declarer.declare(main); + await declarer.declare(main, + zoneValues: {#test.platformChannel: controller.foreign}); var suite = Suite( declarer.build(), diff --git a/pkgs/test_api/lib/src/scaffolding/spawn_hybrid.dart b/pkgs/test_api/lib/src/scaffolding/spawn_hybrid.dart index 7222d5272..21868940f 100644 --- a/pkgs/test_api/lib/src/scaffolding/spawn_hybrid.dart +++ b/pkgs/test_api/lib/src/scaffolding/spawn_hybrid.dart @@ -170,7 +170,7 @@ StreamChannel _spawn(String uri, Object? message, {bool stayAlive = false}) { }); if (!stayAlive) { - var disconnector = Disconnector(); + var disconnector = Disconnector(); addTearDown(() => disconnector.disconnect()); isolateChannel = isolateChannel.transform(disconnector); } diff --git a/pkgs/test_api/pubspec.yaml b/pkgs/test_api/pubspec.yaml index 47403c705..3b65f6193 100644 --- a/pkgs/test_api/pubspec.yaml +++ b/pkgs/test_api/pubspec.yaml @@ -1,5 +1,5 @@ name: test_api -version: 0.7.6 +version: 0.7.7-WIP description: >- The user facing API for structuring Dart tests and checking expectations. repository: https://github.com/dart-lang/test/tree/master/pkgs/test_api diff --git a/pkgs/test_core/CHANGELOG.md b/pkgs/test_core/CHANGELOG.md index 8029c3fe2..193d8c9cd 100644 --- a/pkgs/test_core/CHANGELOG.md +++ b/pkgs/test_core/CHANGELOG.md @@ -1,3 +1,5 @@ +## 0.6.12-WIP + ## 0.6.11 * Graduate native assets from experiment to preview. diff --git a/pkgs/test_core/pubspec.yaml b/pkgs/test_core/pubspec.yaml index 78cc8ea24..aebba8089 100644 --- a/pkgs/test_core/pubspec.yaml +++ b/pkgs/test_core/pubspec.yaml @@ -1,5 +1,5 @@ name: test_core -version: 0.6.11 +version: 0.6.12-WIP description: A basic library for writing tests and running them on the VM. repository: https://github.com/dart-lang/test/tree/master/pkgs/test_core issue_tracker: https://github.com/dart-lang/test/issues?q=is%3Aissue+is%3Aopen+label%3Apackage%3Atest @@ -28,7 +28,7 @@ dependencies: stack_trace: ^1.10.0 stream_channel: ^2.1.0 # Use an exact version until the test_api package is stable. - test_api: 0.7.6 + test_api: 0.7.7 vm_service: '>=6.0.0 <16.0.0' yaml: ^3.0.0 From 0a4b93ce02fdbfc5f099727da5368debc8b1d899 Mon Sep 17 00:00:00 2001 From: Nate Bosch Date: Wed, 18 Jun 2025 04:44:34 +0000 Subject: [PATCH 2/3] Align versions --- pkgs/test/pubspec.yaml | 4 ++-- pkgs/test_core/pubspec.yaml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pkgs/test/pubspec.yaml b/pkgs/test/pubspec.yaml index eb30f0d55..3edd5a889 100644 --- a/pkgs/test/pubspec.yaml +++ b/pkgs/test/pubspec.yaml @@ -36,8 +36,8 @@ dependencies: stream_channel: ^2.1.0 # Use an exact version until the test_api and test_core package are stable. - test_api: 0.7.7 - test_core: 0.6.12 + test_api: 0.7.7-WIP + test_core: 0.6.12-WIP typed_data: ^1.3.0 web_socket_channel: '>=2.0.0 <4.0.0' diff --git a/pkgs/test_core/pubspec.yaml b/pkgs/test_core/pubspec.yaml index aebba8089..af02b93a5 100644 --- a/pkgs/test_core/pubspec.yaml +++ b/pkgs/test_core/pubspec.yaml @@ -28,7 +28,7 @@ dependencies: stack_trace: ^1.10.0 stream_channel: ^2.1.0 # Use an exact version until the test_api package is stable. - test_api: 0.7.7 + test_api: 0.7.7-WIP vm_service: '>=6.0.0 <16.0.0' yaml: ^3.0.0 From 01e08cc72ace330265fbd9a892cee72051361bed Mon Sep 17 00:00:00 2001 From: Nate Bosch Date: Wed, 18 Jun 2025 04:47:20 +0000 Subject: [PATCH 3/3] back out accidental change hit undo one too many times and undid an already committed fix --- pkgs/test_api/lib/src/scaffolding/spawn_hybrid.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/test_api/lib/src/scaffolding/spawn_hybrid.dart b/pkgs/test_api/lib/src/scaffolding/spawn_hybrid.dart index 21868940f..7222d5272 100644 --- a/pkgs/test_api/lib/src/scaffolding/spawn_hybrid.dart +++ b/pkgs/test_api/lib/src/scaffolding/spawn_hybrid.dart @@ -170,7 +170,7 @@ StreamChannel _spawn(String uri, Object? message, {bool stayAlive = false}) { }); if (!stayAlive) { - var disconnector = Disconnector(); + var disconnector = Disconnector(); addTearDown(() => disconnector.disconnect()); isolateChannel = isolateChannel.transform(disconnector); }