Skip to content

Commit f41db48

Browse files
committed
Move config cache tests into own test package and some cleanup
1 parent b5fc768 commit f41db48

File tree

4 files changed

+17
-63
lines changed

4 files changed

+17
-63
lines changed

build.gradle.kts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,11 +73,12 @@ testing.suites.named<JvmTestSuite>("test") {
7373
description = "Runs tests against Gradle $gradleVersionUnderTest"
7474
systemProperty("gradleVersionUnderTest", gradleVersionUnderTest)
7575
exclude("**/*SamplesTest.class") // Not yet cross-version ready
76+
exclude("**/initialization/**") // Settings plugin only for Gradle 8.8+
7677
if (gradleVersionUnderTest == "7.4") {
77-
// affected by long since fixed bugs in gradle
78-
exclude("**/*ConfigurationCacheTest.class")
78+
// Configuration cache only "reliable" since 7.6 (?)
79+
// https://github.com/gradlex-org/java-module-dependencies/issues/129
80+
exclude("**/configcache/**")
7981
}
80-
exclude("**/initialization/**") // Settings plugin only for Gradle 8.8+
8182
}
8283
}
8384
}

src/main/resources/org/gradlex/javamodule/dependencies/unique_modules.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1151,7 +1151,7 @@ com.github.gv2011.util.gcol=com.github.gv2011:util-gcol
11511151
com.github.gv2011.util.html.imp=com.github.gv2011:util-html
11521152
com.github.gv2011.util.image=com.github.gv2011:util-image
11531153
com.github.gv2011.util.json.imp=com.github.gv2011:util-json
1154-
com.github.gv2011.util.swing=com.github.gv2011:util-swing
1154+
com.github.gv2011.util.swing.imp=com.github.gv2011:util-swing
11551155
com.github.gv2011.util.tika=com.github.gv2011:util-tika
11561156
com.github.gw2toolbelt.gw2ml=com.github.gw2toolbelt.gw2ml:gw2ml
11571157
com.github.hanshsieh.pixivj=com.github.hanshsieh:pixivj

src/test/groovy/org/gradlex/javamodule/dependencies/test/ConfigurationCacheTest.groovy renamed to src/test/groovy/org/gradlex/javamodule/dependencies/test/configcache/ConfigurationCacheTest.groovy

Lines changed: 9 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
1-
package org.gradlex.javamodule.dependencies.test
1+
package org.gradlex.javamodule.dependencies.test.configcache
22

3-
import org.gradle.util.GradleVersion
43
import org.gradlex.javamodule.dependencies.test.fixture.GradleBuild
54
import spock.lang.Specification
65

76
class ConfigurationCacheTest extends Specification {
87

8+
static final NO_CACHE_MESSAGE =
9+
"Calculating task graph as no cached configuration is available for tasks: :app:compileJava"
10+
911
@Delegate
1012
GradleBuild build = new GradleBuild()
1113

@@ -19,36 +21,18 @@ class ConfigurationCacheTest extends Specification {
1921
}
2022
'''
2123

22-
2324
def runner = runner('--configuration-cache',':app:compileJava')
2425
when:
2526
def result = runner.build()
2627

2728
then:
28-
result.getOutput().contains(getNoCacheMessage() )
29+
result.output.contains(NO_CACHE_MESSAGE)
2930

3031
when:
3132
result = runner.build()
3233

3334
then:
34-
result.getOutput().contains("Reusing configuration cache.")
35-
}
36-
37-
private String getNoCacheMessage() {
38-
if (getVersionTest() >= GradleVersion.version("8.8")) {
39-
return "Calculating task graph as no cached configuration is available for tasks: :app:compileJava"
40-
} else {
41-
return "Calculating task graph as no configuration cache is available for tasks: :app:compileJava"
42-
}
43-
44-
45-
}
46-
47-
private GradleVersion getVersionTest() {
48-
if (gradleVersionUnderTest == null) {
49-
return GradleVersion.current()
50-
}
51-
return GradleVersion.version(gradleVersionUnderTest)
35+
result.output.contains("Reusing configuration cache.")
5236
}
5337

5438
def "configurationCacheHitIrrelevantChange"() {
@@ -64,7 +48,7 @@ class ConfigurationCacheTest extends Specification {
6448
def result = runner.build()
6549

6650
then:
67-
result.getOutput().contains(getNoCacheMessage())
51+
result.output.contains(NO_CACHE_MESSAGE)
6852

6953
when:
7054
appModuleInfoFile.write('''
@@ -75,7 +59,7 @@ class ConfigurationCacheTest extends Specification {
7559
result = runner.build()
7660

7761
then:
78-
result.getOutput().contains("Reusing configuration cache.")
62+
result.output.contains("Reusing configuration cache.")
7963
}
8064

8165
def "configurationCacheMissRelevantChange"() {
@@ -92,7 +76,7 @@ class ConfigurationCacheTest extends Specification {
9276
def result = runner.build()
9377

9478
then:
95-
result.getOutput().contains(getNoCacheMessage())
79+
result.output.contains(NO_CACHE_MESSAGE)
9680

9781
when:
9882
appModuleInfoFile.write('''

src/test/groovy/org/gradlex/javamodule/dependencies/test/initialization/SettingsPluginTest.groovy

Lines changed: 3 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package org.gradlex.javamodule.dependencies.test.initialization
22

3-
import org.gradle.testkit.runner.GradleRunner
43
import org.gradlex.javamodule.dependencies.test.fixture.GradleBuild
54
import spock.lang.Specification
65

@@ -91,37 +90,7 @@ class SettingsPluginTest extends Specification {
9190
result.getOutput().contains("Calculating task graph as no cached configuration is available for tasks: :app:compileJava")
9291

9392
when:
94-
result = runner.build() //TODO Thats a big problem with the Settings Plugin AAAAAAAAH
95-
result = runner.build()
96-
97-
then:
98-
result.getOutput().contains("Reusing configuration cache.")
99-
}
100-
101-
def "configurationCacheHit"() {
102-
given:
103-
settingsFile << '''
104-
javaModules {
105-
directory(".") { plugin("java-library") }
106-
}
107-
'''
108-
libModuleInfoFile << 'module abc.lib { }'
109-
appModuleInfoFile << '''
110-
module org.gradlex.test.app {
111-
requires abc.lib;
112-
}
113-
'''
114-
115-
116-
def runner = runner(':app:compileJava')
117-
when:
118-
def result = runner.build()
119-
120-
then:
121-
result.getOutput().contains("Calculating task graph as no cached configuration is available for tasks: :app:compileJava")
122-
123-
when:
124-
result = runner.build() //TODO Thats a big problem with the Settings Plugin AAAAAAAAH
93+
runner.build() // https://github.com/gradlex-org/java-module-dependencies/issues/128
12594
result = runner.build()
12695

12796
then:
@@ -150,7 +119,7 @@ class SettingsPluginTest extends Specification {
150119
result.getOutput().contains("Calculating task graph as no cached configuration is available for tasks: :app:compileJava")
151120

152121
when:
153-
result = runner.build() //TODO Thats a big problem with the Settings Plugin AAAAAAAAH
122+
runner.build() // https://github.com/gradlex-org/java-module-dependencies/issues/128
154123
appModuleInfoFile.write('''
155124
module org.gradlex.test.app {
156125
requires abc.lib; //This is a comment and should not break the configurationCache
@@ -184,7 +153,7 @@ class SettingsPluginTest extends Specification {
184153
result.getOutput().contains("Calculating task graph as no cached configuration is available for tasks: :app:compileJava")
185154

186155
when:
187-
result = runner.build() //TODO Thats a big problem with the Settings Plugin AAAAAAAAH
156+
runner.build() // https://github.com/gradlex-org/java-module-dependencies/issues/128
188157
appModuleInfoFile.write('''
189158
module org.gradlex.test.app {
190159
//dependency removed; so thats indeed a configuration change

0 commit comments

Comments
 (0)