diff --git a/.ci.yaml b/.ci.yaml index ef12337e4fb..0ead1bc4406 100644 --- a/.ci.yaml +++ b/.ci.yaml @@ -5912,6 +5912,40 @@ targets: - engine/** - DEPS + - name: Windows framework_tests_misc_leak_tracking + recipe: flutter/flutter_drone + timeout: 60 + bringup: true # New builder https://github.com/flutter/flutter/pull/176992 + properties: + test_timeout_secs: "3600" # 1 hour + dependencies: >- + [ + {"dependency": "goldctl", "version": "git_revision:2387d6fff449587eecbb7e45b2692ca0710b63b9"} + ] + shard: framework_tests + subshard: misc + tags: > + ["framework", "hostonly", "shard", "windows"] + env_variables: >- + { + "LEAK_TRACKING": "true", + "TEST_RANDOMIZATION_OFF": "true" + } + runIf: + - dev/** + - packages/flutter/** + - packages/flutter_driver/** + - packages/integration_test/** + - packages/flutter_localizations/** + - packages/fuchsia_remote_debug_protocol/** + - packages/flutter_test/** + - packages/flutter_goldens/** + - packages/flutter_tools/** + - bin/** + - .ci.yaml + - engine/** + - DEPS + - name: Windows framework_tests_widgets recipe: flutter/flutter_drone timeout: 60 diff --git a/packages/flutter_test/test/flutter_test_config.dart b/packages/flutter_test/test/flutter_test_config.dart new file mode 100644 index 00000000000..694e0775402 --- /dev/null +++ b/packages/flutter_test/test/flutter_test_config.dart @@ -0,0 +1,44 @@ +// 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 'dart:async'; +import 'dart:io'; + +import 'package:flutter/foundation.dart'; +import 'package:flutter_test/flutter_test.dart'; +import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart'; + +/// If true, leak tracking is enabled for all `test`. +/// +/// By default it is false. +/// To enable the leak tracking, either pass the compilation flag +/// `--dart-define LEAK_TRACKING=true` or invoke `export LEAK_TRACKING=true`. +/// +/// See documentation for [testWidgets] on how to except individual tests. +bool _isLeakTrackingEnabled() { + 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. +/// +/// See https://api.flutter.dev/flutter/flutter_test/flutter_test-library.html. +Future testExecutable(FutureOr Function() testMain) async { + if (_isLeakTrackingEnabled()) { + LeakTesting.enable(); + LeakTracking.warnForUnsupportedPlatforms = false; + // Customized link to documentation on how to troubleshoot leaks, + // to print in the error message. + LeakTracking.troubleshootingDocumentationLink = + 'https://github.com/flutter/flutter/blob/main/docs/contributing/testing/Leak-tracking.md'; + // Do not ignore createdByTestHelpers here, as this is a test of the test + // helper itself. + } + + return testMain(); +}