Repository navigation
Commit b3804a3
authored
[stable] [flutter_tools] Fix StateError in testCompilerBuildNativeAssets when package root does not match projectUri (#194959)
This pull request is created by [automatic cherry pick workflow](https://github.com/flutter/flutter/blob/main/docs/releases/Flutter-Cherrypick-Process.md#automatically-creates-a-cherry-pick-request)
Please fill in the form below, and a flutter domain expert will evaluate this cherry pick request.
### Issue Link:
#192933
### Impact Description:
Fixes a `StateError (Bad state: No element)` crash in `testCompilerBuildNativeAssets` when running `flutter test` in directories where the package root URI does not strictly match `projectUri` in `package_config.json` (such as in pub workspaces, monorepos, symlinked project directories, or when ancestor `package_config.json` files are used). This crash was observed in Flutter 3.47.3 crash telemetry and blocks affected users from running `flutter test`.
### Changelog Description:
[flutter/192933] When running `flutter test` in pub workspaces, monorepos, or symlinked directories, fix a StateError crash during native assets compilation by falling back to appName matching.
### Workaround:
Run `flutter test` from the exact directory matching the package root or pass `--no-native-assets` when native assets are not required.
### Risk:
### Test Coverage:
Are you confident that your fix is well-tested by automated tests?
### Validation Steps:
Run `flutter test` in a project with a symlinked path or inside a pub workspace member package and verify that `testCompilerBuildNativeAssets` executes cleanly without throwing `StateError (Bad state: No element)`.
### Conflicts Resolved:
- `packages/flutter_tools/lib/src/isolated/native_assets/test/native_assets.dart`: Adapted `testCompilerBuildNativeAssets` to maintain the `Future<Uri?>` return type and constructor signature present on `flutter-3.47-candidate.0`, returning `null` on failure and `nativeAssetsFileUri` on success.
- `packages/flutter_tools/test/general.shard/isolated/native_assets_test.dart`: Updated regression tests to expect `Uri?` rather than the `TestCompilerNativeAssetsBuildResult` record type introduced in later master commits.1 parent cbf63ce commit b3804a3
2 files changed
Lines changed: 441 additions & 13 deletions
File tree
- packages/flutter_tools
- lib/src/isolated/native_assets/test
- test/general.shard/isolated
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| 8 | + | |
8 | 9 | | |
9 | 10 | | |
| 11 | + | |
10 | 12 | | |
11 | 13 | | |
12 | 14 | | |
| |||
15 | 17 | | |
16 | 18 | | |
17 | 19 | | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
18 | 25 | | |
19 | 26 | | |
20 | 27 | | |
| |||
28 | 35 | | |
29 | 36 | | |
30 | 37 | | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
31 | 47 | | |
32 | | - | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
33 | 70 | | |
34 | 71 | | |
35 | | - | |
36 | | - | |
37 | | - | |
38 | | - | |
39 | 72 | | |
40 | | - | |
41 | | - | |
| 73 | + | |
| 74 | + | |
42 | 75 | | |
43 | | - | |
44 | | - | |
| 76 | + | |
| 77 | + | |
45 | 78 | | |
46 | 79 | | |
47 | 80 | | |
48 | | - | |
49 | 81 | | |
| 82 | + | |
50 | 83 | | |
51 | 84 | | |
52 | 85 | | |
| |||
66 | 99 | | |
67 | 100 | | |
68 | 101 | | |
69 | | - | |
| 102 | + | |
70 | 103 | | |
71 | | - | |
| 104 | + | |
72 | 105 | | |
73 | 106 | | |
74 | 107 | | |
| |||
93 | 126 | | |
94 | 127 | | |
95 | 128 | | |
96 | | - | |
| 129 | + | |
97 | 130 | | |
98 | 131 | | |
99 | 132 | | |
100 | 133 | | |
101 | 134 | | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
0 commit comments