From 8796242724d65717acc0225987ab2397e955990d Mon Sep 17 00:00:00 2001 From: Nate Bosch Date: Mon, 5 Jun 2023 17:37:01 +0000 Subject: [PATCH 1/5] Remove test_api copies of scaffolding functions There are definitions in `test_core` which override the `_declarer` to work even when the test script is run directly instead of through the test runner. The definitions from `test_api` should not be used anywhere currently. --- pkgs/test/pubspec.yaml | 2 +- pkgs/test_api/CHANGELOG.md | 5 +- pkgs/test_api/lib/scaffolding.dart | 9 +- .../lib/src/scaffolding/test_structure.dart | 249 ------------------ pkgs/test_api/lib/src/scaffolding/utils.dart | 15 ++ pkgs/test_api/pubspec.yaml | 2 +- pkgs/test_core/lib/scaffolding.dart | 14 +- pkgs/test_core/pubspec.yaml | 2 +- 8 files changed, 41 insertions(+), 257 deletions(-) delete mode 100644 pkgs/test_api/lib/src/scaffolding/test_structure.dart diff --git a/pkgs/test/pubspec.yaml b/pkgs/test/pubspec.yaml index 9a64021f3..b6f88c82b 100644 --- a/pkgs/test/pubspec.yaml +++ b/pkgs/test/pubspec.yaml @@ -32,7 +32,7 @@ dependencies: webkit_inspection_protocol: ^1.0.0 yaml: ^3.0.0 # Use an exact version until the test_api and test_core package are stable. - test_api: 0.6.1 + test_api: 0.7.0 test_core: 0.5.4 # Use a tight version constraint to ensure that a constraint on matcher # properly constrains all features it provides. diff --git a/pkgs/test_api/CHANGELOG.md b/pkgs/test_api/CHANGELOG.md index b620b8dbb..812b52672 100644 --- a/pkgs/test_api/CHANGELOG.md +++ b/pkgs/test_api/CHANGELOG.md @@ -1,4 +1,4 @@ -## 0.6.1-wip +## 0.7.0-wip * Drop support for null unsafe Dart, bump SDK constraint to `3.0.0`. * Make some implementation classes `final`. These classes were never intended to @@ -9,6 +9,9 @@ * Mark an implementation class `interface`: `StackTraceMapper`. * Change the `Compiler` class into an `enum`. * Make `Fake` a `mixin class`. +* Remove the definitions of `group`, `test`, `setUp`, `tearDown`, `setUpAll`, + and `tearDownAll`. These methods are available in `package:test_core` and + re-exported in `package:test`. ## 0.6.0 diff --git a/pkgs/test_api/lib/scaffolding.dart b/pkgs/test_api/lib/scaffolding.dart index 9d1e4a6b6..76d4ead45 100644 --- a/pkgs/test_api/lib/scaffolding.dart +++ b/pkgs/test_api/lib/scaffolding.dart @@ -17,7 +17,10 @@ export 'src/backend/configuration/tags.dart' show Tags; export 'src/backend/configuration/test_on.dart' show TestOn; export 'src/backend/configuration/timeout.dart' show Timeout; export 'src/scaffolding/spawn_hybrid.dart' show spawnHybridUri, spawnHybridCode; -export 'src/scaffolding/test_structure.dart' - show group, test, setUp, setUpAll, tearDown, tearDownAll, addTearDown; export 'src/scaffolding/utils.dart' - show markTestSkipped, printOnFailure, pumpEventQueue, registerException; + show + addTearDown, + markTestSkipped, + printOnFailure, + pumpEventQueue, + registerException; diff --git a/pkgs/test_api/lib/src/scaffolding/test_structure.dart b/pkgs/test_api/lib/src/scaffolding/test_structure.dart deleted file mode 100644 index ec8691d1a..000000000 --- a/pkgs/test_api/lib/src/scaffolding/test_structure.dart +++ /dev/null @@ -1,249 +0,0 @@ -// Copyright (c) 2021, the Dart project authors. Please see the AUTHORS file -// 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 'package:meta/meta.dart'; - -import '../backend/configuration/timeout.dart'; -import '../backend/declarer.dart'; -import '../backend/invoker.dart'; - -// test_core does not support running tests directly, so the Declarer should -// always be on the Zone. -Declarer get _declarer => Zone.current[#test.declarer] as Declarer; - -// TODO(nweiz): This and other top-level functions should throw exceptions if -// they're called after the declarer has finished declaring. -/// Creates a new test case with the given description (converted to a string) -/// and body. -/// -/// The description will be added to the descriptions of any surrounding -/// [group]s. If [testOn] is passed, it's parsed as a [platform selector][]; the -/// test will only be run on matching platforms. -/// -/// [platform selector]: https://github.com/dart-lang/test/tree/master/pkgs/test#platform-selectors -/// -/// If [timeout] is passed, it's used to modify or replace the default timeout -/// of 30 seconds. Timeout modifications take precedence in suite-group-test -/// order, so [timeout] will also modify any timeouts set on the group or suite. -/// -/// If [skip] is a String or `true`, the test is skipped. If it's a String, it -/// should explain why the test is skipped; this reason will be printed instead -/// of running the test. -/// -/// If [tags] is passed, it declares user-defined tags that are applied to the -/// test. These tags can be used to select or skip the test on the command line, -/// or to do bulk test configuration. All tags should be declared in the -/// [package configuration file][configuring tags]. The parameter can be an -/// [Iterable] of tag names, or a [String] representing a single tag. -/// -/// If [retry] is passed, the test will be retried the provided number of times -/// before being marked as a failure. -/// -/// [configuring tags]: https://github.com/dart-lang/test/blob/master/pkgs/test/doc/configuration.md#configuring-tags -/// -/// [onPlatform] allows tests to be configured on a platform-by-platform -/// basis. It's a map from strings that are parsed as [PlatformSelector]s to -/// annotation classes: [Timeout], [Skip], or lists of those. These -/// annotations apply only on the given platforms. For example: -/// -/// test('potentially slow test', () { -/// // ... -/// }, onPlatform: { -/// // This test is especially slow on Windows. -/// 'windows': Timeout.factor(2), -/// 'browser': [ -/// Skip('TODO: add browser support'), -/// // This will be slow on browsers once it works on them. -/// Timeout.factor(2) -/// ] -/// }); -/// -/// If multiple platforms match, the annotations apply in order as through -/// they were in nested groups. -/// -/// If the `solo` flag is `true`, only tests and groups marked as -/// "solo" will be be run. This only restricts tests *within this test -/// suite*—tests in other suites will run as normal. We recommend that users -/// avoid this flag if possible and instead use the test runner flag `-n` to -/// filter tests by name. -@isTest -void test(description, dynamic Function() body, - {String? testOn, - Timeout? timeout, - skip, - tags, - Map? onPlatform, - int? retry, - @Deprecated('Debug only') bool solo = false}) { - _declarer.test(description.toString(), body, - testOn: testOn, - timeout: timeout, - skip: skip, - onPlatform: onPlatform, - tags: tags, - retry: retry, - solo: solo); - - // Force dart2js not to inline this function. We need it to be separate from - // `main()` in JS stack traces in order to properly determine the line and - // column where the test was defined. See sdk#26705. - return; - return; // ignore: dead_code -} - -/// Creates a group of tests. -/// -/// A group's description (converted to a string) is included in the descriptions -/// of any tests or sub-groups it contains. [setUp] and [tearDown] are also scoped -/// to the containing group. -/// -/// If [testOn] is passed, it's parsed as a [platform selector][]; the test will -/// only be run on matching platforms. -/// -/// [platform selector]: https://github.com/dart-lang/test/tree/master/pkgs/test#platform-selectors -/// -/// If [timeout] is passed, it's used to modify or replace the default timeout -/// of 30 seconds. Timeout modifications take precedence in suite-group-test -/// order, so [timeout] will also modify any timeouts set on the suite, and will -/// be modified by any timeouts set on individual tests. -/// -/// If [skip] is a String or `true`, the group is skipped. If it's a String, it -/// should explain why the group is skipped; this reason will be printed instead -/// of running the group's tests. -/// -/// If [tags] is passed, it declares user-defined tags that are applied to the -/// test. These tags can be used to select or skip the test on the command line, -/// or to do bulk test configuration. All tags should be declared in the -/// [package configuration file][configuring tags]. The parameter can be an -/// [Iterable] of tag names, or a [String] representing a single tag. -/// -/// [configuring tags]: https://github.com/dart-lang/test/blob/master/pkgs/test/doc/configuration.md#configuring-tags -/// -/// [onPlatform] allows groups to be configured on a platform-by-platform -/// basis. It's a map from strings that are parsed as [PlatformSelector]s to -/// annotation classes: [Timeout], [Skip], or lists of those. These -/// annotations apply only on the given platforms. For example: -/// -/// group('potentially slow tests', () { -/// // ... -/// }, onPlatform: { -/// // These tests are especially slow on Windows. -/// 'windows': Timeout.factor(2), -/// 'browser': [ -/// Skip('TODO: add browser support'), -/// // They'll be slow on browsers once it works on them. -/// Timeout.factor(2) -/// ] -/// }); -/// -/// If multiple platforms match, the annotations apply in order as through -/// they were in nested groups. -/// -/// If the `solo` flag is `true`, only tests and groups marked as -/// "solo" will be be run. This only restricts tests *within this test -/// suite*—tests in other suites will run as normal. We recommend that users -/// avoid this flag if possible, and instead use the test runner flag `-n` to -/// filter tests by name. -@isTestGroup -void group(description, dynamic Function() body, - {String? testOn, - Timeout? timeout, - skip, - tags, - Map? onPlatform, - int? retry, - @Deprecated('Debug only') bool solo = false}) { - _declarer.group(description.toString(), body, - testOn: testOn, - timeout: timeout, - skip: skip, - tags: tags, - onPlatform: onPlatform, - retry: retry, - solo: solo); - - // Force dart2js not to inline this function. We need it to be separate from - // `main()` in JS stack traces in order to properly determine the line and - // column where the test was defined. See sdk#26705. - return; - return; // ignore: dead_code -} - -/// Registers a function to be run before tests. -/// -/// This function will be called before each test is run. [callback] may be -/// asynchronous; if so, it must return a [Future]. -/// -/// If this is called within a test group, it applies only to tests in that -/// group. [callback] will be run after any set-up callbacks in parent groups or -/// at the top level. -/// -/// Each callback at the top level or in a given group will be run in the order -/// they were declared. -void setUp(dynamic Function() callback) => _declarer.setUp(callback); - -/// Registers a function to be run after tests. -/// -/// This function will be called after each test is run. [callback] may be -/// asynchronous; if so, it must return a [Future]. -/// -/// If this is called within a test group, it applies only to tests in that -/// group. [callback] will be run before any tear-down callbacks in parent -/// groups or at the top level. -/// -/// Each callback at the top level or in a given group will be run in the -/// reverse of the order they were declared. -/// -/// See also [addTearDown], which adds tear-downs to a running test. -void tearDown(dynamic Function() callback) => _declarer.tearDown(callback); - -/// Registers a function to be run after the current test. -/// -/// This is called within a running test, and adds a tear-down only for the -/// current test. It allows testing libraries to add cleanup logic as soon as -/// there's something to clean up. -/// -/// The [callback] is run before any callbacks registered with [tearDown]. Like -/// [tearDown], the most recently registered callback is run first. -/// -/// If this is called from within a [setUpAll] or [tearDownAll] callback, it -/// instead runs the function after *all* tests in the current test suite. -void addTearDown(dynamic Function() callback) { - if (Invoker.current == null) { - throw StateError('addTearDown() may only be called within a test.'); - } - - Invoker.current!.addTearDown(callback); -} - -/// Registers a function to be run once before all tests. -/// -/// [callback] may be asynchronous; if so, it must return a [Future]. -/// -/// If this is called within a test group, [callback] will run before all tests -/// in that group. It will be run after any [setUpAll] callbacks in parent -/// groups or at the top level. It won't be run if none of the tests in the -/// group are run. -/// -/// **Note**: This function makes it very easy to accidentally introduce hidden -/// dependencies between tests that should be isolated. In general, you should -/// prefer [setUp], and only use [setUpAll] if the callback is prohibitively -/// slow. -void setUpAll(dynamic Function() callback) => _declarer.setUpAll(callback); - -/// Registers a function to be run once after all tests. -/// -/// If this is called within a test group, [callback] will run after all tests -/// in that group. It will be run before any [tearDownAll] callbacks in parent -/// groups or at the top level. It won't be run if none of the tests in the -/// group are run. -/// -/// **Note**: This function makes it very easy to accidentally introduce hidden -/// dependencies between tests that should be isolated. In general, you should -/// prefer [tearDown], and only use [tearDownAll] if the callback is -/// prohibitively slow. -void tearDownAll(dynamic Function() callback) => - _declarer.tearDownAll(callback); diff --git a/pkgs/test_api/lib/src/scaffolding/utils.dart b/pkgs/test_api/lib/src/scaffolding/utils.dart index 134dc497c..fc17fc626 100644 --- a/pkgs/test_api/lib/src/scaffolding/utils.dart +++ b/pkgs/test_api/lib/src/scaffolding/utils.dart @@ -37,6 +37,21 @@ void printOnFailure(String message) { _currentInvoker.printOnFailure(message); } +/// Registers a function to be run after the current test. +/// +/// This is called within a running test, and adds a tear-down only for the +/// current test. It allows testing libraries to add cleanup logic as soon as +/// there's something to clean up. +/// +/// The [callback] is run before any callbacks registered with [tearDown]. Like +/// [tearDown], the most recently registered callback is run first. +/// +/// If this is called from within a [setUpAll] or [tearDownAll] callback, it +/// instead runs the function after *all* tests in the current test suite. +void addTearDown(dynamic Function() callback) { + _currentInvoker.addTearDown(callback); +} + /// Marks the current test as skipped. /// /// A skipped test may still fail if any exception is thrown, including uncaught diff --git a/pkgs/test_api/pubspec.yaml b/pkgs/test_api/pubspec.yaml index 2a3ee2331..70cd09a97 100644 --- a/pkgs/test_api/pubspec.yaml +++ b/pkgs/test_api/pubspec.yaml @@ -1,5 +1,5 @@ name: test_api -version: 0.6.1-wip +version: 0.7.0-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/lib/scaffolding.dart b/pkgs/test_core/lib/scaffolding.dart index ab1ec5985..1067c2598 100644 --- a/pkgs/test_core/lib/scaffolding.dart +++ b/pkgs/test_core/lib/scaffolding.dart @@ -28,7 +28,19 @@ import 'src/util/print_sink.dart'; // This file is an almost direct copy of import below, but with the global // declarer added. export 'package:test_api/scaffolding.dart' - hide test, group, setUp, setUpAll, tearDown, tearDownAll; + show + OnPlatform, + Retry, + Skip, + Tags, + TestOn, + Timeout, + spawnHybridUri, + spawnHybridCode, + markTestSkipped, + printOnFailure, + pumpEventQueue, + registerException; /// The global declarer. /// diff --git a/pkgs/test_core/pubspec.yaml b/pkgs/test_core/pubspec.yaml index 1d3bf5203..2e045aabd 100644 --- a/pkgs/test_core/pubspec.yaml +++ b/pkgs/test_core/pubspec.yaml @@ -28,7 +28,7 @@ dependencies: vm_service: ">=6.0.0 <12.0.0" yaml: ^3.0.0 # Use an exact version until the test_api package is stable. - test_api: 0.6.1 + test_api: 0.7.0 dev_dependencies: lints: '>=1.0.0 <3.0.0' From b5ebbdd29717d126cd858277fd159b2052e0d39d Mon Sep 17 00:00:00 2001 From: Nate Bosch Date: Mon, 5 Jun 2023 18:07:52 +0000 Subject: [PATCH 2/5] Add addTearDown to show list for test_core/scaffolding.dart Add an override on `matcher` for `test_api` for breaking version change. --- pkgs/test_api/pubspec_overrides.yaml | 1 + pkgs/test_core/lib/scaffolding.dart | 7 ++++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/pkgs/test_api/pubspec_overrides.yaml b/pkgs/test_api/pubspec_overrides.yaml index bdb2cf470..f0c4aa378 100644 --- a/pkgs/test_api/pubspec_overrides.yaml +++ b/pkgs/test_api/pubspec_overrides.yaml @@ -3,3 +3,4 @@ dependency_overrides: path: ../test test_core: path: ../test_core + matcher: any diff --git a/pkgs/test_core/lib/scaffolding.dart b/pkgs/test_core/lib/scaffolding.dart index 1067c2598..5257b2f71 100644 --- a/pkgs/test_core/lib/scaffolding.dart +++ b/pkgs/test_core/lib/scaffolding.dart @@ -35,12 +35,13 @@ export 'package:test_api/scaffolding.dart' Tags, TestOn, Timeout, - spawnHybridUri, - spawnHybridCode, + addTearDown, markTestSkipped, printOnFailure, pumpEventQueue, - registerException; + registerException, + spawnHybridCode, + spawnHybridUri; /// The global declarer. /// From 5a622ef4e0dad8ab0ffd19596f9d7206b9ba59b6 Mon Sep 17 00:00:00 2001 From: Nate Bosch Date: Mon, 5 Jun 2023 18:13:10 +0000 Subject: [PATCH 3/5] Fix import for addTearDown --- 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 6e01fe831..ac2290f87 100644 --- a/pkgs/test_api/lib/src/scaffolding/spawn_hybrid.dart +++ b/pkgs/test_api/lib/src/scaffolding/spawn_hybrid.dart @@ -10,7 +10,7 @@ import 'package:stream_channel/stream_channel.dart'; import '../backend/remote_exception.dart'; import '../utils.dart'; -import 'test_structure.dart' show addTearDown; +import 'utils.dart' show addTearDown; /// A transformer that handles messages from the spawned isolate and ensures /// that messages sent to it are JSON-encodable. From 8fa3946814e18a88991e7e448ada851759f9e3f7 Mon Sep 17 00:00:00 2001 From: Nate Bosch Date: Wed, 2 Aug 2023 23:23:38 +0000 Subject: [PATCH 4/5] Fix file removal --- .../lib/src/scaffolding/test_structure.dart | 249 ------------------ 1 file changed, 249 deletions(-) delete mode 100644 pkgs/test_api/lib/src/scaffolding/test_structure.dart diff --git a/pkgs/test_api/lib/src/scaffolding/test_structure.dart b/pkgs/test_api/lib/src/scaffolding/test_structure.dart deleted file mode 100644 index 97c6d79c9..000000000 --- a/pkgs/test_api/lib/src/scaffolding/test_structure.dart +++ /dev/null @@ -1,249 +0,0 @@ -// Copyright (c) 2021, the Dart project authors. Please see the AUTHORS file -// 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 'package:meta/meta.dart'; - -import '../backend/configuration/timeout.dart'; -import '../backend/declarer.dart'; -import '../backend/invoker.dart'; - -// test_core does not support running tests directly, so the Declarer should -// always be on the Zone. -Declarer get _declarer => Zone.current[#test.declarer] as Declarer; - -// TODO(nweiz): This and other top-level functions should throw exceptions if -// they're called after the declarer has finished declaring. -/// Creates a new test case with the given description (converted to a string) -/// and body. -/// -/// The description will be added to the descriptions of any surrounding -/// [group]s. If [testOn] is passed, it's parsed as a [platform selector][]; the -/// test will only be run on matching platforms. -/// -/// [platform selector]: https://github.com/dart-lang/test/tree/master/pkgs/test#platform-selectors -/// -/// If [timeout] is passed, it's used to modify or replace the default timeout -/// of 30 seconds. Timeout modifications take precedence in suite-group-test -/// order, so [timeout] will also modify any timeouts set on the group or suite. -/// -/// If [skip] is a String or `true`, the test is skipped. If it's a String, it -/// should explain why the test is skipped; this reason will be printed instead -/// of running the test. -/// -/// If [tags] is passed, it declares user-defined tags that are applied to the -/// test. These tags can be used to select or skip the test on the command line, -/// or to do bulk test configuration. All tags should be declared in the -/// [package configuration file][configuring tags]. The parameter can be an -/// [Iterable] of tag names, or a [String] representing a single tag. -/// -/// If [retry] is passed, the test will be retried the provided number of times -/// before being marked as a failure. -/// -/// [configuring tags]: https://github.com/dart-lang/test/blob/master/pkgs/test/doc/configuration.md#configuring-tags -/// -/// [onPlatform] allows tests to be configured on a platform-by-platform -/// basis. It's a map from strings that are parsed as [PlatformSelector]s to -/// annotation classes: [Timeout], [Skip], or lists of those. These -/// annotations apply only on the given platforms. For example: -/// -/// test('potentially slow test', () { -/// // ... -/// }, onPlatform: { -/// // This test is especially slow on Windows. -/// 'windows': Timeout.factor(2), -/// 'browser': [ -/// Skip('TODO: add browser support'), -/// // This will be slow on browsers once it works on them. -/// Timeout.factor(2) -/// ] -/// }); -/// -/// If multiple platforms match, the annotations apply in order as through -/// they were in nested groups. -/// -/// If the `solo` flag is `true`, only tests and groups marked as -/// "solo" will be be run. This only restricts tests *within this test -/// suite*—tests in other suites will run as normal. We recommend that users -/// avoid this flag if possible and instead use the test runner flag `-n` to -/// filter tests by name. -@isTest -void test(Object? description, dynamic Function() body, - {String? testOn, - Timeout? timeout, - Object? skip, - Object? tags, - Map? onPlatform, - int? retry, - @Deprecated('Debug only') bool solo = false}) { - _declarer.test(description.toString(), body, - testOn: testOn, - timeout: timeout, - skip: skip, - onPlatform: onPlatform, - tags: tags, - retry: retry, - solo: solo); - - // Force dart2js not to inline this function. We need it to be separate from - // `main()` in JS stack traces in order to properly determine the line and - // column where the test was defined. See sdk#26705. - return; - return; // ignore: dead_code -} - -/// Creates a group of tests. -/// -/// A group's description (converted to a string) is included in the descriptions -/// of any tests or sub-groups it contains. [setUp] and [tearDown] are also scoped -/// to the containing group. -/// -/// If [testOn] is passed, it's parsed as a [platform selector][]; the test will -/// only be run on matching platforms. -/// -/// [platform selector]: https://github.com/dart-lang/test/tree/master/pkgs/test#platform-selectors -/// -/// If [timeout] is passed, it's used to modify or replace the default timeout -/// of 30 seconds. Timeout modifications take precedence in suite-group-test -/// order, so [timeout] will also modify any timeouts set on the suite, and will -/// be modified by any timeouts set on individual tests. -/// -/// If [skip] is a String or `true`, the group is skipped. If it's a String, it -/// should explain why the group is skipped; this reason will be printed instead -/// of running the group's tests. -/// -/// If [tags] is passed, it declares user-defined tags that are applied to the -/// test. These tags can be used to select or skip the test on the command line, -/// or to do bulk test configuration. All tags should be declared in the -/// [package configuration file][configuring tags]. The parameter can be an -/// [Iterable] of tag names, or a [String] representing a single tag. -/// -/// [configuring tags]: https://github.com/dart-lang/test/blob/master/pkgs/test/doc/configuration.md#configuring-tags -/// -/// [onPlatform] allows groups to be configured on a platform-by-platform -/// basis. It's a map from strings that are parsed as [PlatformSelector]s to -/// annotation classes: [Timeout], [Skip], or lists of those. These -/// annotations apply only on the given platforms. For example: -/// -/// group('potentially slow tests', () { -/// // ... -/// }, onPlatform: { -/// // These tests are especially slow on Windows. -/// 'windows': Timeout.factor(2), -/// 'browser': [ -/// Skip('TODO: add browser support'), -/// // They'll be slow on browsers once it works on them. -/// Timeout.factor(2) -/// ] -/// }); -/// -/// If multiple platforms match, the annotations apply in order as through -/// they were in nested groups. -/// -/// If the `solo` flag is `true`, only tests and groups marked as -/// "solo" will be be run. This only restricts tests *within this test -/// suite*—tests in other suites will run as normal. We recommend that users -/// avoid this flag if possible, and instead use the test runner flag `-n` to -/// filter tests by name. -@isTestGroup -void group(Object? description, dynamic Function() body, - {String? testOn, - Timeout? timeout, - Object? skip, - Object? tags, - Map? onPlatform, - int? retry, - @Deprecated('Debug only') bool solo = false}) { - _declarer.group(description.toString(), body, - testOn: testOn, - timeout: timeout, - skip: skip, - tags: tags, - onPlatform: onPlatform, - retry: retry, - solo: solo); - - // Force dart2js not to inline this function. We need it to be separate from - // `main()` in JS stack traces in order to properly determine the line and - // column where the test was defined. See sdk#26705. - return; - return; // ignore: dead_code -} - -/// Registers a function to be run before tests. -/// -/// This function will be called before each test is run. [callback] may be -/// asynchronous; if so, it must return a [Future]. -/// -/// If this is called within a test group, it applies only to tests in that -/// group. [callback] will be run after any set-up callbacks in parent groups or -/// at the top level. -/// -/// Each callback at the top level or in a given group will be run in the order -/// they were declared. -void setUp(dynamic Function() callback) => _declarer.setUp(callback); - -/// Registers a function to be run after tests. -/// -/// This function will be called after each test is run. [callback] may be -/// asynchronous; if so, it must return a [Future]. -/// -/// If this is called within a test group, it applies only to tests in that -/// group. [callback] will be run before any tear-down callbacks in parent -/// groups or at the top level. -/// -/// Each callback at the top level or in a given group will be run in the -/// reverse of the order they were declared. -/// -/// See also [addTearDown], which adds tear-downs to a running test. -void tearDown(dynamic Function() callback) => _declarer.tearDown(callback); - -/// Registers a function to be run after the current test. -/// -/// This is called within a running test, and adds a tear-down only for the -/// current test. It allows testing libraries to add cleanup logic as soon as -/// there's something to clean up. -/// -/// The [callback] is run before any callbacks registered with [tearDown]. Like -/// [tearDown], the most recently registered callback is run first. -/// -/// If this is called from within a [setUpAll] or [tearDownAll] callback, it -/// instead runs the function after *all* tests in the current test suite. -void addTearDown(dynamic Function() callback) { - if (Invoker.current == null) { - throw StateError('addTearDown() may only be called within a test.'); - } - - Invoker.current!.addTearDown(callback); -} - -/// Registers a function to be run once before all tests. -/// -/// [callback] may be asynchronous; if so, it must return a [Future]. -/// -/// If this is called within a test group, [callback] will run before all tests -/// in that group. It will be run after any [setUpAll] callbacks in parent -/// groups or at the top level. It won't be run if none of the tests in the -/// group are run. -/// -/// **Note**: This function makes it very easy to accidentally introduce hidden -/// dependencies between tests that should be isolated. In general, you should -/// prefer [setUp], and only use [setUpAll] if the callback is prohibitively -/// slow. -void setUpAll(dynamic Function() callback) => _declarer.setUpAll(callback); - -/// Registers a function to be run once after all tests. -/// -/// If this is called within a test group, [callback] will run after all tests -/// in that group. It will be run before any [tearDownAll] callbacks in parent -/// groups or at the top level. It won't be run if none of the tests in the -/// group are run. -/// -/// **Note**: This function makes it very easy to accidentally introduce hidden -/// dependencies between tests that should be isolated. In general, you should -/// prefer [tearDown], and only use [tearDownAll] if the callback is -/// prohibitively slow. -void tearDownAll(dynamic Function() callback) => - _declarer.tearDownAll(callback); From 3837a29c9ade27e9e7545b6712761147e6bd5b74 Mon Sep 17 00:00:00 2001 From: Nate Bosch Date: Wed, 2 Aug 2023 23:26:21 +0000 Subject: [PATCH 5/5] Fix show ordering - bad merge? --- pkgs/test_api/lib/scaffolding.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/test_api/lib/scaffolding.dart b/pkgs/test_api/lib/scaffolding.dart index 76d4ead45..fbc016761 100644 --- a/pkgs/test_api/lib/scaffolding.dart +++ b/pkgs/test_api/lib/scaffolding.dart @@ -16,7 +16,7 @@ export 'src/backend/configuration/skip.dart' show Skip; export 'src/backend/configuration/tags.dart' show Tags; export 'src/backend/configuration/test_on.dart' show TestOn; export 'src/backend/configuration/timeout.dart' show Timeout; -export 'src/scaffolding/spawn_hybrid.dart' show spawnHybridUri, spawnHybridCode; +export 'src/scaffolding/spawn_hybrid.dart' show spawnHybridCode, spawnHybridUri; export 'src/scaffolding/utils.dart' show addTearDown,