From f4f6d5d53bb5b5a15a7acf3ed5c104074a90387f Mon Sep 17 00:00:00 2001 From: Rob Becker Date: Sun, 15 Feb 2026 18:05:19 -0700 Subject: [PATCH 01/21] Allow analyzer 10 --- example/project/pubspec.yaml | 2 +- lib/src/builder.dart | 7 +++++-- pubspec.yaml | 8 ++++---- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/example/project/pubspec.yaml b/example/project/pubspec.yaml index 324c8f2..78a0d89 100644 --- a/example/project/pubspec.yaml +++ b/example/project/pubspec.yaml @@ -7,7 +7,7 @@ environment: dev_dependencies: build_runner: ^2.1.2 - build_test: ^2.1.3 + build_test: '>=2.1.3 <4.0.0' build_web_compilers: '>=3.0.0 <5.0.0' test: ^1.17.12 test_html_builder: diff --git a/lib/src/builder.dart b/lib/src/builder.dart index 99e05a3..646fbf5 100644 --- a/lib/src/builder.dart +++ b/lib/src/builder.dart @@ -14,12 +14,14 @@ import 'dart:async'; import 'dart:convert'; +import 'dart:io'; import 'dart:math'; import 'package:build/build.dart'; import 'package:dart_style/dart_style.dart'; import 'package:glob/glob.dart'; import 'package:path/path.dart' as p; +import 'package:pub_semver/pub_semver.dart'; // This import is deprecated to discourage its use, but the build_test package // uses it for the same reason we're using it here. So if they choose to get rid // of this import, they'll presumably have a plan for a different way to @@ -156,8 +158,9 @@ class AggregateTestBuilder extends Builder { // sort the imports. mains.sort(); } - - final contents = DartFormatter().format('''@TestOn('browser') +final globalLanguageVersion = + Version.parse(Platform.version.split(' ').first); + final contents = DartFormatter(languageVersion: globalLanguageVersion).format('''@TestOn('browser') import 'package:test/test.dart'; ${imports.join('\n')} diff --git a/pubspec.yaml b/pubspec.yaml index da7821b..55e0a9e 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -14,8 +14,8 @@ executables: dependencies: args: ^2.3.0 - build: ^2.1.0 - dart_style: ^2.1.1 + build: '>=2.1.0 <5.0.0' + dart_style: '>=2.1.1 <5.0.0' glob: ^2.0.1 json_annotation: ^4.1.0 path: ^1.8.0 @@ -25,9 +25,9 @@ dependencies: dev_dependencies: build_runner: ^2.1.2 - build_test: ^2.1.3 + build_test: '>=2.1.3 <4.0.0' build_web_compilers: '>=3.0.0 <5.0.0' - dependency_validator: ^3.1.0 + dependency_validator: '>=3.1.0 <6.0.0' test_descriptor: ^2.0.0 test_process: ^2.0.2 workiva_analysis_options: ^1.4.1 From b75c3ee0db0f5de3c3ee6b3e6bb40c4d1934b4b1 Mon Sep 17 00:00:00 2001 From: Rob Becker Date: Sun, 15 Feb 2026 19:25:08 -0700 Subject: [PATCH 02/21] fix depval --- pubspec.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pubspec.yaml b/pubspec.yaml index 55e0a9e..8381aff 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -19,7 +19,7 @@ dependencies: glob: ^2.0.1 json_annotation: ^4.1.0 path: ^1.8.0 - test: ^1.17.12 + pub_semver: ^2.0.0 test_core: ">=0.4.2 <0.7.0" yaml: ^3.1.0 @@ -28,6 +28,7 @@ dev_dependencies: build_test: '>=2.1.3 <4.0.0' build_web_compilers: '>=3.0.0 <5.0.0' dependency_validator: '>=3.1.0 <6.0.0' + test: ^1.17.12 test_descriptor: ^2.0.0 test_process: ^2.0.2 workiva_analysis_options: ^1.4.1 From 524b78ea8a7934cdae800b25c6f84f389811bc82 Mon Sep 17 00:00:00 2001 From: Rob Becker Date: Sun, 15 Feb 2026 19:28:52 -0700 Subject: [PATCH 03/21] Dart 3 only --- .github/workflows/dart_ci.yaml | 4 ++-- lib/src/builder.dart | 5 +++-- pubspec.yaml | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/.github/workflows/dart_ci.yaml b/.github/workflows/dart_ci.yaml index f22689a..1345522 100644 --- a/.github/workflows/dart_ci.yaml +++ b/.github/workflows/dart_ci.yaml @@ -18,14 +18,14 @@ jobs: - uses: actions/checkout@v4 - uses: dart-lang/setup-dart@v1 with: - sdk: 2.19.6 + sdk: stable - run: dart format --set-exit-if-changed -o none . test: runs-on: ubuntu-latest strategy: fail-fast: false matrix: - sdk: [ 2.19.6, stable, beta ] + sdk: [ stable ] steps: - uses: actions/checkout@v4 - uses: dart-lang/setup-dart@v1 diff --git a/lib/src/builder.dart b/lib/src/builder.dart index 646fbf5..45d2e13 100644 --- a/lib/src/builder.dart +++ b/lib/src/builder.dart @@ -158,9 +158,10 @@ class AggregateTestBuilder extends Builder { // sort the imports. mains.sort(); } -final globalLanguageVersion = + final globalLanguageVersion = Version.parse(Platform.version.split(' ').first); - final contents = DartFormatter(languageVersion: globalLanguageVersion).format('''@TestOn('browser') + final contents = DartFormatter(languageVersion: globalLanguageVersion) + .format('''@TestOn('browser') import 'package:test/test.dart'; ${imports.join('\n')} diff --git a/pubspec.yaml b/pubspec.yaml index 8381aff..8c255a8 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -7,7 +7,7 @@ description: > environment: - sdk: '>=2.12.0 <4.0.0' + sdk: '>=3.0.0 <4.0.0' executables: browser_aggregate_tests: From 7e1b3ce3c6d9951d319fd539b664b8c916ad2a5c Mon Sep 17 00:00:00 2001 From: Rob Becker Date: Sun, 15 Feb 2026 19:29:55 -0700 Subject: [PATCH 04/21] more dart 3 only fixes --- .github/workflows/dart_ci.yaml | 2 +- example/project/pubspec.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/dart_ci.yaml b/.github/workflows/dart_ci.yaml index 1345522..02bdea1 100644 --- a/.github/workflows/dart_ci.yaml +++ b/.github/workflows/dart_ci.yaml @@ -46,7 +46,7 @@ jobs: strategy: fail-fast: false matrix: - sdk: [ 2.19.6, stable, beta ] + sdk: [ stable ] steps: - uses: actions/checkout@v4 - uses: dart-lang/setup-dart@v1 diff --git a/example/project/pubspec.yaml b/example/project/pubspec.yaml index 78a0d89..a0acb38 100644 --- a/example/project/pubspec.yaml +++ b/example/project/pubspec.yaml @@ -3,7 +3,7 @@ version: 0.0.0 publish_to: none environment: - sdk: '>=2.19.0 <3.0.0' + sdk: '>=3.0.0 <4.0.0' dev_dependencies: build_runner: ^2.1.2 From d1a9e96aed365d7ab74c138972831aea6ef6dd61 Mon Sep 17 00:00:00 2001 From: Rob Becker Date: Sun, 15 Feb 2026 19:36:14 -0700 Subject: [PATCH 05/21] format w 3.11 --- .github/workflows/dart_ci.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/dart_ci.yaml b/.github/workflows/dart_ci.yaml index 02bdea1..939c1e6 100644 --- a/.github/workflows/dart_ci.yaml +++ b/.github/workflows/dart_ci.yaml @@ -18,7 +18,7 @@ jobs: - uses: actions/checkout@v4 - uses: dart-lang/setup-dart@v1 with: - sdk: stable + sdk: 3.11.0 - run: dart format --set-exit-if-changed -o none . test: runs-on: ubuntu-latest From 79169cfda72ab88d35ca53e78ef386acf8957e22 Mon Sep 17 00:00:00 2001 From: Rob Becker Date: Sun, 15 Feb 2026 19:44:16 -0700 Subject: [PATCH 06/21] preserve commas --- analysis_options.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/analysis_options.yaml b/analysis_options.yaml index bccca15..66e4bb4 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -3,6 +3,6 @@ analyzer: exclude: - example/** - lib/**.g.dart - language: - strict-inference: true - strict-raw-types: true + +formatter: + trailing_commas: preserve From ef4bf3f3cf40bdd4c2cd2ddff72b97df2cb94688 Mon Sep 17 00:00:00 2001 From: Rob Becker Date: Sun, 15 Feb 2026 19:45:24 -0700 Subject: [PATCH 07/21] dart format --- bin/browser_aggregate_tests.dart | 132 +++++++----- lib/src/builder.dart | 116 +++++++---- lib/src/config.dart | 36 ++-- lib/src/config.g.dart | 71 ++++--- pubspec.yaml | 2 +- test/bin/browser_aggregate_tests_test.dart | 216 ++++++++++++-------- test/lib/aggregate_test_builder_test.dart | 226 ++++++++++++--------- test/lib/config_test.dart | 36 ++-- test/lib/dart_test_yaml_builder_test.dart | 34 ++-- test/lib/template_builder_test.dart | 193 +++++++++++------- test/lib/test_html_builder_test.dart | 24 ++- 11 files changed, 654 insertions(+), 432 deletions(-) diff --git a/bin/browser_aggregate_tests.dart b/bin/browser_aggregate_tests.dart index bae3ed1..64680a4 100644 --- a/bin/browser_aggregate_tests.dart +++ b/bin/browser_aggregate_tests.dart @@ -8,22 +8,30 @@ const testPreset = '--preset=browser-aggregate'; final argParser = ArgParser() ..addFlag('help', abbr: 'h') - ..addFlag('release', - defaultsTo: false, help: 'Build in release mode (dart2js).') - ..addOption('mode', - allowed: ['args', 'build', 'test'], - allowedHelp: { - 'args': - 'Print to stderr the build and test args needed to run browser aggregate tests.\n' - 'Useful for integrating this into other test runners.', - 'build': 'Build the browser aggregate tests.', - 'test': 'Build and run browser aggregate tests.', - }, - defaultsTo: 'test') - ..addOption('build-args', - help: 'Args to pass to the build runner process.\n' - 'Run "dart run build_runner build -h -v" to see all available ' - 'options.'); + ..addFlag( + 'release', + defaultsTo: false, + help: 'Build in release mode (dart2js).', + ) + ..addOption( + 'mode', + allowed: ['args', 'build', 'test'], + allowedHelp: { + 'args': + 'Print to stderr the build and test args needed to run browser aggregate tests.\n' + 'Useful for integrating this into other test runners.', + 'build': 'Build the browser aggregate tests.', + 'test': 'Build and run browser aggregate tests.', + }, + defaultsTo: 'test', + ) + ..addOption( + 'build-args', + help: + 'Args to pass to the build runner process.\n' + 'Run "dart run build_runner build -h -v" to see all available ' + 'options.', + ); enum Mode { // Print build and test args separated by `--` @@ -95,13 +103,15 @@ void buildAggregateTestYaml(Mode mode, {String? userBuildArgs}) { // Users may also supply additional build arguments. For example, some // repos may need to specify a custom build.yaml file to be used. ...?userBuildArgs?.split(' '), - '--build-filter=dart_test.browser_aggregate.yaml' + '--build-filter=dart_test.browser_aggregate.yaml', ]; logIf(mode != Mode.args, 'Building browser aggregate test config...'); logIf(mode != Mode.args, '$executable ${args.join(' ')}'); var result = Process.runSync(executable, args); - logIf(result.exitCode != 0 || mode != Mode.args, - '${result.stderr}\n${result.stdout}'); + logIf( + result.exitCode != 0 || mode != Mode.args, + '${result.stderr}\n${result.stdout}', + ); if (result.exitCode != 0) { exit(result.exitCode); } @@ -116,8 +126,8 @@ List parseAggregateTestPaths(Mode mode) { logIf(mode != Mode.args, '\nReading browser aggregate test config...'); final configFile = File('dart_test.browser_aggregate.yaml'); if (!configFile.existsSync()) { - stdout - .writeln(r'''browser aggregation is not enabled. Update your build.yaml: + stdout.writeln( + r'''browser aggregation is not enabled. Update your build.yaml: # build.yaml targets: @@ -125,12 +135,15 @@ targets: builders: test_html_builder: options: - browser_aggregation: true'''); + browser_aggregation: true''', + ); exit(1); } - final config = - loadYaml(configFile.readAsStringSync(), sourceUrl: configFile.uri); + final config = loadYaml( + configFile.readAsStringSync(), + sourceUrl: configFile.uri, + ); late List paths; try { paths = List.from(config['presets']['browser-aggregate']['paths']); @@ -152,50 +165,66 @@ targets: /// /// [userBuildArgs] is interpreted as a space delimited string of additional /// build_runner build arguments and will also be included. -List buildRunnerBuildArgs(List testPaths, - {bool? release, String? userBuildArgs}) => - [ - ...?userBuildArgs?.split(' '), - if (release ?? false) '--release', - for (final path in testPaths) - '--build-filter=${p.setExtension(path, '.**')}', - ]; +List buildRunnerBuildArgs( + List testPaths, { + bool? release, + String? userBuildArgs, +}) => [ + ...?userBuildArgs?.split(' '), + if (release ?? false) '--release', + for (final path in testPaths) '--build-filter=${p.setExtension(path, '.**')}', +]; /// Builds aggregate tests at [testPaths]. /// /// Includes `--release` if [release] is true. -Future buildTests(List testPaths, - {bool? release, String? userBuildArgs}) async { +Future buildTests( + List testPaths, { + bool? release, + String? userBuildArgs, +}) async { final executable = 'dart'; final args = [ 'run', 'build_runner', 'build', '--delete-conflicting-outputs', - ...buildRunnerBuildArgs(testPaths, - release: release, userBuildArgs: userBuildArgs), + ...buildRunnerBuildArgs( + testPaths, + release: release, + userBuildArgs: userBuildArgs, + ), ]; stdout ..writeln() ..writeln('Building browser aggregate tests...') ..writeln('$executable ${args.join(' ')}'); - final process = await Process.start(executable, args, - mode: ProcessStartMode.inheritStdio); + final process = await Process.start( + executable, + args, + mode: ProcessStartMode.inheritStdio, + ); exitCode = await process.exitCode; } /// Builds and runs aggregate tests at [testPaths]. /// /// Includes `--release` if [release] is true. -Future runTests(List testPaths, - {bool? release, String? userBuildArgs}) async { +Future runTests( + List testPaths, { + bool? release, + String? userBuildArgs, +}) async { final executable = 'dart'; final args = [ 'run', 'build_runner', 'test', - ...buildRunnerBuildArgs(testPaths, - release: release, userBuildArgs: userBuildArgs), + ...buildRunnerBuildArgs( + testPaths, + release: release, + userBuildArgs: userBuildArgs, + ), '--', testPreset, ]; @@ -203,17 +232,22 @@ Future runTests(List testPaths, ..writeln() ..writeln('Running browser aggregate tests...') ..writeln('$executable ${args.join(' ')}'); - final process = await Process.start(executable, args, - mode: ProcessStartMode.inheritStdio); + final process = await Process.start( + executable, + args, + mode: ProcessStartMode.inheritStdio, + ); exitCode = await process.exitCode; } /// Prints the build and test args separated by `--` needed to build or run the /// browser aggregate tests. void printArgs(List testPaths) { - stdout.write([ - ...buildRunnerBuildArgs(testPaths), - '--', - testPreset, - ].join(' ')); + stdout.write( + [ + ...buildRunnerBuildArgs(testPaths), + '--', + testPreset, + ].join(' '), + ); } diff --git a/lib/src/builder.dart b/lib/src/builder.dart index 45d2e13..58336dc 100644 --- a/lib/src/builder.dart +++ b/lib/src/builder.dart @@ -42,7 +42,7 @@ class TestHtmlBuilder implements Builder { r'$package$': [ 'test/templates/default_template.html', 'test/test_html_builder_config.json', - ] + ], }; @override @@ -50,7 +50,9 @@ class TestHtmlBuilder implements Builder { // Write the default template for any browser tests that don't match one of // the templates defined in the project's config. final defaultTemplateId = AssetId( - buildStep.inputId.package, 'test/templates/default_template.html'); + buildStep.inputId.package, + 'test/templates/default_template.html', + ); await buildStep.writeAsString(defaultTemplateId, ''' @@ -63,7 +65,9 @@ class TestHtmlBuilder implements Builder { // Write the builder options so they can be used by the builders below. final configId = AssetId( - buildStep.inputId.package, 'test/test_html_builder_config.json'); + buildStep.inputId.package, + 'test/test_html_builder_config.json', + ); await buildStep.writeAsString(configId, json.encode(_config)); } } @@ -81,7 +85,8 @@ class AggregateTestBuilder extends Builder { log.fine('browser aggregation disabled'); if (config.randomizeOrderingSeed != null) { log.warning( - '`randomize_ordering_seed` option is set, but `browser_aggregation` is not enabled so it has no effect.'); + '`randomize_ordering_seed` option is set, but `browser_aggregation` is not enabled so it has no effect.', + ); } return; } @@ -92,7 +97,8 @@ class AggregateTestBuilder extends Builder { ? [Glob('test/**_test.dart')] : config.templateGlobs[templatePath] ?? []; log.fine( - 'Test globs found for template: ${buildStep.inputId}:\n${testGlobs.join('\n')}'); + 'Test globs found for template: ${buildStep.inputId}:\n${testGlobs.join('\n')}', + ); final higherPrecedenceGlobs = []; if (isDefault) { @@ -116,14 +122,18 @@ class AggregateTestBuilder extends Builder { // then it will be included in that aggregate test. if (higherPrecedenceGlobs.any((g) => g.matches(id.path))) continue; - final hasCustomHtml = - await buildStep.canRead(id.changeExtension('.custom.html')); + final hasCustomHtml = await buildStep.canRead( + id.changeExtension('.custom.html'), + ); if (hasCustomHtml) continue; Metadata testMetadata; try { testMetadata = parseMetadata( - id.path, await buildStep.readAsString(id), _platformVariables); + id.path, + await buildStep.readAsString(id), + _platformVariables, + ); } catch (e, stack) { log.severe('Error parsing test metadata: ${id.path}', e, stack); continue; @@ -132,8 +142,10 @@ class AggregateTestBuilder extends Builder { if (!_isBrowserTest(testMetadata)) continue; final prefix = _importPrefixForTest(id.path); - final path = - p.relative(id.path, from: p.dirname(buildStep.inputId.path)); + final path = p.relative( + id.path, + from: p.dirname(buildStep.inputId.path), + ); imports.add("import '$path' as $prefix;"); mains.add(" $prefix.main();"); } @@ -151,15 +163,18 @@ class AggregateTestBuilder extends Builder { if (seed != null) { log.info('Shuffling test order with `randomize_ordering_seed: $seed`\n'); mains.shuffle(Random(seed)); - mains.insert(0, - "print('${buildStep.inputId.path} built with `randomize_ordering_seed: \"$seed\"`');"); + mains.insert( + 0, + "print('${buildStep.inputId.path} built with `randomize_ordering_seed: \"$seed\"`');", + ); } else { // If the test order was not shuffled, sort them for the same reason we // sort the imports. mains.sort(); } - final globalLanguageVersion = - Version.parse(Platform.version.split(' ').first); + final globalLanguageVersion = Version.parse( + Platform.version.split(' ').first, + ); final contents = DartFormatter(languageVersion: globalLanguageVersion) .format('''@TestOn('browser') import 'package:test/test.dart'; @@ -171,18 +186,19 @@ ${mains.join('\n')} } '''); - final outputId = - buildStep.inputId.changeExtension('.browser_aggregate_test.dart'); + final outputId = buildStep.inputId.changeExtension( + '.browser_aggregate_test.dart', + ); await buildStep.writeAsString(outputId, contents); } final _browserRuntimes = Runtime.builtIn.where((r) => r.isBrowser == true); Set get _platformVariables => [ - Runtime.vm, - Runtime.nodeJS, - ..._browserRuntimes, - ].map((r) => r.identifier).toSet(); + Runtime.vm, + Runtime.nodeJS, + ..._browserRuntimes, + ].map((r) => r.identifier).toSet(); String _importPrefixForTest(String path) { // Remove `test/` segment. @@ -192,8 +208,9 @@ ${mains.join('\n')} return result.replaceAll(p.separator, '_').replaceAll('.', '_'); } - bool _isBrowserTest(Metadata testMetadata) => _browserRuntimes - .any((r) => testMetadata.testOn.evaluate(SuitePlatform(r))); + bool _isBrowserTest(Metadata testMetadata) => _browserRuntimes.any( + (r) => testMetadata.testOn.evaluate(SuitePlatform(r)), + ); Future _getConfig(BuildStep buildStep) async => __config ??= await decodeConfig(buildStep); @@ -235,10 +252,14 @@ class TemplateBuilder implements Builder { static AssetId getHtmlId(AssetId assetId) => assetId.changeExtension('.html'); AssetId? getTemplateId( - Map> templates, AssetId assetId) { + Map> templates, + AssetId assetId, + ) { if (assetId.path.endsWith('.browser_aggregate_test.dart')) { - return AssetId(assetId.package, - assetId.path.replaceFirst('.browser_aggregate_test.dart', '.html')); + return AssetId( + assetId.package, + assetId.path.replaceFirst('.browser_aggregate_test.dart', '.html'), + ); } for (final templatePath in templates.keys) { @@ -258,7 +279,9 @@ class TemplateBuilder implements Builder { if (await buildStep.canRead(customHtmlId)) { log.fine('Custom html found for ${buildStep.inputId.path}'); await buildStep.writeAsBytes( - htmlId, await buildStep.readAsBytes(customHtmlId)); + htmlId, + await buildStep.readAsBytes(customHtmlId), + ); return; } @@ -273,11 +296,13 @@ class TemplateBuilder implements Builder { } log.fine( - 'Generating html for ${buildStep.inputId.path} from template at ${templateId.path}'); + 'Generating html for ${buildStep.inputId.path} from template at ${templateId.path}', + ); var htmlContents = await buildStep.readAsString(templateId); if ('{{testScript}}'.allMatches(htmlContents).length != 1) { log.severe( - 'Test html template must contain exactly one `{{testScript}}` placeholder: ${templateId.path}'); + 'Test html template must contain exactly one `{{testScript}}` placeholder: ${templateId.path}', + ); return; } @@ -313,39 +338,50 @@ class DartTestYamlBuilder extends Builder { } log.fine('Building dart_test.browser_aggregate.yaml'); - final contents = StringBuffer()..writeln('''presets: + final contents = StringBuffer() + ..writeln('''presets: browser-aggregate: platforms: [chrome] paths:'''); - final aggregateTests = buildStep - .findAssets(Glob('test/**_template.browser_aggregate_test.dart')); + final aggregateTests = buildStep.findAssets( + Glob('test/**_template.browser_aggregate_test.dart'), + ); await for (final testId in aggregateTests) { log.fine('Found aggregate test: ${testId.path}'); contents.writeln(' - ${testId.path}'); } - await for (final customHtml - in buildStep.findAssets(Glob('test/**_test.custom.html'))) { + await for (final customHtml in buildStep.findAssets( + Glob('test/**_test.custom.html'), + )) { log.fine('Found custom HTML test: ${customHtml.path}'); - final customTestPath = - customHtml.path.replaceFirst('_test.custom.html', '_test.dart'); + final customTestPath = customHtml.path.replaceFirst( + '_test.custom.html', + '_test.dart', + ); contents.writeln(' - $customTestPath'); } - final outputId = - AssetId(buildStep.inputId.package, 'dart_test.browser_aggregate.yaml'); + final outputId = AssetId( + buildStep.inputId.package, + 'dart_test.browser_aggregate.yaml', + ); await buildStep.writeAsString(outputId, contents.toString()); final backwardsCompatOutputId = AssetId( - buildStep.inputId.package, 'test/dart_test.browser_aggregate.yaml'); + buildStep.inputId.package, + 'test/dart_test.browser_aggregate.yaml', + ); await buildStep.writeAsString(backwardsCompatOutputId, contents.toString()); } } Future decodeConfig(BuildStep buildStep) async { - final id = - AssetId(buildStep.inputId.package, 'test/test_html_builder_config.json'); + final id = AssetId( + buildStep.inputId.package, + 'test/test_html_builder_config.json', + ); final contents = await buildStep.readAsString(id); return TestHtmlBuilderConfig.fromJson(json.decode(contents)); } diff --git a/lib/src/config.dart b/lib/src/config.dart index a4d725d..cc22ee7 100644 --- a/lib/src/config.dart +++ b/lib/src/config.dart @@ -24,25 +24,28 @@ import 'package:json_annotation/json_annotation.dart'; part 'config.g.dart'; @JsonSerializable( - anyMap: true, - checked: true, - disallowUnrecognizedKeys: true, - fieldRename: FieldRename.snake) + anyMap: true, + checked: true, + disallowUnrecognizedKeys: true, + fieldRename: FieldRename.snake, +) class TestHtmlBuilderConfig { - TestHtmlBuilderConfig( - {bool? browserAggregation, - String? randomizeOrderingSeed, - Map>? templates}) - : browserAggregation = browserAggregation ?? false, - randomizeOrderingSeed = randomizeOrderingSeed, - templates = templates ?? {}; + TestHtmlBuilderConfig({ + bool? browserAggregation, + String? randomizeOrderingSeed, + Map>? templates, + }) : browserAggregation = browserAggregation ?? false, + randomizeOrderingSeed = randomizeOrderingSeed, + templates = templates ?? {}; factory TestHtmlBuilderConfig.fromBuilderOptions(BuilderOptions options) { final config = TestHtmlBuilderConfig.fromJson(options.config); for (final path in config.templates.keys) { if (!path.startsWith('./test/') && !path.startsWith('test/')) { - throw StateError('Invalid template path: $path\n' - 'Every test html template must be located in the `test/` directory.'); + throw StateError( + 'Invalid template path: $path\n' + 'Every test html template must be located in the `test/` directory.', + ); } } return config; @@ -53,7 +56,7 @@ class TestHtmlBuilderConfig { return _$TestHtmlBuilderConfigFromJson(json); } on CheckedFromJsonException catch (e) { final lines = [ - 'Could not parse the options provided for `test_html_builder`.' + 'Could not parse the options provided for `test_html_builder`.', ]; final key = e.key; @@ -81,8 +84,9 @@ class TestHtmlBuilderConfig { final Map> templates; late final Map> templateGlobs = templates.map( - (key, globPatterns) => - MapEntry(key, globPatterns.map((pattern) => Glob(pattern)))); + (key, globPatterns) => + MapEntry(key, globPatterns.map((pattern) => Glob(pattern))), + ); Map toJson() => _$TestHtmlBuilderConfigToJson(this); } diff --git a/lib/src/config.g.dart b/lib/src/config.g.dart index 2c4151f..e25ce89 100644 --- a/lib/src/config.g.dart +++ b/lib/src/config.g.dart @@ -7,36 +7,53 @@ part of lib.src.config; // ************************************************************************** TestHtmlBuilderConfig _$TestHtmlBuilderConfigFromJson(Map json) { - return $checkedNew('TestHtmlBuilderConfig', json, () { - $checkKeys(json, allowedKeys: const [ - 'browser_aggregation', - 'randomize_ordering_seed', - 'templates' - ]); - final val = TestHtmlBuilderConfig( - browserAggregation: - $checkedConvert(json, 'browser_aggregation', (v) => v as bool?), - randomizeOrderingSeed: - $checkedConvert(json, 'randomize_ordering_seed', (v) => v as String?), - templates: $checkedConvert( + return $checkedNew( + 'TestHtmlBuilderConfig', + json, + () { + $checkKeys( + json, + allowedKeys: const [ + 'browser_aggregation', + 'randomize_ordering_seed', + 'templates', + ], + ); + final val = TestHtmlBuilderConfig( + browserAggregation: $checkedConvert( + json, + 'browser_aggregation', + (v) => v as bool?, + ), + randomizeOrderingSeed: $checkedConvert( + json, + 'randomize_ordering_seed', + (v) => v as String?, + ), + templates: $checkedConvert( json, 'templates', (v) => (v as Map?)?.map( - (k, e) => MapEntry(k as String, - (e as List).map((e) => e as String).toList()), - )), - ); - return val; - }, fieldKeyMap: const { - 'browserAggregation': 'browser_aggregation', - 'randomizeOrderingSeed': 'randomize_ordering_seed' - }); + (k, e) => MapEntry( + k as String, + (e as List).map((e) => e as String).toList(), + ), + ), + ), + ); + return val; + }, + fieldKeyMap: const { + 'browserAggregation': 'browser_aggregation', + 'randomizeOrderingSeed': 'randomize_ordering_seed', + }, + ); } Map _$TestHtmlBuilderConfigToJson( - TestHtmlBuilderConfig instance) => - { - 'browser_aggregation': instance.browserAggregation, - 'randomize_ordering_seed': instance.randomizeOrderingSeed, - 'templates': instance.templates, - }; + TestHtmlBuilderConfig instance, +) => { + 'browser_aggregation': instance.browserAggregation, + 'randomize_ordering_seed': instance.randomizeOrderingSeed, + 'templates': instance.templates, +}; diff --git a/pubspec.yaml b/pubspec.yaml index 8c255a8..aefd7db 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -7,7 +7,7 @@ description: > environment: - sdk: '>=3.0.0 <4.0.0' + sdk: '>=3.11.0 <4.0.0' executables: browser_aggregate_tests: diff --git a/test/bin/browser_aggregate_tests_test.dart b/test/bin/browser_aggregate_tests_test.dart index 4abcd9d..e9e1a6f 100644 --- a/test/bin/browser_aggregate_tests_test.dart +++ b/test/bin/browser_aggregate_tests_test.dart @@ -6,8 +6,10 @@ import 'package:test_descriptor/test_descriptor.dart' as d; import 'package:test_process/test_process.dart'; void main() { - Future createProject( - {bool? browserAggregation, bool? customBuildYaml}) async { + Future createProject({ + bool? browserAggregation, + bool? customBuildYaml, + }) async { browserAggregation ??= true; customBuildYaml ??= false; await d.dir('pkg', [ @@ -44,137 +46,173 @@ void main() { return d.path('pkg'); } - Future testBrowserAggregateExecutable(List args, - {String? workingDirectory}) async { - final pubGet = await TestProcess.start('dart', ['pub', 'get'], - workingDirectory: workingDirectory); + Future testBrowserAggregateExecutable( + List args, { + String? workingDirectory, + }) async { + final pubGet = await TestProcess.start('dart', [ + 'pub', + 'get', + ], workingDirectory: workingDirectory); await pubGet.shouldExit(0); - return TestProcess.start( - 'dart', ['run', 'test_html_builder:browser_aggregate_tests', ...args], - workingDirectory: workingDirectory); + return TestProcess.start('dart', [ + 'run', + 'test_html_builder:browser_aggregate_tests', + ...args, + ], workingDirectory: workingDirectory); } test('--mode=args', () async { final dir = await createProject(); - final process = await testBrowserAggregateExecutable(['--mode=args'], - workingDirectory: dir); + final process = await testBrowserAggregateExecutable([ + '--mode=args', + ], workingDirectory: dir); expect( - process.stdout, - emitsInOrder([ - '--build-filter=test/templates/default_template.browser_aggregate_test.** -- --preset=browser-aggregate', - emitsDone - ])); + process.stdout, + emitsInOrder([ + '--build-filter=test/templates/default_template.browser_aggregate_test.** -- --preset=browser-aggregate', + emitsDone, + ]), + ); await process.shouldExit(0); }); test('--mode=args --release --build-args="-c custom"', () async { final dir = await createProject(customBuildYaml: true); - final process = await testBrowserAggregateExecutable( - ['--mode=args', '--release', '--build-args', '-c custom'], - workingDirectory: dir); + final process = await testBrowserAggregateExecutable([ + '--mode=args', + '--release', + '--build-args', + '-c custom', + ], workingDirectory: dir); expect( - process.stdout, - emitsInOrder([ - '--build-filter=test/templates/default_template.browser_aggregate_test.** -- --preset=browser-aggregate', - emitsDone - ])); + process.stdout, + emitsInOrder([ + '--build-filter=test/templates/default_template.browser_aggregate_test.** -- --preset=browser-aggregate', + emitsDone, + ]), + ); await process.shouldExit(0); }); test('--mode=build', () async { final dir = await createProject(); - final process = await testBrowserAggregateExecutable(['--mode=build'], - workingDirectory: dir); + final process = await testBrowserAggregateExecutable([ + '--mode=build', + ], workingDirectory: dir); expect( - process.stdout, - emitsInOrder([ - emitsThrough('Building browser aggregate test config...'), - emitsThrough( - 'dart run build_runner build --delete-conflicting-outputs --build-filter=dart_test.browser_aggregate.yaml'), - emitsThrough(contains('Succeeded')), - emitsThrough('Reading browser aggregate test config...'), - emitsThrough('Found 1 aggregate tests to run.'), - emitsThrough( - 'dart run build_runner build --delete-conflicting-outputs --build-filter=test/templates/default_template.browser_aggregate_test.**'), - emitsThrough(contains('Succeeded')), - ])); + process.stdout, + emitsInOrder([ + emitsThrough('Building browser aggregate test config...'), + emitsThrough( + 'dart run build_runner build --delete-conflicting-outputs --build-filter=dart_test.browser_aggregate.yaml', + ), + emitsThrough(contains('Succeeded')), + emitsThrough('Reading browser aggregate test config...'), + emitsThrough('Found 1 aggregate tests to run.'), + emitsThrough( + 'dart run build_runner build --delete-conflicting-outputs --build-filter=test/templates/default_template.browser_aggregate_test.**', + ), + emitsThrough(contains('Succeeded')), + ]), + ); await process.shouldExit(0); }); test('--mode=build --release --build-args="-c custom"', () async { final dir = await createProject(customBuildYaml: true); - final process = await testBrowserAggregateExecutable( - ['--mode=build', '--release', '--build-args', '-c custom'], - workingDirectory: dir); + final process = await testBrowserAggregateExecutable([ + '--mode=build', + '--release', + '--build-args', + '-c custom', + ], workingDirectory: dir); expect( - process.stdout, - emitsInOrder([ - emitsThrough('Building browser aggregate test config...'), - emitsThrough( - 'dart run build_runner build --delete-conflicting-outputs -c custom --build-filter=dart_test.browser_aggregate.yaml'), - emitsThrough(contains('Succeeded')), - emitsThrough('Reading browser aggregate test config...'), - emitsThrough('Found 1 aggregate tests to run.'), - emitsThrough( - 'dart run build_runner build --delete-conflicting-outputs -c custom --release --build-filter=test/templates/default_template.browser_aggregate_test.**'), - emitsThrough(contains('Succeeded')), - ])); + process.stdout, + emitsInOrder([ + emitsThrough('Building browser aggregate test config...'), + emitsThrough( + 'dart run build_runner build --delete-conflicting-outputs -c custom --build-filter=dart_test.browser_aggregate.yaml', + ), + emitsThrough(contains('Succeeded')), + emitsThrough('Reading browser aggregate test config...'), + emitsThrough('Found 1 aggregate tests to run.'), + emitsThrough( + 'dart run build_runner build --delete-conflicting-outputs -c custom --release --build-filter=test/templates/default_template.browser_aggregate_test.**', + ), + emitsThrough(contains('Succeeded')), + ]), + ); await process.shouldExit(0); }); test('--mode=test', () async { final dir = await createProject(); // --mode=test is the default - final process = - await testBrowserAggregateExecutable([], workingDirectory: dir); + final process = await testBrowserAggregateExecutable( + [], + workingDirectory: dir, + ); expect( - process.stdout, - emitsInOrder([ - emitsThrough('Building browser aggregate test config...'), - emitsThrough( - 'dart run build_runner build --delete-conflicting-outputs --build-filter=dart_test.browser_aggregate.yaml'), - emitsThrough(contains('Succeeded')), - emitsThrough('Reading browser aggregate test config...'), - emitsThrough('Found 1 aggregate tests to run.'), - emitsThrough( - 'dart run build_runner test --build-filter=test/templates/default_template.browser_aggregate_test.** -- --preset=browser-aggregate'), - emitsThrough( - anyOf(contains('All tests passed!'), contains('1 test passed.'))), - ])); + process.stdout, + emitsInOrder([ + emitsThrough('Building browser aggregate test config...'), + emitsThrough( + 'dart run build_runner build --delete-conflicting-outputs --build-filter=dart_test.browser_aggregate.yaml', + ), + emitsThrough(contains('Succeeded')), + emitsThrough('Reading browser aggregate test config...'), + emitsThrough('Found 1 aggregate tests to run.'), + emitsThrough( + 'dart run build_runner test --build-filter=test/templates/default_template.browser_aggregate_test.** -- --preset=browser-aggregate', + ), + emitsThrough( + anyOf(contains('All tests passed!'), contains('1 test passed.')), + ), + ]), + ); await process.shouldExit(0); }); test('--mode=test --build-args="--release -c custom"', () async { final dir = await createProject(customBuildYaml: true); // --mode=test is the default - final process = await testBrowserAggregateExecutable( - ['--build-args', '--release -c custom'], - workingDirectory: dir); + final process = await testBrowserAggregateExecutable([ + '--build-args', + '--release -c custom', + ], workingDirectory: dir); expect( - process.stdout, - emitsInOrder([ - emitsThrough('Building browser aggregate test config...'), - emitsThrough( - 'dart run build_runner build --delete-conflicting-outputs --release -c custom --build-filter=dart_test.browser_aggregate.yaml'), - emitsThrough(contains('Succeeded')), - emitsThrough('Reading browser aggregate test config...'), - emitsThrough('Found 1 aggregate tests to run.'), - emitsThrough( - 'dart run build_runner test --release -c custom --build-filter=test/templates/default_template.browser_aggregate_test.** -- --preset=browser-aggregate'), - emitsThrough( - anyOf(contains('All tests passed!'), contains('1 test passed.'))), - ])); + process.stdout, + emitsInOrder([ + emitsThrough('Building browser aggregate test config...'), + emitsThrough( + 'dart run build_runner build --delete-conflicting-outputs --release -c custom --build-filter=dart_test.browser_aggregate.yaml', + ), + emitsThrough(contains('Succeeded')), + emitsThrough('Reading browser aggregate test config...'), + emitsThrough('Found 1 aggregate tests to run.'), + emitsThrough( + 'dart run build_runner test --release -c custom --build-filter=test/templates/default_template.browser_aggregate_test.** -- --preset=browser-aggregate', + ), + emitsThrough( + anyOf(contains('All tests passed!'), contains('1 test passed.')), + ), + ]), + ); await process.shouldExit(0); }); test('warns when browser aggregation is not enabled', () async { final dir = await createProject(browserAggregation: false); - final process = await testBrowserAggregateExecutable(['--mode=args'], - workingDirectory: dir); + final process = await testBrowserAggregateExecutable([ + '--mode=args', + ], workingDirectory: dir); expect( - process.stdout, - emits(contains( - 'browser aggregation is not enabled. Update your build.yaml'))); + process.stdout, + emits( + contains('browser aggregation is not enabled. Update your build.yaml'), + ), + ); await process.shouldExit(isNot(0)); }); } diff --git a/test/lib/aggregate_test_builder_test.dart b/test/lib/aggregate_test_builder_test.dart index 75b753f..489d1c7 100644 --- a/test/lib/aggregate_test_builder_test.dart +++ b/test/lib/aggregate_test_builder_test.dart @@ -9,9 +9,11 @@ import 'package:test_html_builder/src/config.dart'; void main() { group('AggregateTestBuilder', () { test('does nothing if browser aggregate not enabled', () async { - final config = TestHtmlBuilderConfig(templates: { - 'test/foo_template.html': ['test/foo_test.dart'], - }); + final config = TestHtmlBuilderConfig( + templates: { + 'test/foo_template.html': ['test/foo_test.dart'], + }, + ); final builder = AggregateTestBuilder(); await testBuilder(builder, { 'a|test/test_html_builder_config.json': jsonEncode(config), @@ -21,22 +23,27 @@ void main() { }); test('generates an aggregate test for each template', () async { - final config = - TestHtmlBuilderConfig(browserAggregation: true, templates: { - 'test/templates/foo_template.html': ['test/foo_test.dart'], - 'test/templates/bar_template.html': ['test/bar_test.dart'], - }); + final config = TestHtmlBuilderConfig( + browserAggregation: true, + templates: { + 'test/templates/foo_template.html': ['test/foo_test.dart'], + 'test/templates/bar_template.html': ['test/bar_test.dart'], + }, + ); final builder = AggregateTestBuilder(); - await testBuilder(builder, { - 'a|test/test_html_builder_config.json': jsonEncode(config), - 'a|test/vm_test.dart': "@TestOn('vm') library vm_test;", - 'a|test/foo_test.dart': '', - 'a|test/bar_test.dart': '', - 'a|test/templates/foo_template.html': '', - 'a|test/templates/bar_template.html': '', - }, outputs: { - 'a|test/templates/foo_template.browser_aggregate_test.dart': - '''@TestOn('browser') + await testBuilder( + builder, + { + 'a|test/test_html_builder_config.json': jsonEncode(config), + 'a|test/vm_test.dart': "@TestOn('vm') library vm_test;", + 'a|test/foo_test.dart': '', + 'a|test/bar_test.dart': '', + 'a|test/templates/foo_template.html': '', + 'a|test/templates/bar_template.html': '', + }, + outputs: { + 'a|test/templates/foo_template.browser_aggregate_test.dart': + '''@TestOn('browser') import 'package:test/test.dart'; import '../foo_test.dart' as foo_test; @@ -45,8 +52,8 @@ void main() { foo_test.main(); } ''', - 'a|test/templates/bar_template.browser_aggregate_test.dart': - '''@TestOn('browser') + 'a|test/templates/bar_template.browser_aggregate_test.dart': + '''@TestOn('browser') import 'package:test/test.dart'; import '../bar_test.dart' as bar_test; @@ -54,28 +61,34 @@ import '../bar_test.dart' as bar_test; void main() { bar_test.main(); } -''' - }); +''', + }, + ); }); test('generates a default aggregate test for browser tests', () async { - final config = - TestHtmlBuilderConfig(browserAggregation: true, templates: { - 'test/templates/foo_template.html': ['test/foo_test.dart'], - 'test/templates/bar_template.html': ['test/bar_test.dart'], - }); + final config = TestHtmlBuilderConfig( + browserAggregation: true, + templates: { + 'test/templates/foo_template.html': ['test/foo_test.dart'], + 'test/templates/bar_template.html': ['test/bar_test.dart'], + }, + ); final builder = AggregateTestBuilder(); - await testBuilder(builder, { - 'a|test/test_html_builder_config.json': jsonEncode(config), - 'a|test/templates/default_template.html': '', - 'a|test/templates/foo_template.html': '', - 'a|test/templates/bar_template.html': '', - 'a|test/vm_test.dart': "@TestOn('vm') library vm_test;", - 'a|test/a_test.dart': '', - 'a|test/b_test.dart': '', - }, outputs: { - 'a|test/templates/default_template.browser_aggregate_test.dart': - '''@TestOn('browser') + await testBuilder( + builder, + { + 'a|test/test_html_builder_config.json': jsonEncode(config), + 'a|test/templates/default_template.html': '', + 'a|test/templates/foo_template.html': '', + 'a|test/templates/bar_template.html': '', + 'a|test/vm_test.dart': "@TestOn('vm') library vm_test;", + 'a|test/a_test.dart': '', + 'a|test/b_test.dart': '', + }, + outputs: { + 'a|test/templates/default_template.browser_aggregate_test.dart': + '''@TestOn('browser') import 'package:test/test.dart'; import '../a_test.dart' as a_test; @@ -85,31 +98,36 @@ void main() { a_test.main(); b_test.main(); } -''' - }); +''', + }, + ); }); - test('randomizes the ordering of tests in aggregate for browser tests', - () async { - final config = TestHtmlBuilderConfig( - browserAggregation: true, - randomizeOrderingSeed: '2', - ); - final builder = AggregateTestBuilder(); - await testBuilder(builder, { - 'a|test/test_html_builder_config.json': jsonEncode(config), - 'a|test/templates/default_template.html': '', - 'a|test/templates/foo_template.html': '', - 'a|test/templates/bar_template.html': '', - 'a|test/vm_test.dart': "@TestOn('vm') library vm_test;", - 'a|test/a_test.dart': '', - 'a|test/b_test.dart': '', - 'a|test/c_test.dart': '', - 'a|test/d_test.dart': '', - 'a|test/e_test.dart': '', - }, outputs: { - 'a|test/templates/default_template.browser_aggregate_test.dart': - '''@TestOn('browser') + test( + 'randomizes the ordering of tests in aggregate for browser tests', + () async { + final config = TestHtmlBuilderConfig( + browserAggregation: true, + randomizeOrderingSeed: '2', + ); + final builder = AggregateTestBuilder(); + await testBuilder( + builder, + { + 'a|test/test_html_builder_config.json': jsonEncode(config), + 'a|test/templates/default_template.html': '', + 'a|test/templates/foo_template.html': '', + 'a|test/templates/bar_template.html': '', + 'a|test/vm_test.dart': "@TestOn('vm') library vm_test;", + 'a|test/a_test.dart': '', + 'a|test/b_test.dart': '', + 'a|test/c_test.dart': '', + 'a|test/d_test.dart': '', + 'a|test/e_test.dart': '', + }, + outputs: { + 'a|test/templates/default_template.browser_aggregate_test.dart': + '''@TestOn('browser') import 'package:test/test.dart'; import '../a_test.dart' as a_test; @@ -127,26 +145,33 @@ void main() { b_test.main(); d_test.main(); } -''' - }); - }); +''', + }, + ); + }, + ); test('if multiple templates match, chooses first one', () async { - final config = - TestHtmlBuilderConfig(browserAggregation: true, templates: { - 'test/templates/foo_template.html': ['test/**_test.dart'], - 'test/templates/bar_template.html': ['test/**_test.dart'], - }); + final config = TestHtmlBuilderConfig( + browserAggregation: true, + templates: { + 'test/templates/foo_template.html': ['test/**_test.dart'], + 'test/templates/bar_template.html': ['test/**_test.dart'], + }, + ); final builder = AggregateTestBuilder(); - await testBuilder(builder, { - 'a|test/test_html_builder_config.json': jsonEncode(config), - 'a|test/bar_test.dart': '', - 'a|test/foo_test.dart': '', - 'a|test/templates/foo_template.html': '', - 'a|test/templates/bar_template.html': '', - }, outputs: { - 'a|test/templates/foo_template.browser_aggregate_test.dart': - '''@TestOn('browser') + await testBuilder( + builder, + { + 'a|test/test_html_builder_config.json': jsonEncode(config), + 'a|test/bar_test.dart': '', + 'a|test/foo_test.dart': '', + 'a|test/templates/foo_template.html': '', + 'a|test/templates/bar_template.html': '', + }, + outputs: { + 'a|test/templates/foo_template.browser_aggregate_test.dart': + '''@TestOn('browser') import 'package:test/test.dart'; import '../bar_test.dart' as bar_test; @@ -156,27 +181,33 @@ void main() { bar_test.main(); foo_test.main(); } -''' - }); +''', + }, + ); }); test('sorts the test imports and invocations', () async { - final config = - TestHtmlBuilderConfig(browserAggregation: true, templates: { - 'test/templates/foo_template.html': ['test/**_test.dart'], - }); + final config = TestHtmlBuilderConfig( + browserAggregation: true, + templates: { + 'test/templates/foo_template.html': ['test/**_test.dart'], + }, + ); final builder = AggregateTestBuilder(); - await testBuilder(builder, { - 'a|test/test_html_builder_config.json': jsonEncode(config), - 'a|test/templates/foo_template.html': '', - // These three are intentionally unsorted so that this test can verify - // that the builder sorts them. - 'a|test/foo_test.dart': '', - 'a|test/baz/baz_test.dart': '', - 'a|test/bar_test.dart': '', - }, outputs: { - 'a|test/templates/foo_template.browser_aggregate_test.dart': - '''@TestOn('browser') + await testBuilder( + builder, + { + 'a|test/test_html_builder_config.json': jsonEncode(config), + 'a|test/templates/foo_template.html': '', + // These three are intentionally unsorted so that this test can verify + // that the builder sorts them. + 'a|test/foo_test.dart': '', + 'a|test/baz/baz_test.dart': '', + 'a|test/bar_test.dart': '', + }, + outputs: { + 'a|test/templates/foo_template.browser_aggregate_test.dart': + '''@TestOn('browser') import 'package:test/test.dart'; import '../bar_test.dart' as bar_test; @@ -188,8 +219,9 @@ void main() { baz_baz_test.main(); foo_test.main(); } -''' - }); +''', + }, + ); }); }); } diff --git a/test/lib/config_test.dart b/test/lib/config_test.dart index 73b2d84..13d84c9 100644 --- a/test/lib/config_test.dart +++ b/test/lib/config_test.dart @@ -19,7 +19,7 @@ void main() { 'randomize_ordering_seed': 'random', 'templates': { 'test/foo_template.html': ['test/**_test.dart'], - } + }, }); final config = TestHtmlBuilderConfig.fromBuilderOptions(options); expect(config.browserAggregation, isTrue); @@ -28,37 +28,49 @@ void main() { 'test/foo_template.html': ['test/**_test.dart'], }); expect( - config.templateGlobs['test/foo_template.html']!.first - .matches('test/foo_test.dart'), - isTrue); + config.templateGlobs['test/foo_template.html']!.first.matches( + 'test/foo_test.dart', + ), + isTrue, + ); }); test('throws StateError if any templates are not in test/', () { final options = BuilderOptions({ 'templates': { 'lib/bad_template.html': ['test/**_test.dart'], - } + }, }); expect( - () => TestHtmlBuilderConfig.fromBuilderOptions(options), - throwsA(isA().having( - (e) => e.message, 'message', contains('lib/bad_template.html')))); + () => TestHtmlBuilderConfig.fromBuilderOptions(options), + throwsA( + isA().having( + (e) => e.message, + 'message', + contains('lib/bad_template.html'), + ), + ), + ); }); test('throws StateError if unsupported option key is provided', () { final options = BuilderOptions({ 'badkey': 'foo', }); - expect(() => TestHtmlBuilderConfig.fromBuilderOptions(options), - throwsStateError); + expect( + () => TestHtmlBuilderConfig.fromBuilderOptions(options), + throwsStateError, + ); }); test('throws StateError if templates format is invalid', () { final options = BuilderOptions({ 'templates': ['invalid format'], }); - expect(() => TestHtmlBuilderConfig.fromBuilderOptions(options), - throwsStateError); + expect( + () => TestHtmlBuilderConfig.fromBuilderOptions(options), + throwsStateError, + ); }); }); } diff --git a/test/lib/dart_test_yaml_builder_test.dart b/test/lib/dart_test_yaml_builder_test.dart index 6445d05..7e3e929 100644 --- a/test/lib/dart_test_yaml_builder_test.dart +++ b/test/lib/dart_test_yaml_builder_test.dart @@ -21,32 +21,36 @@ void main() { test('generates a preset with a path for each aggregate test', () async { final config = TestHtmlBuilderConfig(browserAggregation: true); final builder = DartTestYamlBuilder(); - await testBuilder(builder, { - 'a|test/test_html_builder_config.json': jsonEncode(config), - 'a|test/foo_template.browser_aggregate_test.dart': '', - 'a|test/foo_template.html': '', - // This template should be found, but ignored because there is no - // accompanying .browser_aggregate_test.dart - 'a|test/bar_template.html': '', - // This test should get included because it has a custom HTML - 'a|test/custom_test.dart': '', - 'a|test/custom_test.custom.html': '', - }, outputs: { - 'a|dart_test.browser_aggregate.yaml': '''presets: + await testBuilder( + builder, + { + 'a|test/test_html_builder_config.json': jsonEncode(config), + 'a|test/foo_template.browser_aggregate_test.dart': '', + 'a|test/foo_template.html': '', + // This template should be found, but ignored because there is no + // accompanying .browser_aggregate_test.dart + 'a|test/bar_template.html': '', + // This test should get included because it has a custom HTML + 'a|test/custom_test.dart': '', + 'a|test/custom_test.custom.html': '', + }, + outputs: { + 'a|dart_test.browser_aggregate.yaml': '''presets: browser-aggregate: platforms: [chrome] paths: - test/foo_template.browser_aggregate_test.dart - test/custom_test.dart ''', - 'a|test/dart_test.browser_aggregate.yaml': '''presets: + 'a|test/dart_test.browser_aggregate.yaml': '''presets: browser-aggregate: platforms: [chrome] paths: - test/foo_template.browser_aggregate_test.dart - test/custom_test.dart -''' - }); +''', + }, + ); }); }); } diff --git a/test/lib/template_builder_test.dart b/test/lib/template_builder_test.dart index 074191d..21c978a 100644 --- a/test/lib/template_builder_test.dart +++ b/test/lib/template_builder_test.dart @@ -33,9 +33,11 @@ void main() { }); test('does nothing if template does not match asset', () async { - final config = TestHtmlBuilderConfig(templates: { - 'test/template.html': ['test/no_match.dart'], - }); + final config = TestHtmlBuilderConfig( + templates: { + 'test/template.html': ['test/no_match.dart'], + }, + ); final builder = TemplateBuilder(); await testBuilder(builder, { 'a|test/test_html_builder_config.json': jsonEncode(config), @@ -45,98 +47,135 @@ void main() { }); test('outputs .html if template matches asset', () async { - final config = TestHtmlBuilderConfig(templates: { - 'test/template.html': ['test/**_test.dart'], - }); + final config = TestHtmlBuilderConfig( + templates: { + 'test/template.html': ['test/**_test.dart'], + }, + ); final builder = TemplateBuilder(); - await testBuilder(builder, { - 'a|test/test_html_builder_config.json': jsonEncode(config), - 'a|test/bar_test.dart': '', - 'a|test/foo_test.dart': '', - 'a|test/template.html': '{{testScript}}', - }, outputs: { - 'a|test/bar_test.html': - '''''', - 'a|test/foo_test.html': - '''''', - }); + await testBuilder( + builder, + { + 'a|test/test_html_builder_config.json': jsonEncode(config), + 'a|test/bar_test.dart': '', + 'a|test/foo_test.dart': '', + 'a|test/template.html': '{{testScript}}', + }, + outputs: { + 'a|test/bar_test.html': + '''''', + 'a|test/foo_test.html': + '''''', + }, + ); }); - test('chooses first template that matches asset if multiple match', - () async { - final config = TestHtmlBuilderConfig(templates: { - 'test/a_template.html': ['test/bar_test.dart'], - 'test/b_template.html': ['test/**_test.dart'], - }); + test('chooses first template that matches asset if multiple match', () async { + final config = TestHtmlBuilderConfig( + templates: { + 'test/a_template.html': ['test/bar_test.dart'], + 'test/b_template.html': ['test/**_test.dart'], + }, + ); final builder = TemplateBuilder(); - await testBuilder(builder, { - 'a|test/test_html_builder_config.json': jsonEncode(config), - 'a|test/bar_test.dart': '', - 'a|test/foo_test.dart': '', - 'a|test/a_template.html': - '{{testScript}}', - 'a|test/b_template.html': - '{{testScript}}', - }, outputs: { - 'a|test/bar_test.html': - '''''', - 'a|test/foo_test.html': - '''''', - }); + await testBuilder( + builder, + { + 'a|test/test_html_builder_config.json': jsonEncode(config), + 'a|test/bar_test.dart': '', + 'a|test/foo_test.dart': '', + 'a|test/a_template.html': + '{{testScript}}', + 'a|test/b_template.html': + '{{testScript}}', + }, + outputs: { + 'a|test/bar_test.html': + '''''', + 'a|test/foo_test.html': + '''''', + }, + ); }); test('copies .custom.html asset if found', () async { - final config = TestHtmlBuilderConfig(templates: { - 'test/template.html': ['test/**_test.dart'], - }); + final config = TestHtmlBuilderConfig( + templates: { + 'test/template.html': ['test/**_test.dart'], + }, + ); final builder = TemplateBuilder(); - await testBuilder(builder, { - 'a|test/test_html_builder_config.json': jsonEncode(config), - 'a|test/bar_test.dart': '', - 'a|test/bar_test.custom.html': 'CUSTOM BAR TEST', - 'a|test/foo_test.dart': '', - 'a|test/foo_test.custom.html': 'CUSTOM FOO TEST', - 'a|test/template.html': '{{testScript}}', - }, outputs: { - 'a|test/bar_test.html': 'CUSTOM BAR TEST', - 'a|test/foo_test.html': 'CUSTOM FOO TEST', - }); + await testBuilder( + builder, + { + 'a|test/test_html_builder_config.json': jsonEncode(config), + 'a|test/bar_test.dart': '', + 'a|test/bar_test.custom.html': 'CUSTOM BAR TEST', + 'a|test/foo_test.dart': '', + 'a|test/foo_test.custom.html': 'CUSTOM FOO TEST', + 'a|test/template.html': '{{testScript}}', + }, + outputs: { + 'a|test/bar_test.html': 'CUSTOM BAR TEST', + 'a|test/foo_test.html': 'CUSTOM FOO TEST', + }, + ); }); test('logs SEVERE if template cannot be read', () async { - final config = TestHtmlBuilderConfig(templates: { - 'test/template.html': ['test/**_test.dart'], - }); + final config = TestHtmlBuilderConfig( + templates: { + 'test/template.html': ['test/**_test.dart'], + }, + ); final builder = TemplateBuilder(); - final logs = recordLogs(() => testBuilder(builder, { - 'a|test/test_html_builder_config.json': jsonEncode(config), - 'a|test/foo_test.dart': '', - })); + final logs = recordLogs( + () => testBuilder(builder, { + 'a|test/test_html_builder_config.json': jsonEncode(config), + 'a|test/foo_test.dart': '', + }), + ); expect( - logs, - emits(severeLogOf(allOf( - contains('Could not read template'), - contains('test/template.html'), - )))); + logs, + emits( + severeLogOf( + allOf( + contains('Could not read template'), + contains('test/template.html'), + ), + ), + ), + ); }); - test('logs SEVERE if template does not contain `{{testScript}}` token', - () async { - final config = TestHtmlBuilderConfig(templates: { - 'test/template.html': ['test/**_test.dart'], - }); - final builder = TemplateBuilder(); - final logs = recordLogs(() => testBuilder(builder, { + test( + 'logs SEVERE if template does not contain `{{testScript}}` token', + () async { + final config = TestHtmlBuilderConfig( + templates: { + 'test/template.html': ['test/**_test.dart'], + }, + ); + final builder = TemplateBuilder(); + final logs = recordLogs( + () => testBuilder(builder, { 'a|test/test_html_builder_config.json': jsonEncode(config), 'a|test/foo_test.dart': '', 'a|test/template.html': 'MISSING TOKEN', - })); - expect( + }), + ); + expect( logs, - emits(severeLogOf(allOf( - contains('template must contain exactly one `{{testScript}}`'), - contains('test/template.html'), - )))); - }); + emits( + severeLogOf( + allOf( + contains('template must contain exactly one `{{testScript}}`'), + contains('test/template.html'), + ), + ), + ), + ); + }, + ); }); } diff --git a/test/lib/test_html_builder_test.dart b/test/lib/test_html_builder_test.dart index ddbbbfb..3fe504b 100644 --- a/test/lib/test_html_builder_test.dart +++ b/test/lib/test_html_builder_test.dart @@ -8,14 +8,19 @@ import 'package:test_html_builder/src/config.dart'; void main() { test('TestHtmlBuilder', () async { - final config = TestHtmlBuilderConfig(templates: { - 'test/template.html': ['test/foo_test.dart'], - }); + final config = TestHtmlBuilderConfig( + templates: { + 'test/template.html': ['test/foo_test.dart'], + }, + ); final builder = TestHtmlBuilder(config); - await testBuilder(builder, { - r'a|$package$': '', - }, outputs: { - 'a|test/templates/default_template.html': ''' + await testBuilder( + builder, + { + r'a|$package$': '', + }, + outputs: { + 'a|test/templates/default_template.html': ''' {{testName}} Test @@ -24,7 +29,8 @@ void main() { ''', - 'a|test/test_html_builder_config.json': jsonEncode(config), - }); + 'a|test/test_html_builder_config.json': jsonEncode(config), + }, + ); }); } From d9effae95b52eabc212b8073e4cef49c52440026 Mon Sep 17 00:00:00 2001 From: Rob Becker Date: Sun, 15 Feb 2026 22:33:52 -0700 Subject: [PATCH 08/21] regenerate json serializable --- lib/src/config.g.dart | 78 ++++++++++++++++++++----------------------- 1 file changed, 37 insertions(+), 41 deletions(-) diff --git a/lib/src/config.g.dart b/lib/src/config.g.dart index e25ce89..d015cec 100644 --- a/lib/src/config.g.dart +++ b/lib/src/config.g.dart @@ -1,54 +1,50 @@ // GENERATED CODE - DO NOT MODIFY BY HAND -part of lib.src.config; +part of 'config.dart'; // ************************************************************************** // JsonSerializableGenerator // ************************************************************************** -TestHtmlBuilderConfig _$TestHtmlBuilderConfigFromJson(Map json) { - return $checkedNew( - 'TestHtmlBuilderConfig', - json, - () { - $checkKeys( - json, - allowedKeys: const [ - 'browser_aggregation', - 'randomize_ordering_seed', - 'templates', - ], - ); - final val = TestHtmlBuilderConfig( - browserAggregation: $checkedConvert( +TestHtmlBuilderConfig _$TestHtmlBuilderConfigFromJson(Map json) => + $checkedCreate( + 'TestHtmlBuilderConfig', + json, + ($checkedConvert) { + $checkKeys( json, - 'browser_aggregation', - (v) => v as bool?, - ), - randomizeOrderingSeed: $checkedConvert( - json, - 'randomize_ordering_seed', - (v) => v as String?, - ), - templates: $checkedConvert( - json, - 'templates', - (v) => (v as Map?)?.map( - (k, e) => MapEntry( - k as String, - (e as List).map((e) => e as String).toList(), + allowedKeys: const [ + 'browser_aggregation', + 'randomize_ordering_seed', + 'templates', + ], + ); + final val = TestHtmlBuilderConfig( + browserAggregation: $checkedConvert( + 'browser_aggregation', + (v) => v as bool?, + ), + randomizeOrderingSeed: $checkedConvert( + 'randomize_ordering_seed', + (v) => v as String?, + ), + templates: $checkedConvert( + 'templates', + (v) => (v as Map?)?.map( + (k, e) => MapEntry( + k as String, + (e as List).map((e) => e as String).toList(), + ), ), ), - ), - ); - return val; - }, - fieldKeyMap: const { - 'browserAggregation': 'browser_aggregation', - 'randomizeOrderingSeed': 'randomize_ordering_seed', - }, - ); -} + ); + return val; + }, + fieldKeyMap: const { + 'browserAggregation': 'browser_aggregation', + 'randomizeOrderingSeed': 'randomize_ordering_seed', + }, + ); Map _$TestHtmlBuilderConfigToJson( TestHtmlBuilderConfig instance, From 84d7ece649bfbb25187deb2ff61e22ac5ffbd077 Mon Sep 17 00:00:00 2001 From: Rob Becker Date: Sun, 15 Feb 2026 22:34:20 -0700 Subject: [PATCH 09/21] raise minimums --- pubspec.yaml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/pubspec.yaml b/pubspec.yaml index aefd7db..f85c2e8 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -14,20 +14,20 @@ executables: dependencies: args: ^2.3.0 - build: '>=2.1.0 <5.0.0' - dart_style: '>=2.1.1 <5.0.0' + build: ^4.0.4 + dart_style: ^3.1.5 glob: ^2.0.1 json_annotation: ^4.1.0 path: ^1.8.0 pub_semver: ^2.0.0 - test_core: ">=0.4.2 <0.7.0" + test_core: ^0.6.0 yaml: ^3.1.0 dev_dependencies: build_runner: ^2.1.2 - build_test: '>=2.1.3 <4.0.0' - build_web_compilers: '>=3.0.0 <5.0.0' - dependency_validator: '>=3.1.0 <6.0.0' + build_test: ^3.0.0 + build_web_compilers: ^4.0.0 + dependency_validator: ^5.0.0 test: ^1.17.12 test_descriptor: ^2.0.0 test_process: ^2.0.2 @@ -36,4 +36,4 @@ dev_dependencies: # If changes are made to `lib/src/config.dart` and regeneration is needed, # uncomment this and comment out the test_html_builder definition in # `build.yaml`. - # json_serializable: ^4.0.0 + # json_serializable: ^6.0.0 From 8260ba927651f24512d8a660508b94aded997853 Mon Sep 17 00:00:00 2001 From: Rob Becker Date: Sun, 15 Feb 2026 22:39:27 -0700 Subject: [PATCH 10/21] change example --- example/project/dart_test.browser_aggregate.yaml | 2 +- example/project/pubspec.yaml | 4 ++-- example/project/test/dart_test.browser_aggregate.yaml | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/example/project/dart_test.browser_aggregate.yaml b/example/project/dart_test.browser_aggregate.yaml index 6f52248..e27d03b 100644 --- a/example/project/dart_test.browser_aggregate.yaml +++ b/example/project/dart_test.browser_aggregate.yaml @@ -3,6 +3,6 @@ presets: platforms: [chrome] paths: - test/templates/css_template.browser_aggregate_test.dart - - test/templates/script_template.browser_aggregate_test.dart - test/templates/default_template.browser_aggregate_test.dart + - test/templates/script_template.browser_aggregate_test.dart - test/unit/custom_html_test.dart diff --git a/example/project/pubspec.yaml b/example/project/pubspec.yaml index a0acb38..ff4c5fd 100644 --- a/example/project/pubspec.yaml +++ b/example/project/pubspec.yaml @@ -7,8 +7,8 @@ environment: dev_dependencies: build_runner: ^2.1.2 - build_test: '>=2.1.3 <4.0.0' - build_web_compilers: '>=3.0.0 <5.0.0' + build_test: ^3.0.0 + build_web_compilers: ^4.0.0 test: ^1.17.12 test_html_builder: path: ../.. diff --git a/example/project/test/dart_test.browser_aggregate.yaml b/example/project/test/dart_test.browser_aggregate.yaml index 6f52248..e27d03b 100644 --- a/example/project/test/dart_test.browser_aggregate.yaml +++ b/example/project/test/dart_test.browser_aggregate.yaml @@ -3,6 +3,6 @@ presets: platforms: [chrome] paths: - test/templates/css_template.browser_aggregate_test.dart - - test/templates/script_template.browser_aggregate_test.dart - test/templates/default_template.browser_aggregate_test.dart + - test/templates/script_template.browser_aggregate_test.dart - test/unit/custom_html_test.dart From b3ad4beb67991cb7b52ca8dbcf8ab7f1e70b4b4c Mon Sep 17 00:00:00 2001 From: Rob Becker Date: Sun, 15 Feb 2026 22:48:44 -0700 Subject: [PATCH 11/21] show all format files --- .github/workflows/dart_ci.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/dart_ci.yaml b/.github/workflows/dart_ci.yaml index 939c1e6..4d0b3b7 100644 --- a/.github/workflows/dart_ci.yaml +++ b/.github/workflows/dart_ci.yaml @@ -19,7 +19,7 @@ jobs: - uses: dart-lang/setup-dart@v1 with: sdk: 3.11.0 - - run: dart format --set-exit-if-changed -o none . + - run: dart format --set-exit-if-changed -o none --show all . test: runs-on: ubuntu-latest strategy: From 6ae880790d06f7623a6c70db43a8ae9656c69621 Mon Sep 17 00:00:00 2001 From: Rob Becker Date: Sun, 15 Feb 2026 22:53:19 -0700 Subject: [PATCH 12/21] format --- bin/browser_aggregate_tests.dart | 4 +++- lib/src/builder.dart | 9 +++++++-- test/bin/browser_aggregate_tests_test.dart | 11 ++++++++--- test/lib/template_builder_test.dart | 4 +++- 4 files changed, 21 insertions(+), 7 deletions(-) diff --git a/bin/browser_aggregate_tests.dart b/bin/browser_aggregate_tests.dart index 64680a4..2b53d84 100644 --- a/bin/browser_aggregate_tests.dart +++ b/bin/browser_aggregate_tests.dart @@ -146,7 +146,9 @@ targets: ); late List paths; try { - paths = List.from(config['presets']['browser-aggregate']['paths']); + paths = List.from( + config['presets']['browser-aggregate']['paths'], + ); } catch (e, stack) { stdout ..writeln('Failed to read test paths from "${configFile.uri}"') diff --git a/lib/src/builder.dart b/lib/src/builder.dart index 58336dc..4ffcae1 100644 --- a/lib/src/builder.dart +++ b/lib/src/builder.dart @@ -161,7 +161,9 @@ class AggregateTestBuilder extends Builder { final seed = _getRandomSeed(); if (seed != null) { - log.info('Shuffling test order with `randomize_ordering_seed: $seed`\n'); + log.info( + 'Shuffling test order with `randomize_ordering_seed: $seed`\n', + ); mains.shuffle(Random(seed)); mains.insert( 0, @@ -373,7 +375,10 @@ class DartTestYamlBuilder extends Builder { buildStep.inputId.package, 'test/dart_test.browser_aggregate.yaml', ); - await buildStep.writeAsString(backwardsCompatOutputId, contents.toString()); + await buildStep.writeAsString( + backwardsCompatOutputId, + contents.toString(), + ); } } diff --git a/test/bin/browser_aggregate_tests_test.dart b/test/bin/browser_aggregate_tests_test.dart index e9e1a6f..e5be840 100644 --- a/test/bin/browser_aggregate_tests_test.dart +++ b/test/bin/browser_aggregate_tests_test.dart @@ -25,13 +25,16 @@ dev_dependencies: path: ${p.current} '''), if (browserAggregation) - d.file(customBuildYaml ? 'build.custom.yaml' : 'build.yaml', '''targets: + d.file( + customBuildYaml ? 'build.custom.yaml' : 'build.yaml', + '''targets: \$default: builders: test_html_builder: options: browser_aggregation: true -'''), +''', + ), if (browserAggregation) d.file('dart_test.yaml', 'include: dart_test.browser_aggregate.yaml'), d.dir('test', [ @@ -210,7 +213,9 @@ void main() { expect( process.stdout, emits( - contains('browser aggregation is not enabled. Update your build.yaml'), + contains( + 'browser aggregation is not enabled. Update your build.yaml', + ), ), ); await process.shouldExit(isNot(0)); diff --git a/test/lib/template_builder_test.dart b/test/lib/template_builder_test.dart index 21c978a..33d22b1 100644 --- a/test/lib/template_builder_test.dart +++ b/test/lib/template_builder_test.dart @@ -169,7 +169,9 @@ void main() { emits( severeLogOf( allOf( - contains('template must contain exactly one `{{testScript}}`'), + contains( + 'template must contain exactly one `{{testScript}}`', + ), contains('test/template.html'), ), ), From 4d0652a1c6faa26f68e785ac0131b8b8882aa228 Mon Sep 17 00:00:00 2001 From: Rob Becker Date: Sun, 15 Feb 2026 23:00:52 -0700 Subject: [PATCH 13/21] update format in CI --- .github/workflows/dart_ci.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/dart_ci.yaml b/.github/workflows/dart_ci.yaml index 4d0b3b7..73f3933 100644 --- a/.github/workflows/dart_ci.yaml +++ b/.github/workflows/dart_ci.yaml @@ -19,7 +19,7 @@ jobs: - uses: dart-lang/setup-dart@v1 with: sdk: 3.11.0 - - run: dart format --set-exit-if-changed -o none --show all . + - run: dart run dart_style:format --set-exit-if-changed -o none . test: runs-on: ubuntu-latest strategy: From cbe00545873ccff407a7ac95a3d4ac80c2020cdc Mon Sep 17 00:00:00 2001 From: Rob Becker Date: Thu, 19 Feb 2026 13:31:54 -0700 Subject: [PATCH 14/21] AI fixed the tests --- test/bin/browser_aggregate_tests_test.dart | 12 +++---- test/lib/aggregate_test_builder_test.dart | 3 +- test/lib/template_builder_test.dart | 40 ++++------------------ test/lib/test_html_builder_test.dart | 2 +- 4 files changed, 15 insertions(+), 42 deletions(-) diff --git a/test/bin/browser_aggregate_tests_test.dart b/test/bin/browser_aggregate_tests_test.dart index e5be840..5767536 100644 --- a/test/bin/browser_aggregate_tests_test.dart +++ b/test/bin/browser_aggregate_tests_test.dart @@ -110,13 +110,13 @@ void main() { emitsThrough( 'dart run build_runner build --delete-conflicting-outputs --build-filter=dart_test.browser_aggregate.yaml', ), - emitsThrough(contains('Succeeded')), + emitsThrough(contains('Built with build_runner/jit')), emitsThrough('Reading browser aggregate test config...'), emitsThrough('Found 1 aggregate tests to run.'), emitsThrough( 'dart run build_runner build --delete-conflicting-outputs --build-filter=test/templates/default_template.browser_aggregate_test.**', ), - emitsThrough(contains('Succeeded')), + emitsThrough(contains('Built with build_runner/jit')), ]), ); await process.shouldExit(0); @@ -137,13 +137,13 @@ void main() { emitsThrough( 'dart run build_runner build --delete-conflicting-outputs -c custom --build-filter=dart_test.browser_aggregate.yaml', ), - emitsThrough(contains('Succeeded')), + emitsThrough(contains('Built with build_runner/jit')), emitsThrough('Reading browser aggregate test config...'), emitsThrough('Found 1 aggregate tests to run.'), emitsThrough( 'dart run build_runner build --delete-conflicting-outputs -c custom --release --build-filter=test/templates/default_template.browser_aggregate_test.**', ), - emitsThrough(contains('Succeeded')), + emitsThrough(contains('Built with build_runner/jit')), ]), ); await process.shouldExit(0); @@ -163,7 +163,7 @@ void main() { emitsThrough( 'dart run build_runner build --delete-conflicting-outputs --build-filter=dart_test.browser_aggregate.yaml', ), - emitsThrough(contains('Succeeded')), + emitsThrough(contains('Built with build_runner/jit')), emitsThrough('Reading browser aggregate test config...'), emitsThrough('Found 1 aggregate tests to run.'), emitsThrough( @@ -191,7 +191,7 @@ void main() { emitsThrough( 'dart run build_runner build --delete-conflicting-outputs --release -c custom --build-filter=dart_test.browser_aggregate.yaml', ), - emitsThrough(contains('Succeeded')), + emitsThrough(contains('Built with build_runner/jit')), emitsThrough('Reading browser aggregate test config...'), emitsThrough('Found 1 aggregate tests to run.'), emitsThrough( diff --git a/test/lib/aggregate_test_builder_test.dart b/test/lib/aggregate_test_builder_test.dart index 489d1c7..e3a1e78 100644 --- a/test/lib/aggregate_test_builder_test.dart +++ b/test/lib/aggregate_test_builder_test.dart @@ -138,7 +138,8 @@ import '../e_test.dart' as e_test; void main() { print( - 'test/templates/default_template.html built with `randomize_ordering_seed: "2"`'); + 'test/templates/default_template.html built with `randomize_ordering_seed: "2"`', + ); c_test.main(); a_test.main(); e_test.main(); diff --git a/test/lib/template_builder_test.dart b/test/lib/template_builder_test.dart index 33d22b1..06c5ea8 100644 --- a/test/lib/template_builder_test.dart +++ b/test/lib/template_builder_test.dart @@ -122,34 +122,21 @@ void main() { ); }); - test('logs SEVERE if template cannot be read', () async { + test('does not output .html if template cannot be read', () async { final config = TestHtmlBuilderConfig( templates: { 'test/template.html': ['test/**_test.dart'], }, ); final builder = TemplateBuilder(); - final logs = recordLogs( - () => testBuilder(builder, { + await testBuilder(builder, { 'a|test/test_html_builder_config.json': jsonEncode(config), 'a|test/foo_test.dart': '', - }), - ); - expect( - logs, - emits( - severeLogOf( - allOf( - contains('Could not read template'), - contains('test/template.html'), - ), - ), - ), - ); + }, outputs: {}); }); test( - 'logs SEVERE if template does not contain `{{testScript}}` token', + 'does not output .html if template does not contain `{{testScript}}` token', () async { final config = TestHtmlBuilderConfig( templates: { @@ -157,26 +144,11 @@ void main() { }, ); final builder = TemplateBuilder(); - final logs = recordLogs( - () => testBuilder(builder, { + await testBuilder(builder, { 'a|test/test_html_builder_config.json': jsonEncode(config), 'a|test/foo_test.dart': '', 'a|test/template.html': 'MISSING TOKEN', - }), - ); - expect( - logs, - emits( - severeLogOf( - allOf( - contains( - 'template must contain exactly one `{{testScript}}`', - ), - contains('test/template.html'), - ), - ), - ), - ); + }, outputs: {}); }, ); }); diff --git a/test/lib/test_html_builder_test.dart b/test/lib/test_html_builder_test.dart index 3fe504b..3632f77 100644 --- a/test/lib/test_html_builder_test.dart +++ b/test/lib/test_html_builder_test.dart @@ -17,7 +17,7 @@ void main() { await testBuilder( builder, { - r'a|$package$': '', + 'a|pubspec.yaml': 'name: a', }, outputs: { 'a|test/templates/default_template.html': ''' From 3bda04cb518960354a246d052726ffcbbe1f3fd4 Mon Sep 17 00:00:00 2001 From: Rob Becker Date: Thu, 19 Feb 2026 13:35:46 -0700 Subject: [PATCH 15/21] format --- test/lib/template_builder_test.dart | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/test/lib/template_builder_test.dart b/test/lib/template_builder_test.dart index 06c5ea8..7bcace6 100644 --- a/test/lib/template_builder_test.dart +++ b/test/lib/template_builder_test.dart @@ -130,9 +130,9 @@ void main() { ); final builder = TemplateBuilder(); await testBuilder(builder, { - 'a|test/test_html_builder_config.json': jsonEncode(config), - 'a|test/foo_test.dart': '', - }, outputs: {}); + 'a|test/test_html_builder_config.json': jsonEncode(config), + 'a|test/foo_test.dart': '', + }, outputs: {}); }); test( @@ -145,10 +145,10 @@ void main() { ); final builder = TemplateBuilder(); await testBuilder(builder, { - 'a|test/test_html_builder_config.json': jsonEncode(config), - 'a|test/foo_test.dart': '', - 'a|test/template.html': 'MISSING TOKEN', - }, outputs: {}); + 'a|test/test_html_builder_config.json': jsonEncode(config), + 'a|test/foo_test.dart': '', + 'a|test/template.html': 'MISSING TOKEN', + }, outputs: {}); }, ); }); From f13084ccbffca5ec3cf9596d27a428682160fa01 Mon Sep 17 00:00:00 2001 From: Rob Becker Date: Thu, 19 Feb 2026 13:57:41 -0700 Subject: [PATCH 16/21] =?UTF-8?q?undo=20using=20dart=5Fstyle=20to=20check?= =?UTF-8?q?=20formatting=20=F0=9F=A4=9E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/dart_ci.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/dart_ci.yaml b/.github/workflows/dart_ci.yaml index 73f3933..939c1e6 100644 --- a/.github/workflows/dart_ci.yaml +++ b/.github/workflows/dart_ci.yaml @@ -19,7 +19,7 @@ jobs: - uses: dart-lang/setup-dart@v1 with: sdk: 3.11.0 - - run: dart run dart_style:format --set-exit-if-changed -o none . + - run: dart format --set-exit-if-changed -o none . test: runs-on: ubuntu-latest strategy: From 08a3d93bdc5b714b4b00c544d3fa19328198c10d Mon Sep 17 00:00:00 2001 From: Rob Becker Date: Thu, 19 Feb 2026 14:00:23 -0700 Subject: [PATCH 17/21] nope, needed to match formatting --- .github/workflows/dart_ci.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/dart_ci.yaml b/.github/workflows/dart_ci.yaml index 939c1e6..73f3933 100644 --- a/.github/workflows/dart_ci.yaml +++ b/.github/workflows/dart_ci.yaml @@ -19,7 +19,7 @@ jobs: - uses: dart-lang/setup-dart@v1 with: sdk: 3.11.0 - - run: dart format --set-exit-if-changed -o none . + - run: dart run dart_style:format --set-exit-if-changed -o none . test: runs-on: ubuntu-latest strategy: From 0406b0e7cb6e80c6804d9b11a6b666e48a515212 Mon Sep 17 00:00:00 2001 From: Rob Becker Date: Thu, 19 Feb 2026 14:00:48 -0700 Subject: [PATCH 18/21] do we really need this order change? --- example/project/test/dart_test.browser_aggregate.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/example/project/test/dart_test.browser_aggregate.yaml b/example/project/test/dart_test.browser_aggregate.yaml index e27d03b..6f52248 100644 --- a/example/project/test/dart_test.browser_aggregate.yaml +++ b/example/project/test/dart_test.browser_aggregate.yaml @@ -3,6 +3,6 @@ presets: platforms: [chrome] paths: - test/templates/css_template.browser_aggregate_test.dart - - test/templates/default_template.browser_aggregate_test.dart - test/templates/script_template.browser_aggregate_test.dart + - test/templates/default_template.browser_aggregate_test.dart - test/unit/custom_html_test.dart From 7142c7d98b7a844efad81ea3c7bd8d34f0d7e9d7 Mon Sep 17 00:00:00 2001 From: Rob Becker Date: Thu, 19 Feb 2026 14:07:20 -0700 Subject: [PATCH 19/21] and do we need this reorder? --- example/project/dart_test.browser_aggregate.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/example/project/dart_test.browser_aggregate.yaml b/example/project/dart_test.browser_aggregate.yaml index e27d03b..6f52248 100644 --- a/example/project/dart_test.browser_aggregate.yaml +++ b/example/project/dart_test.browser_aggregate.yaml @@ -3,6 +3,6 @@ presets: platforms: [chrome] paths: - test/templates/css_template.browser_aggregate_test.dart - - test/templates/default_template.browser_aggregate_test.dart - test/templates/script_template.browser_aggregate_test.dart + - test/templates/default_template.browser_aggregate_test.dart - test/unit/custom_html_test.dart From be9661864bac9697138af2d838108b14bd1d47d3 Mon Sep 17 00:00:00 2001 From: Rob Becker Date: Thu, 19 Feb 2026 19:20:56 -0700 Subject: [PATCH 20/21] do a pub upgrade before format check --- .github/workflows/dart_ci.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/dart_ci.yaml b/.github/workflows/dart_ci.yaml index 73f3933..d54db87 100644 --- a/.github/workflows/dart_ci.yaml +++ b/.github/workflows/dart_ci.yaml @@ -19,7 +19,8 @@ jobs: - uses: dart-lang/setup-dart@v1 with: sdk: 3.11.0 - - run: dart run dart_style:format --set-exit-if-changed -o none . + - run: dart pub upgrade + - run: dart format --set-exit-if-changed -o none . test: runs-on: ubuntu-latest strategy: From 78f311c885b160f773d8ccfb101790a44bdb8ab4 Mon Sep 17 00:00:00 2001 From: Rob Becker Date: Fri, 20 Feb 2026 08:45:23 -0700 Subject: [PATCH 21/21] restore 2 tests to check logs, but with a different approach --- test/lib/template_builder_test.dart | 54 +++++++++++++++++++++++------ 1 file changed, 43 insertions(+), 11 deletions(-) diff --git a/test/lib/template_builder_test.dart b/test/lib/template_builder_test.dart index 7bcace6..c30bf88 100644 --- a/test/lib/template_builder_test.dart +++ b/test/lib/template_builder_test.dart @@ -122,21 +122,37 @@ void main() { ); }); - test('does not output .html if template cannot be read', () async { + test('logs SEVERE if template cannot be read', () async { final config = TestHtmlBuilderConfig( templates: { 'test/template.html': ['test/**_test.dart'], }, ); final builder = TemplateBuilder(); - await testBuilder(builder, { - 'a|test/test_html_builder_config.json': jsonEncode(config), - 'a|test/foo_test.dart': '', - }, outputs: {}); + final logs = []; + await testBuilder( + builder, + { + 'a|test/test_html_builder_config.json': jsonEncode(config), + 'a|test/foo_test.dart': '', + }, + onLog: logs.add, + ); + expect( + logs, + contains( + severeLogOf( + allOf( + contains('Could not read template'), + contains('test/template.html'), + ), + ), + ), + ); }); test( - 'does not output .html if template does not contain `{{testScript}}` token', + 'logs SEVERE if template does not contain `{{testScript}}` token', () async { final config = TestHtmlBuilderConfig( templates: { @@ -144,11 +160,27 @@ void main() { }, ); final builder = TemplateBuilder(); - await testBuilder(builder, { - 'a|test/test_html_builder_config.json': jsonEncode(config), - 'a|test/foo_test.dart': '', - 'a|test/template.html': 'MISSING TOKEN', - }, outputs: {}); + final logs = []; + await testBuilder( + builder, + { + 'a|test/test_html_builder_config.json': jsonEncode(config), + 'a|test/foo_test.dart': '', + 'a|test/template.html': 'MISSING TOKEN', + }, + onLog: logs.add, + ); + expect( + logs, + contains( + severeLogOf( + allOf( + contains('template must contain exactly one `{{testScript}}`'), + contains('test/template.html'), + ), + ), + ), + ); }, ); });