Repository navigation
Commit e8ecaf8
committed
[flutter_tools] Simplify native_assets.json overwrite and EXDEV tests
Simplifies the fix and tests for avoiding redundant `native_assets.json` deletion and handling `EXDEV`:
- Restores `ErrorHandlingFileSystem.deleteIfExists` to upstream and removes custom `ForwardingFileSystem` test doubles in `error_handling_io_test.dart`, testing `EXDEV` (`errno = 18`) directly with `MemoryFileSystem.test(opHandle: exceptionHandler.opHandle)`.
- Streams `targetDir.list(followLinks: false)` in `_copyNativeCodeAssetsForOS` with `entity is File` instead of `.toList()` and `typeSync`, and deduplicates `installCodeAssets` test setup in `native_assets_test.dart`.
- Removes the redundant `flutter test` subprocess integration test (`native_assets_flutter_test_manifest_overwrite_test.dart`).
Reproduction notes: Both output pairs below were captured on a Linux host, which cannot reproduce the macOS external-volume behavior directly. The first pair comes from a small Dart script (`repro_exdev.dart`) calling `ErrorHandlingFileSystem.file(...).renameSync(...)` from `/tmp` (`tmpfs`) to an `ext4` directory to trigger a real kernel `EXDEV` (`errno = 18`). The second pair comes from running `BOT=true flutter test --no-pub -r expanded` on a minimal app after making `build/native_assets/linux` read-only (`chmod 0555`) while leaving `native_assets.json` writable (`0644`), so `unlink(2)` fails while in-place truncation succeeds; with a writable `build/native_assets/linux` directory, the unfixed tool passes with the same 3-line test output. Local workspace paths inside the fenced output blocks are preserved verbatim to match exact command output.
Previous output:
```
Unhandled exception:
FileSystemException: Cannot rename file to '/usr/local/google/home/bkonyi/.gemini/jetski/brain/0a669702-1e2d-46a6-9c37-fdc4d2ca98a9/scratch/repro_196121_dst.tmp', path = '/tmp/repro_196121_src.tmp' (OS Error: Invalid cross-device link, errno = 18)
#0 _File.throwIfError (dart:io/file_impl.dart:779:7)
#1 _File.renameSync (dart:io/file_impl.dart:396:5)
#2 ForwardingFileSystemEntity.renameSync (package:file/src/forwarding/forwarding_file_system_entity.dart:50:49)
#3 ErrorHandlingFile.renameSync.<anonymous closure> (package:flutter_tools/src/base/error_handling_io.dart:430:31)
#4 _runSync (package:flutter_tools/src/base/error_handling_io.dart:1116:16)
#5 ErrorHandlingFile.renameSync (package:flutter_tools/src/base/error_handling_io.dart:429:12)
#6 main (file:///usr/local/google/home/bkonyi/.gemini/jetski/brain/0a669702-1e2d-46a6-9c37-fdc4d2ca98a9/scratch/repro_exdev.dart:24:37)
flutter#7 _delayEntrypointInvocation.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:313:19)
flutter#8 _RawReceivePort._handleMessage (dart:isolate-patch/isolate_patch.dart:192:12)
```
Current output:
```
Flutter failed to rename file at "/tmp/repro_196121_src.tmp" to "/usr/local/google/home/bkonyi/.gemini/jetski/brain/0a669702-1e2d-46a6-9c37-fdc4d2ca98a9/scratch/repro_196121_dst.tmp".
A file system operation failed across different volumes or mount points.
FileSystemException: Cannot rename file to '/usr/local/google/home/bkonyi/.gemini/jetski/brain/0a669702-1e2d-46a6-9c37-fdc4d2ca98a9/scratch/repro_196121_dst.tmp', path = '/tmp/repro_196121_src.tmp' (OS Error: Invalid cross-device link, errno = 18)
Ensure that the project, build output, and temporary directories are on the same writable volume, or check external volume and security software settings.
```
Previous output (flutter test overwriting existing native_assets.json):
```
Flutter failed to delete file at
"/usr/local/google/home/bkonyi/.gemini/jetski/brain/0a669702-1e2d-46a6-9c37-fdc4
d2ca98a9/scratch/repro_app/build/native_assets/linux/native_assets.json".
Please ensure that the SDK and/or project is installed in a location that has
read/write permissions for the current user.
Try running:
sudo chown -R $(whoami)
/usr/local/google/home/bkonyi/.gemini/jetski/brain/0a669702-1e2d-46a6-9c37-fdc
4d2ca98a9/scratch/repro_app/build/native_assets/linux/native_assets.json
```
Current output (flutter test overwriting existing native_assets.json):
```
00:00 +0: loading /usr/local/google/home/bkonyi/.gemini/jetski/brain/0a669702-1e2d-46a6-9c37-fdc4d2ca98a9/scratch/repro_app/test/smoke_test.dart
00:00 +0: smoke test
00:00 +1: All tests passed!
```
Fixes flutter#1961211 parent bc4c193 commit e8ecaf8
6 files changed
Lines changed: 123 additions & 563 deletions
File tree
- dev/bots
- packages/flutter_tools
- lib/src
- base
- isolated/native_assets
- test
- general.shard
- base
- isolated
- integration.shard/isolated
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
159 | 159 | | |
160 | 160 | | |
161 | 161 | | |
162 | | - | |
163 | 162 | | |
164 | 163 | | |
165 | 164 | | |
| |||
377 | 376 | | |
378 | 377 | | |
379 | 378 | | |
380 | | - | |
381 | 379 | | |
382 | 380 | | |
383 | 381 | | |
| |||
595 | 593 | | |
596 | 594 | | |
597 | 595 | | |
598 | | - | |
599 | 596 | | |
600 | 597 | | |
601 | 598 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
123 | 123 | | |
124 | 124 | | |
125 | 125 | | |
126 | | - | |
127 | | - | |
128 | | - | |
| 126 | + | |
129 | 127 | | |
130 | 128 | | |
131 | 129 | | |
132 | 130 | | |
133 | 131 | | |
134 | | - | |
| 132 | + | |
135 | 133 | | |
136 | 134 | | |
137 | 135 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
831 | 831 | | |
832 | 832 | | |
833 | 833 | | |
834 | | - | |
835 | | - | |
836 | | - | |
| 834 | + | |
| 835 | + | |
837 | 836 | | |
838 | 837 | | |
839 | 838 | | |
| |||
0 commit comments