[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
This commit is contained in:
Vadim Salavatov
2025-08-12 15:05:27 +02:00
committed by intellij-monorepo-bot
parent ae237b0bb1
commit 5dd98f16b7

View File

@@ -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)