From 98aca55a2a1e24a0f07930514acdacd18a5edb68 Mon Sep 17 00:00:00 2001 From: Simon Ogorodnik Date: Tue, 11 Apr 2023 18:08:52 +0200 Subject: [PATCH] KT-57927: Fix deserialization of K2JVMCompilerArguments in FP/MT tests Due to changes in 9dcd40d7b76a36b18ae9c7ef9bbd9dd86bed0267 classpath and pluginClasspath arguments become Arrays Now we need to update arguments representation to properly deserialize it ^KT-57927 --- .../kotlin/fir/AbstractModularizedTest.kt | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/compiler/fir/modularized-tests/tests/org/jetbrains/kotlin/fir/AbstractModularizedTest.kt b/compiler/fir/modularized-tests/tests/org/jetbrains/kotlin/fir/AbstractModularizedTest.kt index e87d83e1996..d8f571b9350 100644 --- a/compiler/fir/modularized-tests/tests/org/jetbrains/kotlin/fir/AbstractModularizedTest.kt +++ b/compiler/fir/modularized-tests/tests/org/jetbrains/kotlin/fir/AbstractModularizedTest.kt @@ -149,8 +149,42 @@ abstract class AbstractModularizedTest : KtUsefulTestCase() { return modules.map { node -> loadModule(node).also { it.arguments = arguments } } } + // TODO: remove once support for snapshot 2022 is ended + private fun updateCompilerArgumentsXml(element: Element) { + fun convertOptionToList(optionElement: Element) { + if (optionElement.getAttribute("value") == null) return + val paths = optionElement.getAttributeValue("value").split(":") + + optionElement.removeAttribute("value") + + val listElement = Element("list") + paths.forEach { path -> + val pathElement = Element("option") + pathElement.setAttribute("value", path) + listElement.addContent(pathElement) + } + + optionElement.addContent(listElement) + } + + + fun findOptionElements(parentElement: Element, optionName: String): List { + return parentElement.getChildren("option") + .filter { it.getAttributeValue("name") == optionName } + } + + // See KT-57927 + findOptionElements(element, "classpath").forEach { + convertOptionToList(it) + } + findOptionElements(element, "pluginClasspath").forEach { + convertOptionToList(it) + } + } + private fun loadCompilerArguments(argumentsRoot: Element): CommonCompilerArguments? { val element = argumentsRoot.children.singleOrNull() ?: return null + updateCompilerArgumentsXml(element) return when (element.name) { "K2JVMCompilerArguments" -> K2JVMCompilerArguments().also { XmlSerializer.deserializeInto(it, element) } else -> null