mirror of
https://github.com/flutter/packages.git
synced 2025-06-19 22:03:33 +08:00
[flutter_plugin_tool] Refactor createFakePlugin (#4064)
This commit is contained in:
@ -27,10 +27,10 @@ class BuildExamplesCommand extends PluginCommand {
|
|||||||
Directory packagesDir, {
|
Directory packagesDir, {
|
||||||
ProcessRunner processRunner = const ProcessRunner(),
|
ProcessRunner processRunner = const ProcessRunner(),
|
||||||
}) : super(packagesDir, processRunner: processRunner) {
|
}) : super(packagesDir, processRunner: processRunner) {
|
||||||
argParser.addFlag(kPlatformFlagLinux, defaultsTo: false);
|
argParser.addFlag(kPlatformLinux, defaultsTo: false);
|
||||||
argParser.addFlag(kPlatformFlagMacos, defaultsTo: false);
|
argParser.addFlag(kPlatformMacos, defaultsTo: false);
|
||||||
argParser.addFlag(kPlatformFlagWeb, defaultsTo: false);
|
argParser.addFlag(kPlatformWeb, defaultsTo: false);
|
||||||
argParser.addFlag(kPlatformFlagWindows, defaultsTo: false);
|
argParser.addFlag(kPlatformWindows, defaultsTo: false);
|
||||||
argParser.addFlag(kIpa, defaultsTo: io.Platform.isMacOS);
|
argParser.addFlag(kIpa, defaultsTo: io.Platform.isMacOS);
|
||||||
argParser.addFlag(kApk);
|
argParser.addFlag(kApk);
|
||||||
argParser.addOption(
|
argParser.addOption(
|
||||||
@ -53,10 +53,10 @@ class BuildExamplesCommand extends PluginCommand {
|
|||||||
final List<String> platformSwitches = <String>[
|
final List<String> platformSwitches = <String>[
|
||||||
kApk,
|
kApk,
|
||||||
kIpa,
|
kIpa,
|
||||||
kPlatformFlagLinux,
|
kPlatformLinux,
|
||||||
kPlatformFlagMacos,
|
kPlatformMacos,
|
||||||
kPlatformFlagWeb,
|
kPlatformWeb,
|
||||||
kPlatformFlagWindows,
|
kPlatformWindows,
|
||||||
];
|
];
|
||||||
if (!platformSwitches.any((String platform) => getBoolArg(platform))) {
|
if (!platformSwitches.any((String platform) => getBoolArg(platform))) {
|
||||||
print(
|
print(
|
||||||
@ -75,14 +75,14 @@ class BuildExamplesCommand extends PluginCommand {
|
|||||||
final String packageName =
|
final String packageName =
|
||||||
p.relative(example.path, from: packagesDir.path);
|
p.relative(example.path, from: packagesDir.path);
|
||||||
|
|
||||||
if (getBoolArg(kPlatformFlagLinux)) {
|
if (getBoolArg(kPlatformLinux)) {
|
||||||
print('\nBUILDING Linux for $packageName');
|
print('\nBUILDING Linux for $packageName');
|
||||||
if (isLinuxPlugin(plugin)) {
|
if (isLinuxPlugin(plugin)) {
|
||||||
final int buildExitCode = await processRunner.runAndStream(
|
final int buildExitCode = await processRunner.runAndStream(
|
||||||
flutterCommand,
|
flutterCommand,
|
||||||
<String>[
|
<String>[
|
||||||
'build',
|
'build',
|
||||||
kPlatformFlagLinux,
|
kPlatformLinux,
|
||||||
if (enableExperiment.isNotEmpty)
|
if (enableExperiment.isNotEmpty)
|
||||||
'--enable-experiment=$enableExperiment',
|
'--enable-experiment=$enableExperiment',
|
||||||
],
|
],
|
||||||
@ -95,14 +95,14 @@ class BuildExamplesCommand extends PluginCommand {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getBoolArg(kPlatformFlagMacos)) {
|
if (getBoolArg(kPlatformMacos)) {
|
||||||
print('\nBUILDING macOS for $packageName');
|
print('\nBUILDING macOS for $packageName');
|
||||||
if (isMacOsPlugin(plugin)) {
|
if (isMacOsPlugin(plugin)) {
|
||||||
final int exitCode = await processRunner.runAndStream(
|
final int exitCode = await processRunner.runAndStream(
|
||||||
flutterCommand,
|
flutterCommand,
|
||||||
<String>[
|
<String>[
|
||||||
'build',
|
'build',
|
||||||
kPlatformFlagMacos,
|
kPlatformMacos,
|
||||||
if (enableExperiment.isNotEmpty)
|
if (enableExperiment.isNotEmpty)
|
||||||
'--enable-experiment=$enableExperiment',
|
'--enable-experiment=$enableExperiment',
|
||||||
],
|
],
|
||||||
@ -115,14 +115,14 @@ class BuildExamplesCommand extends PluginCommand {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getBoolArg(kPlatformFlagWeb)) {
|
if (getBoolArg(kPlatformWeb)) {
|
||||||
print('\nBUILDING web for $packageName');
|
print('\nBUILDING web for $packageName');
|
||||||
if (isWebPlugin(plugin)) {
|
if (isWebPlugin(plugin)) {
|
||||||
final int buildExitCode = await processRunner.runAndStream(
|
final int buildExitCode = await processRunner.runAndStream(
|
||||||
flutterCommand,
|
flutterCommand,
|
||||||
<String>[
|
<String>[
|
||||||
'build',
|
'build',
|
||||||
kPlatformFlagWeb,
|
kPlatformWeb,
|
||||||
if (enableExperiment.isNotEmpty)
|
if (enableExperiment.isNotEmpty)
|
||||||
'--enable-experiment=$enableExperiment',
|
'--enable-experiment=$enableExperiment',
|
||||||
],
|
],
|
||||||
@ -135,14 +135,14 @@ class BuildExamplesCommand extends PluginCommand {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getBoolArg(kPlatformFlagWindows)) {
|
if (getBoolArg(kPlatformWindows)) {
|
||||||
print('\nBUILDING Windows for $packageName');
|
print('\nBUILDING Windows for $packageName');
|
||||||
if (isWindowsPlugin(plugin)) {
|
if (isWindowsPlugin(plugin)) {
|
||||||
final int buildExitCode = await processRunner.runAndStream(
|
final int buildExitCode = await processRunner.runAndStream(
|
||||||
flutterCommand,
|
flutterCommand,
|
||||||
<String>[
|
<String>[
|
||||||
'build',
|
'build',
|
||||||
kPlatformFlagWindows,
|
kPlatformWindows,
|
||||||
if (enableExperiment.isNotEmpty)
|
if (enableExperiment.isNotEmpty)
|
||||||
'--enable-experiment=$enableExperiment',
|
'--enable-experiment=$enableExperiment',
|
||||||
],
|
],
|
||||||
|
@ -11,22 +11,22 @@ import 'package:yaml/yaml.dart';
|
|||||||
typedef Print = void Function(Object? object);
|
typedef Print = void Function(Object? object);
|
||||||
|
|
||||||
/// Key for windows platform.
|
/// Key for windows platform.
|
||||||
const String kPlatformFlagWindows = 'windows';
|
const String kPlatformWindows = 'windows';
|
||||||
|
|
||||||
/// Key for macos platform.
|
/// Key for macos platform.
|
||||||
const String kPlatformFlagMacos = 'macos';
|
const String kPlatformMacos = 'macos';
|
||||||
|
|
||||||
/// Key for linux platform.
|
/// Key for linux platform.
|
||||||
const String kPlatformFlagLinux = 'linux';
|
const String kPlatformLinux = 'linux';
|
||||||
|
|
||||||
/// Key for IPA (iOS) platform.
|
/// Key for IPA (iOS) platform.
|
||||||
const String kPlatformFlagIos = 'ios';
|
const String kPlatformIos = 'ios';
|
||||||
|
|
||||||
/// Key for APK (Android) platform.
|
/// Key for APK (Android) platform.
|
||||||
const String kPlatformFlagAndroid = 'android';
|
const String kPlatformAndroid = 'android';
|
||||||
|
|
||||||
/// Key for Web platform.
|
/// Key for Web platform.
|
||||||
const String kPlatformFlagWeb = 'web';
|
const String kPlatformWeb = 'web';
|
||||||
|
|
||||||
/// Key for enable experiment.
|
/// Key for enable experiment.
|
||||||
const String kEnableExperiment = 'enable-experiment';
|
const String kEnableExperiment = 'enable-experiment';
|
||||||
|
@ -29,12 +29,12 @@ enum PlatformSupport {
|
|||||||
/// implementation in order to return true.
|
/// implementation in order to return true.
|
||||||
bool pluginSupportsPlatform(String platform, FileSystemEntity entity,
|
bool pluginSupportsPlatform(String platform, FileSystemEntity entity,
|
||||||
{PlatformSupport? requiredMode}) {
|
{PlatformSupport? requiredMode}) {
|
||||||
assert(platform == kPlatformFlagIos ||
|
assert(platform == kPlatformIos ||
|
||||||
platform == kPlatformFlagAndroid ||
|
platform == kPlatformAndroid ||
|
||||||
platform == kPlatformFlagWeb ||
|
platform == kPlatformWeb ||
|
||||||
platform == kPlatformFlagMacos ||
|
platform == kPlatformMacos ||
|
||||||
platform == kPlatformFlagWindows ||
|
platform == kPlatformWindows ||
|
||||||
platform == kPlatformFlagLinux);
|
platform == kPlatformLinux);
|
||||||
if (entity is! Directory) {
|
if (entity is! Directory) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -59,7 +59,7 @@ bool pluginSupportsPlatform(String platform, FileSystemEntity entity,
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!pluginSection.containsKey('platforms')) {
|
if (!pluginSection.containsKey('platforms')) {
|
||||||
return platform == kPlatformFlagIos || platform == kPlatformFlagAndroid;
|
return platform == kPlatformIos || platform == kPlatformAndroid;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -81,30 +81,30 @@ bool pluginSupportsPlatform(String platform, FileSystemEntity entity,
|
|||||||
|
|
||||||
/// Returns whether the given directory contains a Flutter Android plugin.
|
/// Returns whether the given directory contains a Flutter Android plugin.
|
||||||
bool isAndroidPlugin(FileSystemEntity entity) {
|
bool isAndroidPlugin(FileSystemEntity entity) {
|
||||||
return pluginSupportsPlatform(kPlatformFlagAndroid, entity);
|
return pluginSupportsPlatform(kPlatformAndroid, entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns whether the given directory contains a Flutter iOS plugin.
|
/// Returns whether the given directory contains a Flutter iOS plugin.
|
||||||
bool isIosPlugin(FileSystemEntity entity) {
|
bool isIosPlugin(FileSystemEntity entity) {
|
||||||
return pluginSupportsPlatform(kPlatformFlagIos, entity);
|
return pluginSupportsPlatform(kPlatformIos, entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns whether the given directory contains a Flutter web plugin.
|
/// Returns whether the given directory contains a Flutter web plugin.
|
||||||
bool isWebPlugin(FileSystemEntity entity) {
|
bool isWebPlugin(FileSystemEntity entity) {
|
||||||
return pluginSupportsPlatform(kPlatformFlagWeb, entity);
|
return pluginSupportsPlatform(kPlatformWeb, entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns whether the given directory contains a Flutter Windows plugin.
|
/// Returns whether the given directory contains a Flutter Windows plugin.
|
||||||
bool isWindowsPlugin(FileSystemEntity entity) {
|
bool isWindowsPlugin(FileSystemEntity entity) {
|
||||||
return pluginSupportsPlatform(kPlatformFlagWindows, entity);
|
return pluginSupportsPlatform(kPlatformWindows, entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns whether the given directory contains a Flutter macOS plugin.
|
/// Returns whether the given directory contains a Flutter macOS plugin.
|
||||||
bool isMacOsPlugin(FileSystemEntity entity) {
|
bool isMacOsPlugin(FileSystemEntity entity) {
|
||||||
return pluginSupportsPlatform(kPlatformFlagMacos, entity);
|
return pluginSupportsPlatform(kPlatformMacos, entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns whether the given directory contains a Flutter linux plugin.
|
/// Returns whether the given directory contains a Flutter linux plugin.
|
||||||
bool isLinuxPlugin(FileSystemEntity entity) {
|
bool isLinuxPlugin(FileSystemEntity entity) {
|
||||||
return pluginSupportsPlatform(kPlatformFlagLinux, entity);
|
return pluginSupportsPlatform(kPlatformLinux, entity);
|
||||||
}
|
}
|
||||||
|
@ -18,17 +18,17 @@ class DriveExamplesCommand extends PluginCommand {
|
|||||||
Directory packagesDir, {
|
Directory packagesDir, {
|
||||||
ProcessRunner processRunner = const ProcessRunner(),
|
ProcessRunner processRunner = const ProcessRunner(),
|
||||||
}) : super(packagesDir, processRunner: processRunner) {
|
}) : super(packagesDir, processRunner: processRunner) {
|
||||||
argParser.addFlag(kPlatformFlagAndroid,
|
argParser.addFlag(kPlatformAndroid,
|
||||||
help: 'Runs the Android implementation of the examples');
|
help: 'Runs the Android implementation of the examples');
|
||||||
argParser.addFlag(kPlatformFlagIos,
|
argParser.addFlag(kPlatformIos,
|
||||||
help: 'Runs the iOS implementation of the examples');
|
help: 'Runs the iOS implementation of the examples');
|
||||||
argParser.addFlag(kPlatformFlagLinux,
|
argParser.addFlag(kPlatformLinux,
|
||||||
help: 'Runs the Linux implementation of the examples');
|
help: 'Runs the Linux implementation of the examples');
|
||||||
argParser.addFlag(kPlatformFlagMacos,
|
argParser.addFlag(kPlatformMacos,
|
||||||
help: 'Runs the macOS implementation of the examples');
|
help: 'Runs the macOS implementation of the examples');
|
||||||
argParser.addFlag(kPlatformFlagWeb,
|
argParser.addFlag(kPlatformWeb,
|
||||||
help: 'Runs the web implementation of the examples');
|
help: 'Runs the web implementation of the examples');
|
||||||
argParser.addFlag(kPlatformFlagWindows,
|
argParser.addFlag(kPlatformWindows,
|
||||||
help: 'Runs the Windows implementation of the examples');
|
help: 'Runs the Windows implementation of the examples');
|
||||||
argParser.addOption(
|
argParser.addOption(
|
||||||
kEnableExperiment,
|
kEnableExperiment,
|
||||||
@ -55,10 +55,10 @@ class DriveExamplesCommand extends PluginCommand {
|
|||||||
Future<void> run() async {
|
Future<void> run() async {
|
||||||
final List<String> failingTests = <String>[];
|
final List<String> failingTests = <String>[];
|
||||||
final List<String> pluginsWithoutTests = <String>[];
|
final List<String> pluginsWithoutTests = <String>[];
|
||||||
final bool isLinux = getBoolArg(kPlatformFlagLinux);
|
final bool isLinux = getBoolArg(kPlatformLinux);
|
||||||
final bool isMacos = getBoolArg(kPlatformFlagMacos);
|
final bool isMacos = getBoolArg(kPlatformMacos);
|
||||||
final bool isWeb = getBoolArg(kPlatformFlagWeb);
|
final bool isWeb = getBoolArg(kPlatformWeb);
|
||||||
final bool isWindows = getBoolArg(kPlatformFlagWindows);
|
final bool isWindows = getBoolArg(kPlatformWindows);
|
||||||
await for (final Directory plugin in getPlugins()) {
|
await for (final Directory plugin in getPlugins()) {
|
||||||
final String pluginName = plugin.basename;
|
final String pluginName = plugin.basename;
|
||||||
if (pluginName.endsWith('_platform_interface') &&
|
if (pluginName.endsWith('_platform_interface') &&
|
||||||
@ -222,12 +222,12 @@ Tried searching for the following:
|
|||||||
|
|
||||||
Future<bool> _pluginSupportedOnCurrentPlatform(
|
Future<bool> _pluginSupportedOnCurrentPlatform(
|
||||||
FileSystemEntity plugin) async {
|
FileSystemEntity plugin) async {
|
||||||
final bool isAndroid = getBoolArg(kPlatformFlagAndroid);
|
final bool isAndroid = getBoolArg(kPlatformAndroid);
|
||||||
final bool isIOS = getBoolArg(kPlatformFlagIos);
|
final bool isIOS = getBoolArg(kPlatformIos);
|
||||||
final bool isLinux = getBoolArg(kPlatformFlagLinux);
|
final bool isLinux = getBoolArg(kPlatformLinux);
|
||||||
final bool isMacos = getBoolArg(kPlatformFlagMacos);
|
final bool isMacos = getBoolArg(kPlatformMacos);
|
||||||
final bool isWeb = getBoolArg(kPlatformFlagWeb);
|
final bool isWeb = getBoolArg(kPlatformWeb);
|
||||||
final bool isWindows = getBoolArg(kPlatformFlagWindows);
|
final bool isWindows = getBoolArg(kPlatformWindows);
|
||||||
if (isAndroid) {
|
if (isAndroid) {
|
||||||
return isAndroidPlugin(plugin);
|
return isAndroidPlugin(plugin);
|
||||||
}
|
}
|
||||||
|
@ -37,8 +37,8 @@ class XCTestCommand extends PluginCommand {
|
|||||||
'this is passed to the `-destination` argument in xcodebuild command.\n'
|
'this is passed to the `-destination` argument in xcodebuild command.\n'
|
||||||
'See https://developer.apple.com/library/archive/technotes/tn2339/_index.html#//apple_ref/doc/uid/DTS40014588-CH1-UNIT for details on how to specify the destination.',
|
'See https://developer.apple.com/library/archive/technotes/tn2339/_index.html#//apple_ref/doc/uid/DTS40014588-CH1-UNIT for details on how to specify the destination.',
|
||||||
);
|
);
|
||||||
argParser.addFlag(kPlatformFlagIos, help: 'Runs the iOS tests');
|
argParser.addFlag(kPlatformIos, help: 'Runs the iOS tests');
|
||||||
argParser.addFlag(kPlatformFlagMacos, help: 'Runs the macOS tests');
|
argParser.addFlag(kPlatformMacos, help: 'Runs the macOS tests');
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -51,8 +51,8 @@ class XCTestCommand extends PluginCommand {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Future<void> run() async {
|
Future<void> run() async {
|
||||||
final bool testIos = getBoolArg(kPlatformFlagIos);
|
final bool testIos = getBoolArg(kPlatformIos);
|
||||||
final bool testMacos = getBoolArg(kPlatformFlagMacos);
|
final bool testMacos = getBoolArg(kPlatformMacos);
|
||||||
|
|
||||||
if (!(testIos || testMacos)) {
|
if (!(testIos || testMacos)) {
|
||||||
print('At least one platform flag must be provided.');
|
print('At least one platform flag must be provided.');
|
||||||
|
@ -53,8 +53,7 @@ void main() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('skips flutter pub get for examples', () async {
|
test('skips flutter pub get for examples', () async {
|
||||||
final Directory plugin1Dir =
|
final Directory plugin1Dir = createFakePlugin('a', packagesDir);
|
||||||
createFakePlugin('a', packagesDir, withSingleExample: true);
|
|
||||||
|
|
||||||
final MockProcess mockProcess = MockProcess();
|
final MockProcess mockProcess = MockProcess();
|
||||||
mockProcess.exitCodeCompleter.complete(0);
|
mockProcess.exitCodeCompleter.complete(0);
|
||||||
@ -121,7 +120,7 @@ void main() {
|
|||||||
|
|
||||||
group('verifies analysis settings', () {
|
group('verifies analysis settings', () {
|
||||||
test('fails analysis_options.yaml', () async {
|
test('fails analysis_options.yaml', () async {
|
||||||
createFakePlugin('foo', packagesDir, withExtraFiles: <List<String>>[
|
createFakePlugin('foo', packagesDir, extraFiles: <List<String>>[
|
||||||
<String>['analysis_options.yaml']
|
<String>['analysis_options.yaml']
|
||||||
]);
|
]);
|
||||||
|
|
||||||
@ -130,7 +129,7 @@ void main() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('fails .analysis_options', () async {
|
test('fails .analysis_options', () async {
|
||||||
createFakePlugin('foo', packagesDir, withExtraFiles: <List<String>>[
|
createFakePlugin('foo', packagesDir, extraFiles: <List<String>>[
|
||||||
<String>['.analysis_options']
|
<String>['.analysis_options']
|
||||||
]);
|
]);
|
||||||
|
|
||||||
@ -140,7 +139,7 @@ void main() {
|
|||||||
|
|
||||||
test('takes an allow list', () async {
|
test('takes an allow list', () async {
|
||||||
final Directory pluginDir =
|
final Directory pluginDir =
|
||||||
createFakePlugin('foo', packagesDir, withExtraFiles: <List<String>>[
|
createFakePlugin('foo', packagesDir, extraFiles: <List<String>>[
|
||||||
<String>['analysis_options.yaml']
|
<String>['analysis_options.yaml']
|
||||||
]);
|
]);
|
||||||
|
|
||||||
@ -161,7 +160,7 @@ void main() {
|
|||||||
|
|
||||||
// See: https://github.com/flutter/flutter/issues/78994
|
// See: https://github.com/flutter/flutter/issues/78994
|
||||||
test('takes an empty allow list', () async {
|
test('takes an empty allow list', () async {
|
||||||
createFakePlugin('foo', packagesDir, withExtraFiles: <List<String>>[
|
createFakePlugin('foo', packagesDir, extraFiles: <List<String>>[
|
||||||
<String>['analysis_options.yaml']
|
<String>['analysis_options.yaml']
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
@ -6,6 +6,8 @@ import 'package:args/command_runner.dart';
|
|||||||
import 'package:file/file.dart';
|
import 'package:file/file.dart';
|
||||||
import 'package:file/memory.dart';
|
import 'package:file/memory.dart';
|
||||||
import 'package:flutter_plugin_tools/src/build_examples_command.dart';
|
import 'package:flutter_plugin_tools/src/build_examples_command.dart';
|
||||||
|
import 'package:flutter_plugin_tools/src/common/core.dart';
|
||||||
|
import 'package:flutter_plugin_tools/src/common/plugin_utils.dart';
|
||||||
import 'package:path/path.dart' as p;
|
import 'package:path/path.dart' as p;
|
||||||
import 'package:platform/platform.dart';
|
import 'package:platform/platform.dart';
|
||||||
import 'package:test/test.dart';
|
import 'package:test/test.dart';
|
||||||
@ -35,17 +37,14 @@ void main() {
|
|||||||
|
|
||||||
test('building for iOS when plugin is not set up for iOS results in no-op',
|
test('building for iOS when plugin is not set up for iOS results in no-op',
|
||||||
() async {
|
() async {
|
||||||
final Directory pluginDirectory = createFakePlugin('plugin', packagesDir,
|
final Directory pluginDirectory =
|
||||||
withExtraFiles: <List<String>>[
|
createFakePlugin('plugin', packagesDir, extraFiles: <List<String>>[
|
||||||
<String>['example', 'test'],
|
<String>['example', 'test'],
|
||||||
],
|
]);
|
||||||
isLinuxPlugin: false);
|
|
||||||
|
|
||||||
final Directory pluginExampleDirectory =
|
final Directory pluginExampleDirectory =
|
||||||
pluginDirectory.childDirectory('example');
|
pluginDirectory.childDirectory('example');
|
||||||
|
|
||||||
createFakePubspec(pluginExampleDirectory, isFlutter: true);
|
|
||||||
|
|
||||||
final List<String> output = await runCapturingPrint(
|
final List<String> output = await runCapturingPrint(
|
||||||
runner, <String>['build-examples', '--ipa', '--no-macos']);
|
runner, <String>['build-examples', '--ipa', '--no-macos']);
|
||||||
final String packageName =
|
final String packageName =
|
||||||
@ -67,17 +66,16 @@ void main() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('building for ios', () async {
|
test('building for ios', () async {
|
||||||
final Directory pluginDirectory = createFakePlugin('plugin', packagesDir,
|
final Directory pluginDirectory =
|
||||||
withExtraFiles: <List<String>>[
|
createFakePlugin('plugin', packagesDir, extraFiles: <List<String>>[
|
||||||
<String>['example', 'test'],
|
<String>['example', 'test'],
|
||||||
],
|
], platformSupport: <String, PlatformSupport>{
|
||||||
isIosPlugin: true);
|
kPlatformIos: PlatformSupport.inline
|
||||||
|
});
|
||||||
|
|
||||||
final Directory pluginExampleDirectory =
|
final Directory pluginExampleDirectory =
|
||||||
pluginDirectory.childDirectory('example');
|
pluginDirectory.childDirectory('example');
|
||||||
|
|
||||||
createFakePubspec(pluginExampleDirectory, isFlutter: true);
|
|
||||||
|
|
||||||
final List<String> output = await runCapturingPrint(runner, <String>[
|
final List<String> output = await runCapturingPrint(runner, <String>[
|
||||||
'build-examples',
|
'build-examples',
|
||||||
'--ipa',
|
'--ipa',
|
||||||
@ -114,17 +112,14 @@ void main() {
|
|||||||
test(
|
test(
|
||||||
'building for Linux when plugin is not set up for Linux results in no-op',
|
'building for Linux when plugin is not set up for Linux results in no-op',
|
||||||
() async {
|
() async {
|
||||||
final Directory pluginDirectory = createFakePlugin('plugin', packagesDir,
|
final Directory pluginDirectory =
|
||||||
withExtraFiles: <List<String>>[
|
createFakePlugin('plugin', packagesDir, extraFiles: <List<String>>[
|
||||||
<String>['example', 'test'],
|
<String>['example', 'test'],
|
||||||
],
|
]);
|
||||||
isLinuxPlugin: false);
|
|
||||||
|
|
||||||
final Directory pluginExampleDirectory =
|
final Directory pluginExampleDirectory =
|
||||||
pluginDirectory.childDirectory('example');
|
pluginDirectory.childDirectory('example');
|
||||||
|
|
||||||
createFakePubspec(pluginExampleDirectory, isFlutter: true);
|
|
||||||
|
|
||||||
final List<String> output = await runCapturingPrint(
|
final List<String> output = await runCapturingPrint(
|
||||||
runner, <String>['build-examples', '--no-ipa', '--linux']);
|
runner, <String>['build-examples', '--no-ipa', '--linux']);
|
||||||
final String packageName =
|
final String packageName =
|
||||||
@ -146,17 +141,16 @@ void main() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('building for Linux', () async {
|
test('building for Linux', () async {
|
||||||
final Directory pluginDirectory = createFakePlugin('plugin', packagesDir,
|
final Directory pluginDirectory =
|
||||||
withExtraFiles: <List<String>>[
|
createFakePlugin('plugin', packagesDir, extraFiles: <List<String>>[
|
||||||
<String>['example', 'test'],
|
<String>['example', 'test'],
|
||||||
],
|
], platformSupport: <String, PlatformSupport>{
|
||||||
isLinuxPlugin: true);
|
kPlatformLinux: PlatformSupport.inline,
|
||||||
|
});
|
||||||
|
|
||||||
final Directory pluginExampleDirectory =
|
final Directory pluginExampleDirectory =
|
||||||
pluginDirectory.childDirectory('example');
|
pluginDirectory.childDirectory('example');
|
||||||
|
|
||||||
createFakePubspec(pluginExampleDirectory, isFlutter: true);
|
|
||||||
|
|
||||||
final List<String> output = await runCapturingPrint(
|
final List<String> output = await runCapturingPrint(
|
||||||
runner, <String>['build-examples', '--no-ipa', '--linux']);
|
runner, <String>['build-examples', '--no-ipa', '--linux']);
|
||||||
final String packageName =
|
final String packageName =
|
||||||
@ -181,16 +175,14 @@ void main() {
|
|||||||
|
|
||||||
test('building for macos with no implementation results in no-op',
|
test('building for macos with no implementation results in no-op',
|
||||||
() async {
|
() async {
|
||||||
final Directory pluginDirectory = createFakePlugin('plugin', packagesDir,
|
final Directory pluginDirectory =
|
||||||
withExtraFiles: <List<String>>[
|
createFakePlugin('plugin', packagesDir, extraFiles: <List<String>>[
|
||||||
<String>['example', 'test'],
|
<String>['example', 'test'],
|
||||||
]);
|
]);
|
||||||
|
|
||||||
final Directory pluginExampleDirectory =
|
final Directory pluginExampleDirectory =
|
||||||
pluginDirectory.childDirectory('example');
|
pluginDirectory.childDirectory('example');
|
||||||
|
|
||||||
createFakePubspec(pluginExampleDirectory, isFlutter: true);
|
|
||||||
|
|
||||||
final List<String> output = await runCapturingPrint(
|
final List<String> output = await runCapturingPrint(
|
||||||
runner, <String>['build-examples', '--no-ipa', '--macos']);
|
runner, <String>['build-examples', '--no-ipa', '--macos']);
|
||||||
final String packageName =
|
final String packageName =
|
||||||
@ -212,18 +204,17 @@ void main() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('building for macos', () async {
|
test('building for macos', () async {
|
||||||
final Directory pluginDirectory = createFakePlugin('plugin', packagesDir,
|
final Directory pluginDirectory =
|
||||||
withExtraFiles: <List<String>>[
|
createFakePlugin('plugin', packagesDir, extraFiles: <List<String>>[
|
||||||
<String>['example', 'test'],
|
<String>['example', 'test'],
|
||||||
<String>['example', 'macos', 'macos.swift'],
|
<String>['example', 'macos', 'macos.swift'],
|
||||||
],
|
], platformSupport: <String, PlatformSupport>{
|
||||||
isMacOsPlugin: true);
|
kPlatformMacos: PlatformSupport.inline,
|
||||||
|
});
|
||||||
|
|
||||||
final Directory pluginExampleDirectory =
|
final Directory pluginExampleDirectory =
|
||||||
pluginDirectory.childDirectory('example');
|
pluginDirectory.childDirectory('example');
|
||||||
|
|
||||||
createFakePubspec(pluginExampleDirectory, isFlutter: true);
|
|
||||||
|
|
||||||
final List<String> output = await runCapturingPrint(
|
final List<String> output = await runCapturingPrint(
|
||||||
runner, <String>['build-examples', '--no-ipa', '--macos']);
|
runner, <String>['build-examples', '--no-ipa', '--macos']);
|
||||||
final String packageName =
|
final String packageName =
|
||||||
@ -247,16 +238,14 @@ void main() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('building for web with no implementation results in no-op', () async {
|
test('building for web with no implementation results in no-op', () async {
|
||||||
final Directory pluginDirectory = createFakePlugin('plugin', packagesDir,
|
final Directory pluginDirectory =
|
||||||
withExtraFiles: <List<String>>[
|
createFakePlugin('plugin', packagesDir, extraFiles: <List<String>>[
|
||||||
<String>['example', 'test'],
|
<String>['example', 'test'],
|
||||||
]);
|
]);
|
||||||
|
|
||||||
final Directory pluginExampleDirectory =
|
final Directory pluginExampleDirectory =
|
||||||
pluginDirectory.childDirectory('example');
|
pluginDirectory.childDirectory('example');
|
||||||
|
|
||||||
createFakePubspec(pluginExampleDirectory, isFlutter: true);
|
|
||||||
|
|
||||||
final List<String> output = await runCapturingPrint(
|
final List<String> output = await runCapturingPrint(
|
||||||
runner, <String>['build-examples', '--no-ipa', '--web']);
|
runner, <String>['build-examples', '--no-ipa', '--web']);
|
||||||
final String packageName =
|
final String packageName =
|
||||||
@ -278,18 +267,17 @@ void main() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('building for web', () async {
|
test('building for web', () async {
|
||||||
final Directory pluginDirectory = createFakePlugin('plugin', packagesDir,
|
final Directory pluginDirectory =
|
||||||
withExtraFiles: <List<String>>[
|
createFakePlugin('plugin', packagesDir, extraFiles: <List<String>>[
|
||||||
<String>['example', 'test'],
|
<String>['example', 'test'],
|
||||||
<String>['example', 'web', 'index.html'],
|
<String>['example', 'web', 'index.html'],
|
||||||
],
|
], platformSupport: <String, PlatformSupport>{
|
||||||
isWebPlugin: true);
|
kPlatformWeb: PlatformSupport.inline,
|
||||||
|
});
|
||||||
|
|
||||||
final Directory pluginExampleDirectory =
|
final Directory pluginExampleDirectory =
|
||||||
pluginDirectory.childDirectory('example');
|
pluginDirectory.childDirectory('example');
|
||||||
|
|
||||||
createFakePubspec(pluginExampleDirectory, isFlutter: true);
|
|
||||||
|
|
||||||
final List<String> output = await runCapturingPrint(
|
final List<String> output = await runCapturingPrint(
|
||||||
runner, <String>['build-examples', '--no-ipa', '--web']);
|
runner, <String>['build-examples', '--no-ipa', '--web']);
|
||||||
final String packageName =
|
final String packageName =
|
||||||
@ -315,17 +303,14 @@ void main() {
|
|||||||
test(
|
test(
|
||||||
'building for Windows when plugin is not set up for Windows results in no-op',
|
'building for Windows when plugin is not set up for Windows results in no-op',
|
||||||
() async {
|
() async {
|
||||||
final Directory pluginDirectory = createFakePlugin('plugin', packagesDir,
|
final Directory pluginDirectory =
|
||||||
withExtraFiles: <List<String>>[
|
createFakePlugin('plugin', packagesDir, extraFiles: <List<String>>[
|
||||||
<String>['example', 'test'],
|
<String>['example', 'test'],
|
||||||
],
|
]);
|
||||||
isWindowsPlugin: false);
|
|
||||||
|
|
||||||
final Directory pluginExampleDirectory =
|
final Directory pluginExampleDirectory =
|
||||||
pluginDirectory.childDirectory('example');
|
pluginDirectory.childDirectory('example');
|
||||||
|
|
||||||
createFakePubspec(pluginExampleDirectory, isFlutter: true);
|
|
||||||
|
|
||||||
final List<String> output = await runCapturingPrint(
|
final List<String> output = await runCapturingPrint(
|
||||||
runner, <String>['build-examples', '--no-ipa', '--windows']);
|
runner, <String>['build-examples', '--no-ipa', '--windows']);
|
||||||
final String packageName =
|
final String packageName =
|
||||||
@ -347,17 +332,16 @@ void main() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('building for windows', () async {
|
test('building for windows', () async {
|
||||||
final Directory pluginDirectory = createFakePlugin('plugin', packagesDir,
|
final Directory pluginDirectory =
|
||||||
withExtraFiles: <List<String>>[
|
createFakePlugin('plugin', packagesDir, extraFiles: <List<String>>[
|
||||||
<String>['example', 'test'],
|
<String>['example', 'test'],
|
||||||
],
|
], platformSupport: <String, PlatformSupport>{
|
||||||
isWindowsPlugin: true);
|
kPlatformWindows: PlatformSupport.inline
|
||||||
|
});
|
||||||
|
|
||||||
final Directory pluginExampleDirectory =
|
final Directory pluginExampleDirectory =
|
||||||
pluginDirectory.childDirectory('example');
|
pluginDirectory.childDirectory('example');
|
||||||
|
|
||||||
createFakePubspec(pluginExampleDirectory, isFlutter: true);
|
|
||||||
|
|
||||||
final List<String> output = await runCapturingPrint(
|
final List<String> output = await runCapturingPrint(
|
||||||
runner, <String>['build-examples', '--no-ipa', '--windows']);
|
runner, <String>['build-examples', '--no-ipa', '--windows']);
|
||||||
final String packageName =
|
final String packageName =
|
||||||
@ -383,17 +367,14 @@ void main() {
|
|||||||
test(
|
test(
|
||||||
'building for Android when plugin is not set up for Android results in no-op',
|
'building for Android when plugin is not set up for Android results in no-op',
|
||||||
() async {
|
() async {
|
||||||
final Directory pluginDirectory = createFakePlugin('plugin', packagesDir,
|
final Directory pluginDirectory =
|
||||||
withExtraFiles: <List<String>>[
|
createFakePlugin('plugin', packagesDir, extraFiles: <List<String>>[
|
||||||
<String>['example', 'test'],
|
<String>['example', 'test'],
|
||||||
],
|
]);
|
||||||
isLinuxPlugin: false);
|
|
||||||
|
|
||||||
final Directory pluginExampleDirectory =
|
final Directory pluginExampleDirectory =
|
||||||
pluginDirectory.childDirectory('example');
|
pluginDirectory.childDirectory('example');
|
||||||
|
|
||||||
createFakePubspec(pluginExampleDirectory, isFlutter: true);
|
|
||||||
|
|
||||||
final List<String> output = await runCapturingPrint(
|
final List<String> output = await runCapturingPrint(
|
||||||
runner, <String>['build-examples', '--apk', '--no-ipa']);
|
runner, <String>['build-examples', '--apk', '--no-ipa']);
|
||||||
final String packageName =
|
final String packageName =
|
||||||
@ -415,17 +396,16 @@ void main() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('building for android', () async {
|
test('building for android', () async {
|
||||||
final Directory pluginDirectory = createFakePlugin('plugin', packagesDir,
|
final Directory pluginDirectory =
|
||||||
withExtraFiles: <List<String>>[
|
createFakePlugin('plugin', packagesDir, extraFiles: <List<String>>[
|
||||||
<String>['example', 'test'],
|
<String>['example', 'test'],
|
||||||
],
|
], platformSupport: <String, PlatformSupport>{
|
||||||
isAndroidPlugin: true);
|
kPlatformAndroid: PlatformSupport.inline
|
||||||
|
});
|
||||||
|
|
||||||
final Directory pluginExampleDirectory =
|
final Directory pluginExampleDirectory =
|
||||||
pluginDirectory.childDirectory('example');
|
pluginDirectory.childDirectory('example');
|
||||||
|
|
||||||
createFakePubspec(pluginExampleDirectory, isFlutter: true);
|
|
||||||
|
|
||||||
final List<String> output = await runCapturingPrint(runner, <String>[
|
final List<String> output = await runCapturingPrint(runner, <String>[
|
||||||
'build-examples',
|
'build-examples',
|
||||||
'--apk',
|
'--apk',
|
||||||
@ -453,17 +433,16 @@ void main() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('enable-experiment flag for Android', () async {
|
test('enable-experiment flag for Android', () async {
|
||||||
final Directory pluginDirectory = createFakePlugin('plugin', packagesDir,
|
final Directory pluginDirectory =
|
||||||
withExtraFiles: <List<String>>[
|
createFakePlugin('plugin', packagesDir, extraFiles: <List<String>>[
|
||||||
<String>['example', 'test'],
|
<String>['example', 'test'],
|
||||||
],
|
], platformSupport: <String, PlatformSupport>{
|
||||||
isAndroidPlugin: true);
|
kPlatformAndroid: PlatformSupport.inline
|
||||||
|
});
|
||||||
|
|
||||||
final Directory pluginExampleDirectory =
|
final Directory pluginExampleDirectory =
|
||||||
pluginDirectory.childDirectory('example');
|
pluginDirectory.childDirectory('example');
|
||||||
|
|
||||||
createFakePubspec(pluginExampleDirectory, isFlutter: true);
|
|
||||||
|
|
||||||
await runCapturingPrint(runner, <String>[
|
await runCapturingPrint(runner, <String>[
|
||||||
'build-examples',
|
'build-examples',
|
||||||
'--apk',
|
'--apk',
|
||||||
@ -483,17 +462,16 @@ void main() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('enable-experiment flag for ios', () async {
|
test('enable-experiment flag for ios', () async {
|
||||||
final Directory pluginDirectory = createFakePlugin('plugin', packagesDir,
|
final Directory pluginDirectory =
|
||||||
withExtraFiles: <List<String>>[
|
createFakePlugin('plugin', packagesDir, extraFiles: <List<String>>[
|
||||||
<String>['example', 'test'],
|
<String>['example', 'test'],
|
||||||
],
|
], platformSupport: <String, PlatformSupport>{
|
||||||
isIosPlugin: true);
|
kPlatformIos: PlatformSupport.inline
|
||||||
|
});
|
||||||
|
|
||||||
final Directory pluginExampleDirectory =
|
final Directory pluginExampleDirectory =
|
||||||
pluginDirectory.childDirectory('example');
|
pluginDirectory.childDirectory('example');
|
||||||
|
|
||||||
createFakePubspec(pluginExampleDirectory, isFlutter: true);
|
|
||||||
|
|
||||||
await runCapturingPrint(runner, <String>[
|
await runCapturingPrint(runner, <String>[
|
||||||
'build-examples',
|
'build-examples',
|
||||||
'--ipa',
|
'--ipa',
|
||||||
|
@ -95,8 +95,7 @@ void main() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('exclude federated plugins when plugins flag is specified', () async {
|
test('exclude federated plugins when plugins flag is specified', () async {
|
||||||
createFakePlugin('plugin1', packagesDir,
|
createFakePlugin('plugin1', packagesDir.childDirectory('federated'));
|
||||||
parentDirectoryName: 'federated');
|
|
||||||
final Directory plugin2 = createFakePlugin('plugin2', packagesDir);
|
final Directory plugin2 = createFakePlugin('plugin2', packagesDir);
|
||||||
await runner.run(<String>[
|
await runner.run(<String>[
|
||||||
'sample',
|
'sample',
|
||||||
@ -108,8 +107,7 @@ void main() {
|
|||||||
|
|
||||||
test('exclude entire federated plugins when plugins flag is specified',
|
test('exclude entire federated plugins when plugins flag is specified',
|
||||||
() async {
|
() async {
|
||||||
createFakePlugin('plugin1', packagesDir,
|
createFakePlugin('plugin1', packagesDir.childDirectory('federated'));
|
||||||
parentDirectoryName: 'federated');
|
|
||||||
final Directory plugin2 = createFakePlugin('plugin2', packagesDir);
|
final Directory plugin2 = createFakePlugin('plugin2', packagesDir);
|
||||||
await runner.run(<String>[
|
await runner.run(<String>[
|
||||||
'sample',
|
'sample',
|
||||||
@ -303,8 +301,8 @@ packages/plugin1/plugin1/plugin1.dart
|
|||||||
packages/plugin1/plugin1_platform_interface/plugin1_platform_interface.dart
|
packages/plugin1/plugin1_platform_interface/plugin1_platform_interface.dart
|
||||||
packages/plugin1/plugin1_web/plugin1_web.dart
|
packages/plugin1/plugin1_web/plugin1_web.dart
|
||||||
''';
|
''';
|
||||||
final Directory plugin1 = createFakePlugin('plugin1', packagesDir,
|
final Directory plugin1 =
|
||||||
parentDirectoryName: 'plugin1');
|
createFakePlugin('plugin1', packagesDir.childDirectory('plugin1'));
|
||||||
createFakePlugin('plugin2', packagesDir);
|
createFakePlugin('plugin2', packagesDir);
|
||||||
createFakePlugin('plugin3', packagesDir);
|
createFakePlugin('plugin3', packagesDir);
|
||||||
await runner.run(<String>[
|
await runner.run(<String>[
|
||||||
@ -323,8 +321,8 @@ packages/plugin1/plugin1.dart
|
|||||||
packages/plugin2/ios/plugin2.m
|
packages/plugin2/ios/plugin2.m
|
||||||
packages/plugin3/plugin3.dart
|
packages/plugin3/plugin3.dart
|
||||||
''';
|
''';
|
||||||
final Directory plugin1 = createFakePlugin('plugin1', packagesDir,
|
final Directory plugin1 =
|
||||||
parentDirectoryName: 'plugin1');
|
createFakePlugin('plugin1', packagesDir.childDirectory('plugin1'));
|
||||||
final Directory plugin2 = createFakePlugin('plugin2', packagesDir);
|
final Directory plugin2 = createFakePlugin('plugin2', packagesDir);
|
||||||
createFakePlugin('plugin3', packagesDir);
|
createFakePlugin('plugin3', packagesDir);
|
||||||
await runner.run(<String>[
|
await runner.run(<String>[
|
||||||
@ -343,8 +341,8 @@ packages/plugin1/plugin1.dart
|
|||||||
packages/plugin2/ios/plugin2.m
|
packages/plugin2/ios/plugin2.m
|
||||||
packages/plugin3/plugin3.dart
|
packages/plugin3/plugin3.dart
|
||||||
''';
|
''';
|
||||||
final Directory plugin1 = createFakePlugin('plugin1', packagesDir,
|
final Directory plugin1 =
|
||||||
parentDirectoryName: 'plugin1');
|
createFakePlugin('plugin1', packagesDir.childDirectory('plugin1'));
|
||||||
createFakePlugin('plugin2', packagesDir);
|
createFakePlugin('plugin2', packagesDir);
|
||||||
createFakePlugin('plugin3', packagesDir);
|
createFakePlugin('plugin3', packagesDir);
|
||||||
await runner.run(<String>[
|
await runner.run(<String>[
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
import 'package:file/file.dart';
|
import 'package:file/file.dart';
|
||||||
import 'package:file/memory.dart';
|
import 'package:file/memory.dart';
|
||||||
|
import 'package:flutter_plugin_tools/src/common/core.dart';
|
||||||
import 'package:flutter_plugin_tools/src/common/plugin_utils.dart';
|
import 'package:flutter_plugin_tools/src/common/plugin_utils.dart';
|
||||||
import 'package:test/test.dart';
|
import 'package:test/test.dart';
|
||||||
|
|
||||||
@ -22,113 +23,112 @@ void main() {
|
|||||||
test('no platforms', () async {
|
test('no platforms', () async {
|
||||||
final Directory plugin = createFakePlugin('plugin', packagesDir);
|
final Directory plugin = createFakePlugin('plugin', packagesDir);
|
||||||
|
|
||||||
expect(pluginSupportsPlatform('android', plugin), isFalse);
|
expect(pluginSupportsPlatform(kPlatformAndroid, plugin), isFalse);
|
||||||
expect(pluginSupportsPlatform('ios', plugin), isFalse);
|
expect(pluginSupportsPlatform(kPlatformIos, plugin), isFalse);
|
||||||
expect(pluginSupportsPlatform('linux', plugin), isFalse);
|
expect(pluginSupportsPlatform(kPlatformLinux, plugin), isFalse);
|
||||||
expect(pluginSupportsPlatform('macos', plugin), isFalse);
|
expect(pluginSupportsPlatform(kPlatformMacos, plugin), isFalse);
|
||||||
expect(pluginSupportsPlatform('web', plugin), isFalse);
|
expect(pluginSupportsPlatform(kPlatformWeb, plugin), isFalse);
|
||||||
expect(pluginSupportsPlatform('windows', plugin), isFalse);
|
expect(pluginSupportsPlatform(kPlatformWindows, plugin), isFalse);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('all platforms', () async {
|
test('all platforms', () async {
|
||||||
final Directory plugin = createFakePlugin(
|
final Directory plugin = createFakePlugin('plugin', packagesDir,
|
||||||
'plugin',
|
platformSupport: <String, PlatformSupport>{
|
||||||
packagesDir,
|
kPlatformAndroid: PlatformSupport.inline,
|
||||||
isAndroidPlugin: true,
|
kPlatformIos: PlatformSupport.inline,
|
||||||
isIosPlugin: true,
|
kPlatformLinux: PlatformSupport.inline,
|
||||||
isLinuxPlugin: true,
|
kPlatformMacos: PlatformSupport.inline,
|
||||||
isMacOsPlugin: true,
|
kPlatformWeb: PlatformSupport.inline,
|
||||||
isWebPlugin: true,
|
kPlatformWindows: PlatformSupport.inline,
|
||||||
isWindowsPlugin: true,
|
});
|
||||||
);
|
|
||||||
|
|
||||||
expect(pluginSupportsPlatform('android', plugin), isTrue);
|
expect(pluginSupportsPlatform(kPlatformAndroid, plugin), isTrue);
|
||||||
expect(pluginSupportsPlatform('ios', plugin), isTrue);
|
expect(pluginSupportsPlatform(kPlatformIos, plugin), isTrue);
|
||||||
expect(pluginSupportsPlatform('linux', plugin), isTrue);
|
expect(pluginSupportsPlatform(kPlatformLinux, plugin), isTrue);
|
||||||
expect(pluginSupportsPlatform('macos', plugin), isTrue);
|
expect(pluginSupportsPlatform(kPlatformMacos, plugin), isTrue);
|
||||||
expect(pluginSupportsPlatform('web', plugin), isTrue);
|
expect(pluginSupportsPlatform(kPlatformWeb, plugin), isTrue);
|
||||||
expect(pluginSupportsPlatform('windows', plugin), isTrue);
|
expect(pluginSupportsPlatform(kPlatformWindows, plugin), isTrue);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('some platforms', () async {
|
test('some platforms', () async {
|
||||||
final Directory plugin = createFakePlugin(
|
final Directory plugin = createFakePlugin(
|
||||||
'plugin',
|
'plugin',
|
||||||
packagesDir,
|
packagesDir,
|
||||||
isAndroidPlugin: true,
|
platformSupport: <String, PlatformSupport>{
|
||||||
isIosPlugin: false,
|
kPlatformAndroid: PlatformSupport.inline,
|
||||||
isLinuxPlugin: true,
|
kPlatformLinux: PlatformSupport.inline,
|
||||||
isMacOsPlugin: false,
|
kPlatformWeb: PlatformSupport.inline,
|
||||||
isWebPlugin: true,
|
},
|
||||||
isWindowsPlugin: false,
|
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(pluginSupportsPlatform('android', plugin), isTrue);
|
expect(pluginSupportsPlatform(kPlatformAndroid, plugin), isTrue);
|
||||||
expect(pluginSupportsPlatform('ios', plugin), isFalse);
|
expect(pluginSupportsPlatform(kPlatformIos, plugin), isFalse);
|
||||||
expect(pluginSupportsPlatform('linux', plugin), isTrue);
|
expect(pluginSupportsPlatform(kPlatformLinux, plugin), isTrue);
|
||||||
expect(pluginSupportsPlatform('macos', plugin), isFalse);
|
expect(pluginSupportsPlatform(kPlatformMacos, plugin), isFalse);
|
||||||
expect(pluginSupportsPlatform('web', plugin), isTrue);
|
expect(pluginSupportsPlatform(kPlatformWeb, plugin), isTrue);
|
||||||
expect(pluginSupportsPlatform('windows', plugin), isFalse);
|
expect(pluginSupportsPlatform(kPlatformWindows, plugin), isFalse);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('inline plugins are only detected as inline', () async {
|
test('inline plugins are only detected as inline', () async {
|
||||||
// createFakePlugin makes non-federated pubspec entries.
|
|
||||||
final Directory plugin = createFakePlugin(
|
final Directory plugin = createFakePlugin(
|
||||||
'plugin',
|
'plugin',
|
||||||
packagesDir,
|
packagesDir,
|
||||||
isAndroidPlugin: true,
|
platformSupport: <String, PlatformSupport>{
|
||||||
isIosPlugin: true,
|
kPlatformAndroid: PlatformSupport.inline,
|
||||||
isLinuxPlugin: true,
|
kPlatformIos: PlatformSupport.inline,
|
||||||
isMacOsPlugin: true,
|
kPlatformLinux: PlatformSupport.inline,
|
||||||
isWebPlugin: true,
|
kPlatformMacos: PlatformSupport.inline,
|
||||||
isWindowsPlugin: true,
|
kPlatformWeb: PlatformSupport.inline,
|
||||||
|
kPlatformWindows: PlatformSupport.inline,
|
||||||
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(
|
expect(
|
||||||
pluginSupportsPlatform('android', plugin,
|
pluginSupportsPlatform(kPlatformAndroid, plugin,
|
||||||
requiredMode: PlatformSupport.inline),
|
requiredMode: PlatformSupport.inline),
|
||||||
isTrue);
|
isTrue);
|
||||||
expect(
|
expect(
|
||||||
pluginSupportsPlatform('android', plugin,
|
pluginSupportsPlatform(kPlatformAndroid, plugin,
|
||||||
requiredMode: PlatformSupport.federated),
|
requiredMode: PlatformSupport.federated),
|
||||||
isFalse);
|
isFalse);
|
||||||
expect(
|
expect(
|
||||||
pluginSupportsPlatform('ios', plugin,
|
pluginSupportsPlatform(kPlatformIos, plugin,
|
||||||
requiredMode: PlatformSupport.inline),
|
requiredMode: PlatformSupport.inline),
|
||||||
isTrue);
|
isTrue);
|
||||||
expect(
|
expect(
|
||||||
pluginSupportsPlatform('ios', plugin,
|
pluginSupportsPlatform(kPlatformIos, plugin,
|
||||||
requiredMode: PlatformSupport.federated),
|
requiredMode: PlatformSupport.federated),
|
||||||
isFalse);
|
isFalse);
|
||||||
expect(
|
expect(
|
||||||
pluginSupportsPlatform('linux', plugin,
|
pluginSupportsPlatform(kPlatformLinux, plugin,
|
||||||
requiredMode: PlatformSupport.inline),
|
requiredMode: PlatformSupport.inline),
|
||||||
isTrue);
|
isTrue);
|
||||||
expect(
|
expect(
|
||||||
pluginSupportsPlatform('linux', plugin,
|
pluginSupportsPlatform(kPlatformLinux, plugin,
|
||||||
requiredMode: PlatformSupport.federated),
|
requiredMode: PlatformSupport.federated),
|
||||||
isFalse);
|
isFalse);
|
||||||
expect(
|
expect(
|
||||||
pluginSupportsPlatform('macos', plugin,
|
pluginSupportsPlatform(kPlatformMacos, plugin,
|
||||||
requiredMode: PlatformSupport.inline),
|
requiredMode: PlatformSupport.inline),
|
||||||
isTrue);
|
isTrue);
|
||||||
expect(
|
expect(
|
||||||
pluginSupportsPlatform('macos', plugin,
|
pluginSupportsPlatform(kPlatformMacos, plugin,
|
||||||
requiredMode: PlatformSupport.federated),
|
requiredMode: PlatformSupport.federated),
|
||||||
isFalse);
|
isFalse);
|
||||||
expect(
|
expect(
|
||||||
pluginSupportsPlatform('web', plugin,
|
pluginSupportsPlatform(kPlatformWeb, plugin,
|
||||||
requiredMode: PlatformSupport.inline),
|
requiredMode: PlatformSupport.inline),
|
||||||
isTrue);
|
isTrue);
|
||||||
expect(
|
expect(
|
||||||
pluginSupportsPlatform('web', plugin,
|
pluginSupportsPlatform(kPlatformWeb, plugin,
|
||||||
requiredMode: PlatformSupport.federated),
|
requiredMode: PlatformSupport.federated),
|
||||||
isFalse);
|
isFalse);
|
||||||
expect(
|
expect(
|
||||||
pluginSupportsPlatform('windows', plugin,
|
pluginSupportsPlatform(kPlatformWindows, plugin,
|
||||||
requiredMode: PlatformSupport.inline),
|
requiredMode: PlatformSupport.inline),
|
||||||
isTrue);
|
isTrue);
|
||||||
expect(
|
expect(
|
||||||
pluginSupportsPlatform('windows', plugin,
|
pluginSupportsPlatform(kPlatformWindows, plugin,
|
||||||
requiredMode: PlatformSupport.federated),
|
requiredMode: PlatformSupport.federated),
|
||||||
isFalse);
|
isFalse);
|
||||||
});
|
});
|
||||||
@ -138,71 +138,62 @@ void main() {
|
|||||||
final Directory plugin = createFakePlugin(
|
final Directory plugin = createFakePlugin(
|
||||||
pluginName,
|
pluginName,
|
||||||
packagesDir,
|
packagesDir,
|
||||||
isAndroidPlugin: true,
|
platformSupport: <String, PlatformSupport>{
|
||||||
isIosPlugin: true,
|
kPlatformAndroid: PlatformSupport.federated,
|
||||||
isLinuxPlugin: true,
|
kPlatformIos: PlatformSupport.federated,
|
||||||
isMacOsPlugin: true,
|
kPlatformLinux: PlatformSupport.federated,
|
||||||
isWebPlugin: true,
|
kPlatformMacos: PlatformSupport.federated,
|
||||||
isWindowsPlugin: true,
|
kPlatformWeb: PlatformSupport.federated,
|
||||||
);
|
kPlatformWindows: PlatformSupport.federated,
|
||||||
|
},
|
||||||
createFakePubspec(
|
|
||||||
plugin,
|
|
||||||
name: pluginName,
|
|
||||||
androidSupport: PlatformSupport.federated,
|
|
||||||
iosSupport: PlatformSupport.federated,
|
|
||||||
linuxSupport: PlatformSupport.federated,
|
|
||||||
macosSupport: PlatformSupport.federated,
|
|
||||||
webSupport: PlatformSupport.federated,
|
|
||||||
windowsSupport: PlatformSupport.federated,
|
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(
|
expect(
|
||||||
pluginSupportsPlatform('android', plugin,
|
pluginSupportsPlatform(kPlatformAndroid, plugin,
|
||||||
requiredMode: PlatformSupport.federated),
|
requiredMode: PlatformSupport.federated),
|
||||||
isTrue);
|
isTrue);
|
||||||
expect(
|
expect(
|
||||||
pluginSupportsPlatform('android', plugin,
|
pluginSupportsPlatform(kPlatformAndroid, plugin,
|
||||||
requiredMode: PlatformSupport.inline),
|
requiredMode: PlatformSupport.inline),
|
||||||
isFalse);
|
isFalse);
|
||||||
expect(
|
expect(
|
||||||
pluginSupportsPlatform('ios', plugin,
|
pluginSupportsPlatform(kPlatformIos, plugin,
|
||||||
requiredMode: PlatformSupport.federated),
|
requiredMode: PlatformSupport.federated),
|
||||||
isTrue);
|
isTrue);
|
||||||
expect(
|
expect(
|
||||||
pluginSupportsPlatform('ios', plugin,
|
pluginSupportsPlatform(kPlatformIos, plugin,
|
||||||
requiredMode: PlatformSupport.inline),
|
requiredMode: PlatformSupport.inline),
|
||||||
isFalse);
|
isFalse);
|
||||||
expect(
|
expect(
|
||||||
pluginSupportsPlatform('linux', plugin,
|
pluginSupportsPlatform(kPlatformLinux, plugin,
|
||||||
requiredMode: PlatformSupport.federated),
|
requiredMode: PlatformSupport.federated),
|
||||||
isTrue);
|
isTrue);
|
||||||
expect(
|
expect(
|
||||||
pluginSupportsPlatform('linux', plugin,
|
pluginSupportsPlatform(kPlatformLinux, plugin,
|
||||||
requiredMode: PlatformSupport.inline),
|
requiredMode: PlatformSupport.inline),
|
||||||
isFalse);
|
isFalse);
|
||||||
expect(
|
expect(
|
||||||
pluginSupportsPlatform('macos', plugin,
|
pluginSupportsPlatform(kPlatformMacos, plugin,
|
||||||
requiredMode: PlatformSupport.federated),
|
requiredMode: PlatformSupport.federated),
|
||||||
isTrue);
|
isTrue);
|
||||||
expect(
|
expect(
|
||||||
pluginSupportsPlatform('macos', plugin,
|
pluginSupportsPlatform(kPlatformMacos, plugin,
|
||||||
requiredMode: PlatformSupport.inline),
|
requiredMode: PlatformSupport.inline),
|
||||||
isFalse);
|
isFalse);
|
||||||
expect(
|
expect(
|
||||||
pluginSupportsPlatform('web', plugin,
|
pluginSupportsPlatform(kPlatformWeb, plugin,
|
||||||
requiredMode: PlatformSupport.federated),
|
requiredMode: PlatformSupport.federated),
|
||||||
isTrue);
|
isTrue);
|
||||||
expect(
|
expect(
|
||||||
pluginSupportsPlatform('web', plugin,
|
pluginSupportsPlatform(kPlatformWeb, plugin,
|
||||||
requiredMode: PlatformSupport.inline),
|
requiredMode: PlatformSupport.inline),
|
||||||
isFalse);
|
isFalse);
|
||||||
expect(
|
expect(
|
||||||
pluginSupportsPlatform('windows', plugin,
|
pluginSupportsPlatform(kPlatformWindows, plugin,
|
||||||
requiredMode: PlatformSupport.federated),
|
requiredMode: PlatformSupport.federated),
|
||||||
isTrue);
|
isTrue);
|
||||||
expect(
|
expect(
|
||||||
pluginSupportsPlatform('windows', plugin,
|
pluginSupportsPlatform(kPlatformWindows, plugin,
|
||||||
requiredMode: PlatformSupport.inline),
|
requiredMode: PlatformSupport.inline),
|
||||||
isFalse);
|
isFalse);
|
||||||
});
|
});
|
||||||
|
@ -6,6 +6,7 @@ import 'package:args/command_runner.dart';
|
|||||||
import 'package:file/file.dart';
|
import 'package:file/file.dart';
|
||||||
import 'package:file/memory.dart';
|
import 'package:file/memory.dart';
|
||||||
import 'package:flutter_plugin_tools/src/common/core.dart';
|
import 'package:flutter_plugin_tools/src/common/core.dart';
|
||||||
|
import 'package:flutter_plugin_tools/src/common/plugin_utils.dart';
|
||||||
import 'package:flutter_plugin_tools/src/drive_examples_command.dart';
|
import 'package:flutter_plugin_tools/src/drive_examples_command.dart';
|
||||||
import 'package:path/path.dart' as p;
|
import 'package:path/path.dart' as p;
|
||||||
import 'package:platform/platform.dart';
|
import 'package:platform/platform.dart';
|
||||||
@ -35,19 +36,18 @@ void main() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('driving under folder "test"', () async {
|
test('driving under folder "test"', () async {
|
||||||
final Directory pluginDirectory = createFakePlugin('plugin', packagesDir,
|
final Directory pluginDirectory =
|
||||||
withExtraFiles: <List<String>>[
|
createFakePlugin('plugin', packagesDir, extraFiles: <List<String>>[
|
||||||
<String>['example', 'test_driver', 'plugin_test.dart'],
|
<String>['example', 'test_driver', 'plugin_test.dart'],
|
||||||
<String>['example', 'test', 'plugin.dart'],
|
<String>['example', 'test', 'plugin.dart'],
|
||||||
],
|
], platformSupport: <String, PlatformSupport>{
|
||||||
isIosPlugin: true,
|
kPlatformAndroid: PlatformSupport.inline,
|
||||||
isAndroidPlugin: true);
|
kPlatformIos: PlatformSupport.inline,
|
||||||
|
});
|
||||||
|
|
||||||
final Directory pluginExampleDirectory =
|
final Directory pluginExampleDirectory =
|
||||||
pluginDirectory.childDirectory('example');
|
pluginDirectory.childDirectory('example');
|
||||||
|
|
||||||
createFakePubspec(pluginExampleDirectory, isFlutter: true);
|
|
||||||
|
|
||||||
final List<String> output = await runCapturingPrint(runner, <String>[
|
final List<String> output = await runCapturingPrint(runner, <String>[
|
||||||
'drive-examples',
|
'drive-examples',
|
||||||
]);
|
]);
|
||||||
@ -80,19 +80,18 @@ void main() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('driving under folder "test_driver"', () async {
|
test('driving under folder "test_driver"', () async {
|
||||||
final Directory pluginDirectory = createFakePlugin('plugin', packagesDir,
|
final Directory pluginDirectory =
|
||||||
withExtraFiles: <List<String>>[
|
createFakePlugin('plugin', packagesDir, extraFiles: <List<String>>[
|
||||||
<String>['example', 'test_driver', 'plugin_test.dart'],
|
<String>['example', 'test_driver', 'plugin_test.dart'],
|
||||||
<String>['example', 'test_driver', 'plugin.dart'],
|
<String>['example', 'test_driver', 'plugin.dart'],
|
||||||
],
|
], platformSupport: <String, PlatformSupport>{
|
||||||
isAndroidPlugin: true,
|
kPlatformAndroid: PlatformSupport.inline,
|
||||||
isIosPlugin: true);
|
kPlatformIos: PlatformSupport.inline,
|
||||||
|
});
|
||||||
|
|
||||||
final Directory pluginExampleDirectory =
|
final Directory pluginExampleDirectory =
|
||||||
pluginDirectory.childDirectory('example');
|
pluginDirectory.childDirectory('example');
|
||||||
|
|
||||||
createFakePubspec(pluginExampleDirectory, isFlutter: true);
|
|
||||||
|
|
||||||
final List<String> output = await runCapturingPrint(runner, <String>[
|
final List<String> output = await runCapturingPrint(runner, <String>[
|
||||||
'drive-examples',
|
'drive-examples',
|
||||||
]);
|
]);
|
||||||
@ -126,17 +125,12 @@ void main() {
|
|||||||
|
|
||||||
test('driving under folder "test_driver" when test files are missing"',
|
test('driving under folder "test_driver" when test files are missing"',
|
||||||
() async {
|
() async {
|
||||||
final Directory pluginDirectory = createFakePlugin('plugin', packagesDir,
|
createFakePlugin('plugin', packagesDir, extraFiles: <List<String>>[
|
||||||
withExtraFiles: <List<String>>[
|
<String>['example', 'test_driver', 'plugin_test.dart'],
|
||||||
<String>['example', 'test_driver', 'plugin_test.dart'],
|
], platformSupport: <String, PlatformSupport>{
|
||||||
],
|
kPlatformAndroid: PlatformSupport.inline,
|
||||||
isAndroidPlugin: true,
|
kPlatformIos: PlatformSupport.inline,
|
||||||
isIosPlugin: true);
|
});
|
||||||
|
|
||||||
final Directory pluginExampleDirectory =
|
|
||||||
pluginDirectory.childDirectory('example');
|
|
||||||
|
|
||||||
createFakePubspec(pluginExampleDirectory, isFlutter: true);
|
|
||||||
|
|
||||||
await expectLater(
|
await expectLater(
|
||||||
() => runCapturingPrint(runner, <String>['drive-examples']),
|
() => runCapturingPrint(runner, <String>['drive-examples']),
|
||||||
@ -145,17 +139,12 @@ void main() {
|
|||||||
|
|
||||||
test('a plugin without any integration test files is reported as an error',
|
test('a plugin without any integration test files is reported as an error',
|
||||||
() async {
|
() async {
|
||||||
final Directory pluginDirectory = createFakePlugin('plugin', packagesDir,
|
createFakePlugin('plugin', packagesDir, extraFiles: <List<String>>[
|
||||||
withExtraFiles: <List<String>>[
|
<String>['example', 'lib', 'main.dart'],
|
||||||
<String>['example', 'lib', 'main.dart'],
|
], platformSupport: <String, PlatformSupport>{
|
||||||
],
|
kPlatformAndroid: PlatformSupport.inline,
|
||||||
isAndroidPlugin: true,
|
kPlatformIos: PlatformSupport.inline,
|
||||||
isIosPlugin: true);
|
});
|
||||||
|
|
||||||
final Directory pluginExampleDirectory =
|
|
||||||
pluginDirectory.childDirectory('example');
|
|
||||||
|
|
||||||
createFakePubspec(pluginExampleDirectory, isFlutter: true);
|
|
||||||
|
|
||||||
await expectLater(
|
await expectLater(
|
||||||
() => runCapturingPrint(runner, <String>['drive-examples']),
|
() => runCapturingPrint(runner, <String>['drive-examples']),
|
||||||
@ -165,21 +154,20 @@ void main() {
|
|||||||
test(
|
test(
|
||||||
'driving under folder "test_driver" when targets are under "integration_test"',
|
'driving under folder "test_driver" when targets are under "integration_test"',
|
||||||
() async {
|
() async {
|
||||||
final Directory pluginDirectory = createFakePlugin('plugin', packagesDir,
|
final Directory pluginDirectory =
|
||||||
withExtraFiles: <List<String>>[
|
createFakePlugin('plugin', packagesDir, extraFiles: <List<String>>[
|
||||||
<String>['example', 'test_driver', 'integration_test.dart'],
|
<String>['example', 'test_driver', 'integration_test.dart'],
|
||||||
<String>['example', 'integration_test', 'bar_test.dart'],
|
<String>['example', 'integration_test', 'bar_test.dart'],
|
||||||
<String>['example', 'integration_test', 'foo_test.dart'],
|
<String>['example', 'integration_test', 'foo_test.dart'],
|
||||||
<String>['example', 'integration_test', 'ignore_me.dart'],
|
<String>['example', 'integration_test', 'ignore_me.dart'],
|
||||||
],
|
], platformSupport: <String, PlatformSupport>{
|
||||||
isAndroidPlugin: true,
|
kPlatformAndroid: PlatformSupport.inline,
|
||||||
isIosPlugin: true);
|
kPlatformIos: PlatformSupport.inline,
|
||||||
|
});
|
||||||
|
|
||||||
final Directory pluginExampleDirectory =
|
final Directory pluginExampleDirectory =
|
||||||
pluginDirectory.childDirectory('example');
|
pluginDirectory.childDirectory('example');
|
||||||
|
|
||||||
createFakePubspec(pluginExampleDirectory, isFlutter: true);
|
|
||||||
|
|
||||||
final List<String> output = await runCapturingPrint(runner, <String>[
|
final List<String> output = await runCapturingPrint(runner, <String>[
|
||||||
'drive-examples',
|
'drive-examples',
|
||||||
]);
|
]);
|
||||||
@ -222,17 +210,10 @@ void main() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('driving when plugin does not support Linux is a no-op', () async {
|
test('driving when plugin does not support Linux is a no-op', () async {
|
||||||
final Directory pluginDirectory = createFakePlugin('plugin', packagesDir,
|
createFakePlugin('plugin', packagesDir, extraFiles: <List<String>>[
|
||||||
withExtraFiles: <List<String>>[
|
<String>['example', 'test_driver', 'plugin_test.dart'],
|
||||||
<String>['example', 'test_driver', 'plugin_test.dart'],
|
<String>['example', 'test_driver', 'plugin.dart'],
|
||||||
<String>['example', 'test_driver', 'plugin.dart'],
|
]);
|
||||||
],
|
|
||||||
isMacOsPlugin: false);
|
|
||||||
|
|
||||||
final Directory pluginExampleDirectory =
|
|
||||||
pluginDirectory.childDirectory('example');
|
|
||||||
|
|
||||||
createFakePubspec(pluginExampleDirectory, isFlutter: true);
|
|
||||||
|
|
||||||
final List<String> output = await runCapturingPrint(runner, <String>[
|
final List<String> output = await runCapturingPrint(runner, <String>[
|
||||||
'drive-examples',
|
'drive-examples',
|
||||||
@ -255,18 +236,17 @@ void main() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('driving on a Linux plugin', () async {
|
test('driving on a Linux plugin', () async {
|
||||||
final Directory pluginDirectory = createFakePlugin('plugin', packagesDir,
|
final Directory pluginDirectory =
|
||||||
withExtraFiles: <List<String>>[
|
createFakePlugin('plugin', packagesDir, extraFiles: <List<String>>[
|
||||||
<String>['example', 'test_driver', 'plugin_test.dart'],
|
<String>['example', 'test_driver', 'plugin_test.dart'],
|
||||||
<String>['example', 'test_driver', 'plugin.dart'],
|
<String>['example', 'test_driver', 'plugin.dart'],
|
||||||
],
|
], platformSupport: <String, PlatformSupport>{
|
||||||
isLinuxPlugin: true);
|
kPlatformLinux: PlatformSupport.inline,
|
||||||
|
});
|
||||||
|
|
||||||
final Directory pluginExampleDirectory =
|
final Directory pluginExampleDirectory =
|
||||||
pluginDirectory.childDirectory('example');
|
pluginDirectory.childDirectory('example');
|
||||||
|
|
||||||
createFakePubspec(pluginExampleDirectory, isFlutter: true);
|
|
||||||
|
|
||||||
final List<String> output = await runCapturingPrint(runner, <String>[
|
final List<String> output = await runCapturingPrint(runner, <String>[
|
||||||
'drive-examples',
|
'drive-examples',
|
||||||
'--linux',
|
'--linux',
|
||||||
@ -302,16 +282,10 @@ void main() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('driving when plugin does not suppport macOS is a no-op', () async {
|
test('driving when plugin does not suppport macOS is a no-op', () async {
|
||||||
final Directory pluginDirectory = createFakePlugin('plugin', packagesDir,
|
createFakePlugin('plugin', packagesDir, extraFiles: <List<String>>[
|
||||||
withExtraFiles: <List<String>>[
|
<String>['example', 'test_driver', 'plugin_test.dart'],
|
||||||
<String>['example', 'test_driver', 'plugin_test.dart'],
|
<String>['example', 'test_driver', 'plugin.dart'],
|
||||||
<String>['example', 'test_driver', 'plugin.dart'],
|
]);
|
||||||
]);
|
|
||||||
|
|
||||||
final Directory pluginExampleDirectory =
|
|
||||||
pluginDirectory.childDirectory('example');
|
|
||||||
|
|
||||||
createFakePubspec(pluginExampleDirectory, isFlutter: true);
|
|
||||||
|
|
||||||
final List<String> output = await runCapturingPrint(runner, <String>[
|
final List<String> output = await runCapturingPrint(runner, <String>[
|
||||||
'drive-examples',
|
'drive-examples',
|
||||||
@ -333,19 +307,18 @@ void main() {
|
|||||||
expect(processRunner.recordedCalls, <ProcessCall>[]);
|
expect(processRunner.recordedCalls, <ProcessCall>[]);
|
||||||
});
|
});
|
||||||
test('driving on a macOS plugin', () async {
|
test('driving on a macOS plugin', () async {
|
||||||
final Directory pluginDirectory = createFakePlugin('plugin', packagesDir,
|
final Directory pluginDirectory =
|
||||||
withExtraFiles: <List<String>>[
|
createFakePlugin('plugin', packagesDir, extraFiles: <List<String>>[
|
||||||
<String>['example', 'test_driver', 'plugin_test.dart'],
|
<String>['example', 'test_driver', 'plugin_test.dart'],
|
||||||
<String>['example', 'test_driver', 'plugin.dart'],
|
<String>['example', 'test_driver', 'plugin.dart'],
|
||||||
<String>['example', 'macos', 'macos.swift'],
|
<String>['example', 'macos', 'macos.swift'],
|
||||||
],
|
], platformSupport: <String, PlatformSupport>{
|
||||||
isMacOsPlugin: true);
|
kPlatformMacos: PlatformSupport.inline,
|
||||||
|
});
|
||||||
|
|
||||||
final Directory pluginExampleDirectory =
|
final Directory pluginExampleDirectory =
|
||||||
pluginDirectory.childDirectory('example');
|
pluginDirectory.childDirectory('example');
|
||||||
|
|
||||||
createFakePubspec(pluginExampleDirectory, isFlutter: true);
|
|
||||||
|
|
||||||
final List<String> output = await runCapturingPrint(runner, <String>[
|
final List<String> output = await runCapturingPrint(runner, <String>[
|
||||||
'drive-examples',
|
'drive-examples',
|
||||||
'--macos',
|
'--macos',
|
||||||
@ -381,17 +354,10 @@ void main() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('driving when plugin does not suppport web is a no-op', () async {
|
test('driving when plugin does not suppport web is a no-op', () async {
|
||||||
final Directory pluginDirectory = createFakePlugin('plugin', packagesDir,
|
createFakePlugin('plugin', packagesDir, extraFiles: <List<String>>[
|
||||||
withExtraFiles: <List<String>>[
|
<String>['example', 'test_driver', 'plugin_test.dart'],
|
||||||
<String>['example', 'test_driver', 'plugin_test.dart'],
|
<String>['example', 'test_driver', 'plugin.dart'],
|
||||||
<String>['example', 'test_driver', 'plugin.dart'],
|
]);
|
||||||
],
|
|
||||||
isWebPlugin: false);
|
|
||||||
|
|
||||||
final Directory pluginExampleDirectory =
|
|
||||||
pluginDirectory.childDirectory('example');
|
|
||||||
|
|
||||||
createFakePubspec(pluginExampleDirectory, isFlutter: true);
|
|
||||||
|
|
||||||
final List<String> output = await runCapturingPrint(runner, <String>[
|
final List<String> output = await runCapturingPrint(runner, <String>[
|
||||||
'drive-examples',
|
'drive-examples',
|
||||||
@ -414,18 +380,17 @@ void main() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('driving a web plugin', () async {
|
test('driving a web plugin', () async {
|
||||||
final Directory pluginDirectory = createFakePlugin('plugin', packagesDir,
|
final Directory pluginDirectory =
|
||||||
withExtraFiles: <List<String>>[
|
createFakePlugin('plugin', packagesDir, extraFiles: <List<String>>[
|
||||||
<String>['example', 'test_driver', 'plugin_test.dart'],
|
<String>['example', 'test_driver', 'plugin_test.dart'],
|
||||||
<String>['example', 'test_driver', 'plugin.dart'],
|
<String>['example', 'test_driver', 'plugin.dart'],
|
||||||
],
|
], platformSupport: <String, PlatformSupport>{
|
||||||
isWebPlugin: true);
|
kPlatformWeb: PlatformSupport.inline,
|
||||||
|
});
|
||||||
|
|
||||||
final Directory pluginExampleDirectory =
|
final Directory pluginExampleDirectory =
|
||||||
pluginDirectory.childDirectory('example');
|
pluginDirectory.childDirectory('example');
|
||||||
|
|
||||||
createFakePubspec(pluginExampleDirectory, isFlutter: true);
|
|
||||||
|
|
||||||
final List<String> output = await runCapturingPrint(runner, <String>[
|
final List<String> output = await runCapturingPrint(runner, <String>[
|
||||||
'drive-examples',
|
'drive-examples',
|
||||||
'--web',
|
'--web',
|
||||||
@ -463,17 +428,10 @@ void main() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('driving when plugin does not suppport Windows is a no-op', () async {
|
test('driving when plugin does not suppport Windows is a no-op', () async {
|
||||||
final Directory pluginDirectory = createFakePlugin('plugin', packagesDir,
|
createFakePlugin('plugin', packagesDir, extraFiles: <List<String>>[
|
||||||
withExtraFiles: <List<String>>[
|
<String>['example', 'test_driver', 'plugin_test.dart'],
|
||||||
<String>['example', 'test_driver', 'plugin_test.dart'],
|
<String>['example', 'test_driver', 'plugin.dart'],
|
||||||
<String>['example', 'test_driver', 'plugin.dart'],
|
]);
|
||||||
],
|
|
||||||
isWindowsPlugin: false);
|
|
||||||
|
|
||||||
final Directory pluginExampleDirectory =
|
|
||||||
pluginDirectory.childDirectory('example');
|
|
||||||
|
|
||||||
createFakePubspec(pluginExampleDirectory, isFlutter: true);
|
|
||||||
|
|
||||||
final List<String> output = await runCapturingPrint(runner, <String>[
|
final List<String> output = await runCapturingPrint(runner, <String>[
|
||||||
'drive-examples',
|
'drive-examples',
|
||||||
@ -496,18 +454,17 @@ void main() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('driving on a Windows plugin', () async {
|
test('driving on a Windows plugin', () async {
|
||||||
final Directory pluginDirectory = createFakePlugin('plugin', packagesDir,
|
final Directory pluginDirectory =
|
||||||
withExtraFiles: <List<String>>[
|
createFakePlugin('plugin', packagesDir, extraFiles: <List<String>>[
|
||||||
<String>['example', 'test_driver', 'plugin_test.dart'],
|
<String>['example', 'test_driver', 'plugin_test.dart'],
|
||||||
<String>['example', 'test_driver', 'plugin.dart'],
|
<String>['example', 'test_driver', 'plugin.dart'],
|
||||||
],
|
], platformSupport: <String, PlatformSupport>{
|
||||||
isWindowsPlugin: true);
|
kPlatformWindows: PlatformSupport.inline
|
||||||
|
});
|
||||||
|
|
||||||
final Directory pluginExampleDirectory =
|
final Directory pluginExampleDirectory =
|
||||||
pluginDirectory.childDirectory('example');
|
pluginDirectory.childDirectory('example');
|
||||||
|
|
||||||
createFakePubspec(pluginExampleDirectory, isFlutter: true);
|
|
||||||
|
|
||||||
final List<String> output = await runCapturingPrint(runner, <String>[
|
final List<String> output = await runCapturingPrint(runner, <String>[
|
||||||
'drive-examples',
|
'drive-examples',
|
||||||
'--windows',
|
'--windows',
|
||||||
@ -543,17 +500,12 @@ void main() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('driving when plugin does not support mobile is no-op', () async {
|
test('driving when plugin does not support mobile is no-op', () async {
|
||||||
final Directory pluginDirectory = createFakePlugin('plugin', packagesDir,
|
createFakePlugin('plugin', packagesDir, extraFiles: <List<String>>[
|
||||||
withExtraFiles: <List<String>>[
|
<String>['example', 'test_driver', 'plugin_test.dart'],
|
||||||
<String>['example', 'test_driver', 'plugin_test.dart'],
|
<String>['example', 'test_driver', 'plugin.dart'],
|
||||||
<String>['example', 'test_driver', 'plugin.dart'],
|
], platformSupport: <String, PlatformSupport>{
|
||||||
],
|
kPlatformMacos: PlatformSupport.inline,
|
||||||
isMacOsPlugin: true);
|
});
|
||||||
|
|
||||||
final Directory pluginExampleDirectory =
|
|
||||||
pluginDirectory.childDirectory('example');
|
|
||||||
|
|
||||||
createFakePubspec(pluginExampleDirectory, isFlutter: true);
|
|
||||||
|
|
||||||
final List<String> output = await runCapturingPrint(runner, <String>[
|
final List<String> output = await runCapturingPrint(runner, <String>[
|
||||||
'drive-examples',
|
'drive-examples',
|
||||||
@ -575,7 +527,8 @@ void main() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('platform interface plugins are silently skipped', () async {
|
test('platform interface plugins are silently skipped', () async {
|
||||||
createFakePlugin('aplugin_platform_interface', packagesDir);
|
createFakePlugin('aplugin_platform_interface', packagesDir,
|
||||||
|
examples: <String>[]);
|
||||||
|
|
||||||
final List<String> output = await runCapturingPrint(runner, <String>[
|
final List<String> output = await runCapturingPrint(runner, <String>[
|
||||||
'drive-examples',
|
'drive-examples',
|
||||||
@ -595,19 +548,18 @@ void main() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('enable-experiment flag', () async {
|
test('enable-experiment flag', () async {
|
||||||
final Directory pluginDirectory = createFakePlugin('plugin', packagesDir,
|
final Directory pluginDirectory =
|
||||||
withExtraFiles: <List<String>>[
|
createFakePlugin('plugin', packagesDir, extraFiles: <List<String>>[
|
||||||
<String>['example', 'test_driver', 'plugin_test.dart'],
|
<String>['example', 'test_driver', 'plugin_test.dart'],
|
||||||
<String>['example', 'test', 'plugin.dart'],
|
<String>['example', 'test', 'plugin.dart'],
|
||||||
],
|
], platformSupport: <String, PlatformSupport>{
|
||||||
isIosPlugin: true,
|
kPlatformAndroid: PlatformSupport.inline,
|
||||||
isAndroidPlugin: true);
|
kPlatformIos: PlatformSupport.inline,
|
||||||
|
});
|
||||||
|
|
||||||
final Directory pluginExampleDirectory =
|
final Directory pluginExampleDirectory =
|
||||||
pluginDirectory.childDirectory('example');
|
pluginDirectory.childDirectory('example');
|
||||||
|
|
||||||
createFakePubspec(pluginExampleDirectory, isFlutter: true);
|
|
||||||
|
|
||||||
await runCapturingPrint(runner, <String>[
|
await runCapturingPrint(runner, <String>[
|
||||||
'drive-examples',
|
'drive-examples',
|
||||||
'--enable-experiment=exp1',
|
'--enable-experiment=exp1',
|
||||||
|
@ -40,7 +40,7 @@ void main() {
|
|||||||
final MockProcess mockProcess = MockProcess();
|
final MockProcess mockProcess = MockProcess();
|
||||||
mockProcess.exitCodeCompleter.complete(1);
|
mockProcess.exitCodeCompleter.complete(1);
|
||||||
processRunner.processToReturn = mockProcess;
|
processRunner.processToReturn = mockProcess;
|
||||||
createFakePlugin('plugin', packagesDir, withExtraFiles: <List<String>>[
|
createFakePlugin('plugin', packagesDir, extraFiles: <List<String>>[
|
||||||
<String>['lib/test/should_not_run_e2e.dart'],
|
<String>['lib/test/should_not_run_e2e.dart'],
|
||||||
<String>['example', 'test_driver', 'plugin_e2e.dart'],
|
<String>['example', 'test_driver', 'plugin_e2e.dart'],
|
||||||
<String>['example', 'test_driver', 'plugin_e2e_test.dart'],
|
<String>['example', 'test_driver', 'plugin_e2e_test.dart'],
|
||||||
@ -65,7 +65,7 @@ void main() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('runs e2e tests', () async {
|
test('runs e2e tests', () async {
|
||||||
createFakePlugin('plugin', packagesDir, withExtraFiles: <List<String>>[
|
createFakePlugin('plugin', packagesDir, extraFiles: <List<String>>[
|
||||||
<String>['test', 'plugin_test.dart'],
|
<String>['test', 'plugin_test.dart'],
|
||||||
<String>['test', 'plugin_e2e.dart'],
|
<String>['test', 'plugin_e2e.dart'],
|
||||||
<String>['should_not_run_e2e.dart'],
|
<String>['should_not_run_e2e.dart'],
|
||||||
@ -168,7 +168,7 @@ void main() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('experimental flag', () async {
|
test('experimental flag', () async {
|
||||||
createFakePlugin('plugin', packagesDir, withExtraFiles: <List<String>>[
|
createFakePlugin('plugin', packagesDir, extraFiles: <List<String>>[
|
||||||
<String>['test', 'plugin_test.dart'],
|
<String>['test', 'plugin_test.dart'],
|
||||||
<String>['test', 'plugin_e2e.dart'],
|
<String>['test', 'plugin_e2e.dart'],
|
||||||
<String>['should_not_run_e2e.dart'],
|
<String>['should_not_run_e2e.dart'],
|
||||||
|
@ -5,6 +5,8 @@
|
|||||||
import 'package:args/command_runner.dart';
|
import 'package:args/command_runner.dart';
|
||||||
import 'package:file/file.dart';
|
import 'package:file/file.dart';
|
||||||
import 'package:file/memory.dart';
|
import 'package:file/memory.dart';
|
||||||
|
import 'package:flutter_plugin_tools/src/common/core.dart';
|
||||||
|
import 'package:flutter_plugin_tools/src/common/plugin_utils.dart';
|
||||||
import 'package:flutter_plugin_tools/src/java_test_command.dart';
|
import 'package:flutter_plugin_tools/src/java_test_command.dart';
|
||||||
import 'package:path/path.dart' as p;
|
import 'package:path/path.dart' as p;
|
||||||
import 'package:test/test.dart';
|
import 'package:test/test.dart';
|
||||||
@ -34,10 +36,10 @@ void main() {
|
|||||||
final Directory plugin = createFakePlugin(
|
final Directory plugin = createFakePlugin(
|
||||||
'plugin1',
|
'plugin1',
|
||||||
packagesDir,
|
packagesDir,
|
||||||
isAndroidPlugin: true,
|
platformSupport: <String, PlatformSupport>{
|
||||||
isFlutter: true,
|
kPlatformAndroid: PlatformSupport.inline
|
||||||
withSingleExample: true,
|
},
|
||||||
withExtraFiles: <List<String>>[
|
extraFiles: <List<String>>[
|
||||||
<String>['example/android', 'gradlew'],
|
<String>['example/android', 'gradlew'],
|
||||||
<String>['android/src/test', 'example_test.java'],
|
<String>['android/src/test', 'example_test.java'],
|
||||||
],
|
],
|
||||||
@ -61,10 +63,10 @@ void main() {
|
|||||||
final Directory plugin = createFakePlugin(
|
final Directory plugin = createFakePlugin(
|
||||||
'plugin1',
|
'plugin1',
|
||||||
packagesDir,
|
packagesDir,
|
||||||
isAndroidPlugin: true,
|
platformSupport: <String, PlatformSupport>{
|
||||||
isFlutter: true,
|
kPlatformAndroid: PlatformSupport.inline
|
||||||
withSingleExample: true,
|
},
|
||||||
withExtraFiles: <List<String>>[
|
extraFiles: <List<String>>[
|
||||||
<String>['example/android', 'gradlew'],
|
<String>['example/android', 'gradlew'],
|
||||||
<String>['example/android/app/src/test', 'example_test.java'],
|
<String>['example/android/app/src/test', 'example_test.java'],
|
||||||
],
|
],
|
||||||
|
@ -45,7 +45,7 @@ void main() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('only runs on macOS', () async {
|
test('only runs on macOS', () async {
|
||||||
createFakePlugin('plugin1', packagesDir, withExtraFiles: <List<String>>[
|
createFakePlugin('plugin1', packagesDir, extraFiles: <List<String>>[
|
||||||
<String>['plugin1.podspec'],
|
<String>['plugin1.podspec'],
|
||||||
]);
|
]);
|
||||||
|
|
||||||
@ -59,11 +59,11 @@ void main() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('runs pod lib lint on a podspec', () async {
|
test('runs pod lib lint on a podspec', () async {
|
||||||
final Directory plugin1Dir = createFakePlugin('plugin1', packagesDir,
|
final Directory plugin1Dir =
|
||||||
withExtraFiles: <List<String>>[
|
createFakePlugin('plugin1', packagesDir, extraFiles: <List<String>>[
|
||||||
<String>['ios', 'plugin1.podspec'],
|
<String>['ios', 'plugin1.podspec'],
|
||||||
<String>['bogus.dart'], // Ignore non-podspecs.
|
<String>['bogus.dart'], // Ignore non-podspecs.
|
||||||
]);
|
]);
|
||||||
|
|
||||||
processRunner.resultStdout = 'Foo';
|
processRunner.resultStdout = 'Foo';
|
||||||
processRunner.resultStderr = 'Bar';
|
processRunner.resultStderr = 'Bar';
|
||||||
@ -106,10 +106,10 @@ void main() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('skips podspecs with known issues', () async {
|
test('skips podspecs with known issues', () async {
|
||||||
createFakePlugin('plugin1', packagesDir, withExtraFiles: <List<String>>[
|
createFakePlugin('plugin1', packagesDir, extraFiles: <List<String>>[
|
||||||
<String>['plugin1.podspec']
|
<String>['plugin1.podspec']
|
||||||
]);
|
]);
|
||||||
createFakePlugin('plugin2', packagesDir, withExtraFiles: <List<String>>[
|
createFakePlugin('plugin2', packagesDir, extraFiles: <List<String>>[
|
||||||
<String>['plugin2.podspec']
|
<String>['plugin2.podspec']
|
||||||
]);
|
]);
|
||||||
|
|
||||||
@ -125,10 +125,10 @@ void main() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('allow warnings for podspecs with known warnings', () async {
|
test('allow warnings for podspecs with known warnings', () async {
|
||||||
final Directory plugin1Dir = createFakePlugin('plugin1', packagesDir,
|
final Directory plugin1Dir =
|
||||||
withExtraFiles: <List<String>>[
|
createFakePlugin('plugin1', packagesDir, extraFiles: <List<String>>[
|
||||||
<String>['plugin1.podspec'],
|
<String>['plugin1.podspec'],
|
||||||
]);
|
]);
|
||||||
|
|
||||||
await runner.run(<String>['podspecs', '--ignore-warnings=plugin1']);
|
await runner.run(<String>['podspecs', '--ignore-warnings=plugin1']);
|
||||||
|
|
||||||
|
@ -42,10 +42,10 @@ void main() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('lists examples', () async {
|
test('lists examples', () async {
|
||||||
createFakePlugin('plugin1', packagesDir, withSingleExample: true);
|
createFakePlugin('plugin1', packagesDir);
|
||||||
createFakePlugin('plugin2', packagesDir,
|
createFakePlugin('plugin2', packagesDir,
|
||||||
withExamples: <String>['example1', 'example2']);
|
examples: <String>['example1', 'example2']);
|
||||||
createFakePlugin('plugin3', packagesDir);
|
createFakePlugin('plugin3', packagesDir, examples: <String>[]);
|
||||||
|
|
||||||
final List<String> examples =
|
final List<String> examples =
|
||||||
await runCapturingPrint(runner, <String>['list', '--type=example']);
|
await runCapturingPrint(runner, <String>['list', '--type=example']);
|
||||||
@ -61,10 +61,10 @@ void main() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('lists packages', () async {
|
test('lists packages', () async {
|
||||||
createFakePlugin('plugin1', packagesDir, withSingleExample: true);
|
createFakePlugin('plugin1', packagesDir);
|
||||||
createFakePlugin('plugin2', packagesDir,
|
createFakePlugin('plugin2', packagesDir,
|
||||||
withExamples: <String>['example1', 'example2']);
|
examples: <String>['example1', 'example2']);
|
||||||
createFakePlugin('plugin3', packagesDir);
|
createFakePlugin('plugin3', packagesDir, examples: <String>[]);
|
||||||
|
|
||||||
final List<String> packages =
|
final List<String> packages =
|
||||||
await runCapturingPrint(runner, <String>['list', '--type=package']);
|
await runCapturingPrint(runner, <String>['list', '--type=package']);
|
||||||
@ -83,10 +83,10 @@ void main() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('lists files', () async {
|
test('lists files', () async {
|
||||||
createFakePlugin('plugin1', packagesDir, withSingleExample: true);
|
createFakePlugin('plugin1', packagesDir);
|
||||||
createFakePlugin('plugin2', packagesDir,
|
createFakePlugin('plugin2', packagesDir,
|
||||||
withExamples: <String>['example1', 'example2']);
|
examples: <String>['example1', 'example2']);
|
||||||
createFakePlugin('plugin3', packagesDir);
|
createFakePlugin('plugin3', packagesDir, examples: <String>[]);
|
||||||
|
|
||||||
final List<String> examples =
|
final List<String> examples =
|
||||||
await runCapturingPrint(runner, <String>['list', '--type=file']);
|
await runCapturingPrint(runner, <String>['list', '--type=file']);
|
||||||
@ -95,11 +95,14 @@ void main() {
|
|||||||
examples,
|
examples,
|
||||||
unorderedEquals(<String>[
|
unorderedEquals(<String>[
|
||||||
'/packages/plugin1/pubspec.yaml',
|
'/packages/plugin1/pubspec.yaml',
|
||||||
|
'/packages/plugin1/CHANGELOG.md',
|
||||||
'/packages/plugin1/example/pubspec.yaml',
|
'/packages/plugin1/example/pubspec.yaml',
|
||||||
'/packages/plugin2/pubspec.yaml',
|
'/packages/plugin2/pubspec.yaml',
|
||||||
|
'/packages/plugin2/CHANGELOG.md',
|
||||||
'/packages/plugin2/example/example1/pubspec.yaml',
|
'/packages/plugin2/example/example1/pubspec.yaml',
|
||||||
'/packages/plugin2/example/example2/pubspec.yaml',
|
'/packages/plugin2/example/example2/pubspec.yaml',
|
||||||
'/packages/plugin3/pubspec.yaml',
|
'/packages/plugin3/pubspec.yaml',
|
||||||
|
'/packages/plugin3/CHANGELOG.md',
|
||||||
]),
|
]),
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
@ -40,8 +40,10 @@ void main() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('publish check all packages', () async {
|
test('publish check all packages', () async {
|
||||||
final Directory plugin1Dir = createFakePlugin('a', packagesDir);
|
final Directory plugin1Dir =
|
||||||
final Directory plugin2Dir = createFakePlugin('b', packagesDir);
|
createFakePlugin('plugin_tools_test_package_a', packagesDir);
|
||||||
|
final Directory plugin2Dir =
|
||||||
|
createFakePlugin('plugin_tools_test_package_b', packagesDir);
|
||||||
|
|
||||||
processRunner.processesToReturn.add(
|
processRunner.processesToReturn.add(
|
||||||
MockProcess()..exitCodeCompleter.complete(0),
|
MockProcess()..exitCodeCompleter.complete(0),
|
||||||
@ -66,7 +68,7 @@ void main() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('fail on negative test', () async {
|
test('fail on negative test', () async {
|
||||||
createFakePlugin('a', packagesDir);
|
createFakePlugin('plugin_tools_test_package_a', packagesDir);
|
||||||
|
|
||||||
final MockProcess process = MockProcess();
|
final MockProcess process = MockProcess();
|
||||||
process.stdoutController.close(); // ignore: unawaited_futures
|
process.stdoutController.close(); // ignore: unawaited_futures
|
||||||
@ -186,13 +188,8 @@ void main() {
|
|||||||
);
|
);
|
||||||
runner.addCommand(command);
|
runner.addCommand(command);
|
||||||
|
|
||||||
final Directory plugin1Dir =
|
createFakePlugin('no_publish_a', packagesDir, version: '0.1.0');
|
||||||
createFakePlugin('no_publish_a', packagesDir, includeVersion: true);
|
createFakePlugin('no_publish_b', packagesDir, version: '0.2.0');
|
||||||
final Directory plugin2Dir =
|
|
||||||
createFakePlugin('no_publish_b', packagesDir, includeVersion: true);
|
|
||||||
|
|
||||||
createFakePubspec(plugin1Dir, name: 'no_publish_a', version: '0.1.0');
|
|
||||||
createFakePubspec(plugin2Dir, name: 'no_publish_b', version: '0.2.0');
|
|
||||||
|
|
||||||
processRunner.processesToReturn.add(
|
processRunner.processesToReturn.add(
|
||||||
MockProcess()..exitCodeCompleter.complete(0),
|
MockProcess()..exitCodeCompleter.complete(0),
|
||||||
@ -250,13 +247,8 @@ void main() {
|
|||||||
);
|
);
|
||||||
runner.addCommand(command);
|
runner.addCommand(command);
|
||||||
|
|
||||||
final Directory plugin1Dir =
|
createFakePlugin('no_publish_a', packagesDir, version: '0.1.0');
|
||||||
createFakePlugin('no_publish_a', packagesDir, includeVersion: true);
|
createFakePlugin('no_publish_b', packagesDir, version: '0.2.0');
|
||||||
final Directory plugin2Dir =
|
|
||||||
createFakePlugin('no_publish_b', packagesDir, includeVersion: true);
|
|
||||||
|
|
||||||
createFakePubspec(plugin1Dir, name: 'no_publish_a', version: '0.1.0');
|
|
||||||
createFakePubspec(plugin2Dir, name: 'no_publish_b', version: '0.2.0');
|
|
||||||
|
|
||||||
processRunner.processesToReturn.add(
|
processRunner.processesToReturn.add(
|
||||||
MockProcess()..exitCodeCompleter.complete(0),
|
MockProcess()..exitCodeCompleter.complete(0),
|
||||||
@ -318,12 +310,9 @@ void main() {
|
|||||||
runner.addCommand(command);
|
runner.addCommand(command);
|
||||||
|
|
||||||
final Directory plugin1Dir =
|
final Directory plugin1Dir =
|
||||||
createFakePlugin('no_publish_a', packagesDir, includeVersion: true);
|
createFakePlugin('no_publish_a', packagesDir, version: '0.1.0');
|
||||||
final Directory plugin2Dir =
|
createFakePlugin('no_publish_b', packagesDir, version: '0.2.0');
|
||||||
createFakePlugin('no_publish_b', packagesDir, includeVersion: true);
|
|
||||||
|
|
||||||
createFakePubspec(plugin1Dir, name: 'no_publish_a', version: '0.1.0');
|
|
||||||
createFakePubspec(plugin2Dir, name: 'no_publish_b', version: '0.2.0');
|
|
||||||
await plugin1Dir.childFile('pubspec.yaml').writeAsString('bad-yaml');
|
await plugin1Dir.childFile('pubspec.yaml').writeAsString('bad-yaml');
|
||||||
|
|
||||||
processRunner.processesToReturn.add(
|
processRunner.processesToReturn.add(
|
||||||
|
@ -50,9 +50,8 @@ void main() {
|
|||||||
testRoot = fileSystem.directory(testRoot.resolveSymbolicLinksSync());
|
testRoot = fileSystem.directory(testRoot.resolveSymbolicLinksSync());
|
||||||
packagesDir = createPackagesDirectory(parentDir: testRoot);
|
packagesDir = createPackagesDirectory(parentDir: testRoot);
|
||||||
pluginDir =
|
pluginDir =
|
||||||
createFakePlugin(testPluginName, packagesDir, withSingleExample: false);
|
createFakePlugin(testPluginName, packagesDir, examples: <String>[]);
|
||||||
assert(pluginDir != null && pluginDir.existsSync());
|
assert(pluginDir != null && pluginDir.existsSync());
|
||||||
createFakePubspec(pluginDir, version: '0.0.1');
|
|
||||||
io.Process.runSync('git', <String>['init'],
|
io.Process.runSync('git', <String>['init'],
|
||||||
workingDirectory: testRoot.path);
|
workingDirectory: testRoot.path);
|
||||||
gitDir = await GitDir.fromExisting(testRoot.path);
|
gitDir = await GitDir.fromExisting(testRoot.path);
|
||||||
@ -138,7 +137,8 @@ void main() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('can publish non-flutter package', () async {
|
test('can publish non-flutter package', () async {
|
||||||
createFakePubspec(pluginDir, version: '0.0.1', isFlutter: false);
|
const String packageName = 'a_package';
|
||||||
|
createFakePackage(packageName, packagesDir);
|
||||||
io.Process.runSync('git', <String>['init'],
|
io.Process.runSync('git', <String>['init'],
|
||||||
workingDirectory: testRoot.path);
|
workingDirectory: testRoot.path);
|
||||||
gitDir = await GitDir.fromExisting(testRoot.path);
|
gitDir = await GitDir.fromExisting(testRoot.path);
|
||||||
@ -149,7 +149,7 @@ void main() {
|
|||||||
await commandRunner.run(<String>[
|
await commandRunner.run(<String>[
|
||||||
'publish-plugin',
|
'publish-plugin',
|
||||||
'--package',
|
'--package',
|
||||||
testPluginName,
|
packageName,
|
||||||
'--no-push-tags',
|
'--no-push-tags',
|
||||||
'--no-tag-release'
|
'--no-tag-release'
|
||||||
]);
|
]);
|
||||||
@ -284,9 +284,9 @@ void main() {
|
|||||||
'--no-push-tags',
|
'--no-push-tags',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
final String? tag =
|
final String? tag = (await gitDir
|
||||||
(await gitDir.runCommand(<String>['show-ref', 'fake_package-v0.0.1']))
|
.runCommand(<String>['show-ref', '$testPluginName-v0.0.1']))
|
||||||
.stdout as String?;
|
.stdout as String?;
|
||||||
expect(tag, isNotEmpty);
|
expect(tag, isNotEmpty);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -303,7 +303,7 @@ void main() {
|
|||||||
|
|
||||||
expect(printedMessages, contains('Publish foo failed.'));
|
expect(printedMessages, contains('Publish foo failed.'));
|
||||||
final String? tag = (await gitDir.runCommand(
|
final String? tag = (await gitDir.runCommand(
|
||||||
<String>['show-ref', 'fake_package-v0.0.1'],
|
<String>['show-ref', '$testPluginName-v0.0.1'],
|
||||||
throwOnError: false))
|
throwOnError: false))
|
||||||
.stdout as String?;
|
.stdout as String?;
|
||||||
expect(tag, isEmpty);
|
expect(tag, isEmpty);
|
||||||
@ -342,7 +342,7 @@ void main() {
|
|||||||
|
|
||||||
expect(processRunner.pushTagsArgs.isNotEmpty, isTrue);
|
expect(processRunner.pushTagsArgs.isNotEmpty, isTrue);
|
||||||
expect(processRunner.pushTagsArgs[1], 'upstream');
|
expect(processRunner.pushTagsArgs[1], 'upstream');
|
||||||
expect(processRunner.pushTagsArgs[2], 'fake_package-v0.0.1');
|
expect(processRunner.pushTagsArgs[2], '$testPluginName-v0.0.1');
|
||||||
expect(printedMessages.last, 'Done!');
|
expect(printedMessages.last, 'Done!');
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -360,7 +360,7 @@ void main() {
|
|||||||
|
|
||||||
expect(processRunner.pushTagsArgs.isNotEmpty, isTrue);
|
expect(processRunner.pushTagsArgs.isNotEmpty, isTrue);
|
||||||
expect(processRunner.pushTagsArgs[1], 'upstream');
|
expect(processRunner.pushTagsArgs[1], 'upstream');
|
||||||
expect(processRunner.pushTagsArgs[2], 'fake_package-v0.0.1');
|
expect(processRunner.pushTagsArgs[2], '$testPluginName-v0.0.1');
|
||||||
expect(printedMessages.last, 'Done!');
|
expect(printedMessages.last, 'Done!');
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -378,7 +378,7 @@ void main() {
|
|||||||
containsAllInOrder(<String>[
|
containsAllInOrder(<String>[
|
||||||
'=============== DRY RUN ===============',
|
'=============== DRY RUN ===============',
|
||||||
'Running `pub publish ` in ${pluginDir.path}...\n',
|
'Running `pub publish ` in ${pluginDir.path}...\n',
|
||||||
'Tagging release fake_package-v0.0.1...',
|
'Tagging release $testPluginName-v0.0.1...',
|
||||||
'Pushing tag to upstream...',
|
'Pushing tag to upstream...',
|
||||||
'Done!'
|
'Done!'
|
||||||
]));
|
]));
|
||||||
@ -399,7 +399,7 @@ void main() {
|
|||||||
|
|
||||||
expect(processRunner.pushTagsArgs.isNotEmpty, isTrue);
|
expect(processRunner.pushTagsArgs.isNotEmpty, isTrue);
|
||||||
expect(processRunner.pushTagsArgs[1], 'origin');
|
expect(processRunner.pushTagsArgs[1], 'origin');
|
||||||
expect(processRunner.pushTagsArgs[2], 'fake_package-v0.0.1');
|
expect(processRunner.pushTagsArgs[2], '$testPluginName-v0.0.1');
|
||||||
expect(printedMessages.last, 'Done!');
|
expect(printedMessages.last, 'Done!');
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -428,15 +428,12 @@ void main() {
|
|||||||
|
|
||||||
test('can release newly created plugins', () async {
|
test('can release newly created plugins', () async {
|
||||||
// Non-federated
|
// Non-federated
|
||||||
final Directory pluginDir1 =
|
final Directory pluginDir1 = createFakePlugin('plugin1', packagesDir);
|
||||||
createFakePlugin('plugin1', packagesDir, withSingleExample: true);
|
|
||||||
// federated
|
// federated
|
||||||
final Directory pluginDir2 = createFakePlugin('plugin2', packagesDir,
|
final Directory pluginDir2 = createFakePlugin(
|
||||||
withSingleExample: true, parentDirectoryName: 'plugin2');
|
'plugin2',
|
||||||
createFakePubspec(pluginDir1,
|
packagesDir.childDirectory('plugin2'),
|
||||||
name: 'plugin1', isFlutter: false, version: '0.0.1');
|
);
|
||||||
createFakePubspec(pluginDir2,
|
|
||||||
name: 'plugin2', isFlutter: false, version: '0.0.1');
|
|
||||||
await gitDir.runCommand(<String>['add', '-A']);
|
await gitDir.runCommand(<String>['add', '-A']);
|
||||||
await gitDir.runCommand(<String>['commit', '-m', 'Add plugins']);
|
await gitDir.runCommand(<String>['commit', '-m', 'Add plugins']);
|
||||||
// Immediately return 0 when running `pub publish`.
|
// Immediately return 0 when running `pub publish`.
|
||||||
@ -467,10 +464,7 @@ void main() {
|
|||||||
test('can release newly created plugins, while there are existing plugins',
|
test('can release newly created plugins, while there are existing plugins',
|
||||||
() async {
|
() async {
|
||||||
// Prepare an exiting plugin and tag it
|
// Prepare an exiting plugin and tag it
|
||||||
final Directory pluginDir0 =
|
createFakePlugin('plugin0', packagesDir);
|
||||||
createFakePlugin('plugin0', packagesDir, withSingleExample: true);
|
|
||||||
createFakePubspec(pluginDir0,
|
|
||||||
name: 'plugin0', isFlutter: false, version: '0.0.1');
|
|
||||||
await gitDir.runCommand(<String>['add', '-A']);
|
await gitDir.runCommand(<String>['add', '-A']);
|
||||||
await gitDir.runCommand(<String>['commit', '-m', 'Add plugins']);
|
await gitDir.runCommand(<String>['commit', '-m', 'Add plugins']);
|
||||||
// Immediately return 0 when running `pub publish`.
|
// Immediately return 0 when running `pub publish`.
|
||||||
@ -481,15 +475,10 @@ void main() {
|
|||||||
processRunner.pushTagsArgs.clear();
|
processRunner.pushTagsArgs.clear();
|
||||||
|
|
||||||
// Non-federated
|
// Non-federated
|
||||||
final Directory pluginDir1 =
|
final Directory pluginDir1 = createFakePlugin('plugin1', packagesDir);
|
||||||
createFakePlugin('plugin1', packagesDir, withSingleExample: true);
|
|
||||||
// federated
|
// federated
|
||||||
final Directory pluginDir2 = createFakePlugin('plugin2', packagesDir,
|
final Directory pluginDir2 =
|
||||||
withSingleExample: true, parentDirectoryName: 'plugin2');
|
createFakePlugin('plugin2', packagesDir.childDirectory('plugin2'));
|
||||||
createFakePubspec(pluginDir1,
|
|
||||||
name: 'plugin1', isFlutter: false, version: '0.0.1');
|
|
||||||
createFakePubspec(pluginDir2,
|
|
||||||
name: 'plugin2', isFlutter: false, version: '0.0.1');
|
|
||||||
await gitDir.runCommand(<String>['add', '-A']);
|
await gitDir.runCommand(<String>['add', '-A']);
|
||||||
await gitDir.runCommand(<String>['commit', '-m', 'Add plugins']);
|
await gitDir.runCommand(<String>['commit', '-m', 'Add plugins']);
|
||||||
// Immediately return 0 when running `pub publish`.
|
// Immediately return 0 when running `pub publish`.
|
||||||
@ -517,15 +506,10 @@ void main() {
|
|||||||
|
|
||||||
test('can release newly created plugins, dry run', () async {
|
test('can release newly created plugins, dry run', () async {
|
||||||
// Non-federated
|
// Non-federated
|
||||||
final Directory pluginDir1 =
|
final Directory pluginDir1 = createFakePlugin('plugin1', packagesDir);
|
||||||
createFakePlugin('plugin1', packagesDir, withSingleExample: true);
|
|
||||||
// federated
|
// federated
|
||||||
final Directory pluginDir2 = createFakePlugin('plugin2', packagesDir,
|
final Directory pluginDir2 =
|
||||||
withSingleExample: true, parentDirectoryName: 'plugin2');
|
createFakePlugin('plugin2', packagesDir.childDirectory('plugin2'));
|
||||||
createFakePubspec(pluginDir1,
|
|
||||||
name: 'plugin1', isFlutter: false, version: '0.0.1');
|
|
||||||
createFakePubspec(pluginDir2,
|
|
||||||
name: 'plugin2', isFlutter: false, version: '0.0.1');
|
|
||||||
await gitDir.runCommand(<String>['add', '-A']);
|
await gitDir.runCommand(<String>['add', '-A']);
|
||||||
await gitDir.runCommand(<String>['commit', '-m', 'Add plugins']);
|
await gitDir.runCommand(<String>['commit', '-m', 'Add plugins']);
|
||||||
// Immediately return 1 when running `pub publish`. If dry-run does not work, test should throw.
|
// Immediately return 1 when running `pub publish`. If dry-run does not work, test should throw.
|
||||||
@ -558,15 +542,10 @@ void main() {
|
|||||||
|
|
||||||
test('version change triggers releases.', () async {
|
test('version change triggers releases.', () async {
|
||||||
// Non-federated
|
// Non-federated
|
||||||
final Directory pluginDir1 =
|
final Directory pluginDir1 = createFakePlugin('plugin1', packagesDir);
|
||||||
createFakePlugin('plugin1', packagesDir, withSingleExample: true);
|
|
||||||
// federated
|
// federated
|
||||||
final Directory pluginDir2 = createFakePlugin('plugin2', packagesDir,
|
final Directory pluginDir2 =
|
||||||
withSingleExample: true, parentDirectoryName: 'plugin2');
|
createFakePlugin('plugin2', packagesDir.childDirectory('plugin2'));
|
||||||
createFakePubspec(pluginDir1,
|
|
||||||
name: 'plugin1', isFlutter: false, version: '0.0.1');
|
|
||||||
createFakePubspec(pluginDir2,
|
|
||||||
name: 'plugin2', isFlutter: false, version: '0.0.1');
|
|
||||||
await gitDir.runCommand(<String>['add', '-A']);
|
await gitDir.runCommand(<String>['add', '-A']);
|
||||||
await gitDir.runCommand(<String>['commit', '-m', 'Add plugins']);
|
await gitDir.runCommand(<String>['commit', '-m', 'Add plugins']);
|
||||||
// Immediately return 0 when running `pub publish`.
|
// Immediately return 0 when running `pub publish`.
|
||||||
@ -641,15 +620,10 @@ void main() {
|
|||||||
'delete package will not trigger publish but exit the command successfully.',
|
'delete package will not trigger publish but exit the command successfully.',
|
||||||
() async {
|
() async {
|
||||||
// Non-federated
|
// Non-federated
|
||||||
final Directory pluginDir1 =
|
final Directory pluginDir1 = createFakePlugin('plugin1', packagesDir);
|
||||||
createFakePlugin('plugin1', packagesDir, withSingleExample: true);
|
|
||||||
// federated
|
// federated
|
||||||
final Directory pluginDir2 = createFakePlugin('plugin2', packagesDir,
|
final Directory pluginDir2 =
|
||||||
withSingleExample: true, parentDirectoryName: 'plugin2');
|
createFakePlugin('plugin2', packagesDir.childDirectory('plugin2'));
|
||||||
createFakePubspec(pluginDir1,
|
|
||||||
name: 'plugin1', isFlutter: false, version: '0.0.1');
|
|
||||||
createFakePubspec(pluginDir2,
|
|
||||||
name: 'plugin2', isFlutter: false, version: '0.0.1');
|
|
||||||
await gitDir.runCommand(<String>['add', '-A']);
|
await gitDir.runCommand(<String>['add', '-A']);
|
||||||
await gitDir.runCommand(<String>['commit', '-m', 'Add plugins']);
|
await gitDir.runCommand(<String>['commit', '-m', 'Add plugins']);
|
||||||
// Immediately return 0 when running `pub publish`.
|
// Immediately return 0 when running `pub publish`.
|
||||||
@ -722,14 +696,11 @@ void main() {
|
|||||||
() async {
|
() async {
|
||||||
// Non-federated
|
// Non-federated
|
||||||
final Directory pluginDir1 =
|
final Directory pluginDir1 =
|
||||||
createFakePlugin('plugin1', packagesDir, withSingleExample: true);
|
createFakePlugin('plugin1', packagesDir, version: '0.0.2');
|
||||||
// federated
|
// federated
|
||||||
final Directory pluginDir2 = createFakePlugin('plugin2', packagesDir,
|
final Directory pluginDir2 = createFakePlugin(
|
||||||
withSingleExample: true, parentDirectoryName: 'plugin2');
|
'plugin2', packagesDir.childDirectory('plugin2'),
|
||||||
createFakePubspec(pluginDir1,
|
version: '0.0.2');
|
||||||
name: 'plugin1', isFlutter: false, version: '0.0.2');
|
|
||||||
createFakePubspec(pluginDir2,
|
|
||||||
name: 'plugin2', isFlutter: false, version: '0.0.2');
|
|
||||||
await gitDir.runCommand(<String>['add', '-A']);
|
await gitDir.runCommand(<String>['add', '-A']);
|
||||||
await gitDir.runCommand(<String>['commit', '-m', 'Add plugins']);
|
await gitDir.runCommand(<String>['commit', '-m', 'Add plugins']);
|
||||||
// Immediately return 0 when running `pub publish`.
|
// Immediately return 0 when running `pub publish`.
|
||||||
@ -795,15 +766,10 @@ void main() {
|
|||||||
|
|
||||||
test('No version change does not release any plugins', () async {
|
test('No version change does not release any plugins', () async {
|
||||||
// Non-federated
|
// Non-federated
|
||||||
final Directory pluginDir1 =
|
final Directory pluginDir1 = createFakePlugin('plugin1', packagesDir);
|
||||||
createFakePlugin('plugin1', packagesDir, withSingleExample: true);
|
|
||||||
// federated
|
// federated
|
||||||
final Directory pluginDir2 = createFakePlugin('plugin2', packagesDir,
|
final Directory pluginDir2 =
|
||||||
withSingleExample: true, parentDirectoryName: 'plugin2');
|
createFakePlugin('plugin2', packagesDir.childDirectory('plugin2'));
|
||||||
createFakePubspec(pluginDir1,
|
|
||||||
name: 'plugin1', isFlutter: false, version: '0.0.1');
|
|
||||||
createFakePubspec(pluginDir2,
|
|
||||||
name: 'plugin2', isFlutter: false, version: '0.0.1');
|
|
||||||
|
|
||||||
io.Process.runSync('git', <String>['init'],
|
io.Process.runSync('git', <String>['init'],
|
||||||
workingDirectory: testRoot.path);
|
workingDirectory: testRoot.path);
|
||||||
|
@ -88,8 +88,7 @@ dev_dependencies:
|
|||||||
}
|
}
|
||||||
|
|
||||||
test('passes for a plugin following conventions', () async {
|
test('passes for a plugin following conventions', () async {
|
||||||
final Directory pluginDirectory =
|
final Directory pluginDirectory = createFakePlugin('plugin', packagesDir);
|
||||||
createFakePlugin('plugin', packagesDir, withSingleExample: true);
|
|
||||||
|
|
||||||
pluginDirectory.childFile('pubspec.yaml').writeAsStringSync('''
|
pluginDirectory.childFile('pubspec.yaml').writeAsStringSync('''
|
||||||
${headerSection('plugin', isPlugin: true)}
|
${headerSection('plugin', isPlugin: true)}
|
||||||
@ -114,8 +113,7 @@ ${devDependenciesSection()}
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('passes for a Flutter package following conventions', () async {
|
test('passes for a Flutter package following conventions', () async {
|
||||||
final Directory pluginDirectory =
|
final Directory pluginDirectory = createFakePlugin('plugin', packagesDir);
|
||||||
createFakePlugin('plugin', packagesDir, withSingleExample: true);
|
|
||||||
|
|
||||||
pluginDirectory.childFile('pubspec.yaml').writeAsStringSync('''
|
pluginDirectory.childFile('pubspec.yaml').writeAsStringSync('''
|
||||||
${headerSection('plugin')}
|
${headerSection('plugin')}
|
||||||
@ -163,8 +161,7 @@ ${dependenciesSection()}
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('fails when homepage is included', () async {
|
test('fails when homepage is included', () async {
|
||||||
final Directory pluginDirectory =
|
final Directory pluginDirectory = createFakePlugin('plugin', packagesDir);
|
||||||
createFakePlugin('plugin', packagesDir, withSingleExample: true);
|
|
||||||
|
|
||||||
pluginDirectory.childFile('pubspec.yaml').writeAsStringSync('''
|
pluginDirectory.childFile('pubspec.yaml').writeAsStringSync('''
|
||||||
${headerSection('plugin', isPlugin: true, includeHomepage: true)}
|
${headerSection('plugin', isPlugin: true, includeHomepage: true)}
|
||||||
@ -184,8 +181,7 @@ ${devDependenciesSection()}
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('fails when repository is missing', () async {
|
test('fails when repository is missing', () async {
|
||||||
final Directory pluginDirectory =
|
final Directory pluginDirectory = createFakePlugin('plugin', packagesDir);
|
||||||
createFakePlugin('plugin', packagesDir, withSingleExample: true);
|
|
||||||
|
|
||||||
pluginDirectory.childFile('pubspec.yaml').writeAsStringSync('''
|
pluginDirectory.childFile('pubspec.yaml').writeAsStringSync('''
|
||||||
${headerSection('plugin', isPlugin: true, includeRepository: false)}
|
${headerSection('plugin', isPlugin: true, includeRepository: false)}
|
||||||
@ -205,8 +201,7 @@ ${devDependenciesSection()}
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('fails when homepage is given instead of repository', () async {
|
test('fails when homepage is given instead of repository', () async {
|
||||||
final Directory pluginDirectory =
|
final Directory pluginDirectory = createFakePlugin('plugin', packagesDir);
|
||||||
createFakePlugin('plugin', packagesDir, withSingleExample: true);
|
|
||||||
|
|
||||||
pluginDirectory.childFile('pubspec.yaml').writeAsStringSync('''
|
pluginDirectory.childFile('pubspec.yaml').writeAsStringSync('''
|
||||||
${headerSection('plugin', isPlugin: true, includeHomepage: true, includeRepository: false)}
|
${headerSection('plugin', isPlugin: true, includeHomepage: true, includeRepository: false)}
|
||||||
@ -226,8 +221,7 @@ ${devDependenciesSection()}
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('fails when issue tracker is missing', () async {
|
test('fails when issue tracker is missing', () async {
|
||||||
final Directory pluginDirectory =
|
final Directory pluginDirectory = createFakePlugin('plugin', packagesDir);
|
||||||
createFakePlugin('plugin', packagesDir, withSingleExample: true);
|
|
||||||
|
|
||||||
pluginDirectory.childFile('pubspec.yaml').writeAsStringSync('''
|
pluginDirectory.childFile('pubspec.yaml').writeAsStringSync('''
|
||||||
${headerSection('plugin', isPlugin: true, includeIssueTracker: false)}
|
${headerSection('plugin', isPlugin: true, includeIssueTracker: false)}
|
||||||
@ -247,8 +241,7 @@ ${devDependenciesSection()}
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('fails when environment section is out of order', () async {
|
test('fails when environment section is out of order', () async {
|
||||||
final Directory pluginDirectory =
|
final Directory pluginDirectory = createFakePlugin('plugin', packagesDir);
|
||||||
createFakePlugin('plugin', packagesDir, withSingleExample: true);
|
|
||||||
|
|
||||||
pluginDirectory.childFile('pubspec.yaml').writeAsStringSync('''
|
pluginDirectory.childFile('pubspec.yaml').writeAsStringSync('''
|
||||||
${headerSection('plugin', isPlugin: true)}
|
${headerSection('plugin', isPlugin: true)}
|
||||||
@ -268,8 +261,7 @@ ${environmentSection()}
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('fails when flutter section is out of order', () async {
|
test('fails when flutter section is out of order', () async {
|
||||||
final Directory pluginDirectory =
|
final Directory pluginDirectory = createFakePlugin('plugin', packagesDir);
|
||||||
createFakePlugin('plugin', packagesDir, withSingleExample: true);
|
|
||||||
|
|
||||||
pluginDirectory.childFile('pubspec.yaml').writeAsStringSync('''
|
pluginDirectory.childFile('pubspec.yaml').writeAsStringSync('''
|
||||||
${headerSection('plugin', isPlugin: true)}
|
${headerSection('plugin', isPlugin: true)}
|
||||||
@ -289,8 +281,7 @@ ${devDependenciesSection()}
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('fails when dependencies section is out of order', () async {
|
test('fails when dependencies section is out of order', () async {
|
||||||
final Directory pluginDirectory =
|
final Directory pluginDirectory = createFakePlugin('plugin', packagesDir);
|
||||||
createFakePlugin('plugin', packagesDir, withSingleExample: true);
|
|
||||||
|
|
||||||
pluginDirectory.childFile('pubspec.yaml').writeAsStringSync('''
|
pluginDirectory.childFile('pubspec.yaml').writeAsStringSync('''
|
||||||
${headerSection('plugin', isPlugin: true)}
|
${headerSection('plugin', isPlugin: true)}
|
||||||
@ -310,8 +301,7 @@ ${dependenciesSection()}
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('fails when devDependencies section is out of order', () async {
|
test('fails when devDependencies section is out of order', () async {
|
||||||
final Directory pluginDirectory =
|
final Directory pluginDirectory = createFakePlugin('plugin', packagesDir);
|
||||||
createFakePlugin('plugin', packagesDir, withSingleExample: true);
|
|
||||||
|
|
||||||
pluginDirectory.childFile('pubspec.yaml').writeAsStringSync('''
|
pluginDirectory.childFile('pubspec.yaml').writeAsStringSync('''
|
||||||
${headerSection('plugin', isPlugin: true)}
|
${headerSection('plugin', isPlugin: true)}
|
||||||
|
@ -5,6 +5,8 @@
|
|||||||
import 'package:args/command_runner.dart';
|
import 'package:args/command_runner.dart';
|
||||||
import 'package:file/file.dart';
|
import 'package:file/file.dart';
|
||||||
import 'package:file/memory.dart';
|
import 'package:file/memory.dart';
|
||||||
|
import 'package:flutter_plugin_tools/src/common/core.dart';
|
||||||
|
import 'package:flutter_plugin_tools/src/common/plugin_utils.dart';
|
||||||
import 'package:flutter_plugin_tools/src/test_command.dart';
|
import 'package:flutter_plugin_tools/src/test_command.dart';
|
||||||
import 'package:test/test.dart';
|
import 'package:test/test.dart';
|
||||||
|
|
||||||
@ -29,14 +31,14 @@ void main() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('runs flutter test on each plugin', () async {
|
test('runs flutter test on each plugin', () async {
|
||||||
final Directory plugin1Dir = createFakePlugin('plugin1', packagesDir,
|
final Directory plugin1Dir =
|
||||||
withExtraFiles: <List<String>>[
|
createFakePlugin('plugin1', packagesDir, extraFiles: <List<String>>[
|
||||||
<String>['test', 'empty_test.dart'],
|
<String>['test', 'empty_test.dart'],
|
||||||
]);
|
]);
|
||||||
final Directory plugin2Dir = createFakePlugin('plugin2', packagesDir,
|
final Directory plugin2Dir =
|
||||||
withExtraFiles: <List<String>>[
|
createFakePlugin('plugin2', packagesDir, extraFiles: <List<String>>[
|
||||||
<String>['test', 'empty_test.dart'],
|
<String>['test', 'empty_test.dart'],
|
||||||
]);
|
]);
|
||||||
|
|
||||||
await runner.run(<String>['test']);
|
await runner.run(<String>['test']);
|
||||||
|
|
||||||
@ -53,10 +55,10 @@ void main() {
|
|||||||
|
|
||||||
test('skips testing plugins without test directory', () async {
|
test('skips testing plugins without test directory', () async {
|
||||||
createFakePlugin('plugin1', packagesDir);
|
createFakePlugin('plugin1', packagesDir);
|
||||||
final Directory plugin2Dir = createFakePlugin('plugin2', packagesDir,
|
final Directory plugin2Dir =
|
||||||
withExtraFiles: <List<String>>[
|
createFakePlugin('plugin2', packagesDir, extraFiles: <List<String>>[
|
||||||
<String>['test', 'empty_test.dart'],
|
<String>['test', 'empty_test.dart'],
|
||||||
]);
|
]);
|
||||||
|
|
||||||
await runner.run(<String>['test']);
|
await runner.run(<String>['test']);
|
||||||
|
|
||||||
@ -70,16 +72,14 @@ void main() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('runs pub run test on non-Flutter packages', () async {
|
test('runs pub run test on non-Flutter packages', () async {
|
||||||
final Directory plugin1Dir = createFakePlugin('plugin1', packagesDir,
|
final Directory pluginDir =
|
||||||
isFlutter: true,
|
createFakePlugin('a', packagesDir, extraFiles: <List<String>>[
|
||||||
withExtraFiles: <List<String>>[
|
<String>['test', 'empty_test.dart'],
|
||||||
<String>['test', 'empty_test.dart'],
|
]);
|
||||||
]);
|
final Directory packageDir =
|
||||||
final Directory plugin2Dir = createFakePlugin('plugin2', packagesDir,
|
createFakePackage('b', packagesDir, extraFiles: <List<String>>[
|
||||||
isFlutter: false,
|
<String>['test', 'empty_test.dart'],
|
||||||
withExtraFiles: <List<String>>[
|
]);
|
||||||
<String>['test', 'empty_test.dart'],
|
|
||||||
]);
|
|
||||||
|
|
||||||
await runner.run(<String>['test', '--enable-experiment=exp1']);
|
await runner.run(<String>['test', '--enable-experiment=exp1']);
|
||||||
|
|
||||||
@ -89,12 +89,12 @@ void main() {
|
|||||||
ProcessCall(
|
ProcessCall(
|
||||||
'flutter',
|
'flutter',
|
||||||
const <String>['test', '--color', '--enable-experiment=exp1'],
|
const <String>['test', '--color', '--enable-experiment=exp1'],
|
||||||
plugin1Dir.path),
|
pluginDir.path),
|
||||||
ProcessCall('dart', const <String>['pub', 'get'], plugin2Dir.path),
|
ProcessCall('dart', const <String>['pub', 'get'], packageDir.path),
|
||||||
ProcessCall(
|
ProcessCall(
|
||||||
'dart',
|
'dart',
|
||||||
const <String>['pub', 'run', '--enable-experiment=exp1', 'test'],
|
const <String>['pub', 'run', '--enable-experiment=exp1', 'test'],
|
||||||
plugin2Dir.path),
|
packageDir.path),
|
||||||
]),
|
]),
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
@ -103,11 +103,12 @@ void main() {
|
|||||||
final Directory pluginDir = createFakePlugin(
|
final Directory pluginDir = createFakePlugin(
|
||||||
'plugin',
|
'plugin',
|
||||||
packagesDir,
|
packagesDir,
|
||||||
withExtraFiles: <List<String>>[
|
extraFiles: <List<String>>[
|
||||||
<String>['test', 'empty_test.dart'],
|
<String>['test', 'empty_test.dart'],
|
||||||
],
|
],
|
||||||
isFlutter: true,
|
platformSupport: <String, PlatformSupport>{
|
||||||
isWebPlugin: true,
|
kPlatformWeb: PlatformSupport.inline,
|
||||||
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
await runner.run(<String>['test']);
|
await runner.run(<String>['test']);
|
||||||
@ -124,16 +125,14 @@ void main() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('enable-experiment flag', () async {
|
test('enable-experiment flag', () async {
|
||||||
final Directory plugin1Dir = createFakePlugin('plugin1', packagesDir,
|
final Directory pluginDir =
|
||||||
isFlutter: true,
|
createFakePlugin('a', packagesDir, extraFiles: <List<String>>[
|
||||||
withExtraFiles: <List<String>>[
|
<String>['test', 'empty_test.dart'],
|
||||||
<String>['test', 'empty_test.dart'],
|
]);
|
||||||
]);
|
final Directory packageDir =
|
||||||
final Directory plugin2Dir = createFakePlugin('plugin2', packagesDir,
|
createFakePackage('b', packagesDir, extraFiles: <List<String>>[
|
||||||
isFlutter: false,
|
<String>['test', 'empty_test.dart'],
|
||||||
withExtraFiles: <List<String>>[
|
]);
|
||||||
<String>['test', 'empty_test.dart'],
|
|
||||||
]);
|
|
||||||
|
|
||||||
await runner.run(<String>['test', '--enable-experiment=exp1']);
|
await runner.run(<String>['test', '--enable-experiment=exp1']);
|
||||||
|
|
||||||
@ -143,12 +142,12 @@ void main() {
|
|||||||
ProcessCall(
|
ProcessCall(
|
||||||
'flutter',
|
'flutter',
|
||||||
const <String>['test', '--color', '--enable-experiment=exp1'],
|
const <String>['test', '--color', '--enable-experiment=exp1'],
|
||||||
plugin1Dir.path),
|
pluginDir.path),
|
||||||
ProcessCall('dart', const <String>['pub', 'get'], plugin2Dir.path),
|
ProcessCall('dart', const <String>['pub', 'get'], packageDir.path),
|
||||||
ProcessCall(
|
ProcessCall(
|
||||||
'dart',
|
'dart',
|
||||||
const <String>['pub', 'run', '--enable-experiment=exp1', 'test'],
|
const <String>['pub', 'run', '--enable-experiment=exp1', 'test'],
|
||||||
plugin2Dir.path),
|
packageDir.path),
|
||||||
]),
|
]),
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
@ -9,6 +9,7 @@ import 'dart:io' as io;
|
|||||||
import 'package:args/command_runner.dart';
|
import 'package:args/command_runner.dart';
|
||||||
import 'package:file/file.dart';
|
import 'package:file/file.dart';
|
||||||
import 'package:file/memory.dart';
|
import 'package:file/memory.dart';
|
||||||
|
import 'package:flutter_plugin_tools/src/common/core.dart';
|
||||||
import 'package:flutter_plugin_tools/src/common/plugin_utils.dart';
|
import 'package:flutter_plugin_tools/src/common/plugin_utils.dart';
|
||||||
import 'package:flutter_plugin_tools/src/common/process_runner.dart';
|
import 'package:flutter_plugin_tools/src/common/process_runner.dart';
|
||||||
import 'package:meta/meta.dart';
|
import 'package:meta/meta.dart';
|
||||||
@ -32,70 +33,35 @@ Directory createPackagesDirectory(
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Creates a plugin package with the given [name] in [packagesDirectory].
|
/// Creates a plugin package with the given [name] in [packagesDirectory].
|
||||||
|
///
|
||||||
|
/// [platformSupport] is a map of platform string to the support details for
|
||||||
|
/// that platform.
|
||||||
Directory createFakePlugin(
|
Directory createFakePlugin(
|
||||||
String name,
|
String name,
|
||||||
Directory packagesDirectory, {
|
Directory parentDirectory, {
|
||||||
bool withSingleExample = false,
|
List<String> examples = const <String>['example'],
|
||||||
List<String> withExamples = const <String>[],
|
List<List<String>> extraFiles = const <List<String>>[],
|
||||||
List<List<String>> withExtraFiles = const <List<String>>[],
|
Map<String, PlatformSupport> platformSupport =
|
||||||
bool isFlutter = true,
|
const <String, PlatformSupport>{},
|
||||||
// TODO(stuartmorgan): Change these platform switches to support type enums.
|
String? version = '0.0.1',
|
||||||
bool isAndroidPlugin = false,
|
|
||||||
bool isIosPlugin = false,
|
|
||||||
bool isWebPlugin = false,
|
|
||||||
bool isLinuxPlugin = false,
|
|
||||||
bool isMacOsPlugin = false,
|
|
||||||
bool isWindowsPlugin = false,
|
|
||||||
bool includeChangeLog = false,
|
|
||||||
bool includeVersion = false,
|
|
||||||
String version = '0.0.1',
|
|
||||||
String parentDirectoryName = '',
|
|
||||||
}) {
|
}) {
|
||||||
assert(!(withSingleExample && withExamples.isNotEmpty),
|
final Directory pluginDirectory = createFakePackage(name, parentDirectory,
|
||||||
'cannot pass withSingleExample and withExamples simultaneously');
|
isFlutter: true,
|
||||||
|
examples: examples,
|
||||||
|
extraFiles: extraFiles,
|
||||||
|
version: version);
|
||||||
|
|
||||||
Directory parentDirectory = packagesDirectory;
|
createFakePubspec(
|
||||||
if (parentDirectoryName != '') {
|
pluginDirectory,
|
||||||
parentDirectory = parentDirectory.childDirectory(parentDirectoryName);
|
name: name,
|
||||||
}
|
isFlutter: true,
|
||||||
final Directory pluginDirectory = parentDirectory.childDirectory(name);
|
isPlugin: true,
|
||||||
pluginDirectory.createSync(recursive: true);
|
platformSupport: platformSupport,
|
||||||
|
version: version,
|
||||||
createFakePubspec(pluginDirectory,
|
);
|
||||||
name: name,
|
|
||||||
isFlutter: isFlutter,
|
|
||||||
androidSupport: isAndroidPlugin ? PlatformSupport.inline : null,
|
|
||||||
iosSupport: isIosPlugin ? PlatformSupport.inline : null,
|
|
||||||
webSupport: isWebPlugin ? PlatformSupport.inline : null,
|
|
||||||
linuxSupport: isLinuxPlugin ? PlatformSupport.inline : null,
|
|
||||||
macosSupport: isMacOsPlugin ? PlatformSupport.inline : null,
|
|
||||||
windowsSupport: isWindowsPlugin ? PlatformSupport.inline : null,
|
|
||||||
version: includeVersion ? version : null);
|
|
||||||
if (includeChangeLog) {
|
|
||||||
createFakeCHANGELOG(pluginDirectory, '''
|
|
||||||
## 0.0.1
|
|
||||||
* Some changes.
|
|
||||||
''');
|
|
||||||
}
|
|
||||||
|
|
||||||
if (withSingleExample) {
|
|
||||||
final Directory exampleDir = pluginDirectory.childDirectory('example')
|
|
||||||
..createSync();
|
|
||||||
createFakePubspec(exampleDir,
|
|
||||||
name: '${name}_example', isFlutter: isFlutter, publishTo: 'none');
|
|
||||||
} else if (withExamples.isNotEmpty) {
|
|
||||||
final Directory exampleDir = pluginDirectory.childDirectory('example')
|
|
||||||
..createSync();
|
|
||||||
for (final String example in withExamples) {
|
|
||||||
final Directory currentExample = exampleDir.childDirectory(example)
|
|
||||||
..createSync();
|
|
||||||
createFakePubspec(currentExample,
|
|
||||||
name: example, isFlutter: isFlutter, publishTo: 'none');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
final FileSystem fileSystem = pluginDirectory.fileSystem;
|
final FileSystem fileSystem = pluginDirectory.fileSystem;
|
||||||
for (final List<String> file in withExtraFiles) {
|
for (final List<String> file in extraFiles) {
|
||||||
final List<String> newFilePath = <String>[pluginDirectory.path, ...file];
|
final List<String> newFilePath = <String>[pluginDirectory.path, ...file];
|
||||||
final File newFile = fileSystem.file(fileSystem.path.joinAll(newFilePath));
|
final File newFile = fileSystem.file(fileSystem.path.joinAll(newFilePath));
|
||||||
newFile.createSync(recursive: true);
|
newFile.createSync(recursive: true);
|
||||||
@ -104,51 +70,88 @@ Directory createFakePlugin(
|
|||||||
return pluginDirectory;
|
return pluginDirectory;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Creates a plugin package with the given [name] in [packagesDirectory].
|
||||||
|
Directory createFakePackage(
|
||||||
|
String name,
|
||||||
|
Directory parentDirectory, {
|
||||||
|
List<String> examples = const <String>['example'],
|
||||||
|
List<List<String>> extraFiles = const <List<String>>[],
|
||||||
|
bool isFlutter = false,
|
||||||
|
String? version = '0.0.1',
|
||||||
|
}) {
|
||||||
|
final Directory packageDirectory = parentDirectory.childDirectory(name);
|
||||||
|
packageDirectory.createSync(recursive: true);
|
||||||
|
|
||||||
|
createFakePubspec(packageDirectory, name: name, isFlutter: isFlutter);
|
||||||
|
createFakeCHANGELOG(packageDirectory, '''
|
||||||
|
## $version
|
||||||
|
* Some changes.
|
||||||
|
''');
|
||||||
|
|
||||||
|
if (examples.length == 1) {
|
||||||
|
final Directory exampleDir = packageDirectory.childDirectory(examples.first)
|
||||||
|
..createSync();
|
||||||
|
createFakePubspec(exampleDir,
|
||||||
|
name: '${name}_example', isFlutter: isFlutter, publishTo: 'none');
|
||||||
|
} else if (examples.isNotEmpty) {
|
||||||
|
final Directory exampleDir = packageDirectory.childDirectory('example')
|
||||||
|
..createSync();
|
||||||
|
for (final String example in examples) {
|
||||||
|
final Directory currentExample = exampleDir.childDirectory(example)
|
||||||
|
..createSync();
|
||||||
|
createFakePubspec(currentExample,
|
||||||
|
name: example, isFlutter: isFlutter, publishTo: 'none');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
final FileSystem fileSystem = packageDirectory.fileSystem;
|
||||||
|
for (final List<String> file in extraFiles) {
|
||||||
|
final List<String> newFilePath = <String>[packageDirectory.path, ...file];
|
||||||
|
final File newFile = fileSystem.file(fileSystem.path.joinAll(newFilePath));
|
||||||
|
newFile.createSync(recursive: true);
|
||||||
|
}
|
||||||
|
|
||||||
|
return packageDirectory;
|
||||||
|
}
|
||||||
|
|
||||||
void createFakeCHANGELOG(Directory parent, String texts) {
|
void createFakeCHANGELOG(Directory parent, String texts) {
|
||||||
parent.childFile('CHANGELOG.md').createSync();
|
parent.childFile('CHANGELOG.md').createSync();
|
||||||
parent.childFile('CHANGELOG.md').writeAsStringSync(texts);
|
parent.childFile('CHANGELOG.md').writeAsStringSync(texts);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Creates a `pubspec.yaml` file with a flutter dependency.
|
/// Creates a `pubspec.yaml` file with a flutter dependency.
|
||||||
|
///
|
||||||
|
/// [platformSupport] is a map of platform string to the support details for
|
||||||
|
/// that platform. If empty, no `plugin` entry will be created unless `isPlugin`
|
||||||
|
/// is set to `true`.
|
||||||
void createFakePubspec(
|
void createFakePubspec(
|
||||||
Directory parent, {
|
Directory parent, {
|
||||||
String name = 'fake_package',
|
String name = 'fake_package',
|
||||||
bool isFlutter = true,
|
bool isFlutter = true,
|
||||||
PlatformSupport? androidSupport,
|
bool isPlugin = false,
|
||||||
PlatformSupport? iosSupport,
|
Map<String, PlatformSupport> platformSupport =
|
||||||
PlatformSupport? linuxSupport,
|
const <String, PlatformSupport>{},
|
||||||
PlatformSupport? macosSupport,
|
|
||||||
PlatformSupport? webSupport,
|
|
||||||
PlatformSupport? windowsSupport,
|
|
||||||
String publishTo = 'http://no_pub_server.com',
|
String publishTo = 'http://no_pub_server.com',
|
||||||
String? version,
|
String? version,
|
||||||
}) {
|
}) {
|
||||||
|
isPlugin |= platformSupport.isNotEmpty;
|
||||||
parent.childFile('pubspec.yaml').createSync();
|
parent.childFile('pubspec.yaml').createSync();
|
||||||
String yaml = '''
|
String yaml = '''
|
||||||
name: $name
|
name: $name
|
||||||
|
''';
|
||||||
|
if (isFlutter) {
|
||||||
|
if (isPlugin) {
|
||||||
|
yaml += '''
|
||||||
flutter:
|
flutter:
|
||||||
plugin:
|
plugin:
|
||||||
platforms:
|
platforms:
|
||||||
''';
|
''';
|
||||||
if (androidSupport != null) {
|
for (final MapEntry<String, PlatformSupport> platform
|
||||||
yaml += _pluginPlatformSection('android', androidSupport, name);
|
in platformSupport.entries) {
|
||||||
}
|
yaml += _pluginPlatformSection(platform.key, platform.value, name);
|
||||||
if (iosSupport != null) {
|
}
|
||||||
yaml += _pluginPlatformSection('ios', iosSupport, name);
|
}
|
||||||
}
|
|
||||||
if (webSupport != null) {
|
|
||||||
yaml += _pluginPlatformSection('web', webSupport, name);
|
|
||||||
}
|
|
||||||
if (linuxSupport != null) {
|
|
||||||
yaml += _pluginPlatformSection('linux', linuxSupport, name);
|
|
||||||
}
|
|
||||||
if (macosSupport != null) {
|
|
||||||
yaml += _pluginPlatformSection('macos', macosSupport, name);
|
|
||||||
}
|
|
||||||
if (windowsSupport != null) {
|
|
||||||
yaml += _pluginPlatformSection('windows', windowsSupport, name);
|
|
||||||
}
|
|
||||||
if (isFlutter) {
|
|
||||||
yaml += '''
|
yaml += '''
|
||||||
dependencies:
|
dependencies:
|
||||||
flutter:
|
flutter:
|
||||||
@ -177,34 +180,34 @@ String _pluginPlatformSection(
|
|||||||
''';
|
''';
|
||||||
}
|
}
|
||||||
switch (platform) {
|
switch (platform) {
|
||||||
case 'android':
|
case kPlatformAndroid:
|
||||||
return '''
|
return '''
|
||||||
android:
|
android:
|
||||||
package: io.flutter.plugins.fake
|
package: io.flutter.plugins.fake
|
||||||
pluginClass: FakePlugin
|
pluginClass: FakePlugin
|
||||||
''';
|
''';
|
||||||
case 'ios':
|
case kPlatformIos:
|
||||||
return '''
|
return '''
|
||||||
ios:
|
ios:
|
||||||
pluginClass: FLTFakePlugin
|
pluginClass: FLTFakePlugin
|
||||||
''';
|
''';
|
||||||
case 'linux':
|
case kPlatformLinux:
|
||||||
return '''
|
return '''
|
||||||
linux:
|
linux:
|
||||||
pluginClass: FakePlugin
|
pluginClass: FakePlugin
|
||||||
''';
|
''';
|
||||||
case 'macos':
|
case kPlatformMacos:
|
||||||
return '''
|
return '''
|
||||||
macos:
|
macos:
|
||||||
pluginClass: FakePlugin
|
pluginClass: FakePlugin
|
||||||
''';
|
''';
|
||||||
case 'web':
|
case kPlatformWeb:
|
||||||
return '''
|
return '''
|
||||||
web:
|
web:
|
||||||
pluginClass: FakePlugin
|
pluginClass: FakePlugin
|
||||||
fileName: ${packageName}_web.dart
|
fileName: ${packageName}_web.dart
|
||||||
''';
|
''';
|
||||||
case 'windows':
|
case kPlatformWindows:
|
||||||
return '''
|
return '''
|
||||||
windows:
|
windows:
|
||||||
pluginClass: FakePlugin
|
pluginClass: FakePlugin
|
||||||
|
@ -100,12 +100,12 @@ void main() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('allows valid version', () async {
|
test('allows valid version', () async {
|
||||||
createFakePlugin('plugin', packagesDir,
|
const String newVersion = '2.0.0';
|
||||||
includeChangeLog: true, includeVersion: true);
|
createFakePlugin('plugin', packagesDir, version: newVersion);
|
||||||
gitDiffResponse = 'packages/plugin/pubspec.yaml';
|
gitDiffResponse = 'packages/plugin/pubspec.yaml';
|
||||||
gitShowResponses = <String, String>{
|
gitShowResponses = <String, String>{
|
||||||
'master:packages/plugin/pubspec.yaml': 'version: 1.0.0',
|
'master:packages/plugin/pubspec.yaml': 'version: 1.0.0',
|
||||||
'HEAD:packages/plugin/pubspec.yaml': 'version: 2.0.0',
|
'HEAD:packages/plugin/pubspec.yaml': 'version: $newVersion',
|
||||||
};
|
};
|
||||||
final List<String> output = await runCapturingPrint(
|
final List<String> output = await runCapturingPrint(
|
||||||
runner, <String>['version-check', '--base-sha=master']);
|
runner, <String>['version-check', '--base-sha=master']);
|
||||||
@ -127,12 +127,12 @@ void main() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('denies invalid version', () async {
|
test('denies invalid version', () async {
|
||||||
createFakePlugin('plugin', packagesDir,
|
const String newVersion = '0.2.0';
|
||||||
includeChangeLog: true, includeVersion: true);
|
createFakePlugin('plugin', packagesDir, version: newVersion);
|
||||||
gitDiffResponse = 'packages/plugin/pubspec.yaml';
|
gitDiffResponse = 'packages/plugin/pubspec.yaml';
|
||||||
gitShowResponses = <String, String>{
|
gitShowResponses = <String, String>{
|
||||||
'master:packages/plugin/pubspec.yaml': 'version: 0.0.1',
|
'master:packages/plugin/pubspec.yaml': 'version: 0.0.1',
|
||||||
'HEAD:packages/plugin/pubspec.yaml': 'version: 0.2.0',
|
'HEAD:packages/plugin/pubspec.yaml': 'version: $newVersion',
|
||||||
};
|
};
|
||||||
final Future<List<String>> result = runCapturingPrint(
|
final Future<List<String>> result = runCapturingPrint(
|
||||||
runner, <String>['version-check', '--base-sha=master']);
|
runner, <String>['version-check', '--base-sha=master']);
|
||||||
@ -152,12 +152,12 @@ void main() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('allows valid version without explicit base-sha', () async {
|
test('allows valid version without explicit base-sha', () async {
|
||||||
createFakePlugin('plugin', packagesDir,
|
const String newVersion = '2.0.0';
|
||||||
includeChangeLog: true, includeVersion: true);
|
createFakePlugin('plugin', packagesDir, version: newVersion);
|
||||||
gitDiffResponse = 'packages/plugin/pubspec.yaml';
|
gitDiffResponse = 'packages/plugin/pubspec.yaml';
|
||||||
gitShowResponses = <String, String>{
|
gitShowResponses = <String, String>{
|
||||||
'abc123:packages/plugin/pubspec.yaml': 'version: 1.0.0',
|
'abc123:packages/plugin/pubspec.yaml': 'version: 1.0.0',
|
||||||
'HEAD:packages/plugin/pubspec.yaml': 'version: 2.0.0',
|
'HEAD:packages/plugin/pubspec.yaml': 'version: $newVersion',
|
||||||
};
|
};
|
||||||
final List<String> output =
|
final List<String> output =
|
||||||
await runCapturingPrint(runner, <String>['version-check']);
|
await runCapturingPrint(runner, <String>['version-check']);
|
||||||
@ -171,11 +171,11 @@ void main() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('allows valid version for new package.', () async {
|
test('allows valid version for new package.', () async {
|
||||||
createFakePlugin('plugin', packagesDir,
|
const String newVersion = '1.0.0';
|
||||||
includeChangeLog: true, includeVersion: true);
|
createFakePlugin('plugin', packagesDir, version: newVersion);
|
||||||
gitDiffResponse = 'packages/plugin/pubspec.yaml';
|
gitDiffResponse = 'packages/plugin/pubspec.yaml';
|
||||||
gitShowResponses = <String, String>{
|
gitShowResponses = <String, String>{
|
||||||
'HEAD:packages/plugin/pubspec.yaml': 'version: 1.0.0',
|
'HEAD:packages/plugin/pubspec.yaml': 'version: $newVersion',
|
||||||
};
|
};
|
||||||
final List<String> output =
|
final List<String> output =
|
||||||
await runCapturingPrint(runner, <String>['version-check']);
|
await runCapturingPrint(runner, <String>['version-check']);
|
||||||
@ -190,12 +190,12 @@ void main() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('allows likely reverts.', () async {
|
test('allows likely reverts.', () async {
|
||||||
createFakePlugin('plugin', packagesDir,
|
const String newVersion = '0.6.1';
|
||||||
includeChangeLog: true, includeVersion: true);
|
createFakePlugin('plugin', packagesDir, version: newVersion);
|
||||||
gitDiffResponse = 'packages/plugin/pubspec.yaml';
|
gitDiffResponse = 'packages/plugin/pubspec.yaml';
|
||||||
gitShowResponses = <String, String>{
|
gitShowResponses = <String, String>{
|
||||||
'abc123:packages/plugin/pubspec.yaml': 'version: 0.6.2',
|
'abc123:packages/plugin/pubspec.yaml': 'version: 0.6.2',
|
||||||
'HEAD:packages/plugin/pubspec.yaml': 'version: 0.6.1',
|
'HEAD:packages/plugin/pubspec.yaml': 'version: $newVersion',
|
||||||
};
|
};
|
||||||
final List<String> output =
|
final List<String> output =
|
||||||
await runCapturingPrint(runner, <String>['version-check']);
|
await runCapturingPrint(runner, <String>['version-check']);
|
||||||
@ -209,12 +209,12 @@ void main() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('denies lower version that could not be a simple revert', () async {
|
test('denies lower version that could not be a simple revert', () async {
|
||||||
createFakePlugin('plugin', packagesDir,
|
const String newVersion = '0.5.1';
|
||||||
includeChangeLog: true, includeVersion: true);
|
createFakePlugin('plugin', packagesDir, version: newVersion);
|
||||||
gitDiffResponse = 'packages/plugin/pubspec.yaml';
|
gitDiffResponse = 'packages/plugin/pubspec.yaml';
|
||||||
gitShowResponses = <String, String>{
|
gitShowResponses = <String, String>{
|
||||||
'abc123:packages/plugin/pubspec.yaml': 'version: 0.6.2',
|
'abc123:packages/plugin/pubspec.yaml': 'version: 0.6.2',
|
||||||
'HEAD:packages/plugin/pubspec.yaml': 'version: 0.5.1',
|
'HEAD:packages/plugin/pubspec.yaml': 'version: $newVersion',
|
||||||
};
|
};
|
||||||
final Future<List<String>> result =
|
final Future<List<String>> result =
|
||||||
runCapturingPrint(runner, <String>['version-check']);
|
runCapturingPrint(runner, <String>['version-check']);
|
||||||
@ -226,12 +226,12 @@ void main() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('denies invalid version without explicit base-sha', () async {
|
test('denies invalid version without explicit base-sha', () async {
|
||||||
createFakePlugin('plugin', packagesDir,
|
const String newVersion = '0.2.0';
|
||||||
includeChangeLog: true, includeVersion: true);
|
createFakePlugin('plugin', packagesDir, version: newVersion);
|
||||||
gitDiffResponse = 'packages/plugin/pubspec.yaml';
|
gitDiffResponse = 'packages/plugin/pubspec.yaml';
|
||||||
gitShowResponses = <String, String>{
|
gitShowResponses = <String, String>{
|
||||||
'abc123:packages/plugin/pubspec.yaml': 'version: 0.0.1',
|
'abc123:packages/plugin/pubspec.yaml': 'version: 0.0.1',
|
||||||
'HEAD:packages/plugin/pubspec.yaml': 'version: 0.2.0',
|
'HEAD:packages/plugin/pubspec.yaml': 'version: $newVersion',
|
||||||
};
|
};
|
||||||
final Future<List<String>> result =
|
final Future<List<String>> result =
|
||||||
runCapturingPrint(runner, <String>['version-check']);
|
runCapturingPrint(runner, <String>['version-check']);
|
||||||
@ -243,8 +243,8 @@ void main() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('gracefully handles missing pubspec.yaml', () async {
|
test('gracefully handles missing pubspec.yaml', () async {
|
||||||
final Directory pluginDir = createFakePlugin('plugin', packagesDir,
|
final Directory pluginDir =
|
||||||
includeChangeLog: true, includeVersion: true);
|
createFakePlugin('plugin', packagesDir, examples: <String>[]);
|
||||||
gitDiffResponse = 'packages/plugin/pubspec.yaml';
|
gitDiffResponse = 'packages/plugin/pubspec.yaml';
|
||||||
pluginDir.childFile('pubspec.yaml').deleteSync();
|
pluginDir.childFile('pubspec.yaml').deleteSync();
|
||||||
final List<String> output = await runCapturingPrint(
|
final List<String> output = await runCapturingPrint(
|
||||||
@ -265,14 +265,15 @@ void main() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('allows minor changes to platform interfaces', () async {
|
test('allows minor changes to platform interfaces', () async {
|
||||||
|
const String newVersion = '1.1.0';
|
||||||
createFakePlugin('plugin_platform_interface', packagesDir,
|
createFakePlugin('plugin_platform_interface', packagesDir,
|
||||||
includeChangeLog: true, includeVersion: true);
|
version: newVersion);
|
||||||
gitDiffResponse = 'packages/plugin_platform_interface/pubspec.yaml';
|
gitDiffResponse = 'packages/plugin_platform_interface/pubspec.yaml';
|
||||||
gitShowResponses = <String, String>{
|
gitShowResponses = <String, String>{
|
||||||
'master:packages/plugin_platform_interface/pubspec.yaml':
|
'master:packages/plugin_platform_interface/pubspec.yaml':
|
||||||
'version: 1.0.0',
|
'version: 1.0.0',
|
||||||
'HEAD:packages/plugin_platform_interface/pubspec.yaml':
|
'HEAD:packages/plugin_platform_interface/pubspec.yaml':
|
||||||
'version: 1.1.0',
|
'version: $newVersion',
|
||||||
};
|
};
|
||||||
final List<String> output = await runCapturingPrint(
|
final List<String> output = await runCapturingPrint(
|
||||||
runner, <String>['version-check', '--base-sha=master']);
|
runner, <String>['version-check', '--base-sha=master']);
|
||||||
@ -299,14 +300,15 @@ void main() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('disallows breaking changes to platform interfaces', () async {
|
test('disallows breaking changes to platform interfaces', () async {
|
||||||
|
const String newVersion = '2.0.0';
|
||||||
createFakePlugin('plugin_platform_interface', packagesDir,
|
createFakePlugin('plugin_platform_interface', packagesDir,
|
||||||
includeChangeLog: true, includeVersion: true);
|
version: newVersion);
|
||||||
gitDiffResponse = 'packages/plugin_platform_interface/pubspec.yaml';
|
gitDiffResponse = 'packages/plugin_platform_interface/pubspec.yaml';
|
||||||
gitShowResponses = <String, String>{
|
gitShowResponses = <String, String>{
|
||||||
'master:packages/plugin_platform_interface/pubspec.yaml':
|
'master:packages/plugin_platform_interface/pubspec.yaml':
|
||||||
'version: 1.0.0',
|
'version: 1.0.0',
|
||||||
'HEAD:packages/plugin_platform_interface/pubspec.yaml':
|
'HEAD:packages/plugin_platform_interface/pubspec.yaml':
|
||||||
'version: 2.0.0',
|
'version: $newVersion',
|
||||||
};
|
};
|
||||||
final Future<List<String>> output = runCapturingPrint(
|
final Future<List<String>> output = runCapturingPrint(
|
||||||
runner, <String>['version-check', '--base-sha=master']);
|
runner, <String>['version-check', '--base-sha=master']);
|
||||||
@ -332,16 +334,11 @@ void main() {
|
|||||||
|
|
||||||
test('Allow empty lines in front of the first version in CHANGELOG',
|
test('Allow empty lines in front of the first version in CHANGELOG',
|
||||||
() async {
|
() async {
|
||||||
final Directory pluginDirectory = createFakePlugin('plugin', packagesDir,
|
const String version = '1.0.1';
|
||||||
includeChangeLog: true, includeVersion: true);
|
final Directory pluginDirectory =
|
||||||
|
createFakePlugin('plugin', packagesDir, version: version);
|
||||||
createFakePubspec(pluginDirectory, isFlutter: true, version: '1.0.1');
|
|
||||||
const String changelog = '''
|
const String changelog = '''
|
||||||
|
## $version
|
||||||
|
|
||||||
|
|
||||||
## 1.0.1
|
|
||||||
|
|
||||||
* Some changes.
|
* Some changes.
|
||||||
''';
|
''';
|
||||||
createFakeCHANGELOG(pluginDirectory, changelog);
|
createFakeCHANGELOG(pluginDirectory, changelog);
|
||||||
@ -358,13 +355,10 @@ void main() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('Throws if versions in changelog and pubspec do not match', () async {
|
test('Throws if versions in changelog and pubspec do not match', () async {
|
||||||
final Directory pluginDirectory = createFakePlugin('plugin', packagesDir,
|
final Directory pluginDirectory =
|
||||||
includeChangeLog: true, includeVersion: true);
|
createFakePlugin('plugin', packagesDir, version: '1.0.1');
|
||||||
|
|
||||||
createFakePubspec(pluginDirectory, isFlutter: true, version: '1.0.1');
|
|
||||||
const String changelog = '''
|
const String changelog = '''
|
||||||
## 1.0.2
|
## 1.0.2
|
||||||
|
|
||||||
* Some changes.
|
* Some changes.
|
||||||
''';
|
''';
|
||||||
createFakeCHANGELOG(pluginDirectory, changelog);
|
createFakeCHANGELOG(pluginDirectory, changelog);
|
||||||
@ -392,13 +386,12 @@ The first version listed in CHANGELOG.md is 1.0.2.
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('Success if CHANGELOG and pubspec versions match', () async {
|
test('Success if CHANGELOG and pubspec versions match', () async {
|
||||||
final Directory pluginDirectory = createFakePlugin('plugin', packagesDir,
|
const String version = '1.0.1';
|
||||||
includeChangeLog: true, includeVersion: true);
|
final Directory pluginDirectory =
|
||||||
|
createFakePlugin('plugin', packagesDir, version: version);
|
||||||
|
|
||||||
createFakePubspec(pluginDirectory, isFlutter: true, version: '1.0.1');
|
|
||||||
const String changelog = '''
|
const String changelog = '''
|
||||||
## 1.0.1
|
## $version
|
||||||
|
|
||||||
* Some changes.
|
* Some changes.
|
||||||
''';
|
''';
|
||||||
createFakeCHANGELOG(pluginDirectory, changelog);
|
createFakeCHANGELOG(pluginDirectory, changelog);
|
||||||
@ -417,17 +410,13 @@ The first version listed in CHANGELOG.md is 1.0.2.
|
|||||||
test(
|
test(
|
||||||
'Fail if pubspec version only matches an older version listed in CHANGELOG',
|
'Fail if pubspec version only matches an older version listed in CHANGELOG',
|
||||||
() async {
|
() async {
|
||||||
final Directory pluginDirectory = createFakePlugin('plugin', packagesDir,
|
final Directory pluginDirectory =
|
||||||
includeChangeLog: true, includeVersion: true);
|
createFakePlugin('plugin', packagesDir, version: '1.0.0');
|
||||||
|
|
||||||
createFakePubspec(pluginDirectory, isFlutter: true, version: '1.0.0');
|
|
||||||
const String changelog = '''
|
const String changelog = '''
|
||||||
## 1.0.1
|
## 1.0.1
|
||||||
|
|
||||||
* Some changes.
|
* Some changes.
|
||||||
|
|
||||||
## 1.0.0
|
## 1.0.0
|
||||||
|
|
||||||
* Some other changes.
|
* Some other changes.
|
||||||
''';
|
''';
|
||||||
createFakeCHANGELOG(pluginDirectory, changelog);
|
createFakeCHANGELOG(pluginDirectory, changelog);
|
||||||
@ -458,17 +447,14 @@ The first version listed in CHANGELOG.md is 1.0.1.
|
|||||||
|
|
||||||
test('Allow NEXT as a placeholder for gathering CHANGELOG entries',
|
test('Allow NEXT as a placeholder for gathering CHANGELOG entries',
|
||||||
() async {
|
() async {
|
||||||
final Directory pluginDirectory = createFakePlugin('plugin', packagesDir,
|
const String version = '1.0.0';
|
||||||
includeChangeLog: true, includeVersion: true);
|
final Directory pluginDirectory =
|
||||||
|
createFakePlugin('plugin', packagesDir, version: version);
|
||||||
|
|
||||||
createFakePubspec(pluginDirectory, isFlutter: true, version: '1.0.0');
|
|
||||||
const String changelog = '''
|
const String changelog = '''
|
||||||
## NEXT
|
## NEXT
|
||||||
|
|
||||||
* Some changes that won't be published until the next time there's a release.
|
* Some changes that won't be published until the next time there's a release.
|
||||||
|
## $version
|
||||||
## 1.0.0
|
|
||||||
|
|
||||||
* Some other changes.
|
* Some other changes.
|
||||||
''';
|
''';
|
||||||
createFakeCHANGELOG(pluginDirectory, changelog);
|
createFakeCHANGELOG(pluginDirectory, changelog);
|
||||||
@ -486,21 +472,16 @@ The first version listed in CHANGELOG.md is 1.0.1.
|
|||||||
|
|
||||||
test('Fail if NEXT is left in the CHANGELOG when adding a version bump',
|
test('Fail if NEXT is left in the CHANGELOG when adding a version bump',
|
||||||
() async {
|
() async {
|
||||||
final Directory pluginDirectory = createFakePlugin('plugin', packagesDir,
|
const String version = '1.0.1';
|
||||||
includeChangeLog: true, includeVersion: true);
|
final Directory pluginDirectory =
|
||||||
|
createFakePlugin('plugin', packagesDir, version: version);
|
||||||
|
|
||||||
createFakePubspec(pluginDirectory, isFlutter: true, version: '1.0.1');
|
|
||||||
const String changelog = '''
|
const String changelog = '''
|
||||||
## 1.0.1
|
## $version
|
||||||
|
|
||||||
* Some changes.
|
* Some changes.
|
||||||
|
|
||||||
## NEXT
|
## NEXT
|
||||||
|
|
||||||
* Some changes that should have been folded in 1.0.1.
|
* Some changes that should have been folded in 1.0.1.
|
||||||
|
|
||||||
## 1.0.0
|
## 1.0.0
|
||||||
|
|
||||||
* Some other changes.
|
* Some other changes.
|
||||||
''';
|
''';
|
||||||
createFakeCHANGELOG(pluginDirectory, changelog);
|
createFakeCHANGELOG(pluginDirectory, changelog);
|
||||||
@ -529,17 +510,13 @@ into the new version's release notes.
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('Fail if the version changes without replacing NEXT', () async {
|
test('Fail if the version changes without replacing NEXT', () async {
|
||||||
final Directory pluginDirectory = createFakePlugin('plugin', packagesDir,
|
final Directory pluginDirectory =
|
||||||
includeChangeLog: true, includeVersion: true);
|
createFakePlugin('plugin', packagesDir, version: '1.0.1');
|
||||||
|
|
||||||
createFakePubspec(pluginDirectory, isFlutter: true, version: '1.0.1');
|
|
||||||
const String changelog = '''
|
const String changelog = '''
|
||||||
## NEXT
|
## NEXT
|
||||||
|
|
||||||
* Some changes that should be listed as part of 1.0.1.
|
* Some changes that should be listed as part of 1.0.1.
|
||||||
|
|
||||||
## 1.0.0
|
## 1.0.0
|
||||||
|
|
||||||
* Some other changes.
|
* Some other changes.
|
||||||
''';
|
''';
|
||||||
createFakeCHANGELOG(pluginDirectory, changelog);
|
createFakeCHANGELOG(pluginDirectory, changelog);
|
||||||
@ -588,12 +565,12 @@ The first version listed in CHANGELOG.md is 1.0.0.
|
|||||||
'version_check_command', 'Test for $VersionCheckCommand');
|
'version_check_command', 'Test for $VersionCheckCommand');
|
||||||
runner.addCommand(command);
|
runner.addCommand(command);
|
||||||
|
|
||||||
createFakePlugin('plugin', packagesDir,
|
const String newVersion = '2.0.0';
|
||||||
includeChangeLog: true, includeVersion: true);
|
createFakePlugin('plugin', packagesDir, version: newVersion);
|
||||||
gitDiffResponse = 'packages/plugin/pubspec.yaml';
|
gitDiffResponse = 'packages/plugin/pubspec.yaml';
|
||||||
gitShowResponses = <String, String>{
|
gitShowResponses = <String, String>{
|
||||||
'master:packages/plugin/pubspec.yaml': 'version: 1.0.0',
|
'master:packages/plugin/pubspec.yaml': 'version: 1.0.0',
|
||||||
'HEAD:packages/plugin/pubspec.yaml': 'version: 2.0.0',
|
'HEAD:packages/plugin/pubspec.yaml': 'version: $newVersion',
|
||||||
};
|
};
|
||||||
final List<String> output = await runCapturingPrint(runner,
|
final List<String> output = await runCapturingPrint(runner,
|
||||||
<String>['version-check', '--base-sha=master', '--against-pub']);
|
<String>['version-check', '--base-sha=master', '--against-pub']);
|
||||||
@ -625,12 +602,12 @@ The first version listed in CHANGELOG.md is 1.0.0.
|
|||||||
'version_check_command', 'Test for $VersionCheckCommand');
|
'version_check_command', 'Test for $VersionCheckCommand');
|
||||||
runner.addCommand(command);
|
runner.addCommand(command);
|
||||||
|
|
||||||
createFakePlugin('plugin', packagesDir,
|
const String newVersion = '2.0.0';
|
||||||
includeChangeLog: true, includeVersion: true);
|
createFakePlugin('plugin', packagesDir, version: newVersion);
|
||||||
gitDiffResponse = 'packages/plugin/pubspec.yaml';
|
gitDiffResponse = 'packages/plugin/pubspec.yaml';
|
||||||
gitShowResponses = <String, String>{
|
gitShowResponses = <String, String>{
|
||||||
'master:packages/plugin/pubspec.yaml': 'version: 1.0.0',
|
'master:packages/plugin/pubspec.yaml': 'version: 1.0.0',
|
||||||
'HEAD:packages/plugin/pubspec.yaml': 'version: 2.0.0',
|
'HEAD:packages/plugin/pubspec.yaml': 'version: $newVersion',
|
||||||
};
|
};
|
||||||
|
|
||||||
bool hasError = false;
|
bool hasError = false;
|
||||||
@ -670,12 +647,12 @@ ${indentation}Allowed versions: {1.0.0: NextVersionType.BREAKING_MAJOR, 0.1.0: N
|
|||||||
'version_check_command', 'Test for $VersionCheckCommand');
|
'version_check_command', 'Test for $VersionCheckCommand');
|
||||||
runner.addCommand(command);
|
runner.addCommand(command);
|
||||||
|
|
||||||
createFakePlugin('plugin', packagesDir,
|
const String newVersion = '2.0.0';
|
||||||
includeChangeLog: true, includeVersion: true);
|
createFakePlugin('plugin', packagesDir, version: newVersion);
|
||||||
gitDiffResponse = 'packages/plugin/pubspec.yaml';
|
gitDiffResponse = 'packages/plugin/pubspec.yaml';
|
||||||
gitShowResponses = <String, String>{
|
gitShowResponses = <String, String>{
|
||||||
'master:packages/plugin/pubspec.yaml': 'version: 1.0.0',
|
'master:packages/plugin/pubspec.yaml': 'version: 1.0.0',
|
||||||
'HEAD:packages/plugin/pubspec.yaml': 'version: 2.0.0',
|
'HEAD:packages/plugin/pubspec.yaml': 'version: $newVersion',
|
||||||
};
|
};
|
||||||
bool hasError = false;
|
bool hasError = false;
|
||||||
final List<String> result = await runCapturingPrint(runner, <String>[
|
final List<String> result = await runCapturingPrint(runner, <String>[
|
||||||
@ -714,12 +691,12 @@ ${indentation}HTTP response: xx
|
|||||||
'version_check_command', 'Test for $VersionCheckCommand');
|
'version_check_command', 'Test for $VersionCheckCommand');
|
||||||
runner.addCommand(command);
|
runner.addCommand(command);
|
||||||
|
|
||||||
createFakePlugin('plugin', packagesDir,
|
const String newVersion = '2.0.0';
|
||||||
includeChangeLog: true, includeVersion: true);
|
createFakePlugin('plugin', packagesDir, version: newVersion);
|
||||||
gitDiffResponse = 'packages/plugin/pubspec.yaml';
|
gitDiffResponse = 'packages/plugin/pubspec.yaml';
|
||||||
gitShowResponses = <String, String>{
|
gitShowResponses = <String, String>{
|
||||||
'master:packages/plugin/pubspec.yaml': 'version: 1.0.0',
|
'master:packages/plugin/pubspec.yaml': 'version: 1.0.0',
|
||||||
'HEAD:packages/plugin/pubspec.yaml': 'version: 2.0.0',
|
'HEAD:packages/plugin/pubspec.yaml': 'version: $newVersion',
|
||||||
};
|
};
|
||||||
final List<String> result = await runCapturingPrint(runner,
|
final List<String> result = await runCapturingPrint(runner,
|
||||||
<String>['version-check', '--base-sha=master', '--against-pub']);
|
<String>['version-check', '--base-sha=master', '--against-pub']);
|
||||||
|
@ -113,16 +113,11 @@ void main() {
|
|||||||
|
|
||||||
group('iOS', () {
|
group('iOS', () {
|
||||||
test('skip if iOS is not supported', () async {
|
test('skip if iOS is not supported', () async {
|
||||||
final Directory pluginDirectory =
|
createFakePlugin('plugin', packagesDir, extraFiles: <List<String>>[
|
||||||
createFakePlugin('plugin', packagesDir,
|
<String>['example', 'test'],
|
||||||
withExtraFiles: <List<String>>[
|
], platformSupport: <String, PlatformSupport>{
|
||||||
<String>['example', 'test'],
|
kPlatformMacos: PlatformSupport.inline,
|
||||||
],
|
});
|
||||||
isIosPlugin: false,
|
|
||||||
isMacOsPlugin: true);
|
|
||||||
|
|
||||||
createFakePubspec(pluginDirectory.childDirectory('example'),
|
|
||||||
isFlutter: true);
|
|
||||||
|
|
||||||
final MockProcess mockProcess = MockProcess();
|
final MockProcess mockProcess = MockProcess();
|
||||||
mockProcess.exitCodeCompleter.complete(0);
|
mockProcess.exitCodeCompleter.complete(0);
|
||||||
@ -135,17 +130,11 @@ void main() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('skip if iOS is implemented in a federated package', () async {
|
test('skip if iOS is implemented in a federated package', () async {
|
||||||
final Directory pluginDirectory =
|
createFakePlugin('plugin', packagesDir, extraFiles: <List<String>>[
|
||||||
createFakePlugin('plugin', packagesDir,
|
<String>['example', 'test'],
|
||||||
withExtraFiles: <List<String>>[
|
], platformSupport: <String, PlatformSupport>{
|
||||||
<String>['example', 'test'],
|
kPlatformIos: PlatformSupport.federated
|
||||||
],
|
});
|
||||||
isIosPlugin: true);
|
|
||||||
createFakePubspec(pluginDirectory,
|
|
||||||
iosSupport: PlatformSupport.federated);
|
|
||||||
|
|
||||||
createFakePubspec(pluginDirectory.childDirectory('example'),
|
|
||||||
isFlutter: true);
|
|
||||||
|
|
||||||
final MockProcess mockProcess = MockProcess();
|
final MockProcess mockProcess = MockProcess();
|
||||||
mockProcess.exitCodeCompleter.complete(0);
|
mockProcess.exitCodeCompleter.complete(0);
|
||||||
@ -158,25 +147,20 @@ void main() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('running with correct destination, exclude 1 plugin', () async {
|
test('running with correct destination, exclude 1 plugin', () async {
|
||||||
final Directory pluginDirectory1 =
|
createFakePlugin('plugin1', packagesDir, extraFiles: <List<String>>[
|
||||||
createFakePlugin('plugin1', packagesDir,
|
<String>['example', 'test'],
|
||||||
withExtraFiles: <List<String>>[
|
], platformSupport: <String, PlatformSupport>{
|
||||||
<String>['example', 'test'],
|
kPlatformIos: PlatformSupport.inline
|
||||||
],
|
});
|
||||||
isIosPlugin: true);
|
|
||||||
final Directory pluginDirectory2 =
|
final Directory pluginDirectory2 =
|
||||||
createFakePlugin('plugin2', packagesDir,
|
createFakePlugin('plugin2', packagesDir, extraFiles: <List<String>>[
|
||||||
withExtraFiles: <List<String>>[
|
<String>['example', 'test'],
|
||||||
<String>['example', 'test'],
|
], platformSupport: <String, PlatformSupport>{
|
||||||
],
|
kPlatformIos: PlatformSupport.inline
|
||||||
isIosPlugin: true);
|
});
|
||||||
|
|
||||||
final Directory pluginExampleDirectory1 =
|
|
||||||
pluginDirectory1.childDirectory('example');
|
|
||||||
createFakePubspec(pluginExampleDirectory1, isFlutter: true);
|
|
||||||
final Directory pluginExampleDirectory2 =
|
final Directory pluginExampleDirectory2 =
|
||||||
pluginDirectory2.childDirectory('example');
|
pluginDirectory2.childDirectory('example');
|
||||||
createFakePubspec(pluginExampleDirectory2, isFlutter: true);
|
|
||||||
|
|
||||||
final MockProcess mockProcess = MockProcess();
|
final MockProcess mockProcess = MockProcess();
|
||||||
mockProcess.exitCodeCompleter.complete(0);
|
mockProcess.exitCodeCompleter.complete(0);
|
||||||
@ -223,17 +207,15 @@ void main() {
|
|||||||
test('Not specifying --ios-destination assigns an available simulator',
|
test('Not specifying --ios-destination assigns an available simulator',
|
||||||
() async {
|
() async {
|
||||||
final Directory pluginDirectory =
|
final Directory pluginDirectory =
|
||||||
createFakePlugin('plugin', packagesDir,
|
createFakePlugin('plugin', packagesDir, extraFiles: <List<String>>[
|
||||||
withExtraFiles: <List<String>>[
|
<String>['example', 'test'],
|
||||||
<String>['example', 'test'],
|
], platformSupport: <String, PlatformSupport>{
|
||||||
],
|
kPlatformIos: PlatformSupport.inline
|
||||||
isIosPlugin: true);
|
});
|
||||||
|
|
||||||
final Directory pluginExampleDirectory =
|
final Directory pluginExampleDirectory =
|
||||||
pluginDirectory.childDirectory('example');
|
pluginDirectory.childDirectory('example');
|
||||||
|
|
||||||
createFakePubspec(pluginExampleDirectory, isFlutter: true);
|
|
||||||
|
|
||||||
final MockProcess mockProcess = MockProcess();
|
final MockProcess mockProcess = MockProcess();
|
||||||
mockProcess.exitCodeCompleter.complete(0);
|
mockProcess.exitCodeCompleter.complete(0);
|
||||||
processRunner.processToReturn = mockProcess;
|
processRunner.processToReturn = mockProcess;
|
||||||
@ -276,16 +258,13 @@ void main() {
|
|||||||
|
|
||||||
group('macOS', () {
|
group('macOS', () {
|
||||||
test('skip if macOS is not supported', () async {
|
test('skip if macOS is not supported', () async {
|
||||||
final Directory pluginDirectory =
|
createFakePlugin(
|
||||||
createFakePlugin('plugin', packagesDir,
|
'plugin',
|
||||||
withExtraFiles: <List<String>>[
|
packagesDir,
|
||||||
<String>['example', 'test'],
|
extraFiles: <List<String>>[
|
||||||
],
|
<String>['example', 'test'],
|
||||||
isIosPlugin: true,
|
],
|
||||||
isMacOsPlugin: false);
|
);
|
||||||
|
|
||||||
createFakePubspec(pluginDirectory.childDirectory('example'),
|
|
||||||
isFlutter: true);
|
|
||||||
|
|
||||||
final MockProcess mockProcess = MockProcess();
|
final MockProcess mockProcess = MockProcess();
|
||||||
mockProcess.exitCodeCompleter.complete(0);
|
mockProcess.exitCodeCompleter.complete(0);
|
||||||
@ -298,17 +277,11 @@ void main() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('skip if macOS is implemented in a federated package', () async {
|
test('skip if macOS is implemented in a federated package', () async {
|
||||||
final Directory pluginDirectory =
|
createFakePlugin('plugin', packagesDir, extraFiles: <List<String>>[
|
||||||
createFakePlugin('plugin', packagesDir,
|
<String>['example', 'test'],
|
||||||
withExtraFiles: <List<String>>[
|
], platformSupport: <String, PlatformSupport>{
|
||||||
<String>['example', 'test'],
|
kPlatformMacos: PlatformSupport.federated,
|
||||||
],
|
});
|
||||||
isMacOsPlugin: true);
|
|
||||||
createFakePubspec(pluginDirectory,
|
|
||||||
macosSupport: PlatformSupport.federated);
|
|
||||||
|
|
||||||
createFakePubspec(pluginDirectory.childDirectory('example'),
|
|
||||||
isFlutter: true);
|
|
||||||
|
|
||||||
final MockProcess mockProcess = MockProcess();
|
final MockProcess mockProcess = MockProcess();
|
||||||
mockProcess.exitCodeCompleter.complete(0);
|
mockProcess.exitCodeCompleter.complete(0);
|
||||||
@ -322,15 +295,14 @@ void main() {
|
|||||||
|
|
||||||
test('runs for macOS plugin', () async {
|
test('runs for macOS plugin', () async {
|
||||||
final Directory pluginDirectory1 =
|
final Directory pluginDirectory1 =
|
||||||
createFakePlugin('plugin', packagesDir,
|
createFakePlugin('plugin', packagesDir, extraFiles: <List<String>>[
|
||||||
withExtraFiles: <List<String>>[
|
<String>['example', 'test'],
|
||||||
<String>['example', 'test'],
|
], platformSupport: <String, PlatformSupport>{
|
||||||
],
|
kPlatformMacos: PlatformSupport.inline,
|
||||||
isMacOsPlugin: true);
|
});
|
||||||
|
|
||||||
final Directory pluginExampleDirectory =
|
final Directory pluginExampleDirectory =
|
||||||
pluginDirectory1.childDirectory('example');
|
pluginDirectory1.childDirectory('example');
|
||||||
createFakePubspec(pluginExampleDirectory, isFlutter: true);
|
|
||||||
|
|
||||||
final MockProcess mockProcess = MockProcess();
|
final MockProcess mockProcess = MockProcess();
|
||||||
mockProcess.exitCodeCompleter.complete(0);
|
mockProcess.exitCodeCompleter.complete(0);
|
||||||
|
Reference in New Issue
Block a user