withIgnored method
Returns copy of settings with extended ignore lists.
In the result the ignored limit for a class is the
maximum of two original ignored limits.
Items in classes
will be added to all ignore lists.
Setting createdByTestHelpers
to true may cause significant
performance impact on the test run, caused by conversion of
creation call stack to String.
Implementation
@useResult
LeakTesting withIgnored({
Map<String, int?> notGCed = const {},
bool allNotGCed = false,
Map<String, int?> notDisposed = const {},
bool allNotDisposed = false,
List<String> classes = const [],
bool createdByTestHelpers = false,
List<RegExp> testHelperExceptions = const [],
}) {
Map<String, int?> addClassesToMap(
Map<String, int?> map,
List<String> classes,
) {
return {
...map,
for (final c in classes) c: null,
};
}
return copyWith(
ignoredLeaks: IgnoredLeaks(
experimentalNotGCed: ignoredLeaks.experimentalNotGCed.merge(
IgnoredLeaksSet(
byClass: addClassesToMap(notGCed, classes),
ignoreAll: allNotGCed,
),
),
notDisposed: ignoredLeaks.notDisposed.merge(
IgnoredLeaksSet(
byClass: addClassesToMap(notDisposed, classes),
ignoreAll: allNotDisposed,
),
),
createdByTestHelpers:
ignoredLeaks.createdByTestHelpers || createdByTestHelpers,
testHelperExceptions: [
...ignoredLeaks.testHelperExceptions,
...testHelperExceptions,
],
),
);
}