Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create package leak_tracker_flutter_testing. #119

Merged
merged 20 commits into from
Aug 10, 2023
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:

- name: flutter test
run: flutter test
polina-c marked this conversation as resolved.
Show resolved Hide resolved
working-directory: pkgs/leak_tracker_flutter_test
working-directory: pkgs/leak_tracker_flutter_testing

- name: integration test
run: flutter test integration_test/app_test.dart -d flutter-tester
Expand Down
19 changes: 4 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,28 +1,17 @@

Coming soon! See https://github.com/flutter/devtools/issues/3951 and https://github.com/flutter/devtools/issues/5606.

The text below is under construction.

[![CI](https://github.com/dart-lang/leak_tracker/actions/workflows/ci.yaml/badge.svg)](https://github.com/dart-lang/leak_tracker/actions/workflows/ci.yaml)

# Memory Leak Tracker

This is a framework for detecting memory issues in Dart and Flutter applications. It enables:

1. [Memory leak auto-detection](doc/DETECT.md) for applications and tests.
2. [Memory usage tracking and auto-snapshotting](doc/USAGE.md).

Documentation:
1. [Understand leak tracking concepts](doc/CONCEPTS.md).
2. [Troubleshoot memory leaks](doc/TROUBLESHOOT.md).
This is a framework for detecting memory issues in Dart and Flutter applications.

## Packages

| Package | Description | Version |
| --- | --- | --- |
| [leak_tracker](pkgs/leak_tracker/) | A framework for memory leak tracking for Dart and Flutter applications. | [![pub package](https://img.shields.io/pub/v/leak_tracker.svg)](https://pub.dev/packages/leak_tracker) |
| [leak_tracker_flutter_test](pkgs/leak_tracker_flutter_test/) | Tests for leak_tracker that depend on Flutter framework. | |
| [leak_tracker_testing](pkgs/leak_tracker_testing/) | Leak tracking code intended for usage in tests. | [![pub package](https://img.shields.io/pub/v/leak_tracker_testing.svg)](https://pub.dev/packages/leak_tracker_testing) |
| [leak_tracker](pkgs/leak_tracker/) | A framework for detecting memory issues for Dart and Flutter applications. | [![pub package](https://img.shields.io/pub/v/leak_tracker.svg)](https://pub.dev/packages/leak_tracker) |
| [leak_tracker_flutter_testing](pkgs/leak_tracker_flutter_testing/) | Leak tracking helpers intended for usage in Flutter tests. | [![pub package](https://img.shields.io/pub/v/leak_tracker_flutter_testing.svg)](https://pub.dev/packages/leak_tracker_flutter_testing) |
| [leak_tracker_testing](pkgs/leak_tracker_testing/) | Leak tracking helpers intended for usage in tests. | [![pub package](https://img.shields.io/pub/v/leak_tracker_testing.svg)](https://pub.dev/packages/leak_tracker_testing) |

## How to enable logs

Expand Down
16 changes: 14 additions & 2 deletions pkgs/leak_tracker/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
[![pub package](https://img.shields.io/pub/v/leak_tracker.svg)](https://pub.dev/packages/leak_tracker)
[![package publisher](https://img.shields.io/pub/publisher/leak_tracker.svg)](https://pub.dev/packages/leak_tracker/publisher)

Coming soon!
Coming soon! See https://github.com/flutter/devtools/issues/3951 and https://github.com/flutter/devtools/issues/5606.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd move this into a section below - ## Following package development or similar.

Copy link
Contributor Author

@polina-c polina-c Aug 10, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We do not want to recommend people start using the package yet, because flutter framework contains leaks. I am working on cleaning them. When it is done, I will do what you suggested.


See full documentation at https://github.com/dart-lang/leak_tracker.
The text below is under construction.
polina-c marked this conversation as resolved.
Show resolved Hide resolved

This is a framework for detecting memory issues in Dart and Flutter applications.

It enables:
polina-c marked this conversation as resolved.
Show resolved Hide resolved

1. [Memory leak auto-detection](https://github.com/dart-lang/leak_tracker/blob/main/doc/DETECT.md) for applications and tests.
2. [Memory usage tracking and auto-snapshotting](https://github.com/dart-lang/leak_tracker/blob/main/doc/USAGE.md).

Read more:

1. [Understand leak tracking concepts](https://github.com/dart-lang/leak_tracker/blob/main/doc/CONCEPTS.md).
2. [Troubleshoot memory leaks](https://github.com/dart-lang/leak_tracker/blob/main/doc/TROUBLESHOOT.md).
5 changes: 5 additions & 0 deletions pkgs/leak_tracker/lib/src/leak_tracking/leak_tracking.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,16 @@
// for details. 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:logging/logging.dart';
polina-c marked this conversation as resolved.
Show resolved Hide resolved
import '../devtools_integration/_registration.dart';
import '../shared/_primitives.dart';
import '../shared/shared_model.dart';
import '_leak_tracker.dart';
import '_primitives/_dispatcher.dart' as dispatcher;
import '_primitives/model.dart';

final _log = Logger('leak_tracking.dart');

/// Provides leak tracking functionality.
abstract class LeakTracking {
static LeakTracker? _leakTracker;
Expand Down Expand Up @@ -72,6 +75,7 @@ abstract class LeakTracking {
} else {
registerLeakTrackingServiceExtension();
}
_log.info('started leak tracking');
return true;
}());
}
Expand All @@ -83,6 +87,7 @@ abstract class LeakTracking {
assert(() {
_leakTracker?.dispose();
_leakTracker = null;
_log.info('stopped leak tracking');
return true;
}());
}
Expand Down
24 changes: 0 additions & 24 deletions pkgs/leak_tracker_flutter_test/pubspec.yaml

This file was deleted.

This file was deleted.

3 changes: 3 additions & 0 deletions pkgs/leak_tracker_flutter_testing/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# 1.0.0

* First release.
22 changes: 22 additions & 0 deletions pkgs/leak_tracker_flutter_testing/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
[![pub package](https://img.shields.io/pub/v/leak_tracker_testing.svg)](https://pub.dev/packages/leak_tracker_testing)
polina-c marked this conversation as resolved.
Show resolved Hide resolved
[![package publisher](https://img.shields.io/pub/publisher/leak_tracker_testing.svg)](https://pub.dev/packages/leak_tracker_testing/publisher)

Coming soon! See https://github.com/flutter/devtools/issues/3951.

The text below is under construction.

## What is this?
polina-c marked this conversation as resolved.
Show resolved Hide resolved

This is Flutter specific test helpers for [leak_tracker](https://pub.dev/packages/leak_tracker).
polina-c marked this conversation as resolved.
Show resolved Hide resolved

## How to use the helpers?

To make your widget test failing in case of leaks, use `testWidgetsWithLeakTracking` instead of `testWidgets`:
polina-c marked this conversation as resolved.
Show resolved Hide resolved

```
testWidgetsWithLeakTracking('not leaking', (widgetTester) async {
...
});
```

See more examples in [end_to_end_test.dart](https://github.com/dart-lang/leak_tracker/tree/main/pkgs/leak_tracker_flutter_testing/test/tests/end_to_end).
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// Copyright (c) 2022, the Dart project authors. Please see the AUTHORS file
polina-c marked this conversation as resolved.
Show resolved Hide resolved
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

export 'src/leak_tracking_flutter_testing.dart';
export 'src/model.dart';
Loading