mirror of
https://github.com/flutter/packages.git
synced 2025-06-19 05:30:13 +08:00
[tool] Add a package inclusion filter (#4904)
Creates a package filter flag that is an opt-in mirror to the `exclude` flag, for use with the automatic package selection options used in CI. Like `exclude`, it allows for YAML files as input. This allows for creating split test runs in CI (e.g., during incremental migrations), where the same file is an inclusion filter for one run and an exclusion filter for the other, guaranteeing that tests are in one or the other without the possibility of some tests falling through the cracks.
This commit is contained in:
@ -204,6 +204,21 @@ void main() {
|
||||
expect(command.plugins, unorderedEquals(<String>[]));
|
||||
});
|
||||
|
||||
test('filter-packages-to accepts config files', () async {
|
||||
final RepositoryPackage plugin1 =
|
||||
createFakePlugin('plugin1', packagesDir);
|
||||
createFakePlugin('plugin2', packagesDir);
|
||||
final File configFile = packagesDir.childFile('exclude.yaml');
|
||||
configFile.writeAsStringSync('- plugin1');
|
||||
|
||||
await runCapturingPrint(runner, <String>[
|
||||
'sample',
|
||||
'--packages=plugin1,plugin2',
|
||||
'--filter-packages-to=${configFile.path}'
|
||||
]);
|
||||
expect(command.plugins, unorderedEquals(<String>[plugin1.path]));
|
||||
});
|
||||
|
||||
test(
|
||||
'explicitly specifying the plugin (group) name of a federated plugin '
|
||||
'should include all plugins in the group', () async {
|
||||
@ -765,7 +780,7 @@ packages/plugin1/plugin1/plugin1.dart
|
||||
expect(command.plugins, unorderedEquals(<String>[plugin1.path]));
|
||||
});
|
||||
|
||||
test('--exclude flag works with --run-on-changed-packages', () async {
|
||||
test('honors --exclude flag', () async {
|
||||
processRunner.mockProcessesForExecutable['git-diff'] =
|
||||
<FakeProcessInfo>[
|
||||
FakeProcessInfo(MockProcess(stdout: '''
|
||||
@ -787,6 +802,29 @@ packages/plugin3/plugin3.dart
|
||||
|
||||
expect(command.plugins, unorderedEquals(<String>[plugin1.path]));
|
||||
});
|
||||
|
||||
test('honors --filter-packages-to flag', () async {
|
||||
processRunner.mockProcessesForExecutable['git-diff'] =
|
||||
<FakeProcessInfo>[
|
||||
FakeProcessInfo(MockProcess(stdout: '''
|
||||
packages/plugin1/plugin1.dart
|
||||
packages/plugin2/ios/plugin2.m
|
||||
packages/plugin3/plugin3.dart
|
||||
''')),
|
||||
];
|
||||
final RepositoryPackage plugin1 =
|
||||
createFakePlugin('plugin1', packagesDir.childDirectory('plugin1'));
|
||||
createFakePlugin('plugin2', packagesDir);
|
||||
createFakePlugin('plugin3', packagesDir);
|
||||
await runCapturingPrint(runner, <String>[
|
||||
'sample',
|
||||
'--filter-packages-to=plugin1',
|
||||
'--base-sha=main',
|
||||
'--run-on-changed-packages'
|
||||
]);
|
||||
|
||||
expect(command.plugins, unorderedEquals(<String>[plugin1.path]));
|
||||
});
|
||||
});
|
||||
|
||||
group('test run-on-dirty-packages', () {
|
||||
|
Reference in New Issue
Block a user