Skip to content

Commit

Permalink
Use real file to check path includes/excludes
Browse files Browse the repository at this point in the history
  • Loading branch information
3flex committed May 6, 2024
1 parent 5444c1d commit 0dbdcbf
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package io.gitlab.arturbosch.detekt.core
import io.github.detekt.test.utils.StringPrintStream
import io.github.detekt.test.utils.compileContentForTest
import io.github.detekt.test.utils.compileForTest
import io.github.detekt.test.utils.resourceAsPath
import io.gitlab.arturbosch.detekt.api.CodeSmell
import io.gitlab.arturbosch.detekt.api.Config
import io.gitlab.arturbosch.detekt.api.Entity
Expand All @@ -25,8 +26,6 @@ import org.junit.jupiter.api.Nested
import org.junit.jupiter.api.Test
import org.junit.jupiter.params.ParameterizedTest
import org.junit.jupiter.params.provider.ValueSource
import kotlin.io.path.Path
import kotlin.io.path.absolute

@KotlinCoreEnvironmentTest
class AnalyzerSpec(val env: KotlinCoreEnvironment) {
Expand Down Expand Up @@ -349,12 +348,13 @@ class AnalyzerSpec(val env: KotlinCoreEnvironment) {
path: String,
config: Config,
): Boolean {
val root = Path("").absolute()
val root = resourceAsPath("include_exclude")
val pathToCheck = resourceAsPath("include_exclude").resolve(path)

return createProcessingSettings(config = config) { project { basePath = root } }
.use { settings ->
Analyzer(settings, listOf(CustomRuleSetProvider()), emptyList())
.run(listOf(compileContentForTest("", Path(path))))
.run(listOf(compileForTest(pathToCheck)))
.isNotEmpty()
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
package io.gitlab.arturbosch.detekt.core.util

import io.github.detekt.test.utils.compileContentForTest
import io.github.detekt.test.utils.compileForTest
import io.github.detekt.test.utils.resourceAsPath
import io.gitlab.arturbosch.detekt.api.Config
import io.gitlab.arturbosch.detekt.test.TestConfig
import io.gitlab.arturbosch.detekt.test.yamlConfigFromContent
import org.assertj.core.api.Assertions.assertThat
import org.junit.jupiter.api.DisplayName
import org.junit.jupiter.api.Nested
import org.junit.jupiter.api.Test
import kotlin.io.path.Path
import kotlin.io.path.absolute

class IsActiveOrDefaultSpec {

Expand All @@ -35,8 +34,8 @@ class IsActiveOrDefaultSpec {
@Nested
class ShouldAnalyzeFileSpec {

private val basePath = Path("/cases").absolute()
private val file = compileContentForTest("", path = Path("/cases/Default.kt"))
private val basePath = resourceAsPath("cases")
private val file = compileForTest(basePath.resolve("Default.kt"))

@Test
fun `analyzes file with an empty config`() {
Expand Down
Empty file.

0 comments on commit 0dbdcbf

Please sign in to comment.