Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions .github/workflows/dart_ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,15 @@ jobs:
- uses: actions/checkout@v4
- uses: dart-lang/setup-dart@v1
with:
sdk: 2.19.6
sdk: 3.11.0
- run: dart pub upgrade
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

format before format check is needed for consistency between CI/local

- 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
Expand All @@ -46,7 +47,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
Expand Down
6 changes: 3 additions & 3 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ analyzer:
exclude:
- example/**
- lib/**.g.dart
language:
strict-inference: true
strict-raw-types: true

formatter:
trailing_commas: preserve
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed old unsupported options and added config to keep trailing commas as that reduces the amount of formatting changes

136 changes: 86 additions & 50 deletions bin/browser_aggregate_tests.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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.',
);
Copy link
Member Author

@robbecker-wf robbecker-wf Feb 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only formatting changes in this file


enum Mode {
// Print build and test args separated by `--`
Expand Down Expand Up @@ -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);
}
Expand All @@ -116,24 +126,29 @@ List<String> 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:
$default:
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<String> paths;
try {
paths = List<String>.from(config['presets']['browser-aggregate']['paths']);
paths = List<String>.from(
config['presets']['browser-aggregate']['paths'],
);
} catch (e, stack) {
stdout
..writeln('Failed to read test paths from "${configFile.uri}"')
Expand All @@ -152,68 +167,89 @@ targets:
///
/// [userBuildArgs] is interpreted as a space delimited string of additional
/// build_runner build arguments and will also be included.
List<String> buildRunnerBuildArgs(List<String> testPaths,
{bool? release, String? userBuildArgs}) =>
[
...?userBuildArgs?.split(' '),
if (release ?? false) '--release',
for (final path in testPaths)
'--build-filter=${p.setExtension(path, '.**')}',
];
List<String> buildRunnerBuildArgs(
List<String> 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<void> buildTests(List<String> testPaths,
{bool? release, String? userBuildArgs}) async {
Future<void> buildTests(
List<String> 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<void> runTests(List<String> testPaths,
{bool? release, String? userBuildArgs}) async {
Future<void> runTests(
List<String> 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,
];
stdout
..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<String> testPaths) {
stdout.write([
...buildRunnerBuildArgs(testPaths),
'--',
testPreset,
].join(' '));
stdout.write(
[
...buildRunnerBuildArgs(testPaths),
'--',
testPreset,
].join(' '),
);
}
6 changes: 3 additions & 3 deletions example/project/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ 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
build_test: ^2.1.3
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: ../..
Loading