[flutter_tool] allow disabling profile mode timeline traces (#97622)

This commit is contained in:
Jonah Williams 2022-02-02 16:00:16 -08:00 committed by GitHub
parent 4a7e30f87d
commit 0b72d5ca58
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 4 deletions

View File

@ -177,8 +177,12 @@ List<String> buildModeOptions(BuildMode mode, List<String> dartDefines) {
];
case BuildMode.profile:
return <String>[
'-Ddart.vm.profile=true',
'-Ddart.vm.product=false',
// These checks allow the CLI to override the value of this define for
// benchmarks with most timeline traces disabled.
if (!dartDefines.any((String define) => define.startsWith('dart.vm.profile')))
'-Ddart.vm.profile=true',
if (!dartDefines.any((String define) => define.startsWith('dart.vm.product')))
'-Ddart.vm.product=false',
];
case BuildMode.release:
return <String>[

View File

@ -89,16 +89,27 @@ void main() {
]);
});
testWithoutContext('buildModeOptions removes matching profile define', () {
testWithoutContext('buildModeOptions removes matching profile define in debug mode', () {
expect(buildModeOptions(BuildMode.debug, <String>['dart.vm.profile=true']), <String>[
'-Ddart.vm.product=false',
'--enable-asserts',
]);
});
testWithoutContext('buildModeOptions removes both matching profile and release define', () {
testWithoutContext('buildModeOptions removes both matching profile and release define in debug mode', () {
expect(buildModeOptions(BuildMode.debug, <String>['dart.vm.profile=true', 'dart.vm.product=true']), <String>[
'--enable-asserts',
]);
});
testWithoutContext('buildModeOptions removes matching profile define in profile mode', () {
expect(buildModeOptions(BuildMode.profile, <String>['dart.vm.profile=true']), <String>[
'-Ddart.vm.product=false',
]);
});
testWithoutContext('buildModeOptions removes both matching profile and release define in profile mode', () {
expect(buildModeOptions(BuildMode.profile, <String>['dart.vm.profile=false', 'dart.vm.product=true']), <String>[
]);
});
}