31
31
import org .eclipse .jgit .revwalk .RevCommit ;
32
32
import org .eclipse .jgit .treewalk .TreeWalk ;
33
33
import org .gradle .testkit .runner .BuildResult ;
34
+ import org .gradle .testkit .runner .GradleRunner ;
34
35
import org .gradle .testkit .runner .TaskOutcome ;
35
- import org .junit .jupiter .api .Test ;
36
+ import org .junit .jupiter .params .ParameterizedTest ;
37
+ import org .junit .jupiter .params .provider .ValueSource ;
36
38
37
39
class GitRatchetGradleTest extends GradleIntegrationHarness {
38
40
private static final String TEST_PATH = "src/markdown/test.md" ;
@@ -46,11 +48,24 @@ private Git initRepo() throws IllegalStateException, GitAPIException, IOExceptio
46
48
return git ;
47
49
}
48
50
49
- @ Test
50
- void singleProjectExhaustive () throws Exception {
51
+ @ Override
52
+ protected GradleRunner gradleRunner () throws IOException {
53
+ return super .gradleRunner ().withGradleVersion (GradleVersionSupport .CONFIGURATION_CACHE .version );
54
+ }
55
+
56
+ @ ParameterizedTest
57
+ @ ValueSource (ints = {0 , 1 })
58
+ void singleProjectExhaustive (int useConfigCache ) throws Exception {
51
59
try (Git git = initRepo ()) {
60
+ if (useConfigCache == 1 ) {
61
+ setFile ("gradle.properties" ).toContent ("org.gradle.unsafe.configuration-cache=true" );
62
+ }
52
63
setFile ("build.gradle" ).toLines (
53
- "plugins { id 'com.diffplug.spotless' }" ,
64
+ "plugins {" ,
65
+ " id 'com.diffplug.spotless'" ,
66
+ " id 'com.diffplug.spotless-setup'" ,
67
+ "}" ,
68
+ "spotlessSetup { enableConfigCacheDaemonLocal = true }" ,
54
69
"spotless {" ,
55
70
" ratchetFrom 'baseline'" ,
56
71
" format 'misc', {" ,
@@ -135,13 +150,17 @@ private BuildResultAssertion assertFail(String... tasks) throws Exception {
135
150
return new BuildResultAssertion (gradleRunner ().withArguments (tasks ).buildAndFail ());
136
151
}
137
152
138
- private static final String BASELINE_ROOT = "cf049829afeba064f27cd67911dc36e585c9d869 " ;
153
+ private static final String BASELINE_ROOT = "a5efb43a0da929853e596a85c1f225a60ae0acfd " ;
139
154
private static final String BASELINE_CLEAN = "65fdd75c1ae00c0646f6487d68c44ddca51f0841" ;
140
155
private static final String BASELINE_DIRTY = "4cfc3358ccbf186738b82a60276b1e5306bc3870" ;
141
156
142
- @ Test
143
- void multiProject () throws Exception {
157
+ @ ParameterizedTest
158
+ @ ValueSource (ints = {0 , 1 })
159
+ void multiProject (int useConfigCache ) throws Exception {
144
160
try (Git git = initRepo ()) {
161
+ if (useConfigCache == 1 ) {
162
+ setFile ("gradle.properties" ).toContent ("org.gradle.unsafe.configuration-cache=true" );
163
+ }
145
164
setFile ("settings.gradle" ).toLines (
146
165
"plugins {" ,
147
166
" id 'com.diffplug.spotless' apply false" ,
@@ -159,14 +178,21 @@ void multiProject() throws Exception {
159
178
" bumpThisNumberIfACustomStepChanges(1)" ,
160
179
" }" ,
161
180
"}" );
162
- setFile (".gitignore" ).toContent ("build/\n .gradle\n " );
163
- setFile ("build.gradle" ).toContent ("apply from: rootProject.file('spotless.gradle') // root" );
181
+ setFile (".gitignore" ).toContent ("build/\n .gradle\n *.properties\n " );
182
+ setFile ("build.gradle" ).toLines (
183
+ "apply plugin: 'com.diffplug.spotless-setup'" ,
184
+ "spotlessSetup { enableConfigCacheDaemonLocal = true }" ,
185
+ "apply from: rootProject.file('spotless.gradle') // root" );
164
186
setFile (TEST_PATH ).toContent ("HELLO" );
165
187
setFile ("clean/build.gradle" ).toContent ("apply from: rootProject.file('spotless.gradle') // clean" );
166
188
setFile ("clean/" + TEST_PATH ).toContent ("HELLO" );
167
189
setFile ("dirty/build.gradle" ).toContent ("apply from: rootProject.file('spotless.gradle') // dirty" );
168
190
setFile ("dirty/" + TEST_PATH ).toContent ("HELLO" );
191
+ setFile ("added/build.gradle" ).toContent ("apply from: rootProject.file('spotless.gradle') // added" );
169
192
RevCommit baseline = addAndCommit (git );
193
+ if (useConfigCache == 1 ) {
194
+ setFile ("gradle.properties" ).toContent ("org.gradle.unsafe.configuration-cache=true" );
195
+ }
170
196
171
197
ObjectId cleanFolder = TreeWalk .forPath (git .getRepository (), "clean" , baseline .getTree ()).getObjectId (0 );
172
198
ObjectId dirtyFolder = TreeWalk .forPath (git .getRepository (), "dirty" , baseline .getTree ()).getObjectId (0 );
@@ -180,12 +206,7 @@ void multiProject() throws Exception {
180
206
.outcome (":clean:spotlessCheck" , TaskOutcome .SUCCESS )
181
207
.outcome (":dirty:spotlessCheck" , TaskOutcome .SUCCESS );
182
208
183
- setFile ("added/build.gradle" ).toContent ("apply from: rootProject.file('spotless.gradle') // added" );
184
209
setFile ("added/" + TEST_PATH ).toContent ("HELLO" );
185
-
186
- TreeWalk isNull = TreeWalk .forPath (git .getRepository (), "added" , baseline .getTree ());
187
- Assertions .assertThat (isNull ).isNull ();
188
-
189
210
assertPass ("spotlessMisc" )
190
211
.outcome (":spotlessMisc" , TaskOutcome .UP_TO_DATE )
191
212
.outcome (":clean:spotlessMisc" , TaskOutcome .UP_TO_DATE )
0 commit comments