mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[performance-plugin] add assert find usage count command for perf tests
GitOrigin-RevId: 1265fad054429efe2f05fceea8fc982de22161a5
This commit is contained in:
committed by
intellij-monorepo-bot
parent
520629186c
commit
f2f6c9d1db
+2
-1
@@ -75,7 +75,8 @@ public final class BaseCommandProvider implements CommandProvider {
|
||||
Map.entry(CloseAllTabsCommand.PREFIX, CloseAllTabsCommand::new),
|
||||
Map.entry(CollectAllFilesCommand.PREFIX, CollectAllFilesCommand::new),
|
||||
Map.entry(ExecuteEditorActionCommand.PREFIX, ExecuteEditorActionCommand::new),
|
||||
Map.entry(AssertCompletionCommand.PREFIX, AssertCompletionCommand::new)
|
||||
Map.entry(AssertCompletionCommand.PREFIX, AssertCompletionCommand::new),
|
||||
Map.entry(AssertFindUsagesCommand.PREFIX, AssertFindUsagesCommand::new)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
+33
@@ -0,0 +1,33 @@
|
||||
package com.jetbrains.performancePlugin.commands
|
||||
|
||||
import com.intellij.openapi.ui.playback.PlaybackContext
|
||||
import com.intellij.openapi.ui.playback.commands.PlaybackCommandCoroutineAdapter
|
||||
import com.jetbrains.performancePlugin.utils.DataDumper
|
||||
import org.jetbrains.annotations.NonNls
|
||||
import java.nio.file.Files
|
||||
|
||||
class AssertFindUsagesCommand(text: String, line: Int) : PlaybackCommandCoroutineAdapter(text, line) {
|
||||
companion object {
|
||||
const val PREFIX: @NonNls String = CMD_PREFIX + "assertFindUsagesCommand"
|
||||
}
|
||||
|
||||
override suspend fun doExecute(context: PlaybackContext) {
|
||||
val lastUsageReport = FindUsagesCommand.getFoundUsagesJsonPath()
|
||||
if (lastUsageReport == null) {
|
||||
throw IllegalStateException("Find usages report is null")
|
||||
}
|
||||
if (!Files.exists(lastUsageReport) || !Files.isRegularFile(lastUsageReport)) {
|
||||
throw IllegalStateException("Find usages report file not exists $lastUsageReport")
|
||||
}
|
||||
val args = extractCommandArgument(PREFIX).split(" ").filterNot { it.trim() == "" }
|
||||
if (args.isEmpty()) {
|
||||
throw IllegalStateException("Provide expected count of usages")
|
||||
}
|
||||
|
||||
val data: FindUsagesCommand.FoundUsagesReport = DataDumper.read(lastUsageReport, FindUsagesCommand.FoundUsagesReport::class.java)
|
||||
val expected = args[0].toInt()
|
||||
if (data.totalNumberOfUsages != expected) {
|
||||
throw IllegalStateException("Expected ${expected} find usages, but got ${data.totalNumberOfUsages}")
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user