Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use File.pathSeparator to split entries in classpath #3084

Merged
merged 3 commits into from
Sep 18, 2020
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import org.jetbrains.kotlin.com.intellij.openapi.util.Disposer
import org.jetbrains.kotlin.config.JvmTarget
import org.jetbrains.kotlin.config.LanguageVersion
import java.io.Closeable
import java.io.File

interface EnvironmentAware {

Expand Down Expand Up @@ -43,7 +44,7 @@ internal class EnvironmentFacade(
}

internal fun CompilerSpec.classpathEntries(): List<String> =
classpath?.split(":", ";") ?: emptyList() // support both windows ; and unix :
classpath?.split(File.pathSeparator) ?: emptyList()

internal fun CompilerSpec.parseLanguageVersion(): LanguageVersion? {
fun parse(value: String): LanguageVersion {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,23 @@ package io.gitlab.arturbosch.detekt.core.settings
import io.gitlab.arturbosch.detekt.core.createNullLoggingSpec
import io.gitlab.arturbosch.detekt.core.createProcessingSettings
import org.assertj.core.api.Assertions.assertThat
import org.jetbrains.kotlin.konan.file.File
import org.spekframework.spek2.Spek
import org.spekframework.spek2.style.specification.describe

internal class EnvironmentFacadeSpec : Spek({

describe("classpath entries can be separated by : or ;") {
describe("classpath entries should be separated by platform-specific separator") {

arrayOf(
"supports ;" to "file1;file2;file3",
"supports :" to "file1:file2:file3",
"supports mixing ; and :" to "file1;file2:file3"
).forEach { (testName, classpath) ->
it(testName) {
testSettings(classpath).use {
assertThat(it.classpath).hasSize(3)
}
val classpath = when (File.pathSeparator) {
":" -> "/path/to/file1:/path/to/file2:/path/to/file3"
";" -> """C:\path\to\file1;C:\path\to\file2;C:\path\to\file3"""
else -> ""
}

it("supports ${File.pathSeparator}") {
testSettings(classpath).use {
assertThat(it.classpath).hasSize(3)
}
}
}
Expand Down