From 7d46d436356bfcde84140913548d7bac80824cdb Mon Sep 17 00:00:00 2001 From: Alexandre Ardhuin Date: Wed, 12 May 2021 18:59:02 +0200 Subject: [PATCH] use throwsXxx instead of throwsA(isA()) (#82328) --- .../test/cupertino/bottom_tab_bar_test.dart | 2 +- .../cupertino/segmented_control_test.dart | 6 +- .../sliding_segmented_control_test.dart | 6 +- .../material/dropdown_form_field_test.dart | 4 +- .../flutter/test/material/dropdown_test.dart | 4 +- .../test/material/toggle_buttons_test.dart | 2 +- packages/flutter/test/rendering/box_test.dart | 4 +- .../services/restoration_bucket_test.dart | 2 +- .../flutter/test/widgets/grid_view_test.dart | 2 +- .../widgets/list_wheel_scroll_view_test.dart | 2 +- .../flutter/test/widgets/page_view_test.dart | 4 +- .../src/real_tests/flutter_driver_test.dart | 31 ++++------ .../src/real_tests/io_extension_test.dart | 3 +- packages/flutter_test/test/goldens_test.dart | 10 ++-- .../commands.shard/hermetic/build_test.dart | 4 +- .../hermetic/generate_localizations_test.dart | 4 +- .../commands.shard/hermetic/run_test.dart | 12 ++-- .../hermetic/screenshot_command_test.dart | 4 +- .../commands.shard/hermetic/test_test.dart | 3 +- .../android_device_port_forwarder_test.dart | 5 +- .../android/android_gradle_builder_test.dart | 5 +- .../general.shard/artifact_updater_test.dart | 7 +-- .../test/general.shard/base/common_test.dart | 2 +- .../base/error_handling_io_test.dart | 10 ++-- .../test/general.shard/base/logger_test.dart | 6 +- .../test/general.shard/base/os_test.dart | 3 +- .../test/general.shard/base/process_test.dart | 14 ++--- .../build_system/targets/assets_test.dart | 11 ++-- .../build_system/targets/common_test.dart | 6 +- .../build_system/targets/desktop_test.dart | 4 +- .../build_system/targets/ios_test.dart | 58 ++++++++++--------- .../targets/localizations_test.dart | 2 +- .../build_system/targets/macos_test.dart | 26 +++++---- .../test/general.shard/cache_test.dart | 2 +- .../test/general.shard/device_test.dart | 3 +- .../test/general.shard/ios/devices_test.dart | 4 +- .../general.shard/mdns_discovery_test.dart | 2 +- .../resident_web_runner_cold_test.dart | 2 +- .../runner/flutter_command_test.dart | 4 +- .../test/general.shard/testbed_test.dart | 2 +- 40 files changed, 133 insertions(+), 154 deletions(-) diff --git a/packages/flutter/test/cupertino/bottom_tab_bar_test.dart b/packages/flutter/test/cupertino/bottom_tab_bar_test.dart index a7dc8b8630..6bd33d48e7 100644 --- a/packages/flutter/test/cupertino/bottom_tab_bar_test.dart +++ b/packages/flutter/test/cupertino/bottom_tab_bar_test.dart @@ -39,7 +39,7 @@ Future main() async { ), ], )), - throwsA(isA().having( + throwsA(isAssertionError.having( (AssertionError error) => error.toString(), '.toString()', contains('items.length'), diff --git a/packages/flutter/test/cupertino/segmented_control_test.dart b/packages/flutter/test/cupertino/segmented_control_test.dart index d68a34c1f7..7defd4e247 100644 --- a/packages/flutter/test/cupertino/segmented_control_test.dart +++ b/packages/flutter/test/cupertino/segmented_control_test.dart @@ -94,7 +94,7 @@ void main() { ), ), ), - throwsA(isA().having( + throwsA(isAssertionError.having( (AssertionError error) => error.toString(), '.toString()', contains('children.length'), @@ -110,7 +110,7 @@ void main() { ), ), ), - throwsA(isA().having( + throwsA(isAssertionError.having( (AssertionError error) => error.toString(), '.toString()', contains('children.length'), @@ -220,7 +220,7 @@ void main() { ), ), ), - throwsA(isA().having( + throwsA(isAssertionError.having( (AssertionError error) => error.toString(), '.toString()', contains('children'), diff --git a/packages/flutter/test/cupertino/sliding_segmented_control_test.dart b/packages/flutter/test/cupertino/sliding_segmented_control_test.dart index eca9f7ac82..f48a463dac 100644 --- a/packages/flutter/test/cupertino/sliding_segmented_control_test.dart +++ b/packages/flutter/test/cupertino/sliding_segmented_control_test.dart @@ -82,7 +82,7 @@ void main() { onValueChanged: defaultCallback, ), ), - throwsA(isA().having( + throwsA(isAssertionError.having( (AssertionError error) => error.toString(), '.toString()', contains('children.length'), @@ -97,7 +97,7 @@ void main() { onValueChanged: defaultCallback, ), ), - throwsA(isA().having( + throwsA(isAssertionError.having( (AssertionError error) => error.toString(), '.toString()', contains('children.length'), @@ -117,7 +117,7 @@ void main() { onValueChanged: defaultCallback, ), ), - throwsA(isA().having( + throwsA(isAssertionError.having( (AssertionError error) => error.toString(), '.toString()', contains('groupValue must be either null or one of the keys in the children map'), diff --git a/packages/flutter/test/material/dropdown_form_field_test.dart b/packages/flutter/test/material/dropdown_form_field_test.dart index b1f5d27ce2..66883d6d73 100644 --- a/packages/flutter/test/material/dropdown_form_field_test.dart +++ b/packages/flutter/test/material/dropdown_form_field_test.dart @@ -588,7 +588,7 @@ void main() { ), ), ), - throwsA(isA().having( + throwsA(isAssertionError.having( (AssertionError error) => error.toString(), '.toString()', contains("There should be exactly one item with [DropdownButton]'s value"), @@ -617,7 +617,7 @@ void main() { ), ), ), - throwsA(isA().having( + throwsA(isAssertionError.having( (AssertionError error) => error.toString(), '.toString()', contains("There should be exactly one item with [DropdownButton]'s value"), diff --git a/packages/flutter/test/material/dropdown_test.dart b/packages/flutter/test/material/dropdown_test.dart index c9d7d0abfa..e50291870d 100644 --- a/packages/flutter/test/material/dropdown_test.dart +++ b/packages/flutter/test/material/dropdown_test.dart @@ -457,7 +457,7 @@ void main() { ), ), ), - throwsA(isA().having( + throwsA(isAssertionError.having( (AssertionError error) => error.toString(), '.toString()', contains("There should be exactly one item with [DropdownButton]'s value"), @@ -486,7 +486,7 @@ void main() { ), ), ), - throwsA(isA().having( + throwsA(isAssertionError.having( (AssertionError error) => error.toString(), '.toString()', contains("There should be exactly one item with [DropdownButton]'s value"), diff --git a/packages/flutter/test/material/toggle_buttons_test.dart b/packages/flutter/test/material/toggle_buttons_test.dart index 7bfe2903e0..b4eeefecf2 100644 --- a/packages/flutter/test/material/toggle_buttons_test.dart +++ b/packages/flutter/test/material/toggle_buttons_test.dart @@ -185,7 +185,7 @@ void main() { ), ), ), - throwsA(isA().having( + throwsA(isAssertionError.having( (AssertionError error) => error.toString(), '.toString()', allOf( diff --git a/packages/flutter/test/rendering/box_test.dart b/packages/flutter/test/rendering/box_test.dart index 8737c99082..358aad7e5f 100644 --- a/packages/flutter/test/rendering/box_test.dart +++ b/packages/flutter/test/rendering/box_test.dart @@ -980,7 +980,7 @@ void main() { }, ); }, - throwsA(isA().having( + throwsA(isAssertionError.having( (AssertionError error) => error.message, 'message', 'paintTransform must be invertible.', @@ -996,7 +996,7 @@ void main() { }, ); }, - throwsA(isA().having( + throwsA(isAssertionError.having( (AssertionError error) => error.message, 'message', 'Exactly one transform or offset argument must be provided.', diff --git a/packages/flutter/test/services/restoration_bucket_test.dart b/packages/flutter/test/services/restoration_bucket_test.dart index 1f5c7bb41a..4652ce97b7 100644 --- a/packages/flutter/test/services/restoration_bucket_test.dart +++ b/packages/flutter/test/services/restoration_bucket_test.dart @@ -183,7 +183,7 @@ void main() { // child1 is not given up before running finalizers. expect( () => manager.doSerialization(), - throwsA(isA().having( + throwsA(isFlutterError.having( (FlutterError error) => error.message, 'message', equals( diff --git a/packages/flutter/test/widgets/grid_view_test.dart b/packages/flutter/test/widgets/grid_view_test.dart index e777308e8f..c0f87cdde6 100644 --- a/packages/flutter/test/widgets/grid_view_test.dart +++ b/packages/flutter/test/widgets/grid_view_test.dart @@ -768,7 +768,7 @@ void main() { child: GridView.extent( maxCrossAxisExtent: maxCrossAxisExtent, ), - ), throwsA(isA())); + ), throwsAssertionError); }); } diff --git a/packages/flutter/test/widgets/list_wheel_scroll_view_test.dart b/packages/flutter/test/widgets/list_wheel_scroll_view_test.dart index f1b8fea54a..46ac0c929c 100644 --- a/packages/flutter/test/widgets/list_wheel_scroll_view_test.dart +++ b/packages/flutter/test/widgets/list_wheel_scroll_view_test.dart @@ -56,7 +56,7 @@ void main() { itemExtent: 20.0, children: const [], ), - throwsA(isA().having( + throwsA(isAssertionError.having( (AssertionError error) => error.message, 'message', contains("You can't set a diameterRatio of 0"), diff --git a/packages/flutter/test/widgets/page_view_test.dart b/packages/flutter/test/widgets/page_view_test.dart index 9973b8d0d8..c5daa57529 100644 --- a/packages/flutter/test/widgets/page_view_test.dart +++ b/packages/flutter/test/widgets/page_view_test.dart @@ -758,7 +758,7 @@ void main() { final PageController controller = PageController(); expect( () => controller.page, - throwsA(isA().having( + throwsA(isAssertionError.having( (AssertionError error) => error.message, 'message', equals('PageController.page cannot be accessed before a PageView is built with it.'), @@ -792,7 +792,7 @@ void main() { ); expect( () => controller.page, - throwsA(isA().having( + throwsA(isAssertionError.having( (AssertionError error) => error.message, 'message', equals('PageController.page cannot be accessed before a PageView is built with it.'), diff --git a/packages/flutter_driver/test/src/real_tests/flutter_driver_test.dart b/packages/flutter_driver/test/src/real_tests/flutter_driver_test.dart index 2c08073ed7..b3928e0896 100644 --- a/packages/flutter_driver/test/src/real_tests/flutter_driver_test.dart +++ b/packages/flutter_driver/test/src/real_tests/flutter_driver_test.dart @@ -632,11 +632,11 @@ void main() { group('VMServiceFlutterDriver Unsupported error', () { test('enableAccessibility', () async { - expect(driver.enableAccessibility(), throwsA(isA())); + expect(driver.enableAccessibility(), throwsUnsupportedError); }); test('webDriver', () async { - expect(() => driver.webDriver, throwsA(isA())); + expect(() => driver.webDriver, throwsUnsupportedError); }); }); }); @@ -913,28 +913,23 @@ void main() { group('WebFlutterDriver Unimplemented/Unsupported error', () { test('forceGC', () async { - expect(driver.forceGC(), - throwsA(isA())); + expect(driver.forceGC(), throwsUnimplementedError); }); test('getVmFlags', () async { - expect(driver.getVmFlags(), - throwsA(isA())); + expect(driver.getVmFlags(), throwsUnimplementedError); }); test('waitUntilFirstFrameRasterized', () async { - expect(driver.waitUntilFirstFrameRasterized(), - throwsA(isA())); + expect(driver.waitUntilFirstFrameRasterized(), throwsUnimplementedError); }); test('appIsoloate', () async { - expect(() => driver.appIsolate.extensionRPCs, - throwsA(isA())); + expect(() => driver.appIsolate.extensionRPCs, throwsUnsupportedError); }); test('serviceClient', () async { - expect(() => driver.serviceClient.getVM(), - throwsA(isA())); + expect(() => driver.serviceClient.getVM(), throwsUnsupportedError); }); }); }); @@ -949,14 +944,10 @@ void main() { }); test('tracing', () async { - expect(driver.traceAction(() async { return Future.value(); }), - throwsA(isA())); - expect(driver.startTracing(), - throwsA(isA())); - expect(driver.stopTracingAndDownloadTimeline(), - throwsA(isA())); - expect(driver.clearTimeline(), - throwsA(isA())); + expect(driver.traceAction(() async { return Future.value(); }), throwsUnsupportedError); + expect(driver.startTracing(), throwsUnsupportedError); + expect(driver.stopTracingAndDownloadTimeline(), throwsUnsupportedError); + expect(driver.clearTimeline(), throwsUnsupportedError); }); }); } diff --git a/packages/flutter_driver/test/src/real_tests/io_extension_test.dart b/packages/flutter_driver/test/src/real_tests/io_extension_test.dart index 2e4c663e9b..e61e34ff9a 100644 --- a/packages/flutter_driver/test/src/real_tests/io_extension_test.dart +++ b/packages/flutter_driver/test/src/real_tests/io_extension_test.dart @@ -17,8 +17,7 @@ void main() { }); test('io_extension should throw exception', () { - expect(() => registerWebServiceExtension(call), - throwsA(isA())); + expect(() => registerWebServiceExtension(call), throwsUnsupportedError); }); }); } diff --git a/packages/flutter_test/test/goldens_test.dart b/packages/flutter_test/test/goldens_test.dart index 411e69f702..74f2f947e4 100644 --- a/packages/flutter_test/test/goldens_test.dart +++ b/packages/flutter_test/test/goldens_test.dart @@ -185,7 +185,7 @@ void main() { await fs.file(fix('/golden.png')).writeAsBytes(_kColorFailurePngBytes); await expectLater( () => doComparison(), - throwsA(isA().having( + throwsA(isFlutterError.having( (FlutterError error) => error.message, 'message', contains('% diff detected'), @@ -216,7 +216,7 @@ void main() { ..writeAsBytesSync(_kColorFailurePngBytes); await expectLater( () => doComparison('subdir/golden.png'), - throwsA(isA().having( + throwsA(isFlutterError.having( (FlutterError error) => error.message, 'message', contains('% diff detected'), @@ -255,7 +255,7 @@ void main() { await fs.file(fix('/golden.png')).writeAsBytes(_kSizeFailurePngBytes); await expectLater( () => doComparison(), - throwsA(isA().having( + throwsA(isFlutterError.having( (FlutterError error) => error.message, 'message', contains('image sizes do not match'), @@ -267,7 +267,7 @@ void main() { await fs.file(fix('/golden.png')).writeAsBytes(_kColorFailurePngBytes); await expectLater( () => doComparison(), - throwsA(isA().having( + throwsA(isFlutterError.having( (FlutterError error) => error.message, 'message', contains('% diff detected'), @@ -279,7 +279,7 @@ void main() { await fs.file(fix('/golden.png')).writeAsBytes([]); await expectLater( () => doComparison(), - throwsA(isA().having( + throwsA(isFlutterError.having( (FlutterError error) => error.message, 'message', contains('null image provided'), diff --git a/packages/flutter_tools/test/commands.shard/hermetic/build_test.dart b/packages/flutter_tools/test/commands.shard/hermetic/build_test.dart index ed9e11b211..d168ab2ecd 100644 --- a/packages/flutter_tools/test/commands.shard/hermetic/build_test.dart +++ b/packages/flutter_tools/test/commands.shard/hermetic/build_test.dart @@ -5,9 +5,9 @@ // @dart = 2.8 import 'package:args/command_runner.dart'; -import 'package:flutter_tools/src/base/common.dart'; import 'package:flutter_tools/src/runner/flutter_command.dart'; +import '../../src/common.dart'; import '../../src/context.dart'; import '../../src/test_flutter_command_runner.dart'; @@ -19,7 +19,7 @@ void main() { expect(() => commandRunner.run([ 'build', '--obfuscate', - ]), throwsA(isA())); + ]), throwsToolExit()); }); } diff --git a/packages/flutter_tools/test/commands.shard/hermetic/generate_localizations_test.dart b/packages/flutter_tools/test/commands.shard/hermetic/generate_localizations_test.dart index 05e804d524..6deed87f0b 100644 --- a/packages/flutter_tools/test/commands.shard/hermetic/generate_localizations_test.dart +++ b/packages/flutter_tools/test/commands.shard/hermetic/generate_localizations_test.dart @@ -5,13 +5,13 @@ // @dart = 2.8 import 'package:file/memory.dart'; -import 'package:flutter_tools/src/base/common.dart'; import 'package:flutter_tools/src/base/file_system.dart'; import 'package:flutter_tools/src/base/logger.dart'; import 'package:flutter_tools/src/commands/generate_localizations.dart'; import 'package:flutter_tools/src/runner/flutter_command.dart'; import '../../integration.shard/test_data/basic_project.dart'; +import '../../src/common.dart'; import '../../src/context.dart'; import '../../src/test_flutter_command_runner.dart'; @@ -100,7 +100,7 @@ void main() { '--header="some header', '--header-file="header.txt"', ]), - throwsA(isA()), + throwsToolExit(), ); }); diff --git a/packages/flutter_tools/test/commands.shard/hermetic/run_test.dart b/packages/flutter_tools/test/commands.shard/hermetic/run_test.dart index 5854c81c02..1ed9d541f5 100644 --- a/packages/flutter_tools/test/commands.shard/hermetic/run_test.dart +++ b/packages/flutter_tools/test/commands.shard/hermetic/run_test.dart @@ -75,7 +75,7 @@ void main() { '--no-pub', '--show-test-device', ]), - throwsA(isA().having( + throwsA(isException.having( (Exception exception) => exception.toString(), 'toString', isNot(contains('--fast-start is not supported with --use-application-binary')), @@ -102,7 +102,7 @@ void main() { 'run', '--no-pub', ]), - throwsA(isA()), + throwsToolExit(), ); final BufferLogger bufferLogger = globals.logger as BufferLogger; expect( @@ -127,11 +127,7 @@ void main() { 'run', '--no-pub', ]), - throwsA(isA().having( - (ToolExit error) => error.toString(), - 'toString()', - contains('No pubspec.yaml file found'), - )), + throwsToolExit(message: 'No pubspec.yaml file found'), ); }, overrides: { FileSystem: () => fileSystem, @@ -510,7 +506,7 @@ void main() { 'run', '--no-pub', '--bundle-sksl-path=foo.json', - ]), throwsA(isA().having((ToolExit exit) => exit.message, 'message', contains('No SkSL shader bundle found at foo.json')))); + ]), throwsToolExit(message: 'No SkSL shader bundle found at foo.json')); }); } diff --git a/packages/flutter_tools/test/commands.shard/hermetic/screenshot_command_test.dart b/packages/flutter_tools/test/commands.shard/hermetic/screenshot_command_test.dart index 4dd900bf38..2e075d4c97 100644 --- a/packages/flutter_tools/test/commands.shard/hermetic/screenshot_command_test.dart +++ b/packages/flutter_tools/test/commands.shard/hermetic/screenshot_command_test.dart @@ -30,12 +30,12 @@ void main() { await expectLater(() => createTestCommandRunner(ScreenshotCommand()) .run(['screenshot', '--type=skia', '--observatory-url=http://localhost:8181']), - throwsA(isA().having((dynamic exception) => exception.toString(), 'message', contains('dummy'))), + throwsA(isException.having((Exception exception) => exception.toString(), 'message', contains('dummy'))), ); await expectLater(() => createTestCommandRunner(ScreenshotCommand()) .run(['screenshot', '--type=rasterizer', '--observatory-url=http://localhost:8181']), - throwsA(isA().having((dynamic exception) => exception.toString(), 'message', contains('dummy'))), + throwsA(isException.having((Exception exception) => exception.toString(), 'message', contains('dummy'))), ); }); diff --git a/packages/flutter_tools/test/commands.shard/hermetic/test_test.dart b/packages/flutter_tools/test/commands.shard/hermetic/test_test.dart index 3c059991eb..8ad9454ddb 100644 --- a/packages/flutter_tools/test/commands.shard/hermetic/test_test.dart +++ b/packages/flutter_tools/test/commands.shard/hermetic/test_test.dart @@ -211,8 +211,7 @@ dev_dependencies: '--coverage', '--', 'test/fake_test.dart', - ]), throwsA(isA() - .having((ToolExit toolExit) => toolExit.message, 'message', isNull))); + ]), throwsA(isA().having((ToolExit toolExit) => toolExit.message, 'message', isNull))); }, overrides: { FileSystem: () => fs, ProcessManager: () => FakeProcessManager.any(), diff --git a/packages/flutter_tools/test/general.shard/android/android_device_port_forwarder_test.dart b/packages/flutter_tools/test/general.shard/android/android_device_port_forwarder_test.dart index ae66ad736b..7210c6f7d4 100644 --- a/packages/flutter_tools/test/general.shard/android/android_device_port_forwarder_test.dart +++ b/packages/flutter_tools/test/general.shard/android/android_device_port_forwarder_test.dart @@ -5,7 +5,6 @@ // @dart = 2.8 import 'package:flutter_tools/src/android/android_device.dart'; -import 'package:flutter_tools/src/base/io.dart'; import 'package:flutter_tools/src/base/logger.dart'; import 'package:flutter_tools/src/device_port_forwarder.dart'; @@ -78,7 +77,7 @@ void main() { logger: BufferLogger.test(), ); - expect(forwarder.forward(123, hostPort: 456), throwsA(isA())); + expect(forwarder.forward(123, hostPort: 456), throwsProcessException()); }); testWithoutContext('AndroidDevicePortForwarder forwardedPorts returns empty ' @@ -159,6 +158,6 @@ void main() { logger: BufferLogger.test(), ); - expect(() => forwarder.unforward(ForwardedPort(456, 23)), throwsA(isA())); + expect(() => forwarder.unforward(ForwardedPort(456, 23)), throwsProcessException()); }); } diff --git a/packages/flutter_tools/test/general.shard/android/android_gradle_builder_test.dart b/packages/flutter_tools/test/general.shard/android/android_gradle_builder_test.dart index f8f7170b99..03f6525556 100644 --- a/packages/flutter_tools/test/general.shard/android/android_gradle_builder_test.dart +++ b/packages/flutter_tools/test/general.shard/android/android_gradle_builder_test.dart @@ -358,7 +358,7 @@ void main() { ..writeAsStringSync('apply from: irrelevant/flutter.gradle'); await expectLater(() async { - await builder.buildGradleApp( + await builder.buildGradleApp( project: FlutterProject.fromDirectoryTest(fileSystem.currentDirectory), androidBuildInfo: const AndroidBuildInfo( BuildInfo( @@ -371,8 +371,7 @@ void main() { isBuildingBundle: false, localGradleErrors: const [], ); - }, - throwsA(isA())); + }, throwsProcessException()); expect(processManager, hasNoRemainingExpectations); }); diff --git a/packages/flutter_tools/test/general.shard/artifact_updater_test.dart b/packages/flutter_tools/test/general.shard/artifact_updater_test.dart index 14f64df8d0..6a3f56ded7 100644 --- a/packages/flutter_tools/test/general.shard/artifact_updater_test.dart +++ b/packages/flutter_tools/test/general.shard/artifact_updater_test.dart @@ -4,7 +4,6 @@ import 'package:file/memory.dart'; import 'package:file_testing/file_testing.dart'; -import 'package:flutter_tools/src/base/common.dart'; import 'package:flutter_tools/src/base/file_system.dart'; import 'package:flutter_tools/src/base/io.dart'; import 'package:flutter_tools/src/base/logger.dart'; @@ -288,7 +287,7 @@ void main() { 'test message', Uri.parse('http://test.zip'), fileSystem.currentDirectory.childDirectory('out'), - ), throwsA(isA())); + ), throwsArgumentError); expect(logger.statusText, contains('test message')); expect(fileSystem.file('out/test'), isNot(exists)); @@ -361,7 +360,7 @@ void main() { 'test message', Uri.parse('http://test.zip'), fileSystem.currentDirectory.childDirectory('out'), - ), throwsA(isA())); + ), throwsToolExit()); expect(fileSystem.file('te,[/test'), isNot(exists)); expect(fileSystem.file('out/test'), isNot(exists)); }); @@ -385,7 +384,7 @@ void main() { 'test message', Uri.parse('http://test.zip'), fileSystem.currentDirectory.childDirectory('out'), - ), throwsA(isA())); + ), throwsToolExit()); expect(fileSystem.file('te,[/test'), isNot(exists)); expect(fileSystem.file('out/test'), isNot(exists)); }); 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 0ffb6c2899..626326066d 100644 --- a/packages/flutter_tools/test/general.shard/base/common_test.dart +++ b/packages/flutter_tools/test/general.shard/base/common_test.dart @@ -26,7 +26,7 @@ void main() { }); testWithoutContext('Throws if accessing the Zone', () { - expect(() => context.get(), throwsA(isA())); + expect(() => context.get(), throwsUnsupportedError); }); }); } diff --git a/packages/flutter_tools/test/general.shard/base/error_handling_io_test.dart b/packages/flutter_tools/test/general.shard/base/error_handling_io_test.dart index 62b8112286..25769af3ff 100644 --- a/packages/flutter_tools/test/general.shard/base/error_handling_io_test.dart +++ b/packages/flutter_tools/test/general.shard/base/error_handling_io_test.dart @@ -168,7 +168,7 @@ void main() { when(file.deleteSync(recursive: false)) .thenThrow(const FileSystemException('', '', OSError('', 2))); - expect(() => ErrorHandlingFileSystem.deleteIfExists(file), throwsA(isA())); + expect(() => ErrorHandlingFileSystem.deleteIfExists(file), throwsToolExit()); }); testWithoutContext('deleteIfExists does not tool exit if file exists on read-only ' @@ -182,7 +182,7 @@ void main() { ErrorHandlingFileSystem.noExitOnFailure(() { ErrorHandlingFileSystem.deleteIfExists(file); }); - }, throwsA(isA())); + }, throwsFileSystemException()); }); group('throws ToolExit on Windows', () { @@ -213,7 +213,7 @@ void main() { final File file = fs.file('file'); expect(() => ErrorHandlingFileSystem.noExitOnFailure( - () => file.writeAsStringSync('')), throwsA(isA())); + () => file.writeAsStringSync('')), throwsException); // nesting does not unconditionally re-enable errors. expect(() { @@ -221,10 +221,10 @@ void main() { ErrorHandlingFileSystem.noExitOnFailure(() { }); file.writeAsStringSync(''); }); - }, throwsA(isA())); + }, throwsException); // Check that state does not leak. - expect(() => file.writeAsStringSync(''), throwsA(isA())); + expect(() => file.writeAsStringSync(''), throwsToolExit()); }); testWithoutContext('when access is denied', () async { diff --git a/packages/flutter_tools/test/general.shard/base/logger_test.dart b/packages/flutter_tools/test/general.shard/base/logger_test.dart index e117b8b0a7..f11bcb935f 100644 --- a/packages/flutter_tools/test/general.shard/base/logger_test.dart +++ b/packages/flutter_tools/test/general.shard/base/logger_test.dart @@ -227,7 +227,7 @@ void main() { expect( () => asLogger(notifyingLogger), - throwsA(isA()), + throwsStateError, ); }); @@ -335,8 +335,8 @@ void main() { logger.printStatus('message'); logger.printError('error message'); - expect(() async => stdout.done, throwsA(isA())); - expect(() async => stderr.done, throwsA(isA())); + expect(() async => stdout.done, throwsException); + expect(() async => stderr.done, throwsException); }); group('Spinners', () { 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 7af5b9cb82..2a9f27ad05 100644 --- a/packages/flutter_tools/test/general.shard/base/os_test.dart +++ b/packages/flutter_tools/test/general.shard/base/os_test.dart @@ -4,7 +4,6 @@ import 'package:file/file.dart'; import 'package:file/memory.dart'; -import 'package:flutter_tools/src/base/common.dart'; 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'; @@ -100,7 +99,7 @@ void main() { processManager: fakeProcessManager, ); - expect(() => utils.which(kExecutable), throwsA(isA())); + expect(() => utils.which(kExecutable), throwsToolExit()); }); testWithoutContext('returns null when executable does not exist', () async { diff --git a/packages/flutter_tools/test/general.shard/base/process_test.dart b/packages/flutter_tools/test/general.shard/base/process_test.dart index 12fef9d22a..3792ae5122 100644 --- a/packages/flutter_tools/test/general.shard/base/process_test.dart +++ b/packages/flutter_tools/test/general.shard/base/process_test.dart @@ -35,8 +35,7 @@ void main() { exitCode: 1, )); - expect(() async => processUtils.run(['false'], throwOnError: true), - throwsA(isA())); + expect(() async => processUtils.run(['false'], throwOnError: true), throwsProcessException()); }); }); @@ -124,8 +123,7 @@ void main() { ], exitCode: 1, )); - expect(() => processUtils.run(['kaboom'], throwOnError: true), - throwsA(isA())); + expect(() => processUtils.run(['kaboom'], throwOnError: true), throwsProcessException()); }); testWithoutContext(' does not throw on allowed Failures', () async { @@ -158,7 +156,7 @@ void main() { throwOnError: true, allowedFailures: (int c) => c == 1, ), - throwsA(isA()), + throwsProcessException(), ); }); }); @@ -269,7 +267,8 @@ void main() { throwOnError: true, allowedFailures: (int c) => c == 1, ), - throwsA(isA())); + throwsProcessException(), + ); }); testWithoutContext(' prints stdout and stderr to trace on success', () async { @@ -294,8 +293,7 @@ void main() { stdout: 'stdout', stderr: 'stderr', )); - expect(() => processUtils.runSync(['kaboom'], throwOnError: true), - throwsA(isA())); + expect(() => processUtils.runSync(['kaboom'], throwOnError: true), throwsProcessException()); expect(testLogger.statusText, contains('stdout')); expect(testLogger.errorText, contains('stderr')); }); diff --git a/packages/flutter_tools/test/general.shard/build_system/targets/assets_test.dart b/packages/flutter_tools/test/general.shard/build_system/targets/assets_test.dart index bcdba6e4ab..77b612ed9e 100644 --- a/packages/flutter_tools/test/general.shard/build_system/targets/assets_test.dart +++ b/packages/flutter_tools/test/general.shard/build_system/targets/assets_test.dart @@ -110,8 +110,7 @@ flutter: '''); - expect(() async => const CopyAssets().build(environment), - throwsA(isA())); + expect(() async => const CopyAssets().build(environment), throwsException); }, overrides: { FileSystem: () => fileSystem, ProcessManager: () => FakeProcessManager.any(), @@ -138,7 +137,7 @@ flutter: fileSystem: MemoryFileSystem.test(), logger: BufferLogger.test(), engineVersion: null, - ), throwsA(isA())); + ), throwsException); }); testWithoutContext('processSkSLBundle throws exception if the bundle is not ' @@ -154,7 +153,7 @@ flutter: fileSystem: fileSystem, logger: logger, engineVersion: null, - ), throwsA(isA())); + ), throwsException); expect(logger.errorText, contains('was not a JSON object')); }); @@ -171,7 +170,7 @@ flutter: fileSystem: fileSystem, logger: logger, engineVersion: null, - ), throwsA(isA())); + ), throwsException); expect(logger.errorText, contains('was not a JSON object')); }); @@ -192,7 +191,7 @@ flutter: fileSystem: fileSystem, logger: logger, engineVersion: '2', - ), throwsA(isA())); + ), throwsException); expect(logger.errorText, contains('Expected Flutter 1, but found 2')); }); diff --git a/packages/flutter_tools/test/general.shard/build_system/targets/common_test.dart b/packages/flutter_tools/test/general.shard/build_system/targets/common_test.dart index 3690800ded..90dde14d83 100644 --- a/packages/flutter_tools/test/general.shard/build_system/targets/common_test.dart +++ b/packages/flutter_tools/test/general.shard/build_system/targets/common_test.dart @@ -104,8 +104,7 @@ void main() { ], exitCode: 1), ]); - await expectLater(() => const KernelSnapshot().build(androidEnvironment), - throwsA(isA())); + await expectLater(() => const KernelSnapshot().build(androidEnvironment), throwsException); expect(processManager, hasNoRemainingExpectations); }); @@ -434,8 +433,7 @@ void main() { }); testUsingContext('AotAssemblyProfile throws error if built for non-iOS platform', () async { - expect(const AotAssemblyProfile().build(androidEnvironment), - throwsA(isA())); + expect(const AotAssemblyProfile().build(androidEnvironment), throwsException); }, overrides: { Platform: () => macPlatform, FileSystem: () => fileSystem, diff --git a/packages/flutter_tools/test/general.shard/build_system/targets/desktop_test.dart b/packages/flutter_tools/test/general.shard/build_system/targets/desktop_test.dart index 11c3d106ed..f83abfa2cd 100644 --- a/packages/flutter_tools/test/general.shard/build_system/targets/desktop_test.dart +++ b/packages/flutter_tools/test/general.shard/build_system/targets/desktop_test.dart @@ -64,7 +64,7 @@ void main() { 'a.txt', ], clientSourcePaths: ['foo'], - ), throwsA(isA())); + ), throwsException); }); testWithoutContext('unpackDesktopArtifacts throws when attempting to copy missing directory', () async { @@ -79,7 +79,7 @@ void main() { 'a.txt', ], clientSourcePaths: ['foo'], - ), throwsA(isA())); + ), throwsException); }); testWithoutContext('unpackDesktopArtifacts does not require a client source path', () async { diff --git a/packages/flutter_tools/test/general.shard/build_system/targets/ios_test.dart b/packages/flutter_tools/test/general.shard/build_system/targets/ios_test.dart index dd69acfa5a..f26bc09b55 100644 --- a/packages/flutter_tools/test/general.shard/build_system/targets/ios_test.dart +++ b/packages/flutter_tools/test/general.shard/build_system/targets/ios_test.dart @@ -225,7 +225,7 @@ void main() { fileSystem: fileSystem, ); - expect(const AotAssemblyRelease().build(environment), throwsA(isA() + expect(const AotAssemblyRelease().build(environment), throwsA(isException .having( (Exception exception) => exception.toString(), 'description', @@ -254,13 +254,11 @@ void main() { environment.defines[kBuildMode] = 'release'; environment.defines[kIosArchs] = 'x86_64'; - expect(const AotAssemblyRelease().build(environment), throwsA(isA() - .having( - (Exception exception) => exception.toString(), + expect(const AotAssemblyRelease().build(environment), throwsA(isException.having( + (Exception exception) => exception.toString(), 'description', contains('required define SdkRoot but it was not provided'), - ) - )); + ))); expect(processManager.hasRemainingExpectations, isFalse); }, overrides: { FileSystem: () => fileSystem, @@ -371,7 +369,7 @@ void main() { processManager.addCommand(copyPhysicalFrameworkCommand); await expectLater( const DebugUnpackIOS().build(environment), - throwsA(isA().having( + throwsA(isException.having( (Exception exception) => exception.toString(), 'description', contains('Flutter.framework/Flutter does not exist, cannot thin'), @@ -412,12 +410,13 @@ void main() { ]); await expectLater( - const DebugUnpackIOS().build(environment), - throwsA(isA().having( - (Exception exception) => exception.toString(), - 'description', - contains('does not contain arm64 armv7. Running lipo -info:\nArchitectures in the fat file:'), - ))); + const DebugUnpackIOS().build(environment), + throwsA(isException.having( + (Exception exception) => exception.toString(), + 'description', + contains('does not contain arm64 armv7. Running lipo -info:\nArchitectures in the fat file:'), + )), + ); }); testWithoutContext('fails when lipo extract fails', () async { @@ -466,11 +465,12 @@ void main() { await expectLater( const DebugUnpackIOS().build(environment), - throwsA(isA().having( - (Exception exception) => exception.toString(), + throwsA(isException.having( + (Exception exception) => exception.toString(), 'description', contains('Failed to extract arm64 armv7 for output/Flutter.framework/Flutter.\nlipo error\nRunning lipo -info:\nArchitectures in the fat file:'), - ))); + )), + ); }); testWithoutContext('skips thin framework', () async { @@ -581,12 +581,13 @@ void main() { ]); await expectLater( - const DebugUnpackIOS().build(environment), - throwsA(isA().having( - (Exception exception) => exception.toString(), - 'description', - contains('Failed to strip bitcode for output/Flutter.framework/Flutter.\nbitcode_strip error'), - ))); + const DebugUnpackIOS().build(environment), + throwsA(isException.having( + (Exception exception) => exception.toString(), + 'description', + contains('Failed to strip bitcode for output/Flutter.framework/Flutter.\nbitcode_strip error'), + )), + ); expect(processManager.hasRemainingExpectations, isFalse); }); @@ -653,12 +654,13 @@ void main() { ]); await expectLater( - const DebugUnpackIOS().build(environment), - throwsA(isA().having( - (Exception exception) => exception.toString(), - 'description', - contains('Failed to codesign output/Flutter.framework/Flutter with identity ABC123.\ncodesign error'), - ))); + const DebugUnpackIOS().build(environment), + throwsA(isException.having( + (Exception exception) => exception.toString(), + 'description', + contains('Failed to codesign output/Flutter.framework/Flutter with identity ABC123.\ncodesign error'), + )), + ); expect(processManager.hasRemainingExpectations, isFalse); }); diff --git a/packages/flutter_tools/test/general.shard/build_system/targets/localizations_test.dart b/packages/flutter_tools/test/general.shard/build_system/targets/localizations_test.dart index 509a55bac3..64e053e47d 100644 --- a/packages/flutter_tools/test/general.shard/build_system/targets/localizations_test.dart +++ b/packages/flutter_tools/test/general.shard/build_system/targets/localizations_test.dart @@ -96,7 +96,7 @@ use-deferred-loading: string file: configFile, logger: BufferLogger.test(), ), - throwsA(isA()), + throwsException, ); }); } diff --git a/packages/flutter_tools/test/general.shard/build_system/targets/macos_test.dart b/packages/flutter_tools/test/general.shard/build_system/targets/macos_test.dart index 8a73da9c51..f57c348f32 100644 --- a/packages/flutter_tools/test/general.shard/build_system/targets/macos_test.dart +++ b/packages/flutter_tools/test/general.shard/build_system/targets/macos_test.dart @@ -105,12 +105,13 @@ void main() { testUsingContext('thinning fails when framework missing', () async { processManager.addCommand(copyFrameworkCommand); await expectLater( - const DebugUnpackMacOS().build(environment), - throwsA(isA().having( - (Exception exception) => exception.toString(), - 'description', - contains('FlutterMacOS.framework/FlutterMacOS does not exist, cannot thin'), - ))); + const DebugUnpackMacOS().build(environment), + throwsA(isException.having( + (Exception exception) => exception.toString(), + 'description', + contains('FlutterMacOS.framework/FlutterMacOS does not exist, cannot thin'), + )), + ); }, overrides: { FileSystem: () => fileSystem, ProcessManager: () => processManager, @@ -132,12 +133,13 @@ void main() { ]); await expectLater( - const DebugUnpackMacOS().build(environment), - throwsA(isA().having( - (Exception exception) => exception.toString(), - 'description', - contains('does not contain arm64 x86_64. Running lipo -info:\nArchitectures in the fat file:'), - ))); + const DebugUnpackMacOS().build(environment), + throwsA(isException.having( + (Exception exception) => exception.toString(), + 'description', + contains('does not contain arm64 x86_64. Running lipo -info:\nArchitectures in the fat file:'), + )), + ); }, overrides: { FileSystem: () => fileSystem, ProcessManager: () => processManager, diff --git a/packages/flutter_tools/test/general.shard/cache_test.dart b/packages/flutter_tools/test/general.shard/cache_test.dart index b4a34e24b3..67b8d03d5e 100644 --- a/packages/flutter_tools/test/general.shard/cache_test.dart +++ b/packages/flutter_tools/test/general.shard/cache_test.dart @@ -290,7 +290,7 @@ void main() { ); await expectLater( () => cache.updateAll({null}), - throwsA(isA()), + throwsException, ); verify(artifact1.update(any, any, any, any)); // Don't continue when retrieval fails. diff --git a/packages/flutter_tools/test/general.shard/device_test.dart b/packages/flutter_tools/test/general.shard/device_test.dart index 8b885230c0..5c67089df1 100644 --- a/packages/flutter_tools/test/general.shard/device_test.dart +++ b/packages/flutter_tools/test/general.shard/device_test.dart @@ -7,7 +7,6 @@ import 'dart:async'; import 'package:fake_async/fake_async.dart'; -import 'package:flutter_tools/src/base/common.dart'; import 'package:flutter_tools/src/base/io.dart'; import 'package:flutter_tools/src/base/logger.dart'; import 'package:flutter_tools/src/base/terminal.dart'; @@ -336,7 +335,7 @@ void main() { ); await expectLater( () async => deviceManager.findTargetDevices(FakeFlutterProject()), - throwsA(isA()) + throwsToolExit(), ); }); diff --git a/packages/flutter_tools/test/general.shard/ios/devices_test.dart b/packages/flutter_tools/test/general.shard/ios/devices_test.dart index 7d81aa1799..1da6dffd02 100644 --- a/packages/flutter_tools/test/general.shard/ios/devices_test.dart +++ b/packages/flutter_tools/test/general.shard/ios/devices_test.dart @@ -516,8 +516,8 @@ void main() { ); when(mockXcdevice.isInstalled).thenReturn(false); expect( - () async { await iosDevices.pollingGetDevices(); }, - throwsA(isA()), + () async { await iosDevices.pollingGetDevices(); }, + throwsUnsupportedError, ); }); } diff --git a/packages/flutter_tools/test/general.shard/mdns_discovery_test.dart b/packages/flutter_tools/test/general.shard/mdns_discovery_test.dart index 104bec9ad8..36af829061 100644 --- a/packages/flutter_tools/test/general.shard/mdns_discovery_test.dart +++ b/packages/flutter_tools/test/general.shard/mdns_discovery_test.dart @@ -214,7 +214,7 @@ void main() { ); expect( () async => portDiscovery.query(), - throwsA(isA()), + throwsException, ); }); diff --git a/packages/flutter_tools/test/general.shard/resident_web_runner_cold_test.dart b/packages/flutter_tools/test/general.shard/resident_web_runner_cold_test.dart index df50558d9e..85fc39f11b 100644 --- a/packages/flutter_tools/test/general.shard/resident_web_runner_cold_test.dart +++ b/packages/flutter_tools/test/general.shard/resident_web_runner_cold_test.dart @@ -114,7 +114,7 @@ void main() { usage: TestUsage(), ); - expect(() async => residentWebRunner.run(), throwsA(isA())); + expect(() async => residentWebRunner.run(), throwsException); expect(await residentWebRunner.waitForAppToFinish(), 1); }, overrides: { BuildSystem: () => TestBuildSystem.error(Exception('foo')), diff --git a/packages/flutter_tools/test/general.shard/runner/flutter_command_test.dart b/packages/flutter_tools/test/general.shard/runner/flutter_command_test.dart index 9e16bafcd9..13682419dc 100644 --- a/packages/flutter_tools/test/general.shard/runner/flutter_command_test.dart +++ b/packages/flutter_tools/test/general.shard/runner/flutter_command_test.dart @@ -212,7 +212,7 @@ void main() { ); await expectLater( () => flutterCommand.run(), - throwsA(isA()), + throwsToolExit(), ); expect(usage.events, [ const TestUsageEvent( @@ -436,7 +436,7 @@ void main() { await expectLater( () => flutterCommand.run(), - throwsA(isA()), + throwsToolExit(), ); expect(usage.timings, contains( const TestTimingEvent( diff --git a/packages/flutter_tools/test/general.shard/testbed_test.dart b/packages/flutter_tools/test/general.shard/testbed_test.dart index a69b7d8359..0a15f55617 100644 --- a/packages/flutter_tools/test/general.shard/testbed_test.dart +++ b/packages/flutter_tools/test/general.shard/testbed_test.dart @@ -96,7 +96,7 @@ void main() { ProcessUtils: () => null, }); - expect(() => testbed.run(() {}), throwsA(isA())); + expect(() => testbed.run(() {}), throwsStateError); }); }); }