From 3e5f620a00c15455617f213a40b9f07295726352 Mon Sep 17 00:00:00 2001 From: Jenn Magder Date: Thu, 8 Apr 2021 14:55:19 -0700 Subject: [PATCH] Convert some general.shard base tests to null safety (#79985) --- .../flutter_tools/lib/src/base/common.dart | 2 +- .../flutter_tools/lib/src/base/context.dart | 2 +- .../hermetic}/logs_test.dart | 0 .../general.shard/base/async_guard_test.dart | 9 ++-- .../test/general.shard/base/common_test.dart | 2 - .../base/deferred_component_test.dart | 47 +++++++++---------- .../general.shard/base/file_system_test.dart | 13 ++--- .../general.shard/base/fingerprint_test.dart | 15 +++--- .../test/general.shard/base/io_test.dart | 24 +++++----- .../test/general.shard/base/net_test.dart | 36 +++++++------- .../test/general.shard/base/os_test.dart | 2 +- .../general.shard/base/os_utils_test.dart | 6 +-- .../general.shard/base/platform_test.dart | 6 +-- .../test/general.shard/base/signals_test.dart | 18 ++++--- .../general.shard/base/terminal_test.dart | 14 +++--- .../base/user_messages_test.dart | 2 - .../general.shard/build_system/hash_test.dart | 2 - 17 files changed, 87 insertions(+), 113 deletions(-) rename packages/flutter_tools/test/{general.shard/base => commands.shard/hermetic}/logs_test.dart (100%) diff --git a/packages/flutter_tools/lib/src/base/common.dart b/packages/flutter_tools/lib/src/base/common.dart index e124cfab93..c3a209eda9 100644 --- a/packages/flutter_tools/lib/src/base/common.dart +++ b/packages/flutter_tools/lib/src/base/common.dart @@ -33,4 +33,4 @@ class ToolExit implements Exception { /// the flutter_tools package. However, there are times where one or more /// futures are intentionally not awaited. This function may be used to ignore a /// particular future. It silences the unawaited_futures lint. -void unawaited(Future future) { } +void unawaited(Future? future) { } diff --git a/packages/flutter_tools/lib/src/base/context.dart b/packages/flutter_tools/lib/src/base/context.dart index 23882b6262..ebf2333dfd 100644 --- a/packages/flutter_tools/lib/src/base/context.dart +++ b/packages/flutter_tools/lib/src/base/context.dart @@ -118,7 +118,7 @@ class AppContext { if (value == null && _parent != null) { value = _parent!.get(); } - return _unboxNull(value ?? _generateIfNecessary(T, _fallbacks)) as T; + return _unboxNull(value ?? _generateIfNecessary(T, _fallbacks)) as T?; } /// Runs [body] in a child context and returns the value returned by [body]. diff --git a/packages/flutter_tools/test/general.shard/base/logs_test.dart b/packages/flutter_tools/test/commands.shard/hermetic/logs_test.dart similarity index 100% rename from packages/flutter_tools/test/general.shard/base/logs_test.dart rename to packages/flutter_tools/test/commands.shard/hermetic/logs_test.dart diff --git a/packages/flutter_tools/test/general.shard/base/async_guard_test.dart b/packages/flutter_tools/test/general.shard/base/async_guard_test.dart index e5caf00e7f..80fd6212f4 100644 --- a/packages/flutter_tools/test/general.shard/base/async_guard_test.dart +++ b/packages/flutter_tools/test/general.shard/base/async_guard_test.dart @@ -2,7 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// @dart = 2.8 import 'dart:async'; @@ -32,7 +31,7 @@ Future syncAndAsyncError() { Future delayedThrow(FakeAsync time) { final Future result = Future.delayed(const Duration(milliseconds: 10)) - .then((_) { + .then((_) async { throw 'Delayed Doom'; }); time.elapse(const Duration(seconds: 1)); @@ -41,10 +40,10 @@ Future delayedThrow(FakeAsync time) { } void main() { - Completer caughtInZone; + late Completer caughtInZone; bool caughtByZone = false; bool caughtByHandler = false; - Zone zone; + late Zone zone; setUp(() { caughtInZone = Completer(); @@ -270,7 +269,7 @@ void main() { unawaited(runZonedGuarded(() async { final Future f = asyncGuard( () => delayedThrow(time), - onError: (Object e, [StackTrace s]) { + onError: (Object e, [StackTrace? s]) { caughtByOnError = true; nonNullStackTrace = s != null; }, diff --git a/packages/flutter_tools/test/general.shard/base/common_test.dart b/packages/flutter_tools/test/general.shard/base/common_test.dart index 365bf499f2..0ffb6c2899 100644 --- a/packages/flutter_tools/test/general.shard/base/common_test.dart +++ b/packages/flutter_tools/test/general.shard/base/common_test.dart @@ -2,8 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// @dart = 2.8 - import 'package:flutter_tools/src/base/common.dart'; import 'package:flutter_tools/src/base/context.dart'; diff --git a/packages/flutter_tools/test/general.shard/base/deferred_component_test.dart b/packages/flutter_tools/test/general.shard/base/deferred_component_test.dart index f84261c896..3a718f40f2 100644 --- a/packages/flutter_tools/test/general.shard/base/deferred_component_test.dart +++ b/packages/flutter_tools/test/general.shard/base/deferred_component_test.dart @@ -2,19 +2,16 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// @dart = 2.8 - import 'package:file/memory.dart'; import 'package:flutter_tools/src/base/deferred_component.dart'; import 'package:flutter_tools/src/base/file_system.dart'; import 'package:flutter_tools/src/base/logger.dart'; import '../../src/common.dart'; -import '../../src/context.dart'; void main() { group('DeferredComponent basics', () { - test('constructor sets values', () { + testWithoutContext('constructor sets values', () { final DeferredComponent component = DeferredComponent( name: 'bestcomponent', libraries: ['lib1', 'lib2'], @@ -25,7 +22,7 @@ void main() { expect(component.assets, [Uri.file('asset1'), Uri.file('asset2')]); }); - test('assignLoadingUnits selects the needed loading units and sets assigned', () { + testWithoutContext('assignLoadingUnits selects the needed loading units and sets assigned', () { final DeferredComponent component = DeferredComponent( name: 'bestcomponent', libraries: ['lib1', 'lib2'], @@ -56,10 +53,10 @@ void main() { component.assignLoadingUnits(loadingUnits1); expect(component.assigned, true); - expect(component.loadingUnits.length, 2); - expect(component.loadingUnits.contains(loadingUnits1[0]), true); - expect(component.loadingUnits.contains(loadingUnits1[1]), true); - expect(component.loadingUnits.contains(loadingUnits1[2]), false); + expect(component.loadingUnits, hasLength(2)); + expect(component.loadingUnits, contains(loadingUnits1[0])); + expect(component.loadingUnits, contains(loadingUnits1[1])); + expect(component.loadingUnits, isNot(contains(loadingUnits1[2]))); final List loadingUnits2 = [ LoadingUnit( @@ -82,18 +79,18 @@ void main() { component.assignLoadingUnits(loadingUnits2); expect(component.assigned, true); - expect(component.loadingUnits.length, 1); - expect(component.loadingUnits.contains(loadingUnits2[0]), true); - expect(component.loadingUnits.contains(loadingUnits2[1]), false); - expect(component.loadingUnits.contains(loadingUnits2[2]), false); + expect(component.loadingUnits, hasLength(1)); + expect(component.loadingUnits, contains(loadingUnits2[0])); + expect(component.loadingUnits, isNot(contains(loadingUnits2[1]))); + expect(component.loadingUnits, isNot(contains(loadingUnits2[2]))); component.assignLoadingUnits([]); expect(component.assigned, true); - expect(component.loadingUnits.length, 0); + expect(component.loadingUnits, hasLength(0)); }); - test('toString produces correct string for unassigned component', () { + testWithoutContext('toString produces correct string for unassigned component', () { final DeferredComponent component = DeferredComponent( name: 'bestcomponent', libraries: ['lib1', 'lib2'], @@ -102,7 +99,7 @@ void main() { expect(component.toString(), '\nDeferredComponent: bestcomponent\n Libraries:\n - lib1\n - lib2\n Assets:\n - asset1\n - asset2'); }); - test('toString produces correct string for assigned component', () { + testWithoutContext('toString produces correct string for assigned component', () { final DeferredComponent component = DeferredComponent( name: 'bestcomponent', libraries: ['lib1', 'lib2'], @@ -114,7 +111,7 @@ void main() { }); group('LoadingUnit basics', () { - test('constructor sets values', () { + testWithoutContext('constructor sets values', () { final LoadingUnit unit = LoadingUnit( id: 2, path: 'path/to/so.so', @@ -125,7 +122,7 @@ void main() { expect(unit.libraries, ['lib1', 'lib4']); }); - test('toString produces correct string', () { + testWithoutContext('toString produces correct string', () { final LoadingUnit unit = LoadingUnit( id: 2, path: 'path/to/so.so', @@ -134,7 +131,7 @@ void main() { expect(unit.toString(),'\nLoadingUnit 2\n Libraries:\n - lib1\n - lib4'); }); - test('equalsIgnoringPath works for various input', () { + testWithoutContext('equalsIgnoringPath works for various input', () { final LoadingUnit unit1 = LoadingUnit( id: 2, path: 'path/to/so.so', @@ -172,7 +169,7 @@ void main() { expect(unit5.equalsIgnoringPath(unit6), false); }); - test('parseLoadingUnitManifest parses single manifest file', () { + testWithoutContext('parseLoadingUnitManifest parses single manifest file', () { final FileSystem fileSystem = MemoryFileSystem.test(); final File manifest = fileSystem.file('/manifest.json'); manifest.createSync(recursive: true); @@ -202,7 +199,7 @@ void main() { expect(loadingUnits[1].libraries[1], 'lib4'); }); - testUsingContext('parseLoadingUnitManifest returns empty when manifest is invalid JSON', () { + testWithoutContext('parseLoadingUnitManifest returns empty when manifest is invalid JSON', () { final FileSystem fileSystem = MemoryFileSystem.test(); final File manifest = fileSystem.file('/manifest.json'); manifest.createSync(recursive: true); @@ -225,7 +222,7 @@ void main() { expect(loadingUnits.isEmpty, true); }); - testUsingContext('parseLoadingUnitManifest does not exist', () { + testWithoutContext('parseLoadingUnitManifest does not exist', () { final FileSystem fileSystem = MemoryFileSystem.test(); final File manifest = fileSystem.file('/manifest.json'); if (manifest.existsSync()) { @@ -236,7 +233,7 @@ void main() { expect(loadingUnits.isEmpty, true); }); - test('parseGeneratedLoadingUnits parses all abis if no abis provided', () { + testWithoutContext('parseGeneratedLoadingUnits parses all abis if no abis provided', () { final FileSystem fileSystem = MemoryFileSystem.test(); final File manifest1 = fileSystem.file('/test-abi1/manifest.json'); manifest1.createSync(recursive: true); @@ -293,7 +290,7 @@ void main() { expect(loadingUnits[3].libraries[1], 'lib4'); }); - test('parseGeneratedLoadingUnits only parses provided abis', () { + testWithoutContext('parseGeneratedLoadingUnits only parses provided abis', () { final FileSystem fileSystem = MemoryFileSystem.test(); final File manifest1 = fileSystem.file('/test-abi1/manifest.json'); manifest1.createSync(recursive: true); @@ -340,7 +337,7 @@ void main() { expect(loadingUnits[1].libraries[1], 'lib4'); }); - test('parseGeneratedLoadingUnits returns empty when no manifest files exist', () { + testWithoutContext('parseGeneratedLoadingUnits returns empty when no manifest files exist', () { final FileSystem fileSystem = MemoryFileSystem.test(); final List loadingUnits = LoadingUnit.parseGeneratedLoadingUnits(fileSystem.directory('/'), BufferLogger.test()); diff --git a/packages/flutter_tools/test/general.shard/base/file_system_test.dart b/packages/flutter_tools/test/general.shard/base/file_system_test.dart index b4215b5f93..1c3c998d03 100644 --- a/packages/flutter_tools/test/general.shard/base/file_system_test.dart +++ b/packages/flutter_tools/test/general.shard/base/file_system_test.dart @@ -2,8 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// @dart = 2.8 - import 'dart:async'; import 'dart:io' as io; @@ -15,12 +13,11 @@ import 'package:flutter_tools/src/base/signals.dart'; import 'package:test/fake.dart'; import '../../src/common.dart'; -import '../../src/context.dart'; void main() { group('fsUtils', () { - MemoryFileSystem fs; - FileSystemUtils fsUtils; + late MemoryFileSystem fs; + late FileSystemUtils fsUtils; setUp(() { fs = MemoryFileSystem.test(); @@ -129,15 +126,15 @@ void main() { }); group('LocalFileSystem', () { - FakeProcessSignal fakeSignal; - ProcessSignal signalUnderTest; + late FakeProcessSignal fakeSignal; + late ProcessSignal signalUnderTest; setUp(() { fakeSignal = FakeProcessSignal(); signalUnderTest = ProcessSignal(fakeSignal); }); - testUsingContext('deletes system temp entry on a fatal signal', () async { + testWithoutContext('deletes system temp entry on a fatal signal', () async { final Completer completer = Completer(); final Signals signals = Signals.test(); final LocalFileSystem localFileSystem = LocalFileSystem.test( diff --git a/packages/flutter_tools/test/general.shard/base/fingerprint_test.dart b/packages/flutter_tools/test/general.shard/base/fingerprint_test.dart index 388348fa1c..d7e9b190f4 100644 --- a/packages/flutter_tools/test/general.shard/base/fingerprint_test.dart +++ b/packages/flutter_tools/test/general.shard/base/fingerprint_test.dart @@ -2,8 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// @dart = 2.8 - import 'dart:convert' show json; import 'package:file/memory.dart'; @@ -12,9 +10,10 @@ import 'package:flutter_tools/src/base/logger.dart'; import 'package:flutter_tools/src/base/utils.dart'; import '../../src/common.dart'; + void main() { group('Fingerprinter', () { - MemoryFileSystem fileSystem; + late MemoryFileSystem fileSystem; setUp(() { fileSystem = MemoryFileSystem.test(); @@ -85,7 +84,7 @@ void main() { group('Fingerprint', () { group('fromBuildInputs', () { - MemoryFileSystem fileSystem; + late MemoryFileSystem fileSystem; setUp(() { fileSystem = MemoryFileSystem.test(); @@ -104,8 +103,8 @@ void main() { fileSystem.file('b.dart').writeAsStringSync('This is b'); final Fingerprint fingerprint = Fingerprint.fromBuildInputs(const ['a.dart', 'b.dart'], fileSystem); - final Map jsonObject = castStringKeyedMap(json.decode(fingerprint.toJson())); - expect(jsonObject['files'], hasLength(2)); + final Map? jsonObject = castStringKeyedMap(json.decode(fingerprint.toJson())); + expect(jsonObject!['files'], hasLength(2)); expect(jsonObject['files']['a.dart'], '8a21a15fad560b799f6731d436c1b698'); expect(jsonObject['files']['b.dart'], '6f144e08b58cd0925328610fad7ac07c'); }); @@ -124,9 +123,9 @@ void main() { }, }); final Fingerprint fingerprint = Fingerprint.fromJson(jsonString); - final Map content = castStringKeyedMap(json.decode(fingerprint.toJson())); + final Map? content = castStringKeyedMap(json.decode(fingerprint.toJson())); expect(content, hasLength(1)); - expect(content['files'], hasLength(2)); + expect(content!['files'], hasLength(2)); expect(content['files']['a.dart'], '8a21a15fad560b799f6731d436c1b698'); expect(content['files']['b.dart'], '6f144e08b58cd0925328610fad7ac07c'); }); diff --git a/packages/flutter_tools/test/general.shard/base/io_test.dart b/packages/flutter_tools/test/general.shard/base/io_test.dart index 91c13d08ff..e3717780ad 100644 --- a/packages/flutter_tools/test/general.shard/base/io_test.dart +++ b/packages/flutter_tools/test/general.shard/base/io_test.dart @@ -2,8 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// @dart = 2.8 - import 'dart:async'; import 'dart:io' as io; @@ -13,11 +11,10 @@ import 'package:flutter_tools/src/base/platform.dart'; import 'package:test/fake.dart'; import '../../src/common.dart'; -import '../../src/context.dart'; import '../../src/io.dart'; void main() { - test('IOOverrides can inject a memory file system', () async { + testWithoutContext('IOOverrides can inject a memory file system', () async { final MemoryFileSystem memoryFileSystem = MemoryFileSystem.test(); final FlutterIOOverrides flutterIOOverrides = FlutterIOOverrides(fileSystem: memoryFileSystem); await io.IOOverrides.runWithIOOverrides(() async { @@ -57,7 +54,8 @@ void main() { expect(memoryFileSystem.link('ggg').resolveSymbolicLinksSync(), linkB.resolveSymbolicLinksSync()); }, flutterIOOverrides); }); - testUsingContext('ProcessSignal signals are properly delegated', () async { + + testWithoutContext('ProcessSignal signals are properly delegated', () async { final FakeProcessSignal signal = FakeProcessSignal(); final ProcessSignal signalUnderTest = ProcessSignal(signal); @@ -66,15 +64,15 @@ void main() { expect(signalUnderTest, await signalUnderTest.watch().first); }); - testUsingContext('ProcessSignal toString() works', () async { + testWithoutContext('ProcessSignal toString() works', () async { expect(io.ProcessSignal.sigint.toString(), ProcessSignal.sigint.toString()); }); - test('exit throws a StateError if called without being overriden', () { + testWithoutContext('exit throws a StateError if called without being overriden', () { expect(() => exit(0), throwsAssertionError); }); - test('exit does not throw a StateError if overriden', () { + testWithoutContext('exit does not throw a StateError if overriden', () { try { setExitFunctionForTests((int value) {}); @@ -84,16 +82,16 @@ void main() { } }); - test('test_api defines the Declarer in a known place', () { + testWithoutContext('test_api defines the Declarer in a known place', () { expect(Zone.current[#test.declarer], isNotNull); }); - test('listNetworkInterfaces() uses overrides', () async { + testWithoutContext('listNetworkInterfaces() uses overrides', () async { setNetworkInterfaceLister( ({ - bool includeLoopback, - bool includeLinkLocal, - InternetAddressType type, + bool? includeLoopback, + bool? includeLinkLocal, + InternetAddressType? type, }) async => [], ); diff --git a/packages/flutter_tools/test/general.shard/base/net_test.dart b/packages/flutter_tools/test/general.shard/base/net_test.dart index d5fa4c640e..d4a077098e 100644 --- a/packages/flutter_tools/test/general.shard/base/net_test.dart +++ b/packages/flutter_tools/test/general.shard/base/net_test.dart @@ -2,8 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// @dart = 2.8 - import 'dart:convert'; import 'package:file/file.dart'; @@ -20,7 +18,7 @@ import '../../src/common.dart'; import '../../src/fake_http_client.dart'; void main() { - BufferLogger testLogger; + late BufferLogger testLogger; setUp(() { testLogger = BufferLogger.test(); @@ -36,7 +34,7 @@ void main() { group('successful fetch', () { const String responseString = 'response string'; - List responseData; + late List responseData; setUp(() { responseData = utf8.encode(responseString); @@ -51,7 +49,7 @@ void main() { ]) ); - final List data = await net.fetchUrl(Uri.parse('http://example.invalid/')); + final List? data = await net.fetchUrl(Uri.parse('http://example.invalid/')); expect(data, equals(responseData)); }); @@ -65,7 +63,7 @@ void main() { ); final MemoryFileSystem fileSystem = MemoryFileSystem.test(); final File destFile = fileSystem.file('dest_file')..createSync(); - final List data = await net.fetchUrl( + final List? data = await net.fetchUrl( Uri.parse('http://example.invalid/'), destFile: destFile, ); @@ -127,9 +125,9 @@ void main() { FakeRequest(invalid, responseError: const io.SocketException('')), ]) ); - String error; + String? error; FakeAsync().run((FakeAsync time) { - net.fetchUrl(invalid).then((List value) { + net.fetchUrl(invalid).then((List? value) async { error = 'test completed unexpectedly'; }, onError: (dynamic exception) { error = 'test failed unexpectedly: $exception'; @@ -158,9 +156,9 @@ void main() { FakeRequest(invalid, responseError: const io.HandshakeException('')), ]) ); - String error; + String? error; FakeAsync().run((FakeAsync time) { - net.fetchUrl(invalid).then((List value) { + net.fetchUrl(invalid).then((List? value) async { error = 'test completed unexpectedly'; }, onError: (dynamic exception) { error = 'test failed: $exception'; @@ -188,9 +186,9 @@ void main() { }, ), ); - String error; + String? error; FakeAsync().run((FakeAsync time) { - net.fetchUrl(Uri.parse('example.invalid/')).then((List value) { + net.fetchUrl(Uri.parse('example.invalid/')).then((List? value) async { error = 'test completed unexpectedly'; }, onError: (dynamic exception) { error = 'test failed: $exception'; @@ -214,9 +212,9 @@ void main() { FakeRequest(invalid, responseError: const io.HttpException('')), ]) ); - String error; + String? error; FakeAsync().run((FakeAsync time) { - net.fetchUrl(invalid).then((List value) { + net.fetchUrl(invalid).then((List? value) async { error = 'test completed unexpectedly'; }, onError: (dynamic exception) { error = 'test failed unexpectedly: $exception'; @@ -245,9 +243,9 @@ void main() { FakeRequest(invalid, responseError: const io.HttpException('')), ]) ); - String error; + String? error; FakeAsync().run((FakeAsync time) { - net.fetchUrl(invalid).then((List value) { + net.fetchUrl(invalid).then((List? value) async { error = 'test completed unexpectedly'; }, onError: (dynamic exception) { error = 'test failed unexpectedly: $exception'; @@ -281,10 +279,10 @@ void main() { )), ]) ); - String error; - List actualResult; + String? error; + List? actualResult; FakeAsync().run((FakeAsync time) { - net.fetchUrl(invalid, maxAttempts: 3).then((List value) { + net.fetchUrl(invalid, maxAttempts: 3).then((List? value) async { actualResult = value; }, onError: (dynamic exception) { error = 'test failed unexpectedly: $exception'; diff --git a/packages/flutter_tools/test/general.shard/base/os_test.dart b/packages/flutter_tools/test/general.shard/base/os_test.dart index 1929d7f0ed..870c2ffe4a 100644 --- a/packages/flutter_tools/test/general.shard/base/os_test.dart +++ b/packages/flutter_tools/test/general.shard/base/os_test.dart @@ -13,7 +13,7 @@ import 'package:flutter_tools/src/base/os.dart'; import 'package:flutter_tools/src/base/platform.dart'; import '../../src/common.dart'; -import '../../src/context.dart'; +import '../../src/fake_process_manager.dart'; const String kExecutable = 'foo'; const String kPath1 = '/bar/bin/$kExecutable'; diff --git a/packages/flutter_tools/test/general.shard/base/os_utils_test.dart b/packages/flutter_tools/test/general.shard/base/os_utils_test.dart index 5a21ab7ff7..0ec8408a65 100644 --- a/packages/flutter_tools/test/general.shard/base/os_utils_test.dart +++ b/packages/flutter_tools/test/general.shard/base/os_utils_test.dart @@ -2,8 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// @dart = 2.8 - import 'package:flutter_tools/src/base/file_system.dart'; import 'package:flutter_tools/src/base/logger.dart'; import 'package:flutter_tools/src/base/os.dart'; @@ -15,8 +13,8 @@ import '../../src/common.dart'; void main() { group('OperatingSystemUtils', () { - Directory tempDir; - FileSystem fileSystem; + late Directory tempDir; + late FileSystem fileSystem; setUp(() { fileSystem = LocalFileSystem.test(signals: Signals.test()); diff --git a/packages/flutter_tools/test/general.shard/base/platform_test.dart b/packages/flutter_tools/test/general.shard/base/platform_test.dart index d60928e5f0..c4c77a1c37 100644 --- a/packages/flutter_tools/test/general.shard/base/platform_test.dart +++ b/packages/flutter_tools/test/general.shard/base/platform_test.dart @@ -2,8 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// @dart = 2.8 - import 'package:flutter_tools/src/base/platform.dart'; import '../../src/common.dart'; @@ -26,8 +24,8 @@ void _expectPlatformsEqual(Platform actual, Platform expected) { void main() { group('FakePlatform.fromPlatform', () { - FakePlatform fake; - LocalPlatform local; + late FakePlatform fake; + late LocalPlatform local; setUp(() { local = const LocalPlatform(); diff --git a/packages/flutter_tools/test/general.shard/base/signals_test.dart b/packages/flutter_tools/test/general.shard/base/signals_test.dart index 6e9145b518..0d8cae24c1 100644 --- a/packages/flutter_tools/test/general.shard/base/signals_test.dart +++ b/packages/flutter_tools/test/general.shard/base/signals_test.dart @@ -2,8 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// @dart = 2.8 - import 'dart:async'; import 'dart:io' as io; @@ -15,9 +13,9 @@ import '../../src/common.dart'; void main() { group('Signals', () { - Signals signals; - FakeProcessSignal fakeSignal; - ProcessSignal signalUnderTest; + late Signals signals; + late FakeProcessSignal fakeSignal; + late ProcessSignal signalUnderTest; setUp(() { signals = Signals.test(); @@ -58,7 +56,7 @@ void main() { testWithoutContext('signal handlers do not cause concurrent modification errors when removing handlers in a signal callback', () async { final Completer completer = Completer(); - Object token; + late Object token; Future handle(ProcessSignal s) async { expect(s, signalUnderTest); expect(await signals.removeHandler(signalUnderTest, token), true); @@ -73,7 +71,7 @@ void main() { testWithoutContext('signal handler error goes on error stream', () async { final Exception exn = Exception('Error'); - signals.addHandler(signalUnderTest, (ProcessSignal s) { + signals.addHandler(signalUnderTest, (ProcessSignal s) async { throw exn; }); @@ -95,7 +93,7 @@ void main() { testWithoutContext('removed signal handler does not run', () async { final Object token = signals.addHandler( signalUnderTest, - (ProcessSignal s) { + (ProcessSignal s) async { fail('Signal handler should have been removed.'); }, ); @@ -124,7 +122,7 @@ void main() { final Object token = signals.addHandler( signalUnderTest, - (ProcessSignal s) { + (ProcessSignal s) async { fail('Signal handler should have been removed.'); }, ); @@ -153,7 +151,7 @@ void main() { completer.complete(); }); - signals.addHandler(otherSignal, (ProcessSignal s) { + signals.addHandler(otherSignal, (ProcessSignal s) async { fail('Wrong signal!.'); }); diff --git a/packages/flutter_tools/test/general.shard/base/terminal_test.dart b/packages/flutter_tools/test/general.shard/base/terminal_test.dart index 52c71c9a96..bec4903385 100644 --- a/packages/flutter_tools/test/general.shard/base/terminal_test.dart +++ b/packages/flutter_tools/test/general.shard/base/terminal_test.dart @@ -2,8 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// @dart = 2.8 - import 'package:flutter_tools/src/base/io.dart'; import 'package:flutter_tools/src/base/logger.dart'; import 'package:flutter_tools/src/base/platform.dart'; @@ -37,7 +35,7 @@ void main() { }); group('ANSI coloring and bold', () { - AnsiTerminal terminal; + late AnsiTerminal terminal; setUp(() { terminal = AnsiTerminal( @@ -108,7 +106,7 @@ void main() { }); group('character input prompt', () { - AnsiTerminal terminalUnderTest; + late AnsiTerminal terminalUnderTest; setUp(() { terminalUnderTest = TestTerminal(stdio: FakeStdio()); @@ -118,7 +116,7 @@ void main() { expect(terminalUnderTest.promptForCharInput( ['a', 'b', 'c'], prompt: 'Please choose something', - logger: null, + logger: BufferLogger.test(), ), throwsStateError); }); @@ -183,13 +181,13 @@ void main() { }); } -Stream mockStdInStream; +late Stream mockStdInStream; class TestTerminal extends AnsiTerminal { TestTerminal({ - Stdio stdio, + Stdio? stdio, Platform platform = const LocalPlatform(), - }) : super(stdio: stdio, platform: platform); + }) : super(stdio: stdio ?? Stdio(), platform: platform); @override Stream get keystrokes { diff --git a/packages/flutter_tools/test/general.shard/base/user_messages_test.dart b/packages/flutter_tools/test/general.shard/base/user_messages_test.dart index 11de81779c..21df32079b 100644 --- a/packages/flutter_tools/test/general.shard/base/user_messages_test.dart +++ b/packages/flutter_tools/test/general.shard/base/user_messages_test.dart @@ -2,8 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// @dart = 2.8 - import 'package:flutter_tools/src/base/platform.dart'; import 'package:flutter_tools/src/base/user_messages.dart'; diff --git a/packages/flutter_tools/test/general.shard/build_system/hash_test.dart b/packages/flutter_tools/test/general.shard/build_system/hash_test.dart index 7b0cca9781..69dab5afb9 100644 --- a/packages/flutter_tools/test/general.shard/build_system/hash_test.dart +++ b/packages/flutter_tools/test/general.shard/build_system/hash_test.dart @@ -2,8 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// @dart = 2.8 - import 'dart:convert'; import 'dart:typed_data';