-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Description
flutter test is taking almost the same amount of time on a second run as the first, when the app should already be built.
On iOS this causes every test run to take an additional ~15 seconds.
test is subverting flutter assemble caching logic by passing in a new temp directory target listener.dart path every run, even when running the same test. This causes the build system to create a new build directory from the hash of the inputs including TargetFile.
flutter/packages/flutter_tools/lib/src/build_system/build_system.dart
Lines 351 to 358 in 61a0add
| for (final String key in keys) { | |
| buffer.write(key); | |
| buffer.write(defines[key]); | |
| } | |
| buffer.write(outputDir.path); | |
| final String output = buffer.toString(); | |
| final Digest digest = md5.convert(utf8.encode(output)); | |
| buildPrefix = hex.encode(digest.bytes); |
Every subsequent test run shows the assemble steps as needing a rerun due to InvalidatedReasonKind.inputChanged since each new build directory is missing the file store cache file from the last run:
[ +31 ms] debug_unpack_ios: Starting due to {InvalidatedReasonKind.inputChanged: The following inputs have updated contents: /Users/m/Projects/flutter/packages/flutter_tools/lib/src/build_system/targets/ios.dart,/Users/magder/Projects/flutter/bin/internal/engine.version}
[+1026 ms] Skipping target: gen_localizations
[ +5 ms] gen_dart_plugin_registrant: Starting due to {InvalidatedReasonKind.inputChanged: The following inputs have updated contents: /Users/m/Projects/plugins/packages/google_maps_flutter/google_maps_flutter/example/.dart_tool/package_config_subset}
[ +4 ms] debug_unpack_ios: Complete
...
[ +6 ms] gen_dart_plugin_registrant: Complete
For example, in google_maps_flutter example project running the same command twice:
$ flutter --no-color test --machine --start-paused --plain-name testGetVisibleRegion -v integration_test/google_maps_test.dart
calls identical assemble except for the different -dTargetFiles:
--verbose assemble --no-version-check --output=/Users/m/Projects/plugins/packages/google_maps_flutter/google_maps_flutter/example/build/ios/Debug-iphonesimulator/ -dTargetPlatform=ios -dTargetFile=/var/folders/bx/pyplw7v92lj58gm3_lztz5sc00mfq2/T/flutter_tools.5RYflD/flutter_test_listener.sO5mgy/listener.dart -dBuildMode=debug -dIosArchs=x86_64 -dSdkRoot=/Users/m/Applications/Xcode-14_beta3.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator16.0.sdk -dSplitDebugInfo= -dTreeShakeIcons=false -dTrackWidgetCreation=true -dDartObfuscation=false -dEnableBitcode= --ExtraGenSnapshotOptions= --DartDefines=RkxVVFRFUl9XRUJfQVVUT19ERVRFQ1Q9dHJ1ZQ==,SU5URUdSQVRJT05fVEVTVF9TSE9VTERfUkVQT1JUX1JFU1VMVFNfVE9fTkFUSVZFPWZhbHNl --ExtraFrontEndOptions= -dCodesignIdentity=- debug_ios_bundle_flutter_assets
--verbose assemble --no-version-check --output=/Users/m/Projects/plugins/packages/google_maps_flutter/google_maps_flutter/example/build/ios/Debug-iphonesimulator/ -dTargetPlatform=ios -dTargetFile=/var/folders/bx/pyplw7v92lj58gm3_lztz5sc00mfq2/T/flutter_tools.r0Vvcj/flutter_test_listener.uguobQ/listener.dart -dBuildMode=debug -dIosArchs=x86_64 -dSdkRoot=/Users/m/Applications/Xcode-14_beta3.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator16.0.sdk -dSplitDebugInfo= -dTreeShakeIcons=false -dTrackWidgetCreation=true -dDartObfuscation=false -dEnableBitcode= --ExtraGenSnapshotOptions= --DartDefines=RkxVVFRFUl9XRUJfQVVUT19ERVRFQ1Q9dHJ1ZQ==,SU5URUdSQVRJT05fVEVTVF9TSE9VTERfUkVQT1JUX1JFU1VMVFNfVE9fTkFUSVZFPWZhbHNl --ExtraFrontEndOptions= -dCodesignIdentity=- debug_ios_bundle_flutter_assets
flutter/packages/flutter_tools/lib/src/test/flutter_platform.dart
Lines 570 to 578 in db829c1
| // Prepare a temporary directory to store the Dart file that will talk to us. | |
| final Directory tempDir = globals.fs.systemTempDirectory.createTempSync('flutter_test_listener.'); | |
| finalizers.add(() async { | |
| globals.printTrace('test $ourTestCount: deleting temporary directory'); | |
| tempDir.deleteSync(recursive: true); | |
| }); | |
| // Prepare the Dart file that will talk to us and start the test. | |
| final File listenerFile = globals.fs.file('${tempDir.path}/listener.dart'); |
Metadata
Metadata
Assignees
Labels
Type
Projects
Status