mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
AT-3038: introduce sampleTests plugin without any additional custom modules in IDE classpath
GitOrigin-RevId: 41cd367d0d67b31908d025ce55dc9c1ba803219a
This commit is contained in:
committed by
intellij-monorepo-bot
parent
da53926733
commit
4f9140620c
Generated
+2
-1
@@ -811,9 +811,10 @@
|
||||
<module fileurl="file://$PROJECT_DIR$/plugins/laf/macos/intellij.laf.macos.iml" filepath="$PROJECT_DIR$/plugins/laf/macos/intellij.laf.macos.iml" />
|
||||
<module fileurl="file://$PROJECT_DIR$/plugins/laf/win10/intellij.laf.win10.iml" filepath="$PROJECT_DIR$/plugins/laf/win10/intellij.laf.win10.iml" />
|
||||
<module fileurl="file://$PROJECT_DIR$/tools/intellij.lambda.sampleTests/intellij.lambda.sampleTests.iml" filepath="$PROJECT_DIR$/tools/intellij.lambda.sampleTests/intellij.lambda.sampleTests.iml" />
|
||||
<module fileurl="file://$PROJECT_DIR$/tools/intellij.lambda.sampleTests/plugin/intellij.lambda.sampleTests.plugin.iml" filepath="$PROJECT_DIR$/tools/intellij.lambda.sampleTests/plugin/intellij.lambda.sampleTests.plugin.iml" />
|
||||
<module fileurl="file://$PROJECT_DIR$/tools/intellij.lambda.sampleTestsWithFixtures/intellij.lambda.sampleTestsWithFixtures.iml" filepath="$PROJECT_DIR$/tools/intellij.lambda.sampleTestsWithFixtures/intellij.lambda.sampleTestsWithFixtures.iml" />
|
||||
<module fileurl="file://$PROJECT_DIR$/tools/intellij.lambda.sampleTestsWithFixtures/plugin/intellij.lambda.sampleTestsWithFixtures.plugin.iml" filepath="$PROJECT_DIR$/tools/intellij.lambda.sampleTestsWithFixtures/plugin/intellij.lambda.sampleTestsWithFixtures.plugin.iml" />
|
||||
<module fileurl="file://$PROJECT_DIR$/tools/intellij.lambda.sampleTestsWithPlugin/intellij.lambda.sampleTestsWithPlugin.iml" filepath="$PROJECT_DIR$/tools/intellij.lambda.sampleTestsWithPlugin/intellij.lambda.sampleTestsWithPlugin.iml" />
|
||||
<module fileurl="file://$PROJECT_DIR$/tools/intellij.lambda.sampleTestsWithPlugin/plugin/intellij.lambda.sampleTestsWithPlugin.plugin.iml" filepath="$PROJECT_DIR$/tools/intellij.lambda.sampleTestsWithPlugin/plugin/intellij.lambda.sampleTestsWithPlugin.plugin.iml" />
|
||||
<module fileurl="file://$PROJECT_DIR$/tools/intellij.lambda.testFramework/plugin/intellij.lambda.test.plugin.iml" filepath="$PROJECT_DIR$/tools/intellij.lambda.testFramework/plugin/intellij.lambda.test.plugin.iml" />
|
||||
<module fileurl="file://$PROJECT_DIR$/tools/intellij.lambda.testFramework/intellij.lambda.testFramework.iml" filepath="$PROJECT_DIR$/tools/intellij.lambda.testFramework/intellij.lambda.testFramework.iml" />
|
||||
<module fileurl="file://$PROJECT_DIR$/libraries/aalto-xml/intellij.libraries.aalto.xml.iml" filepath="$PROJECT_DIR$/libraries/aalto-xml/intellij.libraries.aalto.xml.iml" />
|
||||
|
||||
@@ -1494,9 +1494,10 @@ tools/apiDump/testData
|
||||
tools/devLauncher
|
||||
tools/devLauncher/tests
|
||||
tools/intellij.lambda.sampleTests
|
||||
tools/intellij.lambda.sampleTests/plugin
|
||||
tools/intellij.lambda.sampleTestsWithFixtures
|
||||
tools/intellij.lambda.sampleTestsWithFixtures/plugin
|
||||
tools/intellij.lambda.sampleTestsWithPlugin
|
||||
tools/intellij.lambda.sampleTestsWithPlugin/plugin
|
||||
tools/intellij.lambda.testFramework
|
||||
tools/intellij.lambda.testFramework/plugin
|
||||
tools/intellij.tools.ide.metrics.benchmark
|
||||
|
||||
@@ -196,24 +196,32 @@ open class LambdaTestHost(coroutineScope: CoroutineScope) {
|
||||
LambdaRdIdeType.MONOLITH -> LambdaMonolithContextClass()
|
||||
}
|
||||
|
||||
val testModuleId = System.getProperty(TEST_MODULE_ID_PROPERTY_NAME)
|
||||
?: error("Test module ID '$TEST_MODULE_ID_PROPERTY_NAME' is not specified")
|
||||
|
||||
val testModuleDescriptor = PluginManagerCore.getPluginSet().findEnabledModule(PluginModuleId(testModuleId, PluginModuleId.JETBRAINS_NAMESPACE))
|
||||
?: error("Test plugin with test module '$testModuleId' is not found")
|
||||
val testModuleDescriptor = run {
|
||||
val testModuleId = System.getProperty(TEST_MODULE_ID_PROPERTY_NAME)
|
||||
?: return@run null
|
||||
val tmd = PluginManagerCore.getPluginSet().findEnabledModule(PluginModuleId(testModuleId, PluginModuleId.JETBRAINS_NAMESPACE))
|
||||
?: error("Test plugin with test module '$testModuleId' is not found")
|
||||
|
||||
assert(testModuleDescriptor.pluginClassLoader != null) { "Test plugin with test module '$testModuleId' is not loaded." +
|
||||
"Probably due to missing dependencies, see `com.intellij.ide.plugins.ClassLoaderConfigurator#configureContentModule`." }
|
||||
assert(tmd.pluginClassLoader != null) {
|
||||
"Test plugin with test module '${testModuleId}' is not loaded." +
|
||||
"Probably due to missing dependencies, see `com.intellij.ide.plugins.ClassLoaderConfigurator#configureContentModule`."
|
||||
}
|
||||
return@run tmd
|
||||
}
|
||||
|
||||
|
||||
LOG.info("All test code will be loaded using '${testModuleDescriptor.pluginClassLoader}'")
|
||||
LOG.info("All test code will be loaded using '${testModuleDescriptor?.pluginClassLoader}'")
|
||||
|
||||
// Advice for processing events
|
||||
session.runLambda.setSuspend(sessionBgtDispatcher) { _, parameters ->
|
||||
LOG.info("'${parameters.reference}': received lambda execution request")
|
||||
|
||||
assert(testModuleDescriptor != null) {
|
||||
"Test module descriptor is not set, can't find test class '${parameters.reference}'"
|
||||
}
|
||||
try {
|
||||
val lambdaReference = parameters.reference
|
||||
val namedLambdas = findLambdaClasses(lambdaReference = lambdaReference, testModuleDescriptor = testModuleDescriptor, ideContext = ideContext)
|
||||
val namedLambdas = findLambdaClasses(lambdaReference = lambdaReference, testModuleDescriptor = testModuleDescriptor!!, ideContext = ideContext)
|
||||
|
||||
val ideAction = namedLambdas.singleOrNull { it.name() == lambdaReference } ?: run {
|
||||
val text = "There is no Action with reference '${lambdaReference}', something went terribly wrong, " +
|
||||
@@ -271,7 +279,7 @@ open class LambdaTestHost(coroutineScope: CoroutineScope) {
|
||||
|
||||
val urls = serializedLambda.classPath.map { File(it).toURI().toURL() }
|
||||
runLogged(serializedLambda.stepName, 1.minutes) {
|
||||
URLClassLoader(urls.toTypedArray(), testModuleDescriptor.pluginClassLoader).use {
|
||||
URLClassLoader(urls.toTypedArray(), testModuleDescriptor?.pluginClassLoader ?: this::class.java.classLoader).use {
|
||||
SerializedLambdaLoader().load(serializedLambda.serializedDataBase64, classLoader = it, context = ideContext)
|
||||
.accept(ideContext)
|
||||
}
|
||||
|
||||
@@ -1,24 +1,17 @@
|
||||
### auto-generated section `build intellij.lambda.sampleTests` start
|
||||
load("//build:compiler-options.bzl", "create_kotlinc_options")
|
||||
load("@rules_jvm//:jvm.bzl", "jvm_library", "resourcegroup")
|
||||
load("@rules_jvm//:jvm.bzl", "jvm_library")
|
||||
|
||||
create_kotlinc_options(
|
||||
name = "custom_lambda-sampleTests",
|
||||
x_context_parameters = True
|
||||
)
|
||||
|
||||
resourcegroup(
|
||||
name = "lambda-sampleTests_test_resources",
|
||||
srcs = glob(["resources/**/*"]),
|
||||
strip_prefix = "resources"
|
||||
)
|
||||
|
||||
jvm_library(
|
||||
name = "lambda-sampleTests_test_lib",
|
||||
module_name = "intellij.lambda.sampleTests",
|
||||
visibility = ["//visibility:public"],
|
||||
srcs = glob(["tests/**/*.kt", "tests/**/*.java", "tests/**/*.form"], allow_empty = True),
|
||||
resources = [":lambda-sampleTests_test_resources"],
|
||||
kotlinc_opts = ":custom_lambda-sampleTests",
|
||||
deps = [
|
||||
"@lib//:kodein-di-jvm",
|
||||
@@ -63,6 +56,7 @@ jvm_library(
|
||||
"//libraries/junit5-pioneer",
|
||||
"@lib//:rd-framework",
|
||||
"@lib//:rd-core",
|
||||
"//platform/ide-core-impl",
|
||||
]
|
||||
)
|
||||
### auto-generated section `build intellij.lambda.sampleTests` end
|
||||
|
||||
@@ -19,7 +19,6 @@
|
||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/resources" type="java-test-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/tests" isTestSource="true" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
@@ -60,5 +59,6 @@
|
||||
<orderEntry type="module" module-name="intellij.libraries.junit5.pioneer" scope="TEST" />
|
||||
<orderEntry type="library" name="rd-framework" level="project" />
|
||||
<orderEntry type="library" name="rd-core" level="project" />
|
||||
<orderEntry type="module" module-name="intellij.platform.ide.core.impl" scope="TEST" />
|
||||
</component>
|
||||
</module>
|
||||
-1
@@ -1 +0,0 @@
|
||||
com.intellij.lambda.sampleTests.util.SetLambdaPluginCallback
|
||||
+3
-54
@@ -1,79 +1,28 @@
|
||||
// Copyright 2000-2025 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.lambda.sampleTests
|
||||
|
||||
import com.intellij.ide.plugins.PluginModuleDescriptor
|
||||
import com.intellij.lambda.testFramework.junit.ExecuteInMonolithAndSplitMode
|
||||
import com.intellij.lambda.testFramework.junit.UltimateTestCases.JpsEmptyProject
|
||||
import com.intellij.lambda.testFramework.testApi.editor.openFile
|
||||
import com.intellij.lambda.testFramework.testApi.getProject
|
||||
import com.intellij.lambda.testFramework.testApi.getProjects
|
||||
import com.intellij.lambda.testFramework.testApi.utils.tryTimes
|
||||
import com.intellij.lambda.testFramework.testApi.waitForProject
|
||||
import com.intellij.lambda.testFramework.utils.BackgroundRunWithLambda
|
||||
import com.intellij.openapi.diagnostic.Logger
|
||||
import com.intellij.openapi.diagnostic.currentClassLogger
|
||||
import com.intellij.remoteDev.tests.LambdaBackendContext
|
||||
import com.intellij.remoteDev.tests.LambdaFrontendContext
|
||||
import com.intellij.remoteDev.tests.impl.LambdaTestHost.Companion.NamedLambda
|
||||
import com.intellij.remoteDev.tests.modelGenerated.LambdaRdKeyValueEntry
|
||||
import com.intellij.util.io.createDirectories
|
||||
import com.intellij.openapi.project.ex.ProjectManagerEx
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import org.junit.jupiter.api.TestTemplate
|
||||
import kotlin.io.path.createFile
|
||||
import kotlin.io.path.exists
|
||||
import kotlin.time.Duration.Companion.seconds
|
||||
|
||||
@ExecuteInMonolithAndSplitMode
|
||||
class SampleTest {
|
||||
@TestTemplate
|
||||
fun `serialized test`(ide: BackgroundRunWithLambda) = runBlocking {
|
||||
//works in both modes if
|
||||
// headless is turned off for monolith in com.intellij.lambda.testFramework.starter.NewContextWithLambdaKt.newContextWithLambda
|
||||
// as ProjectManager returns empty projects list in headless
|
||||
JpsEmptyProject.projectInfo.projectDir.resolve("src").resolve("FormattingExamplesExpected.java").let {
|
||||
if (!it.exists()) {
|
||||
it.parent.createDirectories()
|
||||
it.createFile()
|
||||
}
|
||||
}
|
||||
ide.apply {
|
||||
runInBackend {
|
||||
waitForProject(20.seconds)
|
||||
}
|
||||
|
||||
run {
|
||||
Logger.getInstance("test").warn("Projects: " + getProjects().joinToString { it.name })
|
||||
Logger.getInstance("test").warn("Projects: " + ProjectManagerEx.getOpenProjects().joinToString { it.name })
|
||||
}
|
||||
|
||||
runInBackend {
|
||||
Logger.getInstance("test").warn("backend Projects: " + getProject())
|
||||
openFile("src/FormattingExamplesExpected.java", waitForReadyState = false, requireFocus = false)
|
||||
Logger.getInstance("test").warn("backend Projects: " + ProjectManagerEx.getOpenProjects().joinToString { it.name })
|
||||
}
|
||||
}
|
||||
Unit
|
||||
}
|
||||
|
||||
@TestTemplate
|
||||
fun `named lambda test`(ide: BackgroundRunWithLambda) = runBlocking {
|
||||
ide.runNamedLambdaInBackend(HelloBackendOnlyLambda::class)
|
||||
ide.runNamedLambda(HelloFrontendOnlyLambda::class)
|
||||
}
|
||||
|
||||
companion object {
|
||||
class HelloFrontendOnlyLambda(frontendIdeContext: LambdaFrontendContext, plugin: PluginModuleDescriptor)
|
||||
: NamedLambda<LambdaFrontendContext>(frontendIdeContext, plugin) {
|
||||
override suspend fun LambdaFrontendContext.lambda(args: List<LambdaRdKeyValueEntry>): Any {
|
||||
return tryTimes(2, "Log") { currentClassLogger().warn("Hi there Frontend") }
|
||||
}
|
||||
}
|
||||
|
||||
class HelloBackendOnlyLambda(backendIdeContext: LambdaBackendContext, plugin: PluginModuleDescriptor)
|
||||
: NamedLambda<LambdaBackendContext>(backendIdeContext, plugin) {
|
||||
override suspend fun LambdaBackendContext.lambda(args: List<LambdaRdKeyValueEntry>): Any {
|
||||
return tryTimes(2, "Log") { currentClassLogger().warn("Hi there Backend") }
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
-18
@@ -1,18 +0,0 @@
|
||||
package com.intellij.lambda.sampleTests.util
|
||||
|
||||
import com.intellij.lambda.testFramework.utils.LambdaTestPluginHolder
|
||||
import org.junit.jupiter.api.extension.AfterAllCallback
|
||||
import org.junit.jupiter.api.extension.BeforeAllCallback
|
||||
import org.junit.jupiter.api.extension.ExtensionContext
|
||||
|
||||
class SetLambdaPluginCallback : BeforeAllCallback, AfterAllCallback {
|
||||
override fun beforeAll(context: ExtensionContext) {
|
||||
LambdaTestPluginHolder.setupAdditionalLambdaPlugin("intellij.lambda.sampleTests._test",
|
||||
"intellij.lambda.sampleTests.plugin",
|
||||
"lambda-sampleTests-plugin")
|
||||
}
|
||||
|
||||
override fun afterAll(context: ExtensionContext) {
|
||||
LambdaTestPluginHolder.cleanUpAdditionalLambdaPlugin()
|
||||
}
|
||||
}
|
||||
+6
-3
@@ -2,15 +2,18 @@
|
||||
package com.intellij.lambda.sampleTestsWithFixtures.util
|
||||
|
||||
import com.intellij.lambda.testFramework.utils.LambdaTestPluginHolder
|
||||
import com.intellij.lambda.testFramework.utils.LambdaTestPluginHolder.defaultLambdaPlugin
|
||||
import org.junit.jupiter.api.extension.AfterAllCallback
|
||||
import org.junit.jupiter.api.extension.BeforeAllCallback
|
||||
import org.junit.jupiter.api.extension.ExtensionContext
|
||||
|
||||
class SetLambdaPluginCallback : BeforeAllCallback, AfterAllCallback {
|
||||
val localCustomLambdaPlugin = LambdaTestPluginHolder.AdditionalLambdaPlugin("intellij.lambda.sampleTestsWithFixtures._test",
|
||||
"intellij.lambda.sampleTestsWithFixtures.plugin",
|
||||
"lambda-sampleTestsWithFixtures-plugin")
|
||||
|
||||
override fun beforeAll(context: ExtensionContext) {
|
||||
LambdaTestPluginHolder.setupAdditionalLambdaPlugin("intellij.lambda.sampleTestsWithFixtures._test",
|
||||
"intellij.lambda.sampleTestsWithFixtures.plugin",
|
||||
"lambda-sampleTestsWithFixtures-plugin")
|
||||
LambdaTestPluginHolder.setupAdditionalLambdaPlugins(localCustomLambdaPlugin.moduleID, listOf(localCustomLambdaPlugin, defaultLambdaPlugin))
|
||||
}
|
||||
|
||||
override fun afterAll(context: ExtensionContext) {
|
||||
|
||||
@@ -0,0 +1,77 @@
|
||||
### auto-generated section `build intellij.lambda.sampleTestsWithPlugin` start
|
||||
load("//build:compiler-options.bzl", "create_kotlinc_options")
|
||||
load("@rules_jvm//:jvm.bzl", "jvm_library", "resourcegroup")
|
||||
|
||||
create_kotlinc_options(
|
||||
name = "custom_lambda-sampleTestsWithPlugin",
|
||||
x_context_parameters = True
|
||||
)
|
||||
|
||||
resourcegroup(
|
||||
name = "lambda-sampleTestsWithPlugin_test_resources",
|
||||
srcs = glob(["resources/**/*"]),
|
||||
strip_prefix = "resources"
|
||||
)
|
||||
|
||||
jvm_library(
|
||||
name = "lambda-sampleTestsWithPlugin_test_lib",
|
||||
module_name = "intellij.lambda.sampleTestsWithPlugin",
|
||||
visibility = ["//visibility:public"],
|
||||
srcs = glob(["tests/**/*.kt", "tests/**/*.java", "tests/**/*.form"], allow_empty = True),
|
||||
resources = [":lambda-sampleTestsWithPlugin_test_resources"],
|
||||
kotlinc_opts = ":custom_lambda-sampleTestsWithPlugin",
|
||||
deps = [
|
||||
"@lib//:kodein-di-jvm",
|
||||
"@lib//:kotlin-stdlib",
|
||||
"@lib//:kotlin-test",
|
||||
"@lib//:assert_j",
|
||||
"//libraries/kotlin/reflect",
|
||||
"//tools/intellij.tools.ide.starter:ide-starter",
|
||||
"//tools/intellij.tools.ide.starter.junit5:ide-starter-junit5",
|
||||
"//tools/intellij.tools.ide.starter.junit5:ide-starter-junit5_test_lib",
|
||||
"//tools/intellij.tools.ide.starter.driver:ide-starter-driver",
|
||||
"//tools/intellij.tools.ide.starter.build.server:ide-starter-build-server",
|
||||
"//platform/core-api:core",
|
||||
"//platform/core-impl",
|
||||
"//platform/core-ui",
|
||||
"//platform/lang-api:lang",
|
||||
"//platform/lang-impl",
|
||||
"//platform/platform-api:ide",
|
||||
"//platform/editor-ui-api:editor-ui",
|
||||
"//platform/editor-ui-ex:editor-ex",
|
||||
"//platform/testFramework/junit5",
|
||||
"//platform/testFramework/junit5:junit5_test_lib",
|
||||
"//platform/code-style-api:codeStyle",
|
||||
"//platform/execution-impl",
|
||||
"//platform/platform-impl:ide-impl",
|
||||
"//platform/remoteDev-util",
|
||||
"//platform/remoteDev-util:remoteDev-util_test_lib",
|
||||
"//platform/analysis-api:analysis",
|
||||
"//plugins/performanceTesting/core:performanceTesting",
|
||||
"//plugins/performanceTesting/core:performanceTesting_test_lib",
|
||||
"//platform/platform-impl/codeinsight-inline:ide-codeinsight-inline",
|
||||
"//platform/xdebugger-api:debugger",
|
||||
"//platform/xdebugger-impl:debugger-impl",
|
||||
"//platform/xdebugger-impl:debugger-impl_test_lib",
|
||||
"//platform/util/concurrency",
|
||||
"//platform/util/concurrency:concurrency_test_lib",
|
||||
"//platform/usageView",
|
||||
"//tools/intellij.lambda.testFramework:lambda-testFramework",
|
||||
"//libraries/junit5",
|
||||
"//libraries/junit5-launcher",
|
||||
"//libraries/junit5-params",
|
||||
"//libraries/junit5-pioneer",
|
||||
"@lib//:rd-framework",
|
||||
"@lib//:rd-core",
|
||||
]
|
||||
)
|
||||
### auto-generated section `build intellij.lambda.sampleTestsWithPlugin` end
|
||||
|
||||
### auto-generated section `test intellij.lambda.sampleTestsWithPlugin` start
|
||||
load("@community//build:tests-options.bzl", "jps_test")
|
||||
|
||||
jps_test(
|
||||
name = "lambda-sampleTestsWithPlugin_test",
|
||||
runtime_deps = [":lambda-sampleTestsWithPlugin_test_lib"]
|
||||
)
|
||||
### auto-generated section `test intellij.lambda.sampleTestsWithPlugin` end
|
||||
@@ -0,0 +1,64 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="JAVA_MODULE" version="4">
|
||||
<component name="FacetManager">
|
||||
<facet type="kotlin-language" name="Kotlin">
|
||||
<configuration version="5" platform="JVM 21" allPlatforms="JVM [21]" useProjectSettings="false">
|
||||
<compilerSettings>
|
||||
<option name="additionalArguments" value="-Xjvm-default=all -XXLanguage:+AllowEagerSupertypeAccessibilityChecks -opt-in=com.intellij.openapi.util.IntellijInternalApi -Xcontext-parameters" />
|
||||
</compilerSettings>
|
||||
<compilerArguments>
|
||||
<stringArguments>
|
||||
<stringArg name="jvmTarget" arg="21" />
|
||||
<stringArg name="apiVersion" arg="2.2" />
|
||||
<stringArg name="languageVersion" arg="2.2" />
|
||||
</stringArguments>
|
||||
</compilerArguments>
|
||||
</configuration>
|
||||
</facet>
|
||||
</component>
|
||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/resources" type="java-test-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/tests" isTestSource="true" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="library" name="kodein-di-jvm" level="project" />
|
||||
<orderEntry type="library" name="kotlin-stdlib" level="project" />
|
||||
<orderEntry type="library" name="kotlin-test" level="project" />
|
||||
<orderEntry type="library" name="assertJ" level="project" />
|
||||
<orderEntry type="module" module-name="intellij.libraries.kotlin.reflect" />
|
||||
<orderEntry type="module" module-name="intellij.tools.ide.starter" />
|
||||
<orderEntry type="module" module-name="intellij.tools.ide.starter.junit5" scope="TEST" />
|
||||
<orderEntry type="module" module-name="intellij.tools.ide.starter.driver" />
|
||||
<orderEntry type="module" module-name="intellij.tools.ide.starter.build.server" />
|
||||
<orderEntry type="module" module-name="intellij.platform.core" />
|
||||
<orderEntry type="module" module-name="intellij.platform.core.impl" />
|
||||
<orderEntry type="module" module-name="intellij.platform.core.ui" />
|
||||
<orderEntry type="module" module-name="intellij.platform.lang" />
|
||||
<orderEntry type="module" module-name="intellij.platform.lang.impl" />
|
||||
<orderEntry type="module" module-name="intellij.platform.ide" />
|
||||
<orderEntry type="module" module-name="intellij.platform.editor.ui" />
|
||||
<orderEntry type="module" module-name="intellij.platform.editor.ex" />
|
||||
<orderEntry type="module" module-name="intellij.platform.testFramework.junit5" />
|
||||
<orderEntry type="module" module-name="intellij.platform.codeStyle" />
|
||||
<orderEntry type="module" module-name="intellij.platform.execution.impl" />
|
||||
<orderEntry type="module" module-name="intellij.platform.ide.impl" />
|
||||
<orderEntry type="module" module-name="intellij.remoteDev.util" />
|
||||
<orderEntry type="module" module-name="intellij.platform.analysis" />
|
||||
<orderEntry type="module" module-name="intellij.performanceTesting" />
|
||||
<orderEntry type="module" module-name="intellij.platform.ide.codeinsight.inline" />
|
||||
<orderEntry type="module" module-name="intellij.platform.debugger" />
|
||||
<orderEntry type="module" module-name="intellij.platform.debugger.impl" />
|
||||
<orderEntry type="module" module-name="intellij.platform.concurrency" />
|
||||
<orderEntry type="module" module-name="intellij.platform.usageView" />
|
||||
<orderEntry type="module" module-name="intellij.lambda.testFramework" />
|
||||
<orderEntry type="module" module-name="intellij.libraries.junit5" scope="TEST" />
|
||||
<orderEntry type="module" module-name="intellij.libraries.junit5.launcher" scope="TEST" />
|
||||
<orderEntry type="module" module-name="intellij.libraries.junit5.params" scope="TEST" />
|
||||
<orderEntry type="module" module-name="intellij.libraries.junit5.pioneer" scope="TEST" />
|
||||
<orderEntry type="library" name="rd-framework" level="project" />
|
||||
<orderEntry type="library" name="rd-core" level="project" />
|
||||
</component>
|
||||
</module>
|
||||
+3
-3
@@ -1,4 +1,4 @@
|
||||
### auto-generated section `build intellij.lambda.sampleTests.plugin` start
|
||||
### auto-generated section `build intellij.lambda.sampleTestsWithPlugin.plugin` start
|
||||
load("@rules_jvm//:jvm.bzl", "jvm_library", "resourcegroup")
|
||||
|
||||
resourcegroup(
|
||||
@@ -9,9 +9,9 @@ resourcegroup(
|
||||
|
||||
jvm_library(
|
||||
name = "plugin_test_lib",
|
||||
module_name = "intellij.lambda.sampleTests.plugin",
|
||||
module_name = "intellij.lambda.sampleTestsWithPlugin.plugin",
|
||||
visibility = ["//visibility:public"],
|
||||
srcs = glob([], allow_empty = True),
|
||||
resources = [":plugin_test_resources"]
|
||||
)
|
||||
### auto-generated section `build intellij.lambda.sampleTests.plugin` end
|
||||
### auto-generated section `build intellij.lambda.sampleTestsWithPlugin.plugin` end
|
||||
+2
-2
@@ -1,9 +1,9 @@
|
||||
<idea-plugin>
|
||||
<id>com.intellij.lambda.sampleTests.plugin</id>
|
||||
<id>com.intellij.lambda.sampleTestsWithPlugin.plugin</id>
|
||||
<vendor>JetBrains</vendor>
|
||||
|
||||
<content namespace="jetbrains">
|
||||
<module name="intellij.lambda.sampleTests._test" />
|
||||
<module name="intellij.lambda.sampleTestsWithPlugin._test" />
|
||||
</content>
|
||||
<dependencies>
|
||||
<module name="intellij.lambda.testFramework"/>
|
||||
+1
@@ -0,0 +1 @@
|
||||
com.intellij.lambda.sampleTestsWithPlugin.util.SetLambdaPluginCallback
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
<idea-plugin>
|
||||
</idea-plugin>
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package com.intellij.lambda.sampleTests
|
||||
package com.intellij.lambda.sampleTestsWithPlugin
|
||||
|
||||
import com.intellij.lambda.testFramework.junit.ExecuteInMonolithAndSplitMode
|
||||
import com.intellij.lambda.testFramework.utils.BackgroundRunWithLambda
|
||||
+79
@@ -0,0 +1,79 @@
|
||||
// Copyright 2000-2025 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.lambda.sampleTestsWithPlugin
|
||||
|
||||
import com.intellij.ide.plugins.PluginModuleDescriptor
|
||||
import com.intellij.lambda.testFramework.junit.ExecuteInMonolithAndSplitMode
|
||||
import com.intellij.lambda.testFramework.junit.UltimateTestCases.JpsEmptyProject
|
||||
import com.intellij.lambda.testFramework.testApi.editor.openFile
|
||||
import com.intellij.lambda.testFramework.testApi.getProject
|
||||
import com.intellij.lambda.testFramework.testApi.getProjects
|
||||
import com.intellij.lambda.testFramework.testApi.utils.tryTimes
|
||||
import com.intellij.lambda.testFramework.testApi.waitForProject
|
||||
import com.intellij.lambda.testFramework.utils.BackgroundRunWithLambda
|
||||
import com.intellij.openapi.diagnostic.Logger
|
||||
import com.intellij.openapi.diagnostic.currentClassLogger
|
||||
import com.intellij.remoteDev.tests.LambdaBackendContext
|
||||
import com.intellij.remoteDev.tests.LambdaFrontendContext
|
||||
import com.intellij.remoteDev.tests.impl.LambdaTestHost.Companion.NamedLambda
|
||||
import com.intellij.remoteDev.tests.modelGenerated.LambdaRdKeyValueEntry
|
||||
import com.intellij.util.io.createDirectories
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import org.junit.jupiter.api.TestTemplate
|
||||
import kotlin.io.path.createFile
|
||||
import kotlin.io.path.exists
|
||||
import kotlin.time.Duration.Companion.seconds
|
||||
|
||||
@ExecuteInMonolithAndSplitMode
|
||||
class SampleTest {
|
||||
@TestTemplate
|
||||
fun `serialized test`(ide: BackgroundRunWithLambda) = runBlocking {
|
||||
//works in both modes if
|
||||
// headless is turned off for monolith in com.intellij.lambda.testFramework.starter.NewContextWithLambdaKt.newContextWithLambda
|
||||
// as ProjectManager returns empty projects list in headless
|
||||
JpsEmptyProject.projectInfo.projectDir.resolve("src").resolve("FormattingExamplesExpected.java").let {
|
||||
if (!it.exists()) {
|
||||
it.parent.createDirectories()
|
||||
it.createFile()
|
||||
}
|
||||
}
|
||||
ide.apply {
|
||||
runInBackend {
|
||||
waitForProject(20.seconds)
|
||||
}
|
||||
|
||||
run {
|
||||
Logger.getInstance("test").warn("Projects: " + getProjects().joinToString { it.name })
|
||||
}
|
||||
|
||||
runInBackend {
|
||||
Logger.getInstance("test").warn("backend Projects: " + getProject())
|
||||
openFile("src/FormattingExamplesExpected.java", waitForReadyState = false, requireFocus = false)
|
||||
}
|
||||
}
|
||||
Unit
|
||||
}
|
||||
|
||||
@TestTemplate
|
||||
fun `named lambda test`(ide: BackgroundRunWithLambda) = runBlocking {
|
||||
ide.runNamedLambdaInBackend(HelloBackendOnlyLambda::class)
|
||||
ide.runNamedLambda(HelloFrontendOnlyLambda::class)
|
||||
}
|
||||
|
||||
companion object {
|
||||
class HelloFrontendOnlyLambda(frontendIdeContext: LambdaFrontendContext, plugin: PluginModuleDescriptor)
|
||||
: NamedLambda<LambdaFrontendContext>(frontendIdeContext, plugin) {
|
||||
override suspend fun LambdaFrontendContext.lambda(args: List<LambdaRdKeyValueEntry>): Any {
|
||||
return tryTimes(2, "Log") { currentClassLogger().warn("Hi there Frontend") }
|
||||
}
|
||||
}
|
||||
|
||||
class HelloBackendOnlyLambda(backendIdeContext: LambdaBackendContext, plugin: PluginModuleDescriptor)
|
||||
: NamedLambda<LambdaBackendContext>(backendIdeContext, plugin) {
|
||||
override suspend fun LambdaBackendContext.lambda(args: List<LambdaRdKeyValueEntry>): Any {
|
||||
return tryTimes(2, "Log") { currentClassLogger().warn("Hi there Backend") }
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package com.intellij.lambda.sampleTests
|
||||
package com.intellij.lambda.sampleTestsWithPlugin
|
||||
|
||||
import com.intellij.lambda.testFramework.junit.ExecuteInMonolithAndSplitMode
|
||||
import com.intellij.openapi.application.ApplicationManager
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
package com.intellij.lambda.sampleTestsWithPlugin.util
|
||||
|
||||
import com.intellij.lambda.testFramework.utils.LambdaTestPluginHolder
|
||||
import com.intellij.lambda.testFramework.utils.LambdaTestPluginHolder.defaultLambdaPlugin
|
||||
import org.junit.jupiter.api.extension.AfterAllCallback
|
||||
import org.junit.jupiter.api.extension.BeforeAllCallback
|
||||
import org.junit.jupiter.api.extension.ExtensionContext
|
||||
|
||||
class SetLambdaPluginCallback : BeforeAllCallback, AfterAllCallback {
|
||||
val localCustomLambdaPlugin = LambdaTestPluginHolder.AdditionalLambdaPlugin("intellij.lambda.sampleTestsWithPlugin._test",
|
||||
"intellij.lambda.sampleTestsWithPlugin.plugin",
|
||||
"lambda-sampleTestsWithPlugin-plugin")
|
||||
|
||||
override fun beforeAll(context: ExtensionContext) {
|
||||
LambdaTestPluginHolder.setupAdditionalLambdaPlugins(localCustomLambdaPlugin.moduleID, listOf(localCustomLambdaPlugin, defaultLambdaPlugin))
|
||||
}
|
||||
override fun afterAll(context: ExtensionContext) {
|
||||
LambdaTestPluginHolder.cleanUpAdditionalLambdaPlugin()
|
||||
}
|
||||
}
|
||||
+3
-1
@@ -69,7 +69,9 @@ object IdeLambdaStarter {
|
||||
|
||||
applyVMOptionsPatch {
|
||||
addSystemProperty(LambdaTestsConstants.protocolPortPropertyName, testProtocolPort)
|
||||
addSystemProperty(TEST_MODULE_ID_PROPERTY_NAME, LambdaTestPluginHolder.testModuleId())
|
||||
LambdaTestPluginHolder.testModuleId()?.let {
|
||||
addSystemProperty(TEST_MODULE_ID_PROPERTY_NAME, it)
|
||||
}
|
||||
}
|
||||
|
||||
val rdSession = LambdaRdTestSession(lambdaRdIdeType)
|
||||
|
||||
+16
-11
@@ -1,21 +1,26 @@
|
||||
package com.intellij.lambda.testFramework.utils
|
||||
|
||||
object LambdaTestPluginHolder {
|
||||
private data class AdditionalLambdaPlugin(val moduleID: String, val pluginId: String, val pluginDirName: String)
|
||||
data class AdditionalLambdaPlugin(val moduleID: String, val pluginId: String, val pluginDirName: String)
|
||||
|
||||
private var additionalLambdaPlugin: AdditionalLambdaPlugin? = null
|
||||
private val defaultLambdaPlugin: AdditionalLambdaPlugin = AdditionalLambdaPlugin("intellij.lambda.testFramework",
|
||||
"intellij.lambda.test.plugin",
|
||||
"lambda-test-plugin")
|
||||
private var additionalLambdaPlugins: List<AdditionalLambdaPlugin> = emptyList()
|
||||
private var mainTestModuleId: String? = null
|
||||
val defaultLambdaPlugin: AdditionalLambdaPlugin = AdditionalLambdaPlugin("intellij.lambda.testFramework",
|
||||
"intellij.lambda.test.plugin",
|
||||
"lambda-test-plugin")
|
||||
|
||||
fun testModuleId(): String = additionalLambdaPlugin?.moduleID ?: defaultLambdaPlugin.moduleID
|
||||
fun additionalPluginIds(): List<String> = listOfNotNull(defaultLambdaPlugin.pluginId, additionalLambdaPlugin?.pluginId)
|
||||
fun additionalPluginDirNames(): List<String> = listOfNotNull(defaultLambdaPlugin.pluginDirName, additionalLambdaPlugin?.pluginDirName)
|
||||
|
||||
fun setupAdditionalLambdaPlugin(moduleID: String, pluginId: String, pluginDirName: String) {
|
||||
additionalLambdaPlugin = AdditionalLambdaPlugin(moduleID, pluginId, pluginDirName)
|
||||
fun testModuleId(): String? = mainTestModuleId
|
||||
fun additionalPluginIds(): List<String> = additionalLambdaPlugins.map { it.pluginId }
|
||||
fun additionalPluginDirNames(): List<String> = additionalLambdaPlugins.map { it.pluginDirName }
|
||||
|
||||
fun setupAdditionalLambdaPlugins(mainTestModuleId: String, additionalLambdaPlugins: List<AdditionalLambdaPlugin>) {
|
||||
this.mainTestModuleId = mainTestModuleId
|
||||
this.additionalLambdaPlugins = additionalLambdaPlugins
|
||||
}
|
||||
|
||||
fun cleanUpAdditionalLambdaPlugin() {
|
||||
additionalLambdaPlugin = null
|
||||
this.mainTestModuleId = null
|
||||
this.additionalLambdaPlugins = emptyList()
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user