mirror of
https://github.com/flutter/packages.git
synced 2025-06-23 08:30:12 +08:00
[flutter_plugin_tools] Include examples in test
(#5453)
This commit is contained in:
@ -1,5 +1,6 @@
|
|||||||
## NEXT
|
## 0.8.5
|
||||||
|
|
||||||
|
- Updates `test` to inculde the Dart unit tests of examples, if any.
|
||||||
- `drive-examples` now supports non-plugin packages.
|
- `drive-examples` now supports non-plugin packages.
|
||||||
- Commands that iterate over examples now include non-Flutter example packages.
|
- Commands that iterate over examples now include non-Flutter example packages.
|
||||||
|
|
||||||
|
@ -36,6 +36,9 @@ class TestCommand extends PackageLoopingCommand {
|
|||||||
final String description = 'Runs the Dart tests for all packages.\n\n'
|
final String description = 'Runs the Dart tests for all packages.\n\n'
|
||||||
'This command requires "flutter" to be in your path.';
|
'This command requires "flutter" to be in your path.';
|
||||||
|
|
||||||
|
@override
|
||||||
|
bool get includeSubpackages => true;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<PackageResult> runForPackage(RepositoryPackage package) async {
|
Future<PackageResult> runForPackage(RepositoryPackage package) async {
|
||||||
if (!package.directory.childDirectory('test').existsSync()) {
|
if (!package.directory.childDirectory('test').existsSync()) {
|
||||||
@ -88,7 +91,6 @@ class TestCommand extends PackageLoopingCommand {
|
|||||||
exitCode = await processRunner.runAndStream(
|
exitCode = await processRunner.runAndStream(
|
||||||
'dart',
|
'dart',
|
||||||
<String>[
|
<String>[
|
||||||
'pub',
|
|
||||||
'run',
|
'run',
|
||||||
if (experiment.isNotEmpty) '--enable-experiment=$experiment',
|
if (experiment.isNotEmpty) '--enable-experiment=$experiment',
|
||||||
'test',
|
'test',
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
name: flutter_plugin_tools
|
name: flutter_plugin_tools
|
||||||
description: Productivity utils for flutter/plugins and flutter/packages
|
description: Productivity utils for flutter/plugins and flutter/packages
|
||||||
repository: https://github.com/flutter/plugins/tree/main/script/tool
|
repository: https://github.com/flutter/plugins/tree/main/script/tool
|
||||||
version: 0.8.4
|
version: 0.8.5
|
||||||
|
|
||||||
dependencies:
|
dependencies:
|
||||||
args: ^2.1.0
|
args: ^2.1.0
|
||||||
|
@ -58,6 +58,28 @@ void main() {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('runs flutter test on Flutter package example tests', () async {
|
||||||
|
final Directory pluginDir = createFakePlugin('a_plugin', packagesDir,
|
||||||
|
extraFiles: <String>[
|
||||||
|
'test/empty_test.dart',
|
||||||
|
'example/test/an_example_test.dart'
|
||||||
|
]);
|
||||||
|
|
||||||
|
await runCapturingPrint(runner, <String>['test']);
|
||||||
|
|
||||||
|
expect(
|
||||||
|
processRunner.recordedCalls,
|
||||||
|
orderedEquals(<ProcessCall>[
|
||||||
|
ProcessCall(getFlutterCommand(mockPlatform),
|
||||||
|
const <String>['test', '--color'], pluginDir.path),
|
||||||
|
ProcessCall(
|
||||||
|
getFlutterCommand(mockPlatform),
|
||||||
|
const <String>['test', '--color'],
|
||||||
|
pluginDir.childDirectory('example').path),
|
||||||
|
]),
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
test('fails when Flutter tests fail', () async {
|
test('fails when Flutter tests fail', () async {
|
||||||
createFakePlugin('plugin1', packagesDir,
|
createFakePlugin('plugin1', packagesDir,
|
||||||
extraFiles: <String>['test/empty_test.dart']);
|
extraFiles: <String>['test/empty_test.dart']);
|
||||||
@ -102,7 +124,7 @@ void main() {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('runs pub run test on non-Flutter packages', () async {
|
test('runs dart run test on non-Flutter packages', () async {
|
||||||
final Directory pluginDir = createFakePlugin('a', packagesDir,
|
final Directory pluginDir = createFakePlugin('a', packagesDir,
|
||||||
extraFiles: <String>['test/empty_test.dart']);
|
extraFiles: <String>['test/empty_test.dart']);
|
||||||
final Directory packageDir = createFakePackage('b', packagesDir,
|
final Directory packageDir = createFakePackage('b', packagesDir,
|
||||||
@ -121,12 +143,34 @@ void main() {
|
|||||||
ProcessCall('dart', const <String>['pub', 'get'], packageDir.path),
|
ProcessCall('dart', const <String>['pub', 'get'], packageDir.path),
|
||||||
ProcessCall(
|
ProcessCall(
|
||||||
'dart',
|
'dart',
|
||||||
const <String>['pub', 'run', '--enable-experiment=exp1', 'test'],
|
const <String>['run', '--enable-experiment=exp1', 'test'],
|
||||||
packageDir.path),
|
packageDir.path),
|
||||||
]),
|
]),
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('runs dart run test on non-Flutter package examples', () async {
|
||||||
|
final Directory packageDir = createFakePackage('a_package', packagesDir,
|
||||||
|
extraFiles: <String>[
|
||||||
|
'test/empty_test.dart',
|
||||||
|
'example/test/an_example_test.dart'
|
||||||
|
]);
|
||||||
|
|
||||||
|
await runCapturingPrint(runner, <String>['test']);
|
||||||
|
|
||||||
|
expect(
|
||||||
|
processRunner.recordedCalls,
|
||||||
|
orderedEquals(<ProcessCall>[
|
||||||
|
ProcessCall('dart', const <String>['pub', 'get'], packageDir.path),
|
||||||
|
ProcessCall('dart', const <String>['run', 'test'], packageDir.path),
|
||||||
|
ProcessCall('dart', const <String>['pub', 'get'],
|
||||||
|
packageDir.childDirectory('example').path),
|
||||||
|
ProcessCall('dart', const <String>['run', 'test'],
|
||||||
|
packageDir.childDirectory('example').path),
|
||||||
|
]),
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
test('fails when getting non-Flutter package dependencies fails', () async {
|
test('fails when getting non-Flutter package dependencies fails', () async {
|
||||||
createFakePackage('a_package', packagesDir,
|
createFakePackage('a_package', packagesDir,
|
||||||
extraFiles: <String>['test/empty_test.dart']);
|
extraFiles: <String>['test/empty_test.dart']);
|
||||||
@ -217,7 +261,7 @@ void main() {
|
|||||||
ProcessCall('dart', const <String>['pub', 'get'], packageDir.path),
|
ProcessCall('dart', const <String>['pub', 'get'], packageDir.path),
|
||||||
ProcessCall(
|
ProcessCall(
|
||||||
'dart',
|
'dart',
|
||||||
const <String>['pub', 'run', '--enable-experiment=exp1', 'test'],
|
const <String>['run', '--enable-experiment=exp1', 'test'],
|
||||||
packageDir.path),
|
packageDir.path),
|
||||||
]),
|
]),
|
||||||
);
|
);
|
||||||
|
Reference in New Issue
Block a user