Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
420b15a7
Unverified
Commit
420b15a7
authored
Jan 10, 2024
by
Polina Cherkasova
Committed by
GitHub
Jan 10, 2024
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix mechanism to pass flag for leak tracking. (#141226)
parent
94e7c9fc
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
19 deletions
+22
-19
flutter_test_config.dart
packages/flutter/test/flutter_test_config.dart
+22
-19
No files found.
packages/flutter/test/flutter_test_config.dart
View file @
420b15a7
...
@@ -3,24 +3,31 @@
...
@@ -3,24 +3,31 @@
// found in the LICENSE file.
// found in the LICENSE file.
import
'dart:async'
;
import
'dart:async'
;
import
'dart:io'
;
import
'package:flutter/foundation.dart'
;
import
'package:flutter/rendering.dart'
;
import
'package:flutter/rendering.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
import
'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart'
;
import
'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart'
;
import
'_goldens_io.dart'
import
'_goldens_io.dart'
if
(
dart
.
library
.
html
)
'_goldens_web.dart'
if
(
dart
.
library
.
html
)
'_goldens_web.dart'
as
flutter_goldens
;
as
flutter_goldens
;
/// If true, leak tracking
will be enabled for all tests `testWidgetsWithLeakTracking
`.
/// If true, leak tracking
is enabled for all `testWidgets
`.
///
///
/// By default, the constant is false.
/// By default it is false.
/// To enable the leak tracking for all tests, either pass the compilation flag
/// To enable the leak tracking, either pass the compilation flag
/// `--dart-define=flutter_test_config.leak_tracking=true` or
/// `--dart-define LEAK_TRACKING=true` or invoke `export LEAK_TRACKING=true`.
/// temporarily pass `defaultValue = true` to `fromEnvironment` in the constant definition.
///
///
/// To enable leak tracking for an individual test file, add the line to the test `main`:
/// See documentation for [testWidgets] on how to except individual tests.
/// `LeakTesting.settings = LeakTesting.settings.withTrackedAll()`.
bool
isLeakTrackingEnabled
(
)
{
const
bool
_kLeakTracking
=
bool
.
fromEnvironment
(
'LEAK_TRACKING'
);
if
(
kIsWeb
)
{
return
false
;
}
// The values can be different, one is compile time, another is run time.
return
const
bool
.
fromEnvironment
(
'LEAK_TRACKING'
)
||
(
bool
.
tryParse
(
Platform
.
environment
[
'LEAK_TRACKING'
]
??
''
)
??
false
);
}
/// Test configuration for each test library in this directory.
/// Test configuration for each test library in this directory.
///
///
...
@@ -34,19 +41,15 @@ Future<void> testExecutable(FutureOr<void> Function() testMain) {
...
@@ -34,19 +41,15 @@ Future<void> testExecutable(FutureOr<void> Function() testMain) {
// receive the event.
// receive the event.
WidgetController
.
hitTestWarningShouldBeFatal
=
true
;
WidgetController
.
hitTestWarningShouldBeFatal
=
true
;
// Leak tracking is off by default.
if
(
isLeakTrackingEnabled
())
{
// To enable it, follow doc for [_kLeakTracking].
if
(
_kLeakTracking
)
{
LeakTesting
.
enable
();
LeakTesting
.
enable
();
LeakTracking
.
warnForUnsupportedPlatforms
=
false
;
LeakTracking
.
warnForUnsupportedPlatforms
=
false
;
LeakTesting
.
settings
=
LeakTesting
LeakTesting
.
settings
=
LeakTesting
.
settings
.
withIgnored
(
.
settings
createdByTestHelpers:
true
,
.
withIgnored
(
allNotGCed:
true
,
createdByTestHelpers:
true
,
);
allNotGCed:
true
,
);
}
}
// Enable golden file testing using Skia Gold.
// Enable golden file testing using Skia Gold.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment