Skip to content

Commit 3437137

Browse files
authored
Enable track widget creation when generating Generated.xcconfig (flutter#101123)
1 parent ff5e27f commit 3437137

File tree

6 files changed

+101
-6
lines changed

6 files changed

+101
-6
lines changed

packages/flutter_tools/lib/src/build_info.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ class BuildInfo {
164164
/// and skips the check and potential invalidation of files.
165165
final bool assumeInitializeFromDillUpToDate;
166166

167-
static const BuildInfo debug = BuildInfo(BuildMode.debug, null, treeShakeIcons: false);
167+
static const BuildInfo debug = BuildInfo(BuildMode.debug, null, trackWidgetCreation: true, treeShakeIcons: false);
168168
static const BuildInfo profile = BuildInfo(BuildMode.profile, null, treeShakeIcons: kIconTreeShakerEnabledDefault);
169169
static const BuildInfo jitRelease = BuildInfo(BuildMode.jitRelease, null, treeShakeIcons: kIconTreeShakerEnabledDefault);
170170
static const BuildInfo release = BuildInfo(BuildMode.release, null, treeShakeIcons: kIconTreeShakerEnabledDefault);

packages/flutter_tools/test/general.shard/build_info_test.dart

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,17 @@ void main() {
107107
expect(() => getIOSArchForName('bogus'), throwsException);
108108
});
109109

110+
testWithoutContext('named BuildInfo has correct defaults', () {
111+
expect(BuildInfo.debug.mode, BuildMode.debug);
112+
expect(BuildInfo.debug.trackWidgetCreation, true);
113+
114+
expect(BuildInfo.profile.mode, BuildMode.profile);
115+
expect(BuildInfo.profile.trackWidgetCreation, false);
116+
117+
expect(BuildInfo.release.mode, BuildMode.release);
118+
expect(BuildInfo.release.trackWidgetCreation, false);
119+
});
120+
110121
testWithoutContext('toBuildSystemEnvironment encoding of standard values', () {
111122
const BuildInfo buildInfo = BuildInfo(BuildMode.debug, '',
112123
treeShakeIcons: true,

packages/flutter_tools/test/general.shard/ios/xcodeproj_test.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -956,7 +956,7 @@ Build settings for action build and target plugin2:
956956
});
957957

958958
testUsingOsxContext('sets TRACK_WIDGET_CREATION=true when trackWidgetCreation is true', () async {
959-
const BuildInfo buildInfo = BuildInfo(BuildMode.debug, null, trackWidgetCreation: true, treeShakeIcons: false);
959+
const BuildInfo buildInfo = BuildInfo.debug;
960960
final FlutterProject project = FlutterProject.fromDirectoryTest(fs.directory('path/to/project'));
961961
await updateGeneratedXcodeProperties(
962962
project: project,
@@ -977,7 +977,7 @@ Build settings for action build and target plugin2:
977977
});
978978

979979
testUsingOsxContext('does not set TRACK_WIDGET_CREATION when trackWidgetCreation is false', () async {
980-
const BuildInfo buildInfo = BuildInfo.debug;
980+
const BuildInfo buildInfo = BuildInfo(BuildMode.debug, null, treeShakeIcons: false);
981981
final FlutterProject project = FlutterProject.fromDirectoryTest(fs.directory('path/to/project'));
982982
await updateGeneratedXcodeProperties(
983983
project: project,

packages/flutter_tools/test/general.shard/resident_runner_test.dart

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1570,7 +1570,13 @@ flutter:
15701570
flutterDevice,
15711571
],
15721572
stayResident: false,
1573-
debuggingOptions: DebuggingOptions.enabled(BuildInfo.debug),
1573+
debuggingOptions: DebuggingOptions.enabled(
1574+
const BuildInfo(
1575+
BuildMode.debug,
1576+
null,
1577+
treeShakeIcons: false,
1578+
)
1579+
),
15741580
target: 'main.dart',
15751581
devtoolsHandler: createNoOpHandler,
15761582
);
@@ -1641,6 +1647,29 @@ flutter:
16411647
'build', 'cache.dill')).readAsString(), 'ABC');
16421648
}));
16431649

1650+
testUsingContext('HotRunner copies compiled app.dill to cache during startup with track-widget-creation', () => testbed.run(() async {
1651+
fakeVmServiceHost = FakeVmServiceHost(requests: <VmServiceExpectation>[
1652+
listViews,
1653+
listViews,
1654+
], wsAddress: testUri);
1655+
globals.fs.file(globals.fs.path.join('lib', 'main.dart')).createSync(recursive: true);
1656+
residentRunner = HotRunner(
1657+
<FlutterDevice>[
1658+
flutterDevice,
1659+
],
1660+
stayResident: false,
1661+
debuggingOptions: DebuggingOptions.enabled(BuildInfo.debug),
1662+
target: 'main.dart',
1663+
devtoolsHandler: createNoOpHandler,
1664+
);
1665+
residentRunner.artifactDirectory.childFile('app.dill').writeAsStringSync('ABC');
1666+
1667+
await residentRunner.run(enableDevTools: true);
1668+
1669+
expect(await globals.fs.file(globals.fs.path.join(
1670+
'build', 'cache.dill.track.dill')).readAsString(), 'ABC');
1671+
}));
1672+
16441673
testUsingContext('HotRunner does not copy app.dill if a dillOutputPath is given', () => testbed.run(() async {
16451674
fakeVmServiceHost = FakeVmServiceHost(requests: <VmServiceExpectation>[
16461675
listViews,

packages/flutter_tools/test/general.shard/resident_web_runner_test.dart

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,10 @@ void main() {
256256
});
257257

258258
testUsingContext('WebRunner copies compiled app.dill to cache during startup', () async {
259-
final ResidentRunner residentWebRunner = setUpResidentRunner(flutterDevice);
259+
final DebuggingOptions debuggingOptions = DebuggingOptions.enabled(
260+
const BuildInfo(BuildMode.debug, null, treeShakeIcons: false),
261+
);
262+
final ResidentRunner residentWebRunner = setUpResidentRunner(flutterDevice, debuggingOptions: debuggingOptions);
260263
fakeVmServiceHost = FakeVmServiceHost(requests: kAttachExpectations.toList());
261264
_setupMocks();
262265

@@ -273,6 +276,24 @@ void main() {
273276
ProcessManager: () => processManager,
274277
});
275278

279+
testUsingContext('WebRunner copies compiled app.dill to cache during startup with track-widget-creation', () async {
280+
final ResidentRunner residentWebRunner = setUpResidentRunner(flutterDevice);
281+
fakeVmServiceHost = FakeVmServiceHost(requests: kAttachExpectations.toList());
282+
_setupMocks();
283+
284+
residentWebRunner.artifactDirectory.childFile('app.dill').writeAsStringSync('ABC');
285+
final Completer<DebugConnectionInfo> connectionInfoCompleter = Completer<DebugConnectionInfo>();
286+
unawaited(residentWebRunner.run(
287+
connectionInfoCompleter: connectionInfoCompleter,
288+
));
289+
await connectionInfoCompleter.future;
290+
291+
expect(await fileSystem.file(fileSystem.path.join('build', 'cache.dill.track.dill')).readAsString(), 'ABC');
292+
}, overrides: <Type, Generator>{
293+
FileSystem: () => fileSystem,
294+
ProcessManager: () => processManager,
295+
});
296+
276297
// Regression test for https://github.com/flutter/flutter/issues/60613
277298
testUsingContext('ResidentWebRunner calls appFailedToStart if initial compilation fails', () async {
278299
fakeVmServiceHost = FakeVmServiceHost(requests: kAttachExpectations.toList());
@@ -1048,11 +1069,12 @@ void main() {
10481069
ResidentRunner setUpResidentRunner(FlutterDevice flutterDevice, {
10491070
Logger logger,
10501071
SystemClock systemClock,
1072+
DebuggingOptions debuggingOptions,
10511073
}) {
10521074
return ResidentWebRunner(
10531075
flutterDevice,
10541076
flutterProject: FlutterProject.fromDirectoryTest(globals.fs.currentDirectory),
1055-
debuggingOptions: DebuggingOptions.enabled(BuildInfo.debug),
1077+
debuggingOptions: debuggingOptions ?? DebuggingOptions.enabled(BuildInfo.debug),
10561078
ipv6: true,
10571079
urlTunneller: null,
10581080
usage: globals.flutterUsage,

packages/flutter_tools/test/general.shard/tester/flutter_tester_test.dart

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,39 @@ Hello!
159159
''',
160160
));
161161

162+
final LaunchResult result = await device.startApp(app,
163+
mainPath: mainPath,
164+
debuggingOptions: DebuggingOptions.enabled(const BuildInfo(BuildMode.debug, null, treeShakeIcons: false)),
165+
);
166+
167+
expect(result.started, isTrue);
168+
expect(result.observatoryUri, observatoryUri);
169+
expect(logLines.last, 'Hello!');
170+
expect(fakeProcessManager.hasRemainingExpectations, isFalse);
171+
}, overrides: startOverrides);
172+
173+
testUsingContext('performs a build and starts in debug mode with track-widget-creation', () async {
174+
final FlutterTesterApp app = FlutterTesterApp.fromCurrentDirectory(fileSystem);
175+
final Uri observatoryUri = Uri.parse('http://127.0.0.1:6666/');
176+
final Completer<void> completer = Completer<void>();
177+
fakeProcessManager.addCommand(FakeCommand(
178+
command: const <String>[
179+
'Artifact.flutterTester',
180+
'--run-forever',
181+
'--non-interactive',
182+
'--enable-dart-profiling',
183+
'--packages=.dart_tool/package_config.json',
184+
'--flutter-assets-dir=/.tmp_rand0/flutter_tester.rand0',
185+
'/.tmp_rand0/flutter_tester.rand0/flutter-tester-app.dill.track.dill',
186+
],
187+
completer: completer,
188+
stdout:
189+
'''
190+
The Dart VM service is listening on $observatoryUri
191+
Hello!
192+
''',
193+
));
194+
162195
final LaunchResult result = await device.startApp(app,
163196
mainPath: mainPath,
164197
debuggingOptions: DebuggingOptions.enabled(BuildInfo.debug),

0 commit comments

Comments
 (0)