Skip to content

[flutter_tools] Bundle data assets from hooks in flutter test - #193435

Merged
auto-submit[bot] merged 1 commit into
flutter:masterfrom
dcharkes:data-assets-flutter-test
Oct 1, 2026
Merged

auto-submit[bot] merged 1 commit into
flutter:masterfrom
dcharkes:data-assets-flutter-test

Conversation

@dcharkes

@dcharkes dcharkes commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

Previously, flutter test ran native assets hooks via TestCompilerNativeAssetsBuilder.build(buildInfo), which only returned the NativeAssetsManifest.json URI and discarded the FlutterHookResult containing hook-generated data assets.

Bug:

Changes

  • Add buildWithHookResult to TestCompilerNativeAssetsBuilder returning both nativeAssetsManifest and flutterHookResult.
  • Pass flutterHookResult to _buildTestAsset / assetBundle.build in TestCommand.
  • Update TestCommand._needsRebuild to check if bundled asset files exist on disk, guard pub.existsSync(), and check flutterHookResult.dependencies modification timestamps.
  • Add a hermetic test in test_test.dart verifying that flutter test bundles data assets from hooks into build/unit_test_assets.

PR Stack

# PR Branch Commit
1 #193434 data-assets-empty-pubspec ab37f42
2 👉 #193435 (this PR) data-assets-flutter-test 4956c97
3 #193436 data-assets-dev-dependencies-release-test 596124d
4 #193437 data-assets-widget-preview bd246d9

Pre-launch Checklist

  • I read the [Contributor Guide] and followed the process outlined there for submitting PRs.
  • I read the [AI contribution guidelines] and understand my responsibilities, or I am not using AI tools.
  • I read the [Tree Hygiene] wiki page, which explains my responsibilities.
  • I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement].
  • I signed the [CLA].
  • I listed at least one issue that this PR fixes in the description above.
  • I updated/added relevant in-code documentation (doc comments with ///).
  • If this PR introduces a new feature or capability, I created and linked a website documentation issue or PR in [flutter/website] (or verified none is needed).
  • I added new tests to check the change I am making, or this PR is [test-exempt].
  • I followed the [breaking change policy] and added [Data Driven Fixes] where supported.
  • All existing and new tests are passing.

@github-actions github-actions Bot added the tool Affects the "flutter" command-line tool. See also t: labels. label Sep 28, 2026
@dcharkes
dcharkes force-pushed the data-assets-flutter-test branch from 964d19e to 25be1ab Compare September 28, 2026 09:58
@dcharkes dcharkes added the CICD Run CI/CD label Sep 28, 2026
@dcharkes
dcharkes requested a review from bkonyi September 28, 2026 10:18
pull Bot pushed a commit to phamminhphuc/flutter that referenced this pull request Sep 28, 2026
…mpty (flutter#193434)

When `flutterManifest.isEmpty` (for example, a `pubspec.yaml` without a
`flutter:` section), `ManifestAssetBundle.build` previously returned
early with an empty `AssetManifest.bin`, ignoring any data assets
produced by build/link hooks (`flutterHookResult.dataAssets`).

Bug:

* flutter#146264

### Changes
- Only short-circuit with an empty manifest in
`ManifestAssetBundle.build` when both `flutterManifest.isEmpty` and
`flutterHookResult?.dataAssets.isEmpty ?? true`.
- Skip `computeTransitiveDependencies` when `flutterManifest.isEmpty`.
- Add a unit test in `asset_bundle_test.dart` verifying that data assets
from hooks are bundled when `pubspec.yaml` is empty.

### PR Stack
| # | PR | Branch | Commit |
| :-: | :--- | :--- | :--- |
| **1** | **👉 flutter#193434 (this PR)**
| `data-assets-empty-pubspec` |
flutter@62199c4
|
| 2 | flutter#193435 |
`data-assets-flutter-test` |
flutter@25be1ab
|
| 3 | flutter#193436 |
`data-assets-dev-dependencies-release-test` |
flutter@79abad9
|
| 4 | flutter#193437 |
`data-assets-widget-preview` |
flutter@98f1001
|

## Pre-launch Checklist

- [x] I read the [Contributor Guide] and followed the process outlined
there for submitting PRs.
- [x] I read the [AI contribution guidelines] and understand my
responsibilities, or I am not using AI tools.
- [x] I read the [Tree Hygiene] wiki page, which explains my
responsibilities.
- [x] I read and followed the [Flutter Style Guide], including [Features
we expect every widget to implement].
- [x] I signed the [CLA].
- [x] I listed at least one issue that this PR fixes in the description
above.
- [x] I updated/added relevant in-code documentation (doc comments with
`///`).
- [x] If this PR introduces a new feature or capability, I created and
linked a website documentation issue or PR in [flutter/website] (or
verified none is needed).
- [x] I added new tests to check the change I am making, or this PR is
[test-exempt].
- [x] I followed the [breaking change policy] and added [Data Driven
Fixes] where supported.
- [x] All existing and new tests are passing.
@dcharkes
dcharkes force-pushed the data-assets-flutter-test branch from 25be1ab to 390c757 Compare September 28, 2026 14:56
@dcharkes
dcharkes marked this pull request as ready for review September 28, 2026 15:02

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request updates the Flutter test command to support building and rebuilding asset bundles with data assets and dependencies generated from Dart hooks. It retrieves hook results from the native assets builder and checks if any hook dependencies have been modified to determine if a rebuild is needed. Feedback on the changes identifies an issue where deleted dependency files will fail to trigger a rebuild; the logic should be updated to trigger a rebuild if a dependency file is missing.

Comment thread packages/flutter_tools/lib/src/commands/test.dart
@dcharkes
dcharkes force-pushed the data-assets-flutter-test branch 2 times, most recently from acdac65 to 7492217 Compare September 29, 2026 08:22
bkonyi
bkonyi previously approved these changes Sep 30, 2026
abstract class TestCompilerNativeAssetsBuilder {
Future<Uri?> build(BuildInfo buildInfo);

Future<({Uri? nativeAssetsManifest, FlutterHookResult? flutterHookResult})> buildWithHookResult(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nit: consider creating a typedef for this record type.

@dcharkes
dcharkes force-pushed the data-assets-flutter-test branch 2 times, most recently from f7d1be0 to 35f079d Compare October 1, 2026 07:49
@dcharkes
dcharkes force-pushed the data-assets-flutter-test branch from 35f079d to afb4ce5 Compare October 1, 2026 09:40
@dcharkes
dcharkes requested a review from bkonyi October 1, 2026 09:43
@dcharkes dcharkes added the autosubmit Merge PR when tree becomes green via auto submit App label Oct 1, 2026
@auto-submit
auto-submit Bot added this pull request to the merge queue Oct 1, 2026
Merged via the queue into flutter:master with commit 4956c97 Oct 1, 2026
22 of 23 checks passed
@flutter-dashboard flutter-dashboard Bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Oct 1, 2026
auto-submit Bot pushed a commit to flutter/packages that referenced this pull request Oct 1, 2026
…13104)

Manual roll requested by [email protected]

flutter/flutter@d649d2b...e89fd0a

2026-10-01 [email protected] Manual roll ICU from 6ebb40c59477 to 5aa526207171 (2 revisions) (flutter/flutter#193661)
2026-10-01 [email protected] fix(web): hash source maps before rewriting sourceMappingURL with --web-content-hash (flutter/flutter#193614)
2026-10-01 [email protected] [flutter_tools] Bootstrap DeviceManager in ToolDependencies (flutter/flutter#193524)
2026-10-01 [email protected] [wasm] Set flutter_runtime_mode in tools/gn to_gn_wasm_args (flutter/flutter#193407)
2026-10-01 [email protected] Remove remaining `download_jdk` references (flutter/flutter#193562)
2026-10-01 [email protected] Synchronize dart2wasm feature probes in roll script and flutter_bootstrap.js (flutter/flutter#193271)
2026-10-01 [email protected] [web] Unskip web tests that now pass in gestures, services, and widgets (flutter/flutter#193512)
2026-10-01 [email protected] Roll Fuchsia Test Scripts from whZAV1mfT-Rdc0rQ8... to fCNknap4ZI0AMcvIf... (flutter/flutter#193640)
2026-10-01 [email protected] Roll Skia from 0575a37d0619 to f2d68e0b8863 (2 revisions) (flutter/flutter#193621)
2026-10-01 [email protected] perf(widgets): use const <Never>{} in InheritedModelElement and avoid redundant casts in RenderObjectElement.update (flutter/flutter#192913)
2026-10-01 [email protected] [web] Unskip and strengthen missing glyph tofu test on Wimp (flutter/flutter#193426)
2026-10-01 [email protected] [flutter_tools] Fix `flutter drive -d chrome` hanging on web (flutter/flutter#193459)
2026-10-01 [email protected] [web] Fix hang when Chromium cannot bind remote debugging port (flutter/flutter#193461)
2026-10-01 [email protected] [flutter_tools] Bundle data assets from hooks in flutter test (flutter/flutter#193435)
2026-10-01 [email protected] Roll Packages from 0ba9a82 to d5ec6db (11 revisions) (flutter/flutter#193641)
2026-10-01 [email protected] Revert: [flutter_tools] Fix DTD "Stream already subscribed" error and wait for analysis over DTD in widget preview (flutter/flutter#193637)
2026-10-01 [email protected] Roll Skia from 6182a3cf8f98 to 0575a37d0619 (5 revisions) (flutter/flutter#193613)
2026-10-01 [email protected] [flutter_tools] Fix DTD "Stream already subscribed" error and wait for analysis over DTD in widget preview (flutter/flutter#192930)
2026-09-30 [email protected] [Impeller] Sample the render target rect in offscreen advanced blends (flutter/flutter#192988)
2026-09-30 [email protected] Roll Skia from 01524014dff5 to 6182a3cf8f98 (11 revisions) (flutter/flutter#193594)
2026-09-30 [email protected] [web] Use Xvfb -displayfd and clean up Xvfb after Firefox test suites (flutter/flutter#193510)
2026-09-30 [email protected] Fixes bug where sibling node fail to update size (flutter/flutter#191220)
2026-09-30 [email protected] Roll Skia from c7b323126bf0 to 01524014dff5 (3 revisions) (flutter/flutter#193577)
2026-09-30 [email protected] Remove some Undefined Behavior from run_customer_testing_tests.dart. (flutter/flutter#193582)
2026-09-30 [email protected] Fix pointer id/coordinate mismatch in Android platform view multi-touch (flutter/flutter#191631)
2026-09-30 [email protected] Roll Packages from 3c6ce59 to 0ba9a82 (11 revisions) (flutter/flutter#193578)
2026-09-30 [email protected] Fix unresolved doc comment references in dev/ tooling (flutter/flutter#193501)

If this roll has caused a breakage, revert this CL and set the roller
to dry run mode 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CICD Run CI/CD tool Affects the "flutter" command-line tool. See also t: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants