refactor: Differentiate pubspec and resolution errors for plugins (#142035)

Part of #137040 and #80374

- Differentiate pubspec and resolution errors
- Rename platform to platformKey
- Add TODO for rework logic of flag [throwOnPluginPubspecError]
- Swap for loop: handle by platform and then by plugin
This commit is contained in:
Gustl22
2024-02-26 20:45:18 +01:00
committed by GitHub
parent 9d5380889d
commit b4f925e85a
2 changed files with 85 additions and 27 deletions

View File

@@ -95,6 +95,63 @@ void main() {
);
});
testWithoutContext(
'selects uncontested implementation from direct dependency with additional native implementation',
() async {
final Set<String> directDependencies = <String>{
'url_launcher_linux',
'url_launcher_macos',
};
final List<PluginInterfaceResolution> resolutions =
resolvePlatformImplementation(
<Plugin>[
// Following plugin is native only and is not resolved as a dart plugin:
Plugin.fromYaml(
'url_launcher_linux',
'',
YamlMap.wrap(<String, dynamic>{
'platforms': <String, dynamic>{
'linux': <String, dynamic>{
'package': 'com.example.url_launcher',
'pluginClass': 'UrlLauncherPluginLinux',
},
},
}),
null,
<String>[],
fileSystem: fs,
appDependencies: directDependencies,
),
Plugin.fromYaml(
'url_launcher_macos',
'',
YamlMap.wrap(<String, dynamic>{
'implements': 'url_launcher',
'platforms': <String, dynamic>{
'macos': <String, dynamic>{
'dartPluginClass': 'UrlLauncherPluginMacOS',
},
},
}),
null,
<String>[],
fileSystem: fs,
appDependencies: directDependencies,
),
],
throwOnPluginPubspecError: false,
);
expect(resolutions.length, equals(1));
expect(
resolutions[0].toMap(),
equals(<String, String>{
'pluginName': 'url_launcher_macos',
'dartClass': 'UrlLauncherPluginMacOS',
'platform': 'macos',
}));
});
testWithoutContext('selects uncontested implementation from transitive dependency', () async {
final Set<String> directDependencies = <String>{
'url_launcher_macos',
@@ -538,7 +595,7 @@ void main() {
},
throwsToolExit(
message: 'Please resolve the errors',
message: 'Please resolve the plugin implementation selection errors',
));
expect(
@@ -627,7 +684,7 @@ void main() {
]);
},
throwsToolExit(
message: 'Please resolve the errors',
message: 'Please resolve the plugin implementation selection errors',
));
expect(
@@ -684,7 +741,7 @@ void main() {
]);
},
throwsToolExit(
message: 'Please resolve the errors',
message: 'Please resolve the plugin implementation selection errors',
));
expect(