/
ConfigurationCacheSpec.kt
62 lines (49 loc) · 2.02 KB
/
ConfigurationCacheSpec.kt
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
package io.gitlab.arturbosch.detekt
import io.gitlab.arturbosch.detekt.testkit.DslTestBuilder
import org.assertj.core.api.Assertions.assertThat
import org.junit.jupiter.api.Nested
import org.junit.jupiter.api.Test
class ConfigurationCacheSpec {
@Test
fun `detekt task can be loaded from the configuration cache`() {
val gradleRunner = DslTestBuilder.kotlin().build()
// First run primes the cache
gradleRunner.runTasks("--configuration-cache", "detekt")
// Second run reuses the cache
val result = gradleRunner.runTasks("--configuration-cache", "detekt")
assertThat(result.output).contains("Reusing configuration cache.")
}
@Nested
inner class `Create baseline task` {
@Test
fun `can be loaded from the configuration cache`() {
@Suppress("TrimMultilineRawString")
val detektConfig = """
|detekt {
| baseline = file("build/baseline.xml")
|}
"""
val gradleRunner = DslTestBuilder.kotlin()
.withDetektConfig(detektConfig)
.build()
// First run primes the cache
gradleRunner.runTasks("--configuration-cache", "detektBaseline")
// Second run reuses the cache
val result = gradleRunner.runTasks("--configuration-cache", "detektBaseline")
assertThat(result.output).contains("Reusing configuration cache.")
}
}
@Nested
inner class `Generate config task` {
@Test
fun `can be loaded from the configuration cache`() {
val gradleRunner = DslTestBuilder.kotlin()
.build()
// First run primes the cache
gradleRunner.runTasks("--configuration-cache", "detektGenerateConfig")
// Second run reuses the cache
val result = gradleRunner.runTasks("--configuration-cache", "detektGenerateConfig")
assertThat(result.output).contains("Reusing configuration cache.")
}
}
}