mirror of
https://github.com/flutter/flutter
synced 2024-08-27 03:50:33 +00:00
[framework] dont null assert in _debugVerifyIllFatedPopulation (#96551)
This commit is contained in:
parent
88327e3b72
commit
e25e1f9037
|
@ -710,6 +710,12 @@ Future<void> _runFrameworkTests() async {
|
|||
options: <String>['--dart-define=dart.vm.product=true', ...soundNullSafetyOptions],
|
||||
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 {
|
||||
|
|
|
@ -2879,7 +2879,7 @@ class BuildOwner {
|
|||
void _debugVerifyIllFatedPopulation() {
|
||||
assert(() {
|
||||
Map<GlobalKey, Set<Element>>? duplicates;
|
||||
for (final Element element in _debugIllFatedElements!) {
|
||||
for (final Element element in _debugIllFatedElements ?? const <Element>{}) {
|
||||
if (element._lifecycleState != _ElementLifecycle.defunct) {
|
||||
assert(element != null);
|
||||
assert(element.widget != null);
|
||||
|
|
3
packages/flutter/test_profile/README.md
Normal file
3
packages/flutter/test_profile/README.md
Normal file
|
@ -0,0 +1,3 @@
|
|||
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/`
|
14
packages/flutter/test_profile/basic_test.dart
Normal file
14
packages/flutter/test_profile/basic_test.dart
Normal file
|
@ -0,0 +1,14 @@
|
|||
// 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) {
|
|||
switch (mode) {
|
||||
case BuildMode.debug:
|
||||
return <String>[
|
||||
'-Ddart.vm.profile=false',
|
||||
// This allows the CLI to override the value of this define for unit
|
||||
// These checks allow the CLI to override the value of this define for unit
|
||||
// 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')))
|
||||
'-Ddart.vm.product=false',
|
||||
'--enable-asserts',
|
||||
|
|
|
@ -88,4 +88,17 @@ void main() {
|
|||
'--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',
|
||||
]);
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue