Skip to content

Commit 16d12b1

Browse files
committed
testCases for the settingsPlugin
1 parent 348b629 commit 16d12b1

File tree

1 file changed

+130
-0
lines changed

1 file changed

+130
-0
lines changed

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

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

3+
import org.gradle.testkit.runner.GradleRunner
34
import org.gradlex.javamodule.dependencies.test.fixture.GradleBuild
45
import spock.lang.Specification
56

@@ -67,6 +68,135 @@ class SettingsPluginTest extends Specification {
6768
result.task(":lib:compileJava").outcome == SUCCESS
6869
}
6970

71+
def "configurationCacheHit"() {
72+
given:
73+
settingsFile << '''
74+
javaModules {
75+
directory(".") { plugin("java-library") }
76+
}
77+
'''
78+
libModuleInfoFile << 'module abc.lib { }'
79+
appModuleInfoFile << '''
80+
module org.gradlex.test.app {
81+
requires abc.lib;
82+
}
83+
'''
84+
85+
86+
def runner = runner(':app:compileJava')
87+
when:
88+
def result = runner.build()
89+
90+
then:
91+
result.getOutput().contains("Calculating task graph as no cached configuration is available for tasks: :app:compileJava")
92+
93+
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
125+
result = runner.build()
126+
127+
then:
128+
result.getOutput().contains("Reusing configuration cache.")
129+
}
130+
131+
def "configurationCacheHitIrrelevantChange"() {
132+
given:
133+
settingsFile << '''
134+
javaModules {
135+
directory(".") { plugin("java-library") }
136+
}
137+
'''
138+
libModuleInfoFile << 'module abc.lib { }'
139+
appModuleInfoFile << '''
140+
module org.gradlex.test.app {
141+
requires abc.lib;
142+
}
143+
'''
144+
145+
def runner = runner(':app:compileJava')
146+
when:
147+
def result = runner.build()
148+
149+
then:
150+
result.getOutput().contains("Calculating task graph as no cached configuration is available for tasks: :app:compileJava")
151+
152+
when:
153+
result = runner.build() //TODO Thats a big problem with the Settings Plugin AAAAAAAAH
154+
appModuleInfoFile.write('''
155+
module org.gradlex.test.app {
156+
requires abc.lib; //This is a comment and should not break the configurationCache
157+
}
158+
''')
159+
result = runner.build()
160+
161+
then:
162+
result.getOutput().contains("Reusing configuration cache.")
163+
}
164+
165+
def "configurationCacheHitRelevantChange"() {
166+
given:
167+
settingsFile << '''
168+
javaModules {
169+
directory(".") { plugin("java-library") }
170+
}
171+
'''
172+
libModuleInfoFile << 'module abc.lib { }'
173+
appModuleInfoFile << '''
174+
module org.gradlex.test.app {
175+
requires abc.lib;
176+
}
177+
'''
178+
179+
def runner = runner(':app:compileJava')
180+
when:
181+
def result = runner.build()
182+
183+
then:
184+
result.getOutput().contains("Calculating task graph as no cached configuration is available for tasks: :app:compileJava")
185+
186+
when:
187+
result = runner.build() //TODO Thats a big problem with the Settings Plugin AAAAAAAAH
188+
appModuleInfoFile.write('''
189+
module org.gradlex.test.app {
190+
//dependency removed; so thats indeed a configuration change
191+
}
192+
''')
193+
result = runner.build()
194+
195+
then:
196+
result.output.contains("Calculating task graph as configuration cache cannot be reused because a build logic input of type 'ValueSourceModuleInfo' has changed.\n")
197+
}
198+
199+
70200
def "automatically sets module for application plugin"() {
71201
given:
72202
settingsFile << '''

0 commit comments

Comments
 (0)