Skip to content

Commit b2ebd84

Browse files
Merge pull request #53 from Workiva/revert-52-smart-output-of-backwards-compat-file
Revert "FEDX-1987: Only generate backwards-compatible output when necessary"
2 parents d7e1979 + bf1d78a commit b2ebd84

File tree

7 files changed

+13
-80
lines changed

7 files changed

+13
-80
lines changed

.github/workflows/dart_ci.yaml

+2-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ jobs:
3636
- run: dart pub get
3737
- run: dart run dependency_validator
3838
- run: dart analyze
39-
- run: dart test
39+
- run: dart test test/lib
40+
- run: dart test test/bin
4041
- uses: anchore/sbom-action@v0
4142
if: ${{ matrix.sdk == 'stable' }}
4243
with:

CHANGELOG.md

-6
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,3 @@
1-
## 3.1.0
2-
3-
- The `test/dart_test.browser_aggregate.yaml` file was previously always
4-
generated for backwards-compatibility. With this release, it is only generated
5-
if a reference to it is found in `dart_test.yaml`.
6-
71
## 3.0.3
82

93
- Compatible with Dart 3.

bin/browser_aggregate_tests.dart

+3-9
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,7 @@ final argParser = ArgParser()
2323
..addOption('build-args',
2424
help: 'Args to pass to the build runner process.\n'
2525
'Run "dart run build_runner build -h -v" to see all available '
26-
'options.')
27-
..addOption('test-args',
28-
help: 'Args to pass to the dart test process.\n'
29-
'Run "dart test -h" to see all available options.');
26+
'options.');
3027

3128
enum Mode {
3229
// Print build and test args separated by `--`
@@ -65,7 +62,6 @@ void main(List<String> args) async {
6562

6663
final bool? release = parsed['release'];
6764
final String? buildArgs = parsed['build-args'];
68-
final String? testArgs = parsed['test-args'];
6965

7066
buildAggregateTestYaml(mode, userBuildArgs: buildArgs);
7167
final testPaths = parseAggregateTestPaths(mode);
@@ -74,8 +70,7 @@ void main(List<String> args) async {
7470
} else if (mode == Mode.build) {
7571
await buildTests(testPaths, release: release, userBuildArgs: buildArgs);
7672
} else {
77-
await runTests(testPaths,
78-
release: release, userBuildArgs: buildArgs, userTestArgs: testArgs);
73+
await runTests(testPaths, release: release, userBuildArgs: buildArgs);
7974
}
8075
}
8176

@@ -192,7 +187,7 @@ Future<void> buildTests(List<String> testPaths,
192187
///
193188
/// Includes `--release` if [release] is true.
194189
Future<void> runTests(List<String> testPaths,
195-
{bool? release, String? userBuildArgs, String? userTestArgs}) async {
190+
{bool? release, String? userBuildArgs}) async {
196191
final executable = 'dart';
197192
final args = [
198193
'run',
@@ -201,7 +196,6 @@ Future<void> runTests(List<String> testPaths,
201196
...buildRunnerBuildArgs(testPaths,
202197
release: release, userBuildArgs: userBuildArgs),
203198
'--',
204-
...?userTestArgs?.split(' '),
205199
testPreset,
206200
];
207201
stdout

lib/src/builder.dart

+3-33
Original file line numberDiff line numberDiff line change
@@ -333,39 +333,9 @@ class DartTestYamlBuilder extends Builder {
333333
AssetId(buildStep.inputId.package, 'dart_test.browser_aggregate.yaml');
334334
await buildStep.writeAsString(outputId, contents.toString());
335335

336-
var shouldWriteBackwardsCompatOutput = false;
337-
try {
338-
final dartTestYamlId =
339-
AssetId(buildStep.inputId.package, 'dart_test.yaml');
340-
final dartTestYaml = await buildStep.readAsString(dartTestYamlId);
341-
if (dartTestYaml.contains('test/dart_test.browser_aggregate.yaml')) {
342-
log.warning(
343-
'Found `test/dart_test.browser_aggregate.yaml` in `dart_test.yaml`, will generate it for backwards-compatibility.\n'
344-
'Please update your `dart_test.yaml` to include `dart_test.browser_aggregate.yaml` instead.');
345-
shouldWriteBackwardsCompatOutput = true;
346-
} else {
347-
log.fine(
348-
'No `test/dart_test.browser_aggregate.yaml` found in `dart_test.yaml`, skipping backwards-compatible generation.');
349-
}
350-
} on AssetNotFoundException catch (_) {
351-
log.fine(
352-
'No `dart_test.yaml` found, skipping backwards-compatible generation of `test/dart_test.browser_aggregate.yaml`.');
353-
} catch (e) {
354-
log.fine(
355-
'Error reading `dart_test.yaml`, skipping backwards-compatible generation of `test/dart_test.browser_aggregate.yaml`.',
356-
e);
357-
}
358-
359-
if (shouldWriteBackwardsCompatOutput) {
360-
final backwardsCompatOutputId = AssetId(
361-
buildStep.inputId.package,
362-
'test/dart_test.browser_aggregate.yaml',
363-
);
364-
await buildStep.writeAsString(
365-
backwardsCompatOutputId,
366-
contents.toString(),
367-
);
368-
}
336+
final backwardsCompatOutputId = AssetId(
337+
buildStep.inputId.package, 'test/dart_test.browser_aggregate.yaml');
338+
await buildStep.writeAsString(backwardsCompatOutputId, contents.toString());
369339
}
370340
}
371341

pubspec.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ dependencies:
2020
json_annotation: ^4.1.0
2121
path: ^1.8.0
2222
test: ^1.17.12
23-
test_core: ">=0.4.2 <0.7.0"
23+
test_core: ">=0.4.2 <0.6.0"
2424
yaml: ^3.1.0
2525

2626
dev_dependencies:

test/lib/dart_test_yaml_builder_test.dart

-26
Original file line numberDiff line numberDiff line change
@@ -38,32 +38,6 @@ void main() {
3838
paths:
3939
- test/foo_template.browser_aggregate_test.dart
4040
- test/custom_test.dart
41-
'''
42-
});
43-
});
44-
45-
test('generates the backwards-compatible yaml output when needed',
46-
() async {
47-
final config = TestHtmlBuilderConfig(browserAggregation: true);
48-
final builder = DartTestYamlBuilder();
49-
await testBuilder(builder, {
50-
'a|dart_test.yaml': 'include: "test/dart_test.browser_aggregate.yaml"',
51-
'a|test/test_html_builder_config.json': jsonEncode(config),
52-
'a|test/foo_template.browser_aggregate_test.dart': '',
53-
'a|test/foo_template.html': '',
54-
// This template should be found, but ignored because there is no
55-
// accompanying .browser_aggregate_test.dart
56-
'a|test/bar_template.html': '',
57-
// This test should get included because it has a custom HTML
58-
'a|test/custom_test.dart': '',
59-
'a|test/custom_test.custom.html': '',
60-
}, outputs: {
61-
'a|dart_test.browser_aggregate.yaml': '''presets:
62-
browser-aggregate:
63-
platforms: [chrome]
64-
paths:
65-
- test/foo_template.browser_aggregate_test.dart
66-
- test/custom_test.dart
6741
''',
6842
'a|test/dart_test.browser_aggregate.yaml': '''presets:
6943
browser-aggregate:

tool/test_example.sh

+4-4
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33
set -e
44

55
cd example/project
6-
dart pub upgrade
6+
dart pub get
77
dart run build_runner build --delete-conflicting-outputs
8-
dart run build_runner test -- --concurrency=1 # concurrency=1 is a workaround for this issue: https://github.com/dart-lang/test/issues/2294
9-
dart run test_html_builder:browser_aggregate_tests --test-args="--concurrency=1" # concurrency=1 is a workaround for this issue: https://github.com/dart-lang/test/issues/2294
8+
dart run build_runner test
9+
dart run test_html_builder:browser_aggregate_tests
1010

1111
# These commands target a scenario where there is no build cache and someone
1212
# uses build filters to run a subset of tests.
1313
dart run build_runner clean
14-
dart run build_runner test --delete-conflicting-outputs --build-filter="test/unit/css_test.**" -- --concurrency=1 test/unit/css_test.dart # concurrency=1 is a workaround for this issue: https://github.com/dart-lang/test/issues/2294
14+
dart run build_runner test --delete-conflicting-outputs --build-filter="test/unit/css_test.**" -- test/unit/css_test.dart

0 commit comments

Comments
 (0)