Unverified Commit e25e1f90 authored by Jonah Williams's avatar Jonah Williams Committed by GitHub

[framework] dont null assert in _debugVerifyIllFatedPopulation (#96551)

parent 88327e3b
...@@ -710,6 +710,12 @@ Future<void> _runFrameworkTests() async { ...@@ -710,6 +710,12 @@ Future<void> _runFrameworkTests() async {
options: <String>['--dart-define=dart.vm.product=true', ...soundNullSafetyOptions], options: <String>['--dart-define=dart.vm.product=true', ...soundNullSafetyOptions],
tests: <String>['test_release${path.separator}'], tests: <String>['test_release${path.separator}'],
); );
// Run profile mode tests (see packages/flutter/test_profile/README.md)
await _runFlutterTest(
path.join(flutterRoot, 'packages', 'flutter'),
options: <String>['--dart-define=dart.vm.product=false', '--dart-define=dart.vm.profile=true', ...soundNullSafetyOptions],
tests: <String>['test_profile${path.separator}'],
);
} }
Future<void> runLibraries() async { Future<void> runLibraries() async {
......
...@@ -2879,7 +2879,7 @@ class BuildOwner { ...@@ -2879,7 +2879,7 @@ class BuildOwner {
void _debugVerifyIllFatedPopulation() { void _debugVerifyIllFatedPopulation() {
assert(() { assert(() {
Map<GlobalKey, Set<Element>>? duplicates; Map<GlobalKey, Set<Element>>? duplicates;
for (final Element element in _debugIllFatedElements!) { for (final Element element in _debugIllFatedElements ?? const <Element>{}) {
if (element._lifecycleState != _ElementLifecycle.defunct) { if (element._lifecycleState != _ElementLifecycle.defunct) {
assert(element != null); assert(element != null);
assert(element.widget != null); assert(element.widget != null);
......
This folder contains unit tests that are run with `kProfileMode` set to true. This can be used for unit testing code that is guarded by this boolean, such as in cases where debug code is intentionally ellided for performance or code size reasons. The unit tests are still run in the VM and are not otherwise precompiled.
To run these test from the command line, use the command: `flutter test --dart-define=dart.vm.profile=true test_release/`
// Copyright 2014 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
void main() {
testWidgets('Can build widget tree in profile mode with asserts enabled', (WidgetTester tester) async {
await tester.pumpWidget(const MaterialApp(home: Scaffold(body: Center(child: Text('Hello World')))));
expect(tester.takeException(), isNull);
});
}
...@@ -167,9 +167,10 @@ List<String> buildModeOptions(BuildMode mode, List<String> dartDefines) { ...@@ -167,9 +167,10 @@ List<String> buildModeOptions(BuildMode mode, List<String> dartDefines) {
switch (mode) { switch (mode) {
case BuildMode.debug: case BuildMode.debug:
return <String>[ return <String>[
'-Ddart.vm.profile=false', // These checks allow the CLI to override the value of this define for unit
// This allows the CLI to override the value of this define for unit
// testing the framework. // testing the framework.
if (!dartDefines.any((String define) => define.startsWith('dart.vm.profile')))
'-Ddart.vm.profile=false',
if (!dartDefines.any((String define) => define.startsWith('dart.vm.product'))) if (!dartDefines.any((String define) => define.startsWith('dart.vm.product')))
'-Ddart.vm.product=false', '-Ddart.vm.product=false',
'--enable-asserts', '--enable-asserts',
......
...@@ -88,4 +88,17 @@ void main() { ...@@ -88,4 +88,17 @@ void main() {
'--enable-asserts', '--enable-asserts',
]); ]);
}); });
testWithoutContext('buildModeOptions removes matching profile define', () {
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', () {
expect(buildModeOptions(BuildMode.debug, <String>['dart.vm.profile=true', 'dart.vm.product=true']), <String>[
'--enable-asserts',
]);
});
} }
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