@@ -69,6 +69,16 @@ void prettierWithSpecificInstallCacheTest() throws IOException {
69
69
Assertions .assertThat (result2 .getOutput ()).containsPattern ("Using cached node_modules for .*\\ Q" + cacheDir .getAbsolutePath () + "\\ E" );
70
70
}
71
71
72
+ @ Test
73
+ void prettierWithNoCacheTest () throws IOException {
74
+ File dir2 = newFolder ("npm-prettier-1" );
75
+ File cacheDir = null ;
76
+ BuildResult result = runPhpPrettierOnDir (dir2 , cacheDir );
77
+ Assertions .assertThat (result .getOutput ())
78
+ .doesNotContainPattern ("Using cached node_modules for .*" )
79
+ .doesNotContainPattern ("Caching node_modules for .*" );
80
+ }
81
+
72
82
@ Test
73
83
@ Order (1 )
74
84
void prettierWithSpecificGlobalInstallCacheTest () throws IOException {
@@ -140,6 +150,16 @@ void tsfmtWithSpecificGlobalInstallCacheTest2() throws IOException {
140
150
.doesNotContainPattern ("Caching node_modules for .*\\ Q" + cacheDir .getAbsolutePath () + "\\ E" );
141
151
}
142
152
153
+ @ Test
154
+ void tsfmtWithNoCacheTest () throws IOException {
155
+ File dir2 = newFolder ("npm-tsfmt-1" );
156
+ File cacheDir = null ;
157
+ BuildResult result = runTsfmtOnDir (dir2 , cacheDir );
158
+ Assertions .assertThat (result .getOutput ())
159
+ .doesNotContainPattern ("Using cached node_modules for .*" )
160
+ .doesNotContainPattern ("Caching node_modules for .*" );
161
+ }
162
+
143
163
private BuildResult runTsfmtOnDir (File projDir , File cacheDir ) throws IOException {
144
164
String baseDir = projDir .getName ();
145
165
String cacheDirEnabled = cacheDirEnabledStringForCacheDir (cacheDir );
@@ -163,6 +183,60 @@ private BuildResult runTsfmtOnDir(File projDir, File cacheDir) throws IOExceptio
163
183
return spotlessApply ;
164
184
}
165
185
186
+ @ Test
187
+ @ Order (5 )
188
+ void eslintWithSpecificGlobalInstallCacheTest () throws IOException {
189
+ File dir1 = newFolder ("npm-eslint-global-1" );
190
+ File cacheDir = pertainingCacheDir ;
191
+ BuildResult result = runEslintOnDir (dir1 , cacheDir );
192
+ Assertions .assertThat (result .getOutput ())
193
+ .doesNotContainPattern ("Using cached node_modules for .*\\ Q" + cacheDir .getAbsolutePath () + "\\ E" )
194
+ .containsPattern ("Caching node_modules for .*\\ Q" + cacheDir .getAbsolutePath () + "\\ E" );
195
+ }
196
+
197
+ @ Test
198
+ @ Order (6 )
199
+ void eslintWithSpecificGlobalInstallCacheTest2 () throws IOException {
200
+ File dir2 = newFolder ("npm-eslint-global-2" );
201
+ File cacheDir = pertainingCacheDir ;
202
+ BuildResult result = runEslintOnDir (dir2 , cacheDir );
203
+ Assertions .assertThat (result .getOutput ())
204
+ .containsPattern ("Using cached node_modules for .*\\ Q" + cacheDir .getAbsolutePath () + "\\ E" )
205
+ .doesNotContainPattern ("Caching node_modules for .*\\ Q" + cacheDir .getAbsolutePath () + "\\ E" );
206
+ }
207
+
208
+ @ Test
209
+ void eslintWithNoCacheTest () throws IOException {
210
+ File dir2 = newFolder ("npm-eslint-1" );
211
+ File cacheDir = null ;
212
+ BuildResult result = runEslintOnDir (dir2 , cacheDir );
213
+ Assertions .assertThat (result .getOutput ())
214
+ .doesNotContainPattern ("Using cached node_modules for .*" )
215
+ .doesNotContainPattern ("Caching node_modules for .*" );
216
+ }
217
+
218
+ private BuildResult runEslintOnDir (File projDir , File cacheDir ) throws IOException {
219
+ String baseDir = projDir .getName ();
220
+ String cacheDirEnabled = cacheDirEnabledStringForCacheDir (cacheDir );
221
+
222
+ setFile (baseDir + "/.eslintrc.js" ).toResource ("npm/eslint/typescript/custom_rules/.eslintrc.js" );
223
+ setFile (baseDir + "/build.gradle" ).toLines (
224
+ "plugins {" ,
225
+ " id 'com.diffplug.spotless'" ,
226
+ "}" ,
227
+ "repositories { mavenCentral() }" ,
228
+ "spotless {" ,
229
+ " typescript {" ,
230
+ " target 'test.ts'" ,
231
+ " eslint().configFile('.eslintrc.js')" + cacheDirEnabled ,
232
+ " }" ,
233
+ "}" );
234
+ setFile (baseDir + "/test.ts" ).toResource ("npm/eslint/typescript/custom_rules/typescript.dirty" );
235
+ BuildResult spotlessApply = gradleRunner ().withProjectDir (projDir ).withArguments ("--stacktrace" , "--info" , "spotlessApply" ).build ();
236
+ assertFile (baseDir + "/test.ts" ).sameAsResource ("npm/eslint/typescript/custom_rules/typescript.clean" );
237
+ return spotlessApply ;
238
+ }
239
+
166
240
private static String cacheDirEnabledStringForCacheDir (File cacheDir ) {
167
241
String cacheDirEnabled ;
168
242
if (cacheDir == null ) {
0 commit comments