From 09ad8dd20a46538877c4b8dc639a1bb447465754 Mon Sep 17 00:00:00 2001 From: Polina Cherkasova Date: Sun, 5 Nov 2023 12:39:36 -0800 Subject: [PATCH 1/4] - --- .../lib/src/leak_tracking/leak_testing.dart | 6 +++--- .../lib/src/leak_tracking/primitives/model.dart | 15 +++++++++++++++ 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/pkgs/leak_tracker/lib/src/leak_tracking/leak_testing.dart b/pkgs/leak_tracker/lib/src/leak_tracking/leak_testing.dart index 2094cc6a..9e5393db 100644 --- a/pkgs/leak_tracker/lib/src/leak_tracking/leak_testing.dart +++ b/pkgs/leak_tracker/lib/src/leak_tracking/leak_testing.dart @@ -62,7 +62,7 @@ class LeakTesting { @useResult LeakTesting withCreationStackTrace() { return copyWith( - leakDiagnosticConfig: const LeakDiagnosticConfig( + leakDiagnosticConfig: leakDiagnosticConfig.copyWith( collectStackTraceOnStart: true, ), ); @@ -74,7 +74,7 @@ class LeakTesting { @useResult LeakTesting withDisposalStackTrace() { return copyWith( - leakDiagnosticConfig: const LeakDiagnosticConfig( + leakDiagnosticConfig: leakDiagnosticConfig.copyWith( collectStackTraceOnDisposal: true, ), ); @@ -84,7 +84,7 @@ class LeakTesting { @useResult LeakTesting withRetainingPath() { return copyWith( - leakDiagnosticConfig: const LeakDiagnosticConfig( + leakDiagnosticConfig: leakDiagnosticConfig.copyWith( collectRetainingPathForNotGCed: true, ), ); diff --git a/pkgs/leak_tracker/lib/src/leak_tracking/primitives/model.dart b/pkgs/leak_tracker/lib/src/leak_tracking/primitives/model.dart index dec1d0ac..77699011 100644 --- a/pkgs/leak_tracker/lib/src/leak_tracking/primitives/model.dart +++ b/pkgs/leak_tracker/lib/src/leak_tracking/primitives/model.dart @@ -190,6 +190,21 @@ class LeakDiagnosticConfig { /// In release mode this flag does not work. final bool collectRetainingPathForNotGCed; + LeakDiagnosticConfig copyWith({ + bool? collectRetainingPathForNotGCed, + bool? collectStackTraceOnStart, + bool? collectStackTraceOnDisposal, + }) { + return LeakDiagnosticConfig( + collectRetainingPathForNotGCed: + collectRetainingPathForNotGCed ?? this.collectRetainingPathForNotGCed, + collectStackTraceOnStart: + collectStackTraceOnStart ?? this.collectStackTraceOnStart, + collectStackTraceOnDisposal: + collectStackTraceOnDisposal ?? this.collectStackTraceOnDisposal, + ); + } + @override bool operator ==(Object other) { if (identical(other, this)) { From 2c9dcf85fe5ae8c6dbd02262faee30b3b7fa4b98 Mon Sep 17 00:00:00 2001 From: Polina Cherkasova Date: Tue, 7 Nov 2023 21:32:51 -0800 Subject: [PATCH 2/4] Update leak_testing_test.dart --- .../leak_tracking/leak_testing_test.dart | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/pkgs/leak_tracker/test/tests/leak_tracking/leak_testing_test.dart b/pkgs/leak_tracker/test/tests/leak_tracking/leak_testing_test.dart index 26ff72bd..261e7ed8 100644 --- a/pkgs/leak_tracker/test/tests/leak_tracking/leak_testing_test.dart +++ b/pkgs/leak_tracker/test/tests/leak_tracking/leak_testing_test.dart @@ -8,6 +8,31 @@ import 'package:test/test.dart'; void main() { group('$LeakTesting', () { + test('debug info preserves other settings', () { + final settings = LeakTesting.settings + .withIgnored(notDisposed: {'MyClass': 1}) + .withCreationStackTrace() + .withDisposalStackTrace() + .withRetainingPath(); + + expect( + settings.leakDiagnosticConfig.collectRetainingPathForNotGCed, + true, + ); + expect( + settings.leakDiagnosticConfig.collectStackTraceOnDisposal, + true, + ); + expect( + settings.leakDiagnosticConfig.collectStackTraceOnStart, + true, + ); + expect( + settings.ignoredLeaks.notDisposed.byClass.keys.firstOrNull, + 'MyClass', + ); + }); + group('withTracked', () { test('not provided args do not affect the instance, tracked', () { final settings = LeakTesting.settings.withTrackedAll().withIgnored( From 8713ee6c214f7ff22debc974b9d42d23530cddb5 Mon Sep 17 00:00:00 2001 From: Polina Cherkasova Date: Tue, 7 Nov 2023 21:39:52 -0800 Subject: [PATCH 3/4] - --- pkgs/leak_tracker/CHANGELOG.md | 4 ++++ pkgs/leak_tracker/pubspec.yaml | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/pkgs/leak_tracker/CHANGELOG.md b/pkgs/leak_tracker/CHANGELOG.md index 12b5382f..ee5c1d94 100644 --- a/pkgs/leak_tracker/CHANGELOG.md +++ b/pkgs/leak_tracker/CHANGELOG.md @@ -1,3 +1,7 @@ +## 9.0.16 + +* Fix: debug information should not wipe other settings. + ## 9.0.15 * Add arguments allNotGCed and allNotDisposed to withTracked. diff --git a/pkgs/leak_tracker/pubspec.yaml b/pkgs/leak_tracker/pubspec.yaml index bce51abc..97bba935 100644 --- a/pkgs/leak_tracker/pubspec.yaml +++ b/pkgs/leak_tracker/pubspec.yaml @@ -1,5 +1,5 @@ name: leak_tracker -version: 9.0.15 +version: 9.0.16 description: A framework for memory leak tracking for Dart and Flutter applications. repository: https://github.com/dart-lang/leak_tracker/tree/main/pkgs/leak_tracker From f87d6a3f07eaf569b0e47c751f4af434d26e1d14 Mon Sep 17 00:00:00 2001 From: Polina Cherkasova Date: Tue, 7 Nov 2023 21:40:54 -0800 Subject: [PATCH 4/4] - --- pkgs/leak_tracker/CHANGELOG.md | 5 +---- pkgs/leak_tracker/pubspec.yaml | 2 +- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/pkgs/leak_tracker/CHANGELOG.md b/pkgs/leak_tracker/CHANGELOG.md index ee5c1d94..2125eee8 100644 --- a/pkgs/leak_tracker/CHANGELOG.md +++ b/pkgs/leak_tracker/CHANGELOG.md @@ -1,9 +1,6 @@ -## 9.0.16 - -* Fix: debug information should not wipe other settings. - ## 9.0.15 +* Fix: debug information should not wipe other settings. * Add arguments allNotGCed and allNotDisposed to withTracked. * Remove the dependency on `package:intl`. * Updated to use `package:lints/recommended.yaml` for analysis. diff --git a/pkgs/leak_tracker/pubspec.yaml b/pkgs/leak_tracker/pubspec.yaml index 97bba935..bce51abc 100644 --- a/pkgs/leak_tracker/pubspec.yaml +++ b/pkgs/leak_tracker/pubspec.yaml @@ -1,5 +1,5 @@ name: leak_tracker -version: 9.0.16 +version: 9.0.15 description: A framework for memory leak tracking for Dart and Flutter applications. repository: https://github.com/dart-lang/leak_tracker/tree/main/pkgs/leak_tracker