Skip to content

Commit

Permalink
(#319) Debug Previewer: add test for configuration creation
Browse files Browse the repository at this point in the history
  • Loading branch information
ForNeVeR committed Aug 31, 2024
1 parent a32400f commit 4214946
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import com.jetbrains.rider.runtime.dotNetCore.DotNetCoreRuntime
import kotlinx.coroutines.CompletableDeferred
import me.fornever.avaloniarider.AvaloniaRiderBundle
import me.fornever.avaloniarider.rider.createExeConfiguration
import me.fornever.avaloniarider.rider.launchConfiguration
import me.fornever.avaloniarider.rider.launchDebugger
import java.nio.file.Path

data class AvaloniaPreviewerParameters(
Expand Down Expand Up @@ -126,7 +126,7 @@ class AvaloniaPreviewerProcess(
ConsoleViewContentType.SYSTEM_OUTPUT
)
val configuration = createExeConfiguration(project, commandLine)
val contentDescriptor = launchConfiguration(lifetime, configuration)
val contentDescriptor = launchDebugger(lifetime, configuration)
return contentDescriptor.processHandler ?: error("Process handler is not available")
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package me.fornever.avaloniarider.rider
import com.intellij.execution.ProgramRunnerUtil
import com.intellij.execution.configurations.ConfigurationTypeUtil
import com.intellij.execution.configurations.GeneralCommandLine
import com.intellij.execution.configurations.RunConfiguration
import com.intellij.execution.executors.DefaultDebugExecutor
import com.intellij.execution.runners.ExecutionEnvironmentBuilder
import com.intellij.execution.runners.ProgramRunner
Expand Down Expand Up @@ -43,7 +44,7 @@ fun createExeConfiguration(project: Project, commandLine: GeneralCommandLine): D
)
}

suspend fun launchConfiguration(lifetime: Lifetime, configuration: DotNetExeConfiguration): RunContentDescriptor {
suspend fun launchDebugger(lifetime: Lifetime, configuration: RunConfiguration): RunContentDescriptor {
val environment = ExecutionEnvironmentBuilder.create(
DefaultDebugExecutor.getDebugExecutorInstance(),
configuration
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package me.fornever.avaloniarider.test.cases

import com.intellij.execution.configurations.GeneralCommandLine
import com.intellij.openapi.project.ProjectManager
import com.jetbrains.rider.test.asserts.shouldBe
import me.fornever.avaloniarider.rider.createExeConfiguration
import me.fornever.avaloniarider.test.framework.AvaloniaIntegrationTest
import org.testng.annotations.Test

class RunConfigurationUtilsTests : AvaloniaIntegrationTest() {

override fun getSolutionDirectoryName() = "MSBuildParameters"

@Test
fun testCreateExeConfiguration() {
val project = ProjectManager.getInstance().defaultProject
val commandLine = GeneralCommandLine("dotnet", "AvaloniaPreviewer")
.withEnvironment("TEST", "123")
val configuration = createExeConfiguration(project, commandLine)
configuration.project.shouldBe(project)
configuration.parameters.apply {
exePath.shouldBe("dotnet")
programParameters.shouldBe("AvaloniaPreviewer")
envs.shouldBe(mapOf("TEST" to "123"))
isPassParentEnvs.shouldBe(true)
}
}
}

0 comments on commit 4214946

Please sign in to comment.