Skip to content

Allow connecting to the runner from test suite #2526

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion pkgs/test_api/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
## 0.7.8-wip

* Add a zone function available from the test suite `main` that allows creating
channels to the test runner.
* Restrict to latest version of analyzer package.
- Require Dart 3.7
* Require Dart 3.7

## 0.7.7

Expand Down
4 changes: 2 additions & 2 deletions pkgs/test_api/lib/src/backend/declarer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,8 @@ class Declarer {
/// Runs [body] with this declarer as [Declarer.current].
///
/// Returns the return value of [body].
T declare<T>(T Function() body) =>
runZoned(body, zoneValues: {#test.declarer: this});
T declare<T>(T Function() body, {Map<Symbol, Object?>? zoneValues}) =>
runZoned(body, zoneValues: {#test.declarer: this, ...?zoneValues});

/// Defines a test case with the given name and body.
void test(
Expand Down
7 changes: 6 additions & 1 deletion pkgs/test_api/lib/src/backend/remote_listener.dart
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,12 @@ final class RemoteListener {
await beforeLoad(suiteChannelManager.connectOut);
}

await declarer.declare(main);
await declarer.declare(
main,
zoneValues: {
#test.openChannelCallback: suiteChannelManager.connectOut,
},
);

var suite = Suite(
declarer.build(),
Expand Down
Loading