Enable macOS XCTest support (#4043)

- Adds macOS support to the `xctest` tool command
- Adds logic to the tool to check for packages that delegate their implementations
  to another package, so they can be skipped when running native unit tests
  - Updates the tool's unit test utility for writing pubspecs to be able to make
    delegated federated implementation references to test it
- Adds initial unit tests to the non-deprecated macOS plugins
- Enables macOS XCTesting in CI

macOS portion of https://github.com/flutter/flutter/issues/82445
This commit is contained in:
stuartmorgan
2021-06-10 14:50:20 -07:00
committed by GitHub
parent b98034dd76
commit cb92e5d416
12 changed files with 956 additions and 549 deletions

View File

@ -11,6 +11,12 @@ import 'package:platform/platform.dart';
import 'common.dart';
/// Key for IPA.
const String kIpa = 'ipa';
/// Key for APK.
const String kApk = 'apk';
/// A command to build the example applications for packages.
class BuildExamplesCommand extends PluginCommand {
/// Creates an instance of the build command.
@ -18,10 +24,10 @@ class BuildExamplesCommand extends PluginCommand {
Directory packagesDir, {
ProcessRunner processRunner = const ProcessRunner(),
}) : super(packagesDir, processRunner: processRunner) {
argParser.addFlag(kLinux, defaultsTo: false);
argParser.addFlag(kMacos, defaultsTo: false);
argParser.addFlag(kWeb, defaultsTo: false);
argParser.addFlag(kWindows, defaultsTo: false);
argParser.addFlag(kPlatformFlagLinux, defaultsTo: false);
argParser.addFlag(kPlatformFlagMacos, defaultsTo: false);
argParser.addFlag(kPlatformFlagWeb, defaultsTo: false);
argParser.addFlag(kPlatformFlagWindows, defaultsTo: false);
argParser.addFlag(kIpa, defaultsTo: io.Platform.isMacOS);
argParser.addFlag(kApk);
argParser.addOption(
@ -44,10 +50,10 @@ class BuildExamplesCommand extends PluginCommand {
final List<String> platformSwitches = <String>[
kApk,
kIpa,
kLinux,
kMacos,
kWeb,
kWindows,
kPlatformFlagLinux,
kPlatformFlagMacos,
kPlatformFlagWeb,
kPlatformFlagWindows,
];
if (!platformSwitches.any((String platform) => getBoolArg(platform))) {
print(
@ -66,14 +72,14 @@ class BuildExamplesCommand extends PluginCommand {
final String packageName =
p.relative(example.path, from: packagesDir.path);
if (getBoolArg(kLinux)) {
if (getBoolArg(kPlatformFlagLinux)) {
print('\nBUILDING Linux for $packageName');
if (isLinuxPlugin(plugin)) {
final int buildExitCode = await processRunner.runAndStream(
flutterCommand,
<String>[
'build',
kLinux,
kPlatformFlagLinux,
if (enableExperiment.isNotEmpty)
'--enable-experiment=$enableExperiment',
],
@ -86,14 +92,14 @@ class BuildExamplesCommand extends PluginCommand {
}
}
if (getBoolArg(kMacos)) {
if (getBoolArg(kPlatformFlagMacos)) {
print('\nBUILDING macOS for $packageName');
if (isMacOsPlugin(plugin)) {
final int exitCode = await processRunner.runAndStream(
flutterCommand,
<String>[
'build',
kMacos,
kPlatformFlagMacos,
if (enableExperiment.isNotEmpty)
'--enable-experiment=$enableExperiment',
],
@ -106,14 +112,14 @@ class BuildExamplesCommand extends PluginCommand {
}
}
if (getBoolArg(kWeb)) {
if (getBoolArg(kPlatformFlagWeb)) {
print('\nBUILDING web for $packageName');
if (isWebPlugin(plugin)) {
final int buildExitCode = await processRunner.runAndStream(
flutterCommand,
<String>[
'build',
kWeb,
kPlatformFlagWeb,
if (enableExperiment.isNotEmpty)
'--enable-experiment=$enableExperiment',
],
@ -126,14 +132,14 @@ class BuildExamplesCommand extends PluginCommand {
}
}
if (getBoolArg(kWindows)) {
if (getBoolArg(kPlatformFlagWindows)) {
print('\nBUILDING Windows for $packageName');
if (isWindowsPlugin(plugin)) {
final int buildExitCode = await processRunner.runAndStream(
flutterCommand,
<String>[
'build',
kWindows,
kPlatformFlagWindows,
if (enableExperiment.isNotEmpty)
'--enable-experiment=$enableExperiment',
],