From 5dd98f16b7d9e8df3d1d2376a1aaea5a34ae2856 Mon Sep 17 00:00:00 2001 From: Vadim Salavatov Date: Tue, 12 Aug 2025 15:05:27 +0200 Subject: [PATCH] [plugins] IJPL-201745 add test that dependencies on core content modules work Previously, an edge from plugin's content module to core's content module was not added and the order of initializion _could_ be so that plugin's content module was initialized first, and it broke the logic test uses multiple plugins because the order is currently dependent on hashmap entries order was fixed by 2402e2b07f97d8b53b4869403b49fea96ac4288b (cherry picked from commit cca338a8b3a909a93754270c6cb862e0230a83ae) GitOrigin-RevId: 5c704b3d2979f288f2dadf7f4e1e64cfdfb7f3f1 --- .../ide/plugins/PluginSetLoadingTest.kt | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/platform/platform-tests/testSrc/com/intellij/ide/plugins/PluginSetLoadingTest.kt b/platform/platform-tests/testSrc/com/intellij/ide/plugins/PluginSetLoadingTest.kt index aad826f95ab6..76c6f9575a51 100644 --- a/platform/platform-tests/testSrc/com/intellij/ide/plugins/PluginSetLoadingTest.kt +++ b/platform/platform-tests/testSrc/com/intellij/ide/plugins/PluginSetLoadingTest.kt @@ -15,6 +15,8 @@ import org.intellij.lang.annotations.Language import org.junit.Rule import org.junit.Test import java.util.function.Function +import kotlin.math.absoluteValue +import kotlin.random.Random class PluginSetLoadingTest { init { @@ -445,6 +447,35 @@ class PluginSetLoadingTest { assertThat(descriptor).isNotMarkedEnabled() } + @Test + fun `dependency on a plugin alias in core content module from a plugin required content module is allowed`() { + // note: result can be order-dependent + val rnd = Random(239) + val ids = (1..20).map { rnd.nextInt().absoluteValue.toString(36) }.distinct() + for (id in ids) { + plugin("intellij.textmate.$id") { + content { + module("intellij.textmate.impl.$id", loadingRule = ModuleLoadingRule.REQUIRED) { + dependencies { + plugin("com.intellij.modules.spellchecker") + } + } + } + }.buildDir(pluginsDirPath.resolve("foo.$id")) + } + plugin(PluginManagerCore.CORE_PLUGIN_ID) { + content { + module("intellij.spellchecker") { + isSeparateJar = true + pluginAlias("com.intellij.modules.spellchecker") + } + module("intellij.required", loadingRule = ModuleLoadingRule.REQUIRED) {} + } + }.buildDir(pluginsDirPath.resolve("core")) + val pluginSet = buildPluginSet() + assertThat(pluginSet).hasExactlyEnabledPlugins(PluginManagerCore.CORE_PLUGIN_ID, *ids.map { "intellij.textmate.$it" }.toTypedArray()) + } + private fun writeDescriptor(id: String, @Language("xml") data: String) { pluginsDirPath.resolve(id) .resolve(PluginManagerCore.PLUGIN_XML_PATH)