Skip to content

WIP add integration test (not working) #8338

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion .idea/compiler.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

202 changes: 149 additions & 53 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import org.jetbrains.intellij.platform.gradle.tasks.VerifyPluginTask
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import org.jetbrains.kotlin.gradle.dsl.KotlinVersion
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
import org.gradle.kotlin.dsl.register

// Specify UTF-8 for all compilations so we avoid Windows-1252.
allprojects {
Expand Down Expand Up @@ -102,23 +103,26 @@ dependencies {
// https://plugins.jetbrains.com/docs/intellij/tools-intellij-platform-gradle-plugin-dependencies-extension.html#default-target-platforms
androidStudio(ideaVersion)
testFramework(TestFrameworkType.Platform)
testFramework(TestFrameworkType.Starter)

// Plugin dependency documentation:
// https://plugins.jetbrains.com/docs/intellij/tools-intellij-platform-gradle-plugin-dependencies-extension.html#plugins
// https://plugins.jetbrains.com/docs/intellij/plugin-dependencies.html#project-setup
bundledPlugins(immutableListOf(
"com.google.tools.ij.aiplugin",
"com.intellij.java",
"com.intellij.properties",
"JUnit",
"Git4Idea",
"org.jetbrains.kotlin",
"org.jetbrains.plugins.gradle",
"org.jetbrains.plugins.yaml",
"org.intellij.intelliLang",
"org.jetbrains.android",
"com.android.tools.idea.smali"
))
bundledPlugins(
immutableListOf(
"com.google.tools.ij.aiplugin",
"com.intellij.java",
"com.intellij.properties",
"JUnit",
"Git4Idea",
"org.jetbrains.kotlin",
"org.jetbrains.plugins.gradle",
"org.jetbrains.plugins.yaml",
"org.intellij.intelliLang",
"org.jetbrains.android",
"com.android.tools.idea.smali"
)
)
plugin("Dart:$dartPluginVersion")

if (sinceBuildInput == "243" || sinceBuildInput == "251") {
Expand All @@ -136,6 +140,16 @@ dependencies {
testImplementation("com.google.guava:guava:32.0.1-jre")
testImplementation("com.google.code.gson:gson:2.10.1")
testImplementation("junit:junit:4.13.2")

// Starter Framework
testImplementation("com.jetbrains.intellij.tools:ide-starter-squashed:LATEST-EAP-SNAPSHOT")
testImplementation("com.jetbrains.intellij.tools:ide-starter-junit5:LATEST-EAP-SNAPSHOT")

testImplementation("com.jetbrains.intellij.tools:ide-starter-driver:LATEST-EAP-SNAPSHOT")
testImplementation("com.jetbrains.intellij.driver:driver-client:LATEST-EAP-SNAPSHOT")
testImplementation("com.jetbrains.intellij.driver:driver-sdk:LATEST-EAP-SNAPSHOT")
testImplementation("com.jetbrains.intellij.driver:driver-model:LATEST-EAP-SNAPSHOT")

implementation(
fileTree(
mapOf(
Expand All @@ -146,6 +160,89 @@ dependencies {
)
}

sourceSets {
main {
java.srcDirs(
listOf(
"flutter-idea/src",
"flutter-idea/third_party/vmServiceDrivers"
)
)
// Add kotlin.srcDirs if we start using Kotlin in the main plugin.
resources.srcDirs(
listOf(
"flutter-idea/src",
"resources"
)
)
java.srcDirs(
listOf(
"flutter-studio/src",
"flutter-studio/third_party/vmServiceDrivers"
)
)
}
test {
// kotlin.srcDir("src/integrationTest/kotlin")
java.srcDirs(
listOf(
"flutter-idea/src",
"flutter-idea/testSrc/unit",
"flutter-idea/third_party/vmServiceDrivers"
)
)
resources.srcDirs(
listOf(
"resources",
"flutter-idea/testData",
"flutter-idea/testSrc/unit"
)
)
}

create("integrationTest") {
// kotlin.srcDir("src/integrationTest/kotlin")
// java.srcDirs(
// listOf(
// "flutter-idea/src",
// "flutter-idea/testSrc/unit",
// "flutter-idea/third_party/vmServiceDrivers"
// )
// )
// // It's good practice to also have a resources directory
// resources.srcDir("src/integrationTest/resources")
//
//
// // This gives your tests access to your main app's code.
// compileClasspath += sourceSets.main.get().output
// compileClasspath += sourceSets.test.get().output
// runtimeClasspath += sourceSets.main.get().output
// runtimeClasspath += sourceSets.test.get().output
compileClasspath += configurations.getByName("testCompileClasspath")
runtimeClasspath += configurations.getByName("testRuntimeClasspath")
// compileClasspath += configurations.getByName("integrationTestImplementation")

}
}

//configurations {
// // Get the configuration that was automatically created for the 'integrationTest' source set...
// getByName("integrationTestImplementation") {
// // ...and tell it to inherit all dependencies from the regular 'testImplementation'.
// // This is the crucial link that provides the IntelliJ test framework.
// extendsFrom(getByName("testImplementation"))
// }
//}

val integrationTestImplementation by configurations.getting {
extendsFrom(configurations.testImplementation.get())
}

dependencies {
integrationTestImplementation("org.junit.jupiter:junit-jupiter:5.7.1")
integrationTestImplementation("org.kodein.di:kodein-di-jvm:7.20.2")
integrationTestImplementation("org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:1.10.1")
}

intellijPlatform {
pluginConfiguration {
Expand Down Expand Up @@ -194,44 +291,13 @@ intellijPlatform {
}
}

sourceSets {
main {
java.srcDirs(
listOf(
"flutter-idea/src",
"flutter-idea/third_party/vmServiceDrivers"
)
)
// Add kotlin.srcDirs if we start using Kotlin in the main plugin.
resources.srcDirs(
listOf(
"flutter-idea/src",
"resources"
)
)
java.srcDirs(
listOf(
"flutter-studio/src",
"flutter-studio/third_party/vmServiceDrivers"
)
)
}
test {
java.srcDirs(
listOf(
"flutter-idea/src",
"flutter-idea/testSrc/unit",
"flutter-idea/third_party/vmServiceDrivers"
)
)
resources.srcDirs(
listOf(
"resources",
"flutter-idea/testData",
"flutter-idea/testSrc/unit"
)
)
}
val integrationTest = tasks.register<Test>("integrationTest") {
val integrationTestSourceSet = sourceSets.getByName("integrationTest")
testClassesDirs = integrationTestSourceSet.output.classesDirs
classpath = integrationTestSourceSet.runtimeClasspath
systemProperty("path.to.build.plugin", tasks.prepareSandbox.get().pluginDirectory.get().asFile)
useJUnitPlatform()
dependsOn(tasks.prepareSandbox)
}

// Documentation for printProductsReleases:
Expand Down Expand Up @@ -269,9 +335,39 @@ tasks {
tasks.register("printCompileClasspath") {
doLast {
println("--- Begin Compile Classpath ---")
configurations.getByName("compileClasspath").forEach { file ->
println(file.absolutePath)
// configurations.getByName("compileClasspath").forEach { file ->
// println(file.absolutePath)
// }
println("\n--- Integration Test Compile Classpath ---")
sourceSets.getByName("integrationTest").compileClasspath.forEach { file ->
println(file.name)
}
//
// println("\n--- Main Compile Classpath ---")
// sourceSets.main.get().compileClasspath.forEach { file ->
// println(file.name)
// }

// println("\n--- Test Compile Classpath ---")
// sourceSets.test.get().compileClasspath.forEach { file ->
// println(file.name)
// }

println("--- End Compile Classpath ---")
}
}

tasks.register("printAllConfigurations") {
group = "help"
description = "Prints all configurations and their properties."

doLast {
println("--- All Project Configurations ---")
project.configurations.all {
println("Name: ${this.name}")
println(" - Can be resolved: ${this.isCanBeResolved}")
println(" - Extends from: ${this.extendsFrom.map { it.name }}")
println("")
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ public void flushFlutterErrorQueue() {
private static final ArrayList<DiagnosticsNode> emptyList = new ArrayList<>();

/**
* Pretty print the error using the available console syling attributes.
* Pretty print the error using the available console styling attributes.
*/
private void processFlutterErrorEvent(@NotNull DiagnosticsNode diagnosticsNode) {
final String description = " " + diagnosticsNode + " ";
Expand Down
4 changes: 2 additions & 2 deletions resources/META-INF/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<category>Custom Languages</category>
<version>SNAPSHOT</version>
<!--suppress PluginXmlValidity -->
<idea-version since-build="243" until-build="243.*"/>
<idea-version since-build="251" until-build="253.*"/>

<depends>com.intellij.modules.platform</depends>
<depends>com.intellij.modules.lang</depends>
Expand All @@ -45,7 +45,7 @@

<!-- Contributes Android Studio-specific features and implementations. -->
<!--suppress PluginXmlValidity -->
<depends optional="true" config-file="studio-contribs.xml">com.intellij.modules.androidstudio</depends>
<depends optional="true" config-file="studio-contribs.xml">com.android.tools.apk</depends>


<change-notes>
Expand Down
31 changes: 31 additions & 0 deletions src/integrationTest/kotlin/PluginTest.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* Copyright 2025 The Chromium Authors. All rights reserved.
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
import com.intellij.ide.starter.ci.CIServer
import com.intellij.ide.starter.ci.NoCIServer
import com.intellij.ide.starter.di.di
import com.intellij.ide.starter.driver.engine.runIdeWithDriver
import com.intellij.ide.starter.ide.IdeProductProvider
import com.intellij.ide.starter.models.TestCase
import com.intellij.ide.starter.plugins.PluginConfigurator
import com.intellij.ide.starter.project.GitHubProject
import com.intellij.ide.starter.runner.Starter
import org.junit.Test

class PluginTest {
@Test
fun simpleTestWithoutProject() {
println("In integration test")
// Starter.newContext(
// testName = "testExample",
// TestCase(IdeProductProvider.IC, projectInfo = NoProject)
// .withVersion("2024.3")
// ).apply {
// val pathToPlugin = System.getProperty("path.to.build.plugin")
// PluginConfigurator(this).installPluginFromFolder(File(pathToPlugin))
// }.runIdeWithDriver().useDriverAndCloseIde {
// }
}
}
Loading