mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-03-22 06:50:54 +07:00
[performanceTests] Add assertion about required combination of parameter for OpenProjectCommand
We need to close a previous project to perform project leak analysis otherwise there will be strong references GitOrigin-RevId: 5586b1e71a2850193d053ffe8df93684818a4a22
This commit is contained in:
committed by
intellij-monorepo-bot
parent
1db19989bb
commit
e4bd3e0189
@@ -99,6 +99,7 @@ fun <T : CommandChain> T.openRandomFile(extension: String): T = apply {
|
||||
}
|
||||
|
||||
fun <T : CommandChain> T.openProject(projectPath: Path, openInNewWindow: Boolean = true, detectProjectLeak: Boolean = false): T = apply {
|
||||
if(detectProjectLeak && openInNewWindow) throw IllegalArgumentException("To analyze the project leak, we need to close the project")
|
||||
addCommand("${CMD_PREFIX}openProject", projectPath.toString(), (!openInNewWindow).toString(), detectProjectLeak.toString())
|
||||
}
|
||||
|
||||
|
||||
@@ -54,8 +54,8 @@ import java.util.*
|
||||
*
|
||||
* In the end, the same project a will be active and there will be 2 window frames.
|
||||
*
|
||||
* To perform Project Leak detection, pass the fourth argument as true.
|
||||
* %openProject /tmp/a true true
|
||||
* To perform Project Leak detection, pass the fourth argument as true but make sure that previous project is closed.
|
||||
* %openProject /tmp/a false true
|
||||
*/
|
||||
class OpenProjectCommand(text: String, line: Int) : PlaybackCommandCoroutineAdapter(text, line) {
|
||||
companion object {
|
||||
@@ -75,6 +75,7 @@ class OpenProjectCommand(text: String, line: Int) : PlaybackCommandCoroutineAdap
|
||||
val projectToOpen = if (arguments.size > 1) arguments[1] else ""
|
||||
val closeProjectBeforeOpening = arguments.size < 3 || arguments[2].toBoolean()
|
||||
val detectProjectLeak = arguments.size > 3 && arguments[3].toBoolean()
|
||||
if(!closeProjectBeforeOpening && detectProjectLeak) throw IllegalArgumentException("Previous project has to be closed to perform project leak detection")
|
||||
val project = context.project
|
||||
if (projectToOpen.isEmpty() && project.isDefault) {
|
||||
throw IllegalArgumentException("Path to project to open required")
|
||||
@@ -137,6 +138,9 @@ class OpenProjectCommand(text: String, line: Int) : PlaybackCommandCoroutineAdap
|
||||
context.setProject(newProject)
|
||||
}
|
||||
|
||||
/**
|
||||
* @param projectName project to exclude from analysis
|
||||
*/
|
||||
private class AnalyzeProjectGraph(analysisContext: AnalysisContext, listProvider: ListProvider, val projectName: String)
|
||||
: AnalyzeGraph(analysisContext, listProvider) {
|
||||
override fun analyze(progress: ProgressIndicator): AnalysisReport = AnalysisReport().apply {
|
||||
@@ -160,6 +164,9 @@ class OpenProjectCommand(text: String, line: Int) : PlaybackCommandCoroutineAdap
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param newProject current opened project, it will be excluded from analysis
|
||||
*/
|
||||
private fun analyzeSnapshot(newProject: Project) {
|
||||
val snapshotDate = SimpleDateFormat("dd.MM.yyyy_HH.mm.ss").format(Date())
|
||||
val snapshotFileName = "reopen-project-$snapshotDate.hprof"
|
||||
|
||||
Reference in New Issue
Block a user