From 583971085983f145297cc08eb8a6b730b6c0c4d4 Mon Sep 17 00:00:00 2001 From: Jonah Williams Date: Sat, 10 Nov 2018 19:32:35 -0800 Subject: [PATCH] Throw a better error when old test versions are loaded. (#24217) --- .../lib/src/test/flutter_platform.dart | 21 ++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/packages/flutter_tools/lib/src/test/flutter_platform.dart b/packages/flutter_tools/lib/src/test/flutter_platform.dart index 4230329af8..1bec9a00be 100644 --- a/packages/flutter_tools/lib/src/test/flutter_platform.dart +++ b/packages/flutter_tools/lib/src/test/flutter_platform.dart @@ -414,10 +414,25 @@ class _FlutterPlatform extends PlatformPlugin { ) async { // loadChannel may throw an exception. That's fine; it will cause the // LoadSuite to emit an error, which will be presented to the user. - final StreamChannel channel = loadChannel(path, platform); - final RunnerSuiteController controller = deserializeSuite(path, platform, + // Except for the Declarer error, which is a specific test incompatibility + // error we need to catch. + try { + final StreamChannel channel = loadChannel(path, platform); + final RunnerSuiteController controller = deserializeSuite(path, platform, suiteConfig, const PluginEnvironment(), channel, message); - return await controller.suite; + return await controller.suite; + } catch (err) { + /// Rethrow a less confusing error if it is a test incompatibility. + if (err.toString().contains('type \'Declarer\' is not a subtype of type \'Declarer\'')) { + throw UnsupportedError('Package incompatibility between flutter and test packages:\n' + ' * flutter is incompatible with test <1.4.0.\n' + ' * flutter is incompatible with mockito <4.0.0\n' + 'To fix this error, update test to at least \'^1.4.0\' and mockito to at least \'^4.0.0\'\n' + ); + } + // Guess it was a different error. + rethrow; + } } @override