Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.

[flutter_plugin_tools] Replace xctest and java-test with native-test #4176

Merged
merged 9 commits into from
Jul 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 10 additions & 8 deletions .cirrus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ task:
memory: 12G
matrix:
### Android tasks ###
- name: build-apks+java-test+firebase-test-lab
- name: build-apks+android-unit+firebase-test-lab
env:
matrix:
PLUGIN_SHARDING: "--shardIndex 0 --shardCount 4"
Expand Down Expand Up @@ -160,13 +160,15 @@ task:
- export CIRRUS_CHANGE_MESSAGE=""
- export CIRRUS_COMMIT_MESSAGE=""
- ./script/tool_runner.sh build-examples --apk
java_test_script:
native_unit_test_script:
# Unsetting CIRRUS_CHANGE_MESSAGE and CIRRUS_COMMIT_MESSAGE as they
# might include non-ASCII characters which makes Gradle crash.
# TODO(stuartmorgan): See https://github.com/flutter/flutter/issues/24935
- export CIRRUS_CHANGE_MESSAGE=""
- export CIRRUS_COMMIT_MESSAGE=""
- ./script/tool_runner.sh java-test # must come after apk build
# Native integration tests are handled by firebase-test-lab below, so
# only run unit tests.
- ./script/tool_runner.sh native-test --android --no-integration # must come after apk build
firebase_test_lab_script:
# Unsetting CIRRUS_CHANGE_MESSAGE and CIRRUS_COMMIT_MESSAGE as they
# might include non-ASCII characters which makes Gradle crash.
Expand Down Expand Up @@ -239,12 +241,12 @@ task:
- ./script/tool_runner.sh build-examples --ios
xcode_analyze_script:
- ./script/tool_runner.sh xcode-analyze --ios
xctest_script:
- ./script/tool_runner.sh xctest --ios --ios-destination "platform=iOS Simulator,name=iPhone 11,OS=latest"
native_test_script:
- ./script/tool_runner.sh native-test --ios --ios-destination "platform=iOS Simulator,name=iPhone 11,OS=latest"
drive_script:
# `drive-examples` contains integration tests, which changes the UI of the application.
# This UI change sometimes affects `xctest`.
# So we run `drive-examples` after `xctest`, changing the order will result ci failure.
# So we run `drive-examples` after `native-test`; changing the order will result ci failure.
- ./script/tool_runner.sh drive-examples --ios --exclude $PLUGINS_TO_EXCLUDE_INTEGRATION_TESTS
### macOS desktop tasks ###
- name: build_all_plugins_macos
Expand All @@ -269,7 +271,7 @@ task:
- ./script/tool_runner.sh build-examples --macos
xcode_analyze_script:
- ./script/tool_runner.sh xcode-analyze --macos
xctest_script:
- ./script/tool_runner.sh xctest --macos --exclude $PLUGINS_TO_EXCLUDE_MACOS_XCTESTS
native_test_script:
- ./script/tool_runner.sh native-test --macos --exclude $PLUGINS_TO_EXCLUDE_MACOS_XCTESTS
drive_script:
- ./script/tool_runner.sh drive-examples --macos
10 changes: 9 additions & 1 deletion script/tool/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,21 @@

- Added an `xctest` flag to select specific test targets, to allow running only
unit tests or integration tests.
- Split Xcode analysis out of `xctest` and into a new `xcode-analyze` command.
- **Breaking change**: Split Xcode analysis out of `xctest` and into a new
`xcode-analyze` command.
- Fixed a bug that caused `firebase-test-lab` to hang if it tried to run more
than one plugin's tests in a single run.
- **Breaking change**: If `firebase-test-lab` is run on a package that supports
Android, but for which no tests are run, it now fails instead of skipping.
This matches `drive-examples`, as this command is what is used for driving
Android Flutter integration tests on CI.
- **Breaking change**: Replaced `xctest` with a new `native-test` command that
will eventually be able to run native unit and integration tests for all
platforms.
- Adds the ability to disable test types via `--no-unit` or
`--no-integration`.
- **Breaking change**: Replaced `java-test` with Android unit test support for
the new `native-test` command.

## 0.4.1

Expand Down
24 changes: 19 additions & 5 deletions script/tool/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,14 +75,28 @@ cd <repository root>
dart run ./script/tool/bin/flutter_plugin_tools.dart test --packages plugin_name
```

### Run XCTests
### Run Dart Integration Tests

```sh
cd <repository root>
# For iOS:
dart run ./script/tool/bin/flutter_plugin_tools.dart xctest --ios --packages plugin_name
# For macOS:
dart run ./script/tool/bin/flutter_plugin_tools.dart xctest --macos --packages plugin_name
dart run ./script/tool/bin/flutter_plugin_tools.dart build-examples --packages plugin_name
dart run ./script/tool/bin/flutter_plugin_tools.dart drive-examples --packages plugin_name
```

### Run Native Tests

`native-test` takes one or more platform flags to run tests for. By default it
runs both unit tests and (on platforms that support it) integration tests, but
`--no-unit` or `--no-integration` can be used to run just one type.

Examples:

```sh
cd <repository root>
# Run just unit tests for iOS and Android:
dart run ./script/tool/bin/flutter_plugin_tools.dart native-test --ios --android --no-integration --packages plugin_name
# Run all tests for macOS:
dart run ./script/tool/bin/flutter_plugin_tools.dart native-test --macos --packages plugin_name
```

### Publish a Release
Expand Down
4 changes: 2 additions & 2 deletions script/tool/lib/src/common/package_looping_command.dart
Original file line number Diff line number Diff line change
Expand Up @@ -165,9 +165,9 @@ abstract class PackageLoopingCommand extends PluginCommand {
final List<String> components = p.posix.split(packageName);
// For the common federated plugin pattern of `foo/foo_subpackage`, drop
// the first part since it's not useful.
if (components.length == 2 &&
if (components.length >= 2 &&
components[1].startsWith('${components[0]}_')) {
packageName = components[1];
packageName = p.posix.joinAll(components.sublist(1));
}
return packageName;
}
Expand Down
78 changes: 0 additions & 78 deletions script/tool/lib/src/java_test_command.dart

This file was deleted.

8 changes: 3 additions & 5 deletions script/tool/lib/src/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,16 @@ import 'create_all_plugins_app_command.dart';
import 'drive_examples_command.dart';
import 'firebase_test_lab_command.dart';
import 'format_command.dart';
import 'java_test_command.dart';
import 'license_check_command.dart';
import 'lint_podspecs_command.dart';
import 'list_command.dart';
import 'native_test_command.dart';
import 'publish_check_command.dart';
import 'publish_plugin_command.dart';
import 'pubspec_check_command.dart';
import 'test_command.dart';
import 'version_check_command.dart';
import 'xcode_analyze_command.dart';
import 'xctest_command.dart';

void main(List<String> args) {
const FileSystem fileSystem = LocalFileSystem();
Expand All @@ -51,17 +50,16 @@ void main(List<String> args) {
..addCommand(DriveExamplesCommand(packagesDir))
..addCommand(FirebaseTestLabCommand(packagesDir))
..addCommand(FormatCommand(packagesDir))
..addCommand(JavaTestCommand(packagesDir))
..addCommand(LicenseCheckCommand(packagesDir))
..addCommand(LintPodspecsCommand(packagesDir))
..addCommand(ListCommand(packagesDir))
..addCommand(NativeTestCommand(packagesDir))
..addCommand(PublishCheckCommand(packagesDir))
..addCommand(PublishPluginCommand(packagesDir))
..addCommand(PubspecCheckCommand(packagesDir))
..addCommand(TestCommand(packagesDir))
..addCommand(VersionCheckCommand(packagesDir))
..addCommand(XcodeAnalyzeCommand(packagesDir))
..addCommand(XCTestCommand(packagesDir));
..addCommand(XcodeAnalyzeCommand(packagesDir));

commandRunner.run(args).catchError((Object e) {
final ToolExit toolExit = e as ToolExit;
Expand Down
Loading