diff --git a/CHANGELOG.md b/CHANGELOG.md index 4cada8500c4..58074e9a8f1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,6 +23,98 @@ [#54557]: https://github.com/dart-lang/sdk/issues/54557 +### Tools + +#### Dart format + +These changes are not language versioned and affect formatting all code: + +* Fix bug where some collections or arguments might split unnecessarily. + +* Don't add a blank line before a comment at the end of a compilation unit or + braced body. + +* Format extension type representation clauses the same way primary constructor + formal parameter lists are formatted: + + ```dart + // Before: + extension type JSExportedDartFunction._( + JSExportedDartFunctionRepType _jsExportedDartFunction + ) + implements JSFunction {} + + // After: + extension type JSExportedDartFunction._( + JSExportedDartFunctionRepType _jsExportedDartFunction + ) implements JSFunction {} + ``` + +* When trailing commas are preserved, don't insert a newline before the `;` in + an enum with members unless there actually is a trailing comma. + (Fix by @Barbirosha.) + +These changes are language versioned and only affect code at 3.13 or higher: + +* Support block-formatting parameter lists: + + ```dart + // Before: + typedef DataViewBuilder = + Widget Function( + BuildContext context, + PagingState state, + NextPageCallback fetchNextPage, + ); + + // After: + typedef DataViewBuilder = Widget Function( + BuildContext context, + PagingState state, + NextPageCallback fetchNextPage, + ); + ``` + +* Allow `as`, `is`, and `is!` expressions to be block formatted: + + ```dart + // Before: + variable = + function( + argument, + argument, + argument, + ) + as Type; + + // After: + variable = function( + argument, + argument, + argument, + ) as Type; + ``` + +* Force blank lines around a mixin or extension type declaration if it doesn't + have a `;` body: + + ```dart + // Before: + int above; + extension type Inches(int x) {} + mixin M {} + int below; + + // After: + int above; + + extension type Inches(int x) {} + + mixin M {} + + int below; + ``` + ## 3.12.0 **Released on:** Unreleased diff --git a/DEPS b/DEPS index 41cf4fb8b40..ae2fceaf5af 100644 --- a/DEPS +++ b/DEPS @@ -129,7 +129,7 @@ vars = { # and land the review. # # For more details, see https://github.com/dart-lang/sdk/issues/30164. - "dart_style_rev": "c9975c66895011079bb3a98dc2271f4e038d45e8", # rolled manually + "dart_style_rev": "f1d10e1e052116aeb3851f90ace55e5447b3bc21", # rolled manually ### /third_party/pkg dependencies # 'tools/rev_sdk_deps.dart' will rev pkg dependencies to their latest; put an diff --git a/pkg/test_runner/lib/src/options.dart b/pkg/test_runner/lib/src/options.dart index 6b988189615..7a2ded0999a 100644 --- a/pkg/test_runner/lib/src/options.dart +++ b/pkg/test_runner/lib/src/options.dart @@ -178,7 +178,7 @@ class OptionsParser { var allSuiteDirectories = [ ...testSuiteDirectories, - Path('tests/co19'), + SuiteDirectory('tests/co19'), ]; var selectors = []; @@ -187,7 +187,7 @@ class OptionsParser { // infer the selector from it. This lets users use tab completion on // the command line. for (var suiteDirectory in allSuiteDirectories) { - var path = suiteDirectory.toString(); + var path = suiteDirectory.directory.toString(); final separator = Platform.pathSeparator; if (separator != '/') { selector = selector.replaceAll(separator, '/'); diff --git a/pkg/test_runner/lib/src/test_configurations.dart b/pkg/test_runner/lib/src/test_configurations.dart index 2eb328947d8..a75faae19d7 100644 --- a/pkg/test_runner/lib/src/test_configurations.dart +++ b/pkg/test_runner/lib/src/test_configurations.dart @@ -28,29 +28,43 @@ export 'configuration.dart' show TestConfiguration; /// simpler to add them to test.dart. Existing test suites should be moved to /// here, if possible. final testSuiteDirectories = [ - Path('pkg'), - Path('runtime/tests/vm'), - Path('samples'), - Path('tests/corelib'), - Path('tests/dartdevc'), - Path('tests/ffi'), - Path('tests/language'), - Path('tests/macro_build'), - Path('tests/lib'), - Path('tests/standalone'), - Path('tests/web'), - Path('third_party/pkg/dart_style'), - Path('third_party/pkg/dartdoc'), - Path('third_party/pkg/native/pkgs/code_assets'), - Path('third_party/pkg/native/pkgs/data_assets'), - Path('third_party/pkg/native/pkgs/hooks_runner'), - Path('third_party/pkg/native/pkgs/hooks'), - Path('third_party/pkg/native/pkgs/native_toolchain_c'), - Path('third_party/pkg/native/pkgs/record_use'), - Path('third_party/pkg/package_config'), - Path('utils/tests/peg'), + SuiteDirectory('pkg'), + SuiteDirectory('runtime/tests/vm'), + SuiteDirectory('samples'), + SuiteDirectory('tests/corelib'), + SuiteDirectory('tests/dartdevc'), + SuiteDirectory('tests/ffi'), + SuiteDirectory('tests/language'), + SuiteDirectory('tests/macro_build'), + SuiteDirectory('tests/lib'), + SuiteDirectory('tests/standalone'), + SuiteDirectory('tests/web'), + SuiteDirectory('third_party/pkg/dart_style', 'test'), + SuiteDirectory('third_party/pkg/dartdoc'), + SuiteDirectory('third_party/pkg/native/pkgs/code_assets'), + SuiteDirectory('third_party/pkg/native/pkgs/data_assets'), + SuiteDirectory('third_party/pkg/native/pkgs/hooks_runner'), + SuiteDirectory('third_party/pkg/native/pkgs/hooks'), + SuiteDirectory('third_party/pkg/native/pkgs/native_toolchain_c'), + SuiteDirectory('third_party/pkg/native/pkgs/record_use'), + SuiteDirectory('third_party/pkg/package_config'), + SuiteDirectory('utils/tests/peg'), ]; +/// Describes a directory whose name defines a test suite and whose contents +/// are tests. +final class SuiteDirectory { + final Path directory; + + /// The subdirectory to look inside [directory] for tests. + /// + /// If `null`, then all tests in [directory] are found. + final String? testSubdirectory; + + SuiteDirectory(String directoryPath, [this.testSubdirectory]) + : directory = Path(directoryPath); +} + // TODO(26372): Ensure that the returned future awaits on all started tasks. Future testConfigurations(List configurations) async { var startTime = DateTime.now(); @@ -129,10 +143,15 @@ Future testConfigurations(List configurations) async { testSuites.add(PackageTestSuite(configuration, suitePath)); } else { for (var testSuiteDir in testSuiteDirectories) { - var name = testSuiteDir.filename; + var name = testSuiteDir.directory.filename; if (configuration.selectors.containsKey(name)) { - testSuites - .add(StandardTestSuite.forDirectory(configuration, testSuiteDir)); + testSuites.add( + StandardTestSuite.forDirectory( + configuration, + testSuiteDir.directory, + testSuiteDir.testSubdirectory, + ), + ); } } diff --git a/pkg/test_runner/lib/src/test_suite.dart b/pkg/test_runner/lib/src/test_suite.dart index 0a8afa06de6..e818d5d334e 100644 --- a/pkg/test_runner/lib/src/test_suite.dart +++ b/pkg/test_runner/lib/src/test_suite.dart @@ -619,9 +619,14 @@ class StandardTestSuite extends TestSuite { /// instead of having to create a custom [StandardTestSuite] subclass. In /// particular, if you add 'path/to/mytestsuite' to `testSuiteDirectories` /// in test.dart, this will all be set up for you. - factory StandardTestSuite.forDirectory( - TestConfiguration configuration, Path directory) { + /// + /// If [testSubdirectory] is given, then tests are only searched for inside + /// that subdirectory of [directory]. Otherwise, tests will be found anywhere + /// in [directory]. + factory StandardTestSuite.forDirectory(TestConfiguration configuration, + Path directory, String? testSubdirectory) { var name = directory.filename; + var statusPaths = [ '$directory/$name.status', '$directory/.status', @@ -645,6 +650,10 @@ class StandardTestSuite extends TestSuite { statusPaths = ['third_party/pkg/$name.status']; } + if (testSubdirectory != null) { + directory = directory.append(testSubdirectory); + } + return StandardTestSuite(configuration, name, directory, statusPaths, recursive: true); }