Repository navigation
Expand file tree
/
Copy pathbuild.gradle.kts
More file actions
99 lines (80 loc) 路 2.43 KB
/
Copy pathbuild.gradle.kts
File metadata and controls
99 lines (80 loc) 路 2.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
plugins {
alias(libs.plugins.kotlin.jvm)
alias(libs.plugins.test.logger)
alias(libs.plugins.spotless)
`jvm-test-suite`
}
repositories {
mavenCentral()
}
sourceSets {
// Generates tests for every solution (see generateTests task)
create("testGenerator")
}
dependencies {
testImplementation(libs.junit.jupiter)
testImplementation(libs.kluent)
testRuntimeOnly(libs.junit.platform.launcher)
"testGeneratorImplementation"(libs.kotlin.compiler.embeddable)
}
testing {
suites {
// Verifies structure of the challenges (file names, solution objects, test classes)
register<JvmTestSuite>("konsistTest") {
useJUnitJupiter(libs.versions.junit)
dependencies {
implementation(libs.konsist)
}
targets.all {
testTask.configure {
// Konsist reads challenge sources directly, so re-run the task when they change
inputs
.dir("src/test/kotlin/com/igorwojda")
.withPathSensitivity(PathSensitivity.RELATIVE)
}
}
}
}
}
tasks.withType<Test>().configureEach {
useJUnitPlatform()
testLogging {
events("failed")
// log full stacktrace of failed test (assertion library descriptive error)
exceptionFormat = TestExceptionFormat.FULL
}
}
// Combines every Challenge.kt with each solution from Solution.kt into src/test/kotlin/generated
tasks.register<JavaExec>("generateTests") {
group = "verification"
val testGenerator = sourceSets["testGenerator"]
classpath = testGenerator.runtimeClasspath
mainClass = "com.igorwojda.challenge.utils.TestUtilsKt"
args(rootDir.path)
}
kotlin {
jvmToolchain(26)
}
spotless {
kotlin {
target(
"src/test/kotlin/com/igorwojda/**/*.kt",
"src/konsistTest/kotlin/**/*.kt",
"src/testGenerator/kotlin/**/*.kt",
)
ktlint().editorConfigOverride(
mapOf(
"ktlint_code_style" to "intellij_idea",
// Every solution for a challenge lives in one Solution.kt
"ktlint_standard_filename" to "disabled",
),
)
leadingTabsToSpaces()
endWithNewline()
}
kotlinGradle {
target("*.gradle.kts")
ktlint()
}
}