[tool] Fix --current-package for app-facing packages (#4399)

The new `--current-package` flag was returning `foo` when run in the app-facing package of a federated plugin called `foo`, but `foo` as a package argument is treated as being the entire group, so it was running all for all of the packages in the plugin. This fixes it to return `foo/foo` in that case, which is how the tool targets app-facing packages specifically.
This commit is contained in:
stuartmorgan
2023-07-07 15:04:13 -04:00
committed by GitHub
parent f2ff19c745
commit 902e4bef4c
2 changed files with 24 additions and 1 deletions

View File

@ -433,6 +433,21 @@ packages/plugin1/plugin1/plugin1.dart
expect(command.plugins, unorderedEquals(<String>[package.path]));
});
test('runs only app-facing package of a federated plugin', () async {
const String pluginName = 'foo';
final Directory groupDir = packagesDir.childDirectory(pluginName);
final RepositoryPackage package =
createFakePlugin(pluginName, groupDir);
createFakePlugin('${pluginName}_someplatform', groupDir);
createFakePackage('${pluginName}_platform_interface', groupDir);
fileSystem.currentDirectory = package.directory;
await runCapturingPrint(
runner, <String>['sample', '--current-package']);
expect(command.plugins, unorderedEquals(<String>[package.path]));
});
test('runs on a package when run from a package example directory',
() async {
final RepositoryPackage package = createFakePlugin(