Reland "[data_assets] Cleanup tests"#184714
Conversation
349f0c3 to
18a26b6
Compare
There was a problem hiding this comment.
Code Review
This pull request introduces a comprehensive integration test suite for Dart data assets, including a new test application and a dependency package. It updates CI targets to incorporate these tests, pins the data_assets package version, and refactors license verification logic to handle HTML formats. Feedback suggests enhancing error messages during asset loading, implementing concurrency guards for asynchronous timers in the test application, and adopting more robust regular expressions for string replacements in test scripts.
| try { | ||
| found[assetId] = await rootBundle.loadString(assetId); | ||
| } catch (e) { | ||
| print('EXCEPTION $e'); |
| _timer = Timer.periodic(const Duration(milliseconds: 500), (_) async { | ||
| final AssetData? appAssetData = await loadAppAssets(); | ||
| final String dependencyAssetContent = await data_asset_package.loadAssetContent(); | ||
| // Print for integration test discovery | ||
| if (appAssetData != null) { | ||
| print('VERSION: ${appAssetData.version}'); | ||
| for (final MapEntry(:key, :value) in appAssetData.found.entries) { | ||
| print('FOUND "$key": "$value".'); | ||
| } | ||
| for (final String id in appAssetData.notFound) { | ||
| print('NOT_FOUND "$id".'); | ||
| } | ||
| } | ||
| print('DEPENDENCY_ASSET: $dependencyAssetContent'); | ||
|
|
||
| if (mounted) { | ||
| setState(() { | ||
| if (appAssetData != null) { | ||
| _assetData = appAssetData; | ||
| } | ||
| _dependencyAsset = dependencyAssetContent; | ||
| }); | ||
| } | ||
| }); |
There was a problem hiding this comment.
Using Timer.periodic with an async callback can lead to overlapping executions if the asynchronous operations take longer than the timer interval. This can cause race conditions or noisy output in integration tests. Consider using a flag to prevent concurrent executions.
bool isProcessing = false;
_timer = Timer.periodic(const Duration(milliseconds: 500), (_) async {
if (isProcessing) {
return;
}
isProcessing = true;
try {
final AssetData? appAssetData = await loadAppAssets();
final String dependencyAssetContent = await data_asset_package.loadAssetContent();
// Print for integration test discovery
if (appAssetData != null) {
print('VERSION: ${appAssetData.version}');
for (final MapEntry(:key, :value) in appAssetData.found.entries) {
print('FOUND "$key": "$value".');
}
for (final String id in appAssetData.notFound) {
print('NOT_FOUND "$id".');
}
}
print('DEPENDENCY_ASSET: $dependencyAssetContent');
if (mounted) {
setState(() {
if (appAssetData != null) {
_assetData = appAssetData;
}
_dependencyAsset = dependencyAssetContent;
});
}
} finally {
isProcessing = false;
}
});| entity.copySync(targetFile.path); | ||
| if (relativePath == 'pubspec.yaml') { | ||
| String content = targetFile.readAsStringSync(); | ||
| content = content.replaceFirst('resolution: workspace', ''); |
There was a problem hiding this comment.
The string replacement replaceFirst('resolution: workspace', '') is fragile as it depends on exact spacing and doesn't handle potential comments or trailing whitespace on the same line. Consider using a regular expression to match the line more robustly.
| content = content.replaceFirst('resolution: workspace', ''); | |
| content = content.replaceFirst(RegExp(r'^\s*resolution:\s*workspace\s*$', multiLine: true), ''); |
|
Golden file changes have been found for this pull request. Click here to view and triage (e.g. because this is an intentional change). If you are still iterating on this change and are not ready to resolve the images on the Flutter Gold dashboard, consider marking this PR as a draft pull request above. You will still be able to view image results on the dashboard, commenting will be silenced, and the check will not try to resolve itself until marked ready for review. For more guidance, visit Writing a golden file test for Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. |
flutter/flutter@9cd60b5...a0924c7 2026-04-07 [email protected] Reland "[data_assets] Cleanup tests" (flutter/flutter#184714) 2026-04-07 [email protected] Use the WindowRegistry in the multiple_windows example app (flutter/flutter#184579) 2026-04-07 [email protected] Introduce command to build a swift package for SwiftPM add to app integration (flutter/flutter#184660) 2026-04-07 [email protected] Have `flutter create` create a pubspec.lock to ensure pinned versions are being used. (flutter/flutter#175352) 2026-04-07 [email protected] [widgets/raw_menu_anchor.dart] Always call onClose and onCloseRequested on descendants before parent. (flutter/flutter#182357) 2026-04-07 [email protected] `WindowsPlugin` should not crash when ffiPlugin enabled (flutter/flutter#184695) 2026-04-06 [email protected] Use full goto.google.com hostname for go/ links (flutter/flutter#184679) 2026-04-06 [email protected] Apply rect clipping to surface views (flutter/flutter#184471) 2026-04-06 [email protected] [A11y] Allow percentage strings like "50%" as `SemanticsValue` for `ProgressIndicator` (flutter/flutter#183670) 2026-04-06 [email protected] Fix invisible accessibility element before scroll view (flutter/flutter#184155) 2026-04-06 [email protected] Roll Skia from 163dfdf500c7 to e264d870a380 (2 revisions) (flutter/flutter#184674) 2026-04-06 [email protected] Keep last character obscured when toggling obscureText (flutter/flutter#183488) 2026-04-06 [email protected] Parse scheme file with XML parser for SwiftPM migrator (flutter/flutter#184525) If this roll has caused a breakage, revert this CL and stop the roller using the controls here: https://autoroll.skia.org/r/flutter-packages Please CC [email protected],[email protected] on the revert to ensure that a human is aware of the problem. To file a bug in Packages: https://github.com/flutter/flutter/issues/new/choose To report a problem with the AutoRoller itself, please file a bug: https://issues.skia.org/issues/new?component=1389291&template=1850622 Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
Relands flutter#184209 adding a mac shard as suggested in flutter#184209 (comment). For adding a shard, I followed flutter#154444, which suggests it's contained in the single `.ci.yaml` file, and the new shard names need to have `bringup: true`. ---- Original PR description: This cleans up the data_assets experiment testing. * Use integration test projects, which are statically analyzed, formatted, etc. * This forces us to be explicit about the `package:data_assets` dependency. * This means the test projects will roll their dependencies with the dependency auto roller. (The test project was still using `native_assets_cli` which has been replaced with `hooks` and `data_assets`.) * Pin `package:data_assets`, because it's experimental, and we might do breaking changes. Also makes the test projects more useful: * The `data_assets_app` now displays the assets in the UI. (Not only prints to the console for the integration tests.) * The `data_assets_package` now actually uses its asset. And cleans up the test projects: * Move the test files into the `data/` dir. * Give the test data assets a proper extension. I saw weird behavior on Windows: * DevFS doesn't pick up the writes to the Dart files, not even with flushing or sleeps: `Compiling dart to kernel with 0 updated files` leading to a state where the Dart variable contents don't get updated while the data assets do. This integration test is not really about Dart hot restart, so I've skipped those checks on Windows. * This reproduces locally in the integration test, but not when running the app and editing the file. The checks in dev/bots/analyze.dart also required some updates: * The template files check didn't allow for the HTML license. P.S. Sorry for all the generated Flutter scaffolding. It seems that that is the way it's done in the integration test directory. (The package with the data assets is clean, but the Flutter app ...)
Relands #184209 adding a mac shard as suggested in #184209 (comment).
For adding a shard, I followed #154444, which suggests it's contained in the single
.ci.yamlfile, and the new shard names need to havebringup: true.Original PR description:
This cleans up the data_assets experiment testing.
package:data_assetsdependency.native_assets_cliwhich has been replaced withhooksanddata_assets.)package:data_assets, because it's experimental, and we might do breaking changes.Also makes the test projects more useful:
data_assets_appnow displays the assets in the UI. (Not only prints to the console for the integration tests.)data_assets_packagenow actually uses its asset.And cleans up the test projects:
data/dir.I saw weird behavior on Windows:
Compiling dart to kernel with 0 updated filesleading to a state where the Dart variable contents don't get updated while the data assets do. This integration test is not really about Dart hot restart, so I've skipped those checks on Windows.The checks in dev/bots/analyze.dart also required some updates:
P.S. Sorry for all the generated Flutter scaffolding. It seems that that is the way it's done in the integration test directory. (The package with the data assets is clean, but the Flutter app ...)