mirror of
https://github.com/flutter/flutter
synced 2024-10-13 11:42:54 +00:00
enable track widget creation on debug builds (#37512)
This commit is contained in:
parent
a785db78fb
commit
caa56d6ac4
|
@ -96,7 +96,7 @@ class KernelSnapshot extends Target {
|
|||
final CompilerOutput output = await compiler.compile(
|
||||
sdkRoot: artifacts.getArtifactPath(Artifact.flutterPatchedSdkPath, mode: buildMode),
|
||||
aot: buildMode != BuildMode.debug,
|
||||
trackWidgetCreation: false,
|
||||
trackWidgetCreation: buildMode == BuildMode.debug,
|
||||
targetModel: TargetModel.flutter,
|
||||
targetProductVm: buildMode == BuildMode.release,
|
||||
outputFilePath: environment.buildDir.childFile('app.dill').path,
|
||||
|
|
|
@ -114,6 +114,59 @@ flutter_tools:lib/''');
|
|||
expect(result.exceptions.values.single.exception, isInstanceOf<MissingDefineException>());
|
||||
}));
|
||||
|
||||
test('kernel_snapshot does not use track widget creation on profile builds', () => testbed.run(() async {
|
||||
final MockKernelCompiler mockKernelCompiler = MockKernelCompiler();
|
||||
when(kernelCompilerFactory.create(any)).thenAnswer((Invocation _) async {
|
||||
return mockKernelCompiler;
|
||||
});
|
||||
when(mockKernelCompiler.compile(
|
||||
sdkRoot: anyNamed('sdkRoot'),
|
||||
aot: anyNamed('aot'),
|
||||
trackWidgetCreation: false,
|
||||
targetModel: anyNamed('targetModel'),
|
||||
targetProductVm: anyNamed('targetProductVm'),
|
||||
outputFilePath: anyNamed('outputFilePath'),
|
||||
depFilePath: anyNamed('depFilePath'),
|
||||
packagesPath: anyNamed('packagesPath'),
|
||||
mainPath: anyNamed('mainPath')
|
||||
)).thenAnswer((Invocation _) async {
|
||||
return const CompilerOutput('example', 0, <Uri>[]);
|
||||
});
|
||||
|
||||
await const KernelSnapshot().build(<File>[], androidEnvironment);
|
||||
}, overrides: <Type, Generator>{
|
||||
KernelCompilerFactory: () => MockKernelCompilerFactory(),
|
||||
}));
|
||||
|
||||
test('kernel_snapshot does use track widget creation on debug builds', () => testbed.run(() async {
|
||||
final MockKernelCompiler mockKernelCompiler = MockKernelCompiler();
|
||||
when(kernelCompilerFactory.create(any)).thenAnswer((Invocation _) async {
|
||||
return mockKernelCompiler;
|
||||
});
|
||||
when(mockKernelCompiler.compile(
|
||||
sdkRoot: anyNamed('sdkRoot'),
|
||||
aot: anyNamed('aot'),
|
||||
trackWidgetCreation: true,
|
||||
targetModel: anyNamed('targetModel'),
|
||||
targetProductVm: anyNamed('targetProductVm'),
|
||||
outputFilePath: anyNamed('outputFilePath'),
|
||||
depFilePath: anyNamed('depFilePath'),
|
||||
packagesPath: anyNamed('packagesPath'),
|
||||
mainPath: anyNamed('mainPath')
|
||||
)).thenAnswer((Invocation _) async {
|
||||
return const CompilerOutput('example', 0, <Uri>[]);
|
||||
});
|
||||
|
||||
await const KernelSnapshot().build(<File>[], Environment(
|
||||
projectDir: fs.currentDirectory,
|
||||
defines: <String, String>{
|
||||
kBuildMode: 'debug',
|
||||
kTargetPlatform: getNameForTargetPlatform(TargetPlatform.android_arm),
|
||||
}));
|
||||
}, overrides: <Type, Generator>{
|
||||
KernelCompilerFactory: () => MockKernelCompilerFactory(),
|
||||
}));
|
||||
|
||||
test('aot_elf_profile Produces correct output directory', () => testbed.run(() async {
|
||||
await buildSystem.build(const AotElfProfile(), androidEnvironment);
|
||||
|
||||
|
@ -321,3 +374,6 @@ class FakeKernelCompiler implements KernelCompiler {
|
|||
return CompilerOutput(outputFilePath, 0, null);
|
||||
}
|
||||
}
|
||||
|
||||
class MockKernelCompilerFactory extends Mock implements KernelCompilerFactory {}
|
||||
class MockKernelCompiler extends Mock implements KernelCompiler {}
|
||||
|
|
Loading…
Reference in a new issue