Skip to content

Commit

Permalink
Detect Orchestrator version and warn about 1.5.0
Browse files Browse the repository at this point in the history
  • Loading branch information
piotruela committed Nov 29, 2024
1 parent 5ff5325 commit a559adb
Show file tree
Hide file tree
Showing 10 changed files with 69 additions and 6 deletions.
3 changes: 2 additions & 1 deletion docs/compatibility-table.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ the table below to assess which version you should use.

| patrol_cli | patrol | Min Flutter Version |
| -------------- | -------------- | ------------------- |
| 3.4.0+ | 3.13.0+ | 3.24.0 |
| 3.4.1+ | 3.13.1+ | 3.24.0 |
| 3.4.0 | 3.13.0 | 3.24.0 |
| 3.3.0 | 3.12.0 | 3.24.0 |
| 3.2.1 | 3.11.2 | 3.24.0 |
| 3.2.0 | 3.11.0 - 3.11.1| 3.22.0 |
Expand Down
4 changes: 4 additions & 0 deletions packages/patrol/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 3.13.1

- Remove whitespace replacement on Android test name. (#2437)

## 3.13.0

- Add support for the `patrol_log` package. (#2387)
Expand Down
2 changes: 2 additions & 0 deletions packages/patrol/example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ dev_dependencies:
leancode_lint: ^14.2.0
patrol:
path: ..
patrol_cli:
path: ../../patrol_cli

flutter_launcher_icons:
android: 'launcher_icon'
Expand Down
2 changes: 1 addition & 1 deletion packages/patrol/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: patrol
description: >
Powerful Flutter-native UI testing framework overcoming limitations of
existing Flutter testing tools. Ready for action!
version: 3.13.0
version: 3.13.1
homepage: https://patrol.leancode.co
repository: https://github.com/leancodepl/patrol/tree/master/packages/patrol
issue_tracker: https://github.com/leancodepl/patrol/issues
Expand Down
3 changes: 2 additions & 1 deletion packages/patrol_cli/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
## Unreleased
## 3.4.1

- Add android product flavor to dart-define. (#2425)
- Detect and warn about Orchestrator 1.5.0. (#2437)

## 3.4.0

Expand Down
33 changes: 33 additions & 0 deletions packages/patrol_cli/lib/src/android/android_test_backend.dart
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ class AndroidTestBackend {
Future<void> build(AndroidAppOptions options) async {
await buildApkConfigOnly(options.flutter.command);
await loadJavaPathFromFlutterDoctor(options.flutter.command);
await detectOrchestratorVersion(options);

await _disposeScope.run((scope) async {
final subject = options.description;
Expand Down Expand Up @@ -179,6 +180,38 @@ class AndroidTestBackend {
);
}

/// Detects the orchestrator version and warns the user if it's 1.5.0.
/// Related to this regression: https://github.com/android/android-test/issues/2255
Future<void> detectOrchestratorVersion(
AndroidAppOptions options,
) async {
await _disposeScope.run((scope) async {
Process process;

process = await _processManager.start(
options.toGradleAppDependencies(isWindows: _platform.isWindows),
runInShell: true,
workingDirectory: _rootDirectory.childDirectory('android').path,
environment: switch (javaPath) {
final javaPath? => {'JAVA_HOME': javaPath},
_ => {},
},
)
..disposedBy(scope);
process.listenStdOut((l) {
if (l.contains('androidx.test:orchestrator:1.5.0')) {
_logger.warn(
'Orchestrator version 1.5.0 detected\n'
'Orchestrator 1.5.0 does not support whitespace in the test name.\n'
'Please update the orchestrator version to 1.5.1 or higher.\n',
);
}
}).disposedBy(scope);

await process.exitCode;
});
}

/// Executes the tests of the given [options] on the given [device].
///
/// [build] must be called before this method.
Expand Down
2 changes: 1 addition & 1 deletion packages/patrol_cli/lib/src/base/constants.dart
Original file line number Diff line number Diff line change
@@ -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 = '3.4.0';
const version = '3.4.1';
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class CompatibilityChecker {
process.listenStdOut(
(line) async {
if (line.startsWith('- patrol ')) {
packageCompleter.complete(line.split(' ').last);
packageCompleter.maybeComplete(line.split(' ').last);
}
},
onDone: () {
Expand Down Expand Up @@ -215,6 +215,10 @@ final _patrolVersionRange = [
),
VersionRange(
min: Version.parse('3.13.0'),
max: Version.parse('3.13.0'),
),
VersionRange(
min: Version.parse('3.13.1'),
),
];

Expand Down Expand Up @@ -265,5 +269,9 @@ final _patrolCliVersionRange = [
),
VersionRange(
min: Version.parse('3.4.0'),
max: Version.parse('3.4.0'),
),
VersionRange(
min: Version.parse('3.4.1'),
),
];
14 changes: 14 additions & 0 deletions packages/patrol_cli/lib/src/crossplatform/app_options.dart
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,20 @@ class AndroidAppOptions {
);
}

List<String> toGradleAppDependencies({required bool isWindows}) {
final List<String> cmd;
if (isWindows) {
cmd = <String>[r'.\gradlew.bat'];
} else {
cmd = <String>['./gradlew'];
}

// Add Gradle task
cmd.add(':app:dependencies');

return cmd;
}

String get _buildMode => flutter.buildMode.androidName;

String get _effectiveFlavor {
Expand Down
2 changes: 1 addition & 1 deletion packages/patrol_cli/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: patrol_cli
description: >
Command-line tool for Patrol, a powerful Flutter-native UI testing framework.
version: 3.4.0 # Must be kept in sync with constants.dart
version: 3.4.1 # 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
Expand Down

0 comments on commit a559adb

Please sign in to comment.