From 5208f70bf891b1ea7b9076dad3ac3fa40092c5bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20Badst=C3=BCbner?= Date: Sat, 3 Feb 2024 00:29:08 +0100 Subject: [PATCH] [patrol_cli] fix(compatibility_checker.dart): it get's stuck when it can't find patrol The packageCompleter.future never returns the way it was before. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jonas Badstübner --- packages/patrol_cli/CHANGELOG.md | 4 +++ .../patrol_cli/lib/src/base/constants.dart | 2 +- .../lib/src/compatibility_checker.dart | 29 ++++++++++--------- packages/patrol_cli/pubspec.yaml | 2 +- 4 files changed, 22 insertions(+), 15 deletions(-) diff --git a/packages/patrol_cli/CHANGELOG.md b/packages/patrol_cli/CHANGELOG.md index 0cfbb1e12..9bac1f17e 100644 --- a/packages/patrol_cli/CHANGELOG.md +++ b/packages/patrol_cli/CHANGELOG.md @@ -1,3 +1,7 @@ +## 2.6.4 + +- Fix compatibility_checker getting stuck (#2091). + ## 2.6.3 - Fix invalid JSON output of version check command (#2087). diff --git a/packages/patrol_cli/lib/src/base/constants.dart b/packages/patrol_cli/lib/src/base/constants.dart index ad7dabc33..330111869 100644 --- a/packages/patrol_cli/lib/src/base/constants.dart +++ b/packages/patrol_cli/lib/src/base/constants.dart @@ -1,3 +1,3 @@ /// Version of Patrol CLI. Must be kept in sync with pubspec.yaml. /// If you update this, make sure that compatibility-table.mdx is updated (if needed) -const version = '2.6.3'; +const version = '2.6.4'; diff --git a/packages/patrol_cli/lib/src/compatibility_checker.dart b/packages/patrol_cli/lib/src/compatibility_checker.dart index c3f655a38..996a6ada1 100644 --- a/packages/patrol_cli/lib/src/compatibility_checker.dart +++ b/packages/patrol_cli/lib/src/compatibility_checker.dart @@ -53,24 +53,27 @@ class CompatibilityChecker { ) ..disposedBy(scope); - process.listenStdOut((line) async { - if (line.startsWith('- patrol ')) { - packageCompleter.complete(line.split(' ').last); - } - }).disposedBy(scope); + process.listenStdOut( + (line) async { + if (line.startsWith('- patrol ')) { + packageCompleter.complete(line.split(' ').last); + } + }, + onDone: () { + if (!packageCompleter.isCompleted) { + throwToolExit( + 'Failed to read patrol version. Make sure you have patrol ' + 'dependency in your pubspec.yaml file', + ); + } + }, + ).disposedBy(scope); }); packageVersion = await packageCompleter.future; - if (packageVersion == null) { - throwToolExit( - 'Failed to read patrol version. Make sure you have patrol ' - 'dependency in your pubspec.yaml file', - ); - } - final cliVersion = Version.parse(constants.version); - final patrolVersion = Version.parse(packageVersion); + final patrolVersion = Version.parse(packageVersion!); final isCompatible = cliVersion.isCompatibleWith(patrolVersion); diff --git a/packages/patrol_cli/pubspec.yaml b/packages/patrol_cli/pubspec.yaml index fcd314a30..408e45ee4 100644 --- a/packages/patrol_cli/pubspec.yaml +++ b/packages/patrol_cli/pubspec.yaml @@ -1,7 +1,7 @@ name: patrol_cli description: > Command-line tool for Patrol, a powerful Flutter-native UI testing framework. -version: 2.6.3 # Must be kept in sync with constants.dart +version: 2.6.4 # Must be kept in sync with constants.dart homepage: https://patrol.leancode.co repository: https://github.com/leancodepl/patrol/tree/master/packages/patrol_cli issue_tracker: https://github.com/leancodepl/patrol/issues?q=is%3Aopen+is%3Aissue+label%3A%22package%3A+patrol_cli%22