diff --git a/docs/compatibility-table.mdx b/docs/compatibility-table.mdx deleted file mode 100644 index b48121033..000000000 --- a/docs/compatibility-table.mdx +++ /dev/null @@ -1,3 +0,0 @@ ---- -redirect: /documentation/compatibility-table ---- diff --git a/docs/documentation/compatibility-table.mdx b/docs/documentation/compatibility-table.mdx index 8786655a4..47595f1d7 100644 --- a/docs/documentation/compatibility-table.mdx +++ b/docs/documentation/compatibility-table.mdx @@ -11,7 +11,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 | diff --git a/docs/documentation/index.mdx b/docs/documentation/index.mdx index 895f163ca..1bc11253c 100644 --- a/docs/documentation/index.mdx +++ b/docs/documentation/index.mdx @@ -182,7 +182,7 @@ Check out our video version of this tutorial on YouTube! Add this line to `dependencies` section: ```groovy title="android/app/build.gradle" - androidTestUtil "androidx.test:orchestrator:1.4.2" + androidTestUtil "androidx.test:orchestrator:1.5.1" ``` diff --git a/docs/getting-started.mdx b/docs/getting-started.mdx deleted file mode 100644 index b4c5570b0..000000000 --- a/docs/getting-started.mdx +++ /dev/null @@ -1,3 +0,0 @@ ---- -redirect: /documentation ---- diff --git a/packages/patrol/CHANGELOG.md b/packages/patrol/CHANGELOG.md index f69a43b08..c1da30793 100644 --- a/packages/patrol/CHANGELOG.md +++ b/packages/patrol/CHANGELOG.md @@ -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) diff --git a/packages/patrol/android/src/main/kotlin/pl/leancode/patrol/PatrolJUnitRunner.java b/packages/patrol/android/src/main/kotlin/pl/leancode/patrol/PatrolJUnitRunner.java index 47e79b3f8..2568cd211 100644 --- a/packages/patrol/android/src/main/kotlin/pl/leancode/patrol/PatrolJUnitRunner.java +++ b/packages/patrol/android/src/main/kotlin/pl/leancode/patrol/PatrolJUnitRunner.java @@ -35,8 +35,6 @@ public class PatrolJUnitRunner extends AndroidJUnitRunner { public PatrolAppServiceClient patrolAppServiceClient; private Map dartTestCaseSkipMap = new HashMap<>(); - private String spaceReplacement = "__"; - @Override protected boolean shouldWaitForActivitiesToComplete() { return false; @@ -117,9 +115,8 @@ public Object[] listDartTests() { List dartTestCases = ContractsExtensionsKt.listTestsFlat(dartTestGroup, ""); List dartTestCaseNamesList = new ArrayList<>(); for (DartGroupEntry dartTestCase : dartTestCases) { - final String testName = sanitizeTestCaseName(dartTestCase.getName()); - dartTestCaseSkipMap.put(testName, dartTestCase.getSkip()); - dartTestCaseNamesList.add(testName); + dartTestCaseSkipMap.put(dartTestCase.getName(), dartTestCase.getSkip()); + dartTestCaseNamesList.add(dartTestCase.getName()); } Object[] dartTestCaseNames = dartTestCaseNamesList.toArray(); Logger.INSTANCE.i(TAG + "Got Dart tests: " + Arrays.toString(dartTestCaseNames)); @@ -145,7 +142,7 @@ public RunDartTestResponse runDartTest(String name) { try { Logger.INSTANCE.i(TAG + "Requested execution"); - RunDartTestResponse response = patrolAppServiceClient.runDartTest(originalTestCaseName(name)); + RunDartTestResponse response = patrolAppServiceClient.runDartTest(name); if (response.getResult() == Contracts.RunDartTestResponseResult.failure) { throw new AssertionError("Dart test failed: " + name + "\n" + response.getDetails()); } @@ -156,19 +153,4 @@ public RunDartTestResponse runDartTest(String name) { throw new RuntimeException(e); } } - - /** - * We need to remove whitespaces from test case name in order to make in compatible with Orchestrator 1.5.0. - * New requirement can be observed (here). - * */ - private String sanitizeTestCaseName(String name) { - return name.replace(" ", spaceReplacement); - } - - /** - * When calling test on dart side, we need to bring back original test case name. - * */ - private String originalTestCaseName(String name) { - return name.replace(spaceReplacement, " "); - } } diff --git a/packages/patrol/example/android/app/build.gradle b/packages/patrol/example/android/app/build.gradle index f5de74ea7..05f6330e5 100644 --- a/packages/patrol/example/android/app/build.gradle +++ b/packages/patrol/example/android/app/build.gradle @@ -82,5 +82,5 @@ flutter { } dependencies { - androidTestUtil 'androidx.test:orchestrator:1.4.2' + androidTestUtil 'androidx.test:orchestrator:1.5.1' } diff --git a/packages/patrol/example/pubspec.yaml b/packages/patrol/example/pubspec.yaml index 45da527da..63a20bb94 100644 --- a/packages/patrol/example/pubspec.yaml +++ b/packages/patrol/example/pubspec.yaml @@ -34,6 +34,8 @@ dev_dependencies: leancode_lint: ^14.2.0 patrol: path: .. + patrol_cli: + path: ../../patrol_cli flutter_launcher_icons: android: 'launcher_icon' diff --git a/packages/patrol/pubspec.yaml b/packages/patrol/pubspec.yaml index 54d482893..ed584f3a0 100644 --- a/packages/patrol/pubspec.yaml +++ b/packages/patrol/pubspec.yaml @@ -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 diff --git a/packages/patrol_cli/CHANGELOG.md b/packages/patrol_cli/CHANGELOG.md index 8072712a5..3fa63465d 100644 --- a/packages/patrol_cli/CHANGELOG.md +++ b/packages/patrol_cli/CHANGELOG.md @@ -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 diff --git a/packages/patrol_cli/lib/src/android/android_test_backend.dart b/packages/patrol_cli/lib/src/android/android_test_backend.dart index 99b0992f7..008732cdc 100644 --- a/packages/patrol_cli/lib/src/android/android_test_backend.dart +++ b/packages/patrol_cli/lib/src/android/android_test_backend.dart @@ -46,6 +46,7 @@ class AndroidTestBackend { Future 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; @@ -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 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. diff --git a/packages/patrol_cli/lib/src/base/constants.dart b/packages/patrol_cli/lib/src/base/constants.dart index d7fcb8c78..173085a39 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 = '3.4.0'; +const version = '3.4.1'; diff --git a/packages/patrol_cli/lib/src/compatibility_checker/compatibility_checker.dart b/packages/patrol_cli/lib/src/compatibility_checker/compatibility_checker.dart index 2f5e47ab4..83c80f152 100644 --- a/packages/patrol_cli/lib/src/compatibility_checker/compatibility_checker.dart +++ b/packages/patrol_cli/lib/src/compatibility_checker/compatibility_checker.dart @@ -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: () { @@ -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'), ), ]; @@ -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'), ), ]; diff --git a/packages/patrol_cli/lib/src/crossplatform/app_options.dart b/packages/patrol_cli/lib/src/crossplatform/app_options.dart index 342ecaac7..d822532c8 100644 --- a/packages/patrol_cli/lib/src/crossplatform/app_options.dart +++ b/packages/patrol_cli/lib/src/crossplatform/app_options.dart @@ -86,6 +86,20 @@ class AndroidAppOptions { ); } + List toGradleAppDependencies({required bool isWindows}) { + final List cmd; + if (isWindows) { + cmd = [r'.\gradlew.bat']; + } else { + cmd = ['./gradlew']; + } + + // Add Gradle task + cmd.add(':app:dependencies'); + + return cmd; + } + String get _buildMode => flutter.buildMode.androidName; String get _effectiveFlavor { diff --git a/packages/patrol_cli/pubspec.yaml b/packages/patrol_cli/pubspec.yaml index 8cfc211e5..4d88bd5b4 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: 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