Skip to content
Closed
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
7 changes: 7 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ dependencies {
testFramework(TestFrameworkType.Bundled)
}

testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.8.1")
testRuntimeOnly("org.junit.vintage:junit-vintage-engine:5.8.1")

implementation(libs.bundles.junixsocket)
implementation(libs.lsp4j)
testImplementation("org.jetbrains.kotlin:kotlin-test-junit")
Expand Down Expand Up @@ -123,6 +126,10 @@ tasks {
defaultCharacterEncoding = "UTF-8"
}

withType<Test> {
useJUnitPlatform()
}

withType<JavaCompile> {
dependsOn(generateLexer, generateParser)

Expand Down
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ intellijPreview = "242.20224-EAP-CANDIDATE-SNAPSHOT"
junixsocket = "2.10.0"

[libraries]
junit = "junit:junit:4.13.2"
junit = "org.junit.jupiter:junit-jupiter-api:5.10.3"
junixsocket-common = { module = "com.kohlschutter.junixsocket:junixsocket-common", version.ref = "junixsocket" }
junixsocket-native-common = { module = "com.kohlschutter.junixsocket:junixsocket-native-common", version.ref = "junixsocket" }
lsp4j = "org.eclipse.lsp4j:org.eclipse.lsp4j:0.23.1"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,38 +5,53 @@ import com.intellij.execution.impl.RunManagerImpl
import com.intellij.execution.impl.RunnerAndConfigurationSettingsImpl
import com.intellij.execution.runners.ExecutionEnvironment
import com.intellij.execution.runners.ProgramRunner
import com.intellij.testFramework.fixtures.BasePlatformTestCase
import com.intellij.openapi.project.Project
import com.intellij.testFramework.junit5.TestApplication
import com.intellij.testFramework.junit5.fixture.projectFixture
import kotlinx.coroutines.runBlocking
import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.Test
import java.nio.file.Path
import kotlin.io.path.Path

class PowerShellRunConfigurationTests : BasePlatformTestCase() {
@TestApplication
class PowerShellRunConfigurationTests {

private val projectFixture = projectFixture()

private val project: Project
get() = projectFixture.get()
private val projectPath: Path
get() = Path(project.basePath!!)
private val defaultWorkingDirectory
get() = projectPath.resolve("scripts")

@Test
fun testCustomWorkingDirectoryPath() {
val customDir = projectPath.resolve("ttt")
assertWorkingDirectory(custom = customDir.toString(), expected = customDir)
}

@Test
fun testNoCustomWorkingDirectory() {
assertWorkingDirectory(custom = null, expected = defaultWorkingDirectory)
}

@Test
fun testEmptyCustomWorkingDirectory() {
assertWorkingDirectory(custom = "", expected = defaultWorkingDirectory)
}

@Test
fun testCustomWorkingDirectoryPathVariable() {
assertWorkingDirectory(custom = "\$PROJECT_DIR$/foobar", expected = projectPath.resolve("foobar"))
}

@Test
fun testInvalidWorkingDir() {
assertWorkingDirectory(custom = invalidPath, expected = defaultWorkingDirectory)
}
@Test
fun testInvalidScriptPath() {
assertWorkingDirectory(custom = null, scriptPath = invalidPath, expected = Path(System.getProperty("user.home")))
}
Expand Down