Unverified Commit 34371372 authored by Yang Chao's avatar Yang Chao Committed by GitHub

Enable track widget creation when generating Generated.xcconfig (#101123)

parent ff5e27f0
......@@ -164,7 +164,7 @@ class BuildInfo {
/// and skips the check and potential invalidation of files.
final bool assumeInitializeFromDillUpToDate;
static const BuildInfo debug = BuildInfo(BuildMode.debug, null, treeShakeIcons: false);
static const BuildInfo debug = BuildInfo(BuildMode.debug, null, trackWidgetCreation: true, treeShakeIcons: false);
static const BuildInfo profile = BuildInfo(BuildMode.profile, null, treeShakeIcons: kIconTreeShakerEnabledDefault);
static const BuildInfo jitRelease = BuildInfo(BuildMode.jitRelease, null, treeShakeIcons: kIconTreeShakerEnabledDefault);
static const BuildInfo release = BuildInfo(BuildMode.release, null, treeShakeIcons: kIconTreeShakerEnabledDefault);
......
......@@ -107,6 +107,17 @@ void main() {
expect(() => getIOSArchForName('bogus'), throwsException);
});
testWithoutContext('named BuildInfo has correct defaults', () {
expect(BuildInfo.debug.mode, BuildMode.debug);
expect(BuildInfo.debug.trackWidgetCreation, true);
expect(BuildInfo.profile.mode, BuildMode.profile);
expect(BuildInfo.profile.trackWidgetCreation, false);
expect(BuildInfo.release.mode, BuildMode.release);
expect(BuildInfo.release.trackWidgetCreation, false);
});
testWithoutContext('toBuildSystemEnvironment encoding of standard values', () {
const BuildInfo buildInfo = BuildInfo(BuildMode.debug, '',
treeShakeIcons: true,
......
......@@ -956,7 +956,7 @@ Build settings for action build and target plugin2:
});
testUsingOsxContext('sets TRACK_WIDGET_CREATION=true when trackWidgetCreation is true', () async {
const BuildInfo buildInfo = BuildInfo(BuildMode.debug, null, trackWidgetCreation: true, treeShakeIcons: false);
const BuildInfo buildInfo = BuildInfo.debug;
final FlutterProject project = FlutterProject.fromDirectoryTest(fs.directory('path/to/project'));
await updateGeneratedXcodeProperties(
project: project,
......@@ -977,7 +977,7 @@ Build settings for action build and target plugin2:
});
testUsingOsxContext('does not set TRACK_WIDGET_CREATION when trackWidgetCreation is false', () async {
const BuildInfo buildInfo = BuildInfo.debug;
const BuildInfo buildInfo = BuildInfo(BuildMode.debug, null, treeShakeIcons: false);
final FlutterProject project = FlutterProject.fromDirectoryTest(fs.directory('path/to/project'));
await updateGeneratedXcodeProperties(
project: project,
......
......@@ -1570,7 +1570,13 @@ flutter:
flutterDevice,
],
stayResident: false,
debuggingOptions: DebuggingOptions.enabled(BuildInfo.debug),
debuggingOptions: DebuggingOptions.enabled(
const BuildInfo(
BuildMode.debug,
null,
treeShakeIcons: false,
)
),
target: 'main.dart',
devtoolsHandler: createNoOpHandler,
);
......@@ -1641,6 +1647,29 @@ flutter:
'build', 'cache.dill')).readAsString(), 'ABC');
}));
testUsingContext('HotRunner copies compiled app.dill to cache during startup with track-widget-creation', () => testbed.run(() async {
fakeVmServiceHost = FakeVmServiceHost(requests: <VmServiceExpectation>[
listViews,
listViews,
], wsAddress: testUri);
globals.fs.file(globals.fs.path.join('lib', 'main.dart')).createSync(recursive: true);
residentRunner = HotRunner(
<FlutterDevice>[
flutterDevice,
],
stayResident: false,
debuggingOptions: DebuggingOptions.enabled(BuildInfo.debug),
target: 'main.dart',
devtoolsHandler: createNoOpHandler,
);
residentRunner.artifactDirectory.childFile('app.dill').writeAsStringSync('ABC');
await residentRunner.run(enableDevTools: true);
expect(await globals.fs.file(globals.fs.path.join(
'build', 'cache.dill.track.dill')).readAsString(), 'ABC');
}));
testUsingContext('HotRunner does not copy app.dill if a dillOutputPath is given', () => testbed.run(() async {
fakeVmServiceHost = FakeVmServiceHost(requests: <VmServiceExpectation>[
listViews,
......
......@@ -256,7 +256,10 @@ void main() {
});
testUsingContext('WebRunner copies compiled app.dill to cache during startup', () async {
final ResidentRunner residentWebRunner = setUpResidentRunner(flutterDevice);
final DebuggingOptions debuggingOptions = DebuggingOptions.enabled(
const BuildInfo(BuildMode.debug, null, treeShakeIcons: false),
);
final ResidentRunner residentWebRunner = setUpResidentRunner(flutterDevice, debuggingOptions: debuggingOptions);
fakeVmServiceHost = FakeVmServiceHost(requests: kAttachExpectations.toList());
_setupMocks();
......@@ -273,6 +276,24 @@ void main() {
ProcessManager: () => processManager,
});
testUsingContext('WebRunner copies compiled app.dill to cache during startup with track-widget-creation', () async {
final ResidentRunner residentWebRunner = setUpResidentRunner(flutterDevice);
fakeVmServiceHost = FakeVmServiceHost(requests: kAttachExpectations.toList());
_setupMocks();
residentWebRunner.artifactDirectory.childFile('app.dill').writeAsStringSync('ABC');
final Completer<DebugConnectionInfo> connectionInfoCompleter = Completer<DebugConnectionInfo>();
unawaited(residentWebRunner.run(
connectionInfoCompleter: connectionInfoCompleter,
));
await connectionInfoCompleter.future;
expect(await fileSystem.file(fileSystem.path.join('build', 'cache.dill.track.dill')).readAsString(), 'ABC');
}, overrides: <Type, Generator>{
FileSystem: () => fileSystem,
ProcessManager: () => processManager,
});
// Regression test for https://github.com/flutter/flutter/issues/60613
testUsingContext('ResidentWebRunner calls appFailedToStart if initial compilation fails', () async {
fakeVmServiceHost = FakeVmServiceHost(requests: kAttachExpectations.toList());
......@@ -1048,11 +1069,12 @@ void main() {
ResidentRunner setUpResidentRunner(FlutterDevice flutterDevice, {
Logger logger,
SystemClock systemClock,
DebuggingOptions debuggingOptions,
}) {
return ResidentWebRunner(
flutterDevice,
flutterProject: FlutterProject.fromDirectoryTest(globals.fs.currentDirectory),
debuggingOptions: DebuggingOptions.enabled(BuildInfo.debug),
debuggingOptions: debuggingOptions ?? DebuggingOptions.enabled(BuildInfo.debug),
ipv6: true,
urlTunneller: null,
usage: globals.flutterUsage,
......
......@@ -159,6 +159,39 @@ Hello!
''',
));
final LaunchResult result = await device.startApp(app,
mainPath: mainPath,
debuggingOptions: DebuggingOptions.enabled(const BuildInfo(BuildMode.debug, null, treeShakeIcons: false)),
);
expect(result.started, isTrue);
expect(result.observatoryUri, observatoryUri);
expect(logLines.last, 'Hello!');
expect(fakeProcessManager.hasRemainingExpectations, isFalse);
}, overrides: startOverrides);
testUsingContext('performs a build and starts in debug mode with track-widget-creation', () async {
final FlutterTesterApp app = FlutterTesterApp.fromCurrentDirectory(fileSystem);
final Uri observatoryUri = Uri.parse('http://127.0.0.1:6666/');
final Completer<void> completer = Completer<void>();
fakeProcessManager.addCommand(FakeCommand(
command: const <String>[
'Artifact.flutterTester',
'--run-forever',
'--non-interactive',
'--enable-dart-profiling',
'--packages=.dart_tool/package_config.json',
'--flutter-assets-dir=/.tmp_rand0/flutter_tester.rand0',
'/.tmp_rand0/flutter_tester.rand0/flutter-tester-app.dill.track.dill',
],
completer: completer,
stdout:
'''
The Dart VM service is listening on $observatoryUri
Hello!
''',
));
final LaunchResult result = await device.startApp(app,
mainPath: mainPath,
debuggingOptions: DebuggingOptions.enabled(BuildInfo.debug),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment