-
Notifications
You must be signed in to change notification settings - Fork 156
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add example implementation of ide-starter
- Loading branch information
Showing
15 changed files
with
169 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
subprojects/ide-provisioning-api/src/main/java/org/gradle/profiler/ide/CommandChain.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package org.gradle.profiler.ide; | ||
|
||
public interface CommandChain { | ||
CommandChain importGradleProject(); | ||
CommandChain waitForSmartMode(); | ||
CommandChain exitApp(); | ||
void run(); | ||
} |
5 changes: 0 additions & 5 deletions
5
subprojects/ide-provisioning-api/src/main/java/org/gradle/profiler/ide/RunIde.java
This file was deleted.
Oops, something went wrong.
6 changes: 6 additions & 0 deletions
6
subprojects/ide-provisioning-api/src/main/java/org/gradle/profiler/ide/RunIdeContext.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package org.gradle.profiler.ide; | ||
|
||
public interface RunIdeContext { | ||
RunIdeContext withSystemProperty(String key, String value); | ||
CommandChain withCommands(); | ||
} |
5 changes: 5 additions & 0 deletions
5
subprojects/ide-provisioning-api/src/main/java/org/gradle/profiler/ide/RunIdeStarter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package org.gradle.profiler.ide; | ||
|
||
public interface RunIdeStarter { | ||
RunIdeContext newContext(String projectLocation, String ideLocation); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 0 additions & 8 deletions
8
subprojects/ide-provisioning/src/main/java/org/gradle/profiler/ide/RunIdeImpl.java
This file was deleted.
Oops, something went wrong.
30 changes: 30 additions & 0 deletions
30
subprojects/ide-provisioning/src/main/kotlin/org/gradle/profiler/ide/CommandChainImpl.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package org.gradle.profiler.ide | ||
|
||
import com.intellij.ide.starter.ide.IDETestContext | ||
import com.intellij.tools.ide.performanceTesting.commands.exitApp | ||
import com.intellij.tools.ide.performanceTesting.commands.importGradleProject | ||
import com.intellij.tools.ide.performanceTesting.commands.waitForSmartMode | ||
|
||
class CommandChainImpl(private val context: IDETestContext) : CommandChain { | ||
|
||
private var commandChain = com.intellij.tools.ide.performanceTesting.commands.CommandChain() | ||
|
||
override fun importGradleProject(): CommandChain { | ||
commandChain = commandChain.importGradleProject() | ||
return this | ||
} | ||
|
||
override fun waitForSmartMode(): CommandChain { | ||
commandChain = commandChain.waitForSmartMode() | ||
return this | ||
} | ||
|
||
override fun exitApp(): CommandChain { | ||
commandChain = commandChain.exitApp() | ||
return this | ||
} | ||
|
||
override fun run() { | ||
context.runIDE(commands = commandChain) | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
subprojects/ide-provisioning/src/main/kotlin/org/gradle/profiler/ide/RunIdeContextImpl.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package org.gradle.profiler.ide | ||
|
||
import com.intellij.ide.starter.ide.IDETestContext | ||
|
||
class RunIdeContextImpl(private val context: IDETestContext) : RunIdeContext { | ||
override fun withSystemProperty(key: String, value: String): RunIdeContext { | ||
context.applyVMOptionsPatch { | ||
addSystemProperty(key, value) | ||
} | ||
return this | ||
} | ||
|
||
override fun withCommands(): CommandChain { | ||
return CommandChainImpl(context) | ||
} | ||
} |
77 changes: 77 additions & 0 deletions
77
subprojects/ide-provisioning/src/main/kotlin/org/gradle/profiler/ide/RunIdeStarterImpl.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
package org.gradle.profiler.ide | ||
|
||
import com.intellij.ide.starter.ide.IDETestContext | ||
import com.intellij.ide.starter.ide.IdeDistributionFactory | ||
import com.intellij.ide.starter.ide.IdeInstaller | ||
import com.intellij.ide.starter.ide.InstalledIde | ||
import com.intellij.ide.starter.ide.installer.ExistingIdeInstaller | ||
import com.intellij.ide.starter.ide.installer.IdeInstallerFile | ||
import com.intellij.ide.starter.models.IdeInfo | ||
import com.intellij.ide.starter.models.TestCase | ||
import com.intellij.ide.starter.path.GlobalPaths | ||
import com.intellij.ide.starter.process.exec.ProcessExecutor | ||
import com.intellij.ide.starter.project.LocalProjectInfo | ||
import com.intellij.ide.starter.runner.TestContainer | ||
import com.intellij.ide.starter.runner.TestContainerImpl | ||
import com.intellij.openapi.util.SystemInfo | ||
import com.intellij.openapi.util.io.FileUtil | ||
import java.nio.file.Path | ||
import java.nio.file.Paths | ||
import kotlin.io.path.div | ||
import kotlin.io.path.name | ||
import kotlin.time.Duration.Companion.minutes | ||
|
||
class RunIdeStarterImpl : RunIdeStarter { | ||
override fun newContext(projectLocation: String, ideLocation: String): RunIdeContext { | ||
val testVersion = "2023.2.3" | ||
val ideInfo = IdeInfo( | ||
productCode = "IC", | ||
version = "2023.2", | ||
// buildNumber = testVersion, | ||
executableFileName = "idea", | ||
fullName = "IntelliJ IDEA Community", | ||
platformPrefix = "idea", | ||
// getInstaller = { _ -> ExistingIdeInstaller(Paths.get(ideLocation)) } | ||
) | ||
val testCase = TestCase( | ||
ideInfo, | ||
LocalProjectInfo(Paths.get(projectLocation)), | ||
) | ||
val context = Starter.newContext("test", testCase) | ||
return RunIdeContextImpl(context) | ||
} | ||
|
||
class ExistingIdeInstaller(private val installedIdePath: Path) : IdeInstaller { | ||
override fun install(ideInfo: IdeInfo, includeRuntimeModuleRepository: Boolean): Pair<String, InstalledIde> { | ||
val ideInstaller = IdeInstallerFile(installedIdePath, "locally-installed-ide") | ||
val installDir = GlobalPaths.instance | ||
.getCacheDirectoryFor("builds") / "${ideInfo.productCode}-${ideInstaller.buildNumber}" | ||
installDir.toFile().deleteRecursively() | ||
val installedIde = installedIdePath.toFile() | ||
val destDir = installDir.resolve(installedIdePath.name).toFile() | ||
if (SystemInfo.isMac) { | ||
ProcessExecutor("copy app", null, 5.minutes, emptyMap(), listOf("ditto", installedIde.absolutePath, destDir.absolutePath)).start() | ||
} | ||
else { | ||
FileUtil.copyDir(installedIde, destDir) | ||
} | ||
return Pair( | ||
ideInstaller.buildNumber, | ||
IdeDistributionFactory.installIDE(installDir.toFile(), ideInfo.executableFileName) | ||
) | ||
} | ||
} | ||
|
||
private object Starter { | ||
private fun newTestContainer(): TestContainer<*> { | ||
return TestContainerImpl() | ||
} | ||
|
||
fun newContext(testName: String, testCase: TestCase<*>, preserveSystemDir: Boolean = false): IDETestContext = | ||
newTestContainer().initializeTestContext( | ||
testName = testName, | ||
testCase = testCase, | ||
preserveSystemDir = preserveSystemDir | ||
) | ||
} | ||
} |
1 change: 0 additions & 1 deletion
1
...ects/ide-provisioning/src/main/resources/META-INF/services/org.gradle.profiler.ide.RunIde
This file was deleted.
Oops, something went wrong.
1 change: 1 addition & 0 deletions
1
...e-provisioning/src/main/resources/META-INF/services/org.gradle.profiler.ide.RunIdeStarter
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
org.gradle.profiler.ide.RunIdeStarterImpl |