Skip to content

Commit 124c3ca

Browse files
authored
Merge pull request #3586 from 1c-syntax/copilot/fix-ci-oom-errors
2 parents 56326b0 + 0bc5547 commit 124c3ca

File tree

1 file changed

+21
-3
lines changed

1 file changed

+21
-3
lines changed

build.gradle.kts

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -207,14 +207,32 @@ tasks.test {
207207
html.required.set(true)
208208
}
209209

210+
// Increase heap size to prevent OOM during test execution with EhCache
211+
maxHeapSize = "2g"
212+
210213
val jmockitPath = classpath.find { it.name.contains("jmockit") }!!.absolutePath
211214
jvmArgs("-javaagent:${jmockitPath}")
212215

213216
// Cleanup test cache directories after tests complete
214217
doLast {
215-
val tmpDir = File(System.getProperty("java.io.tmpdir"))
216-
tmpDir.listFiles()?.filter { it.name.startsWith("bsl-ls-cache-") }?.forEach { cacheDir ->
217-
cacheDir.deleteRecursively()
218+
try {
219+
val tmpDir = File(System.getProperty("java.io.tmpdir"))
220+
// Use walkTopDown with maxDepth to avoid loading all temp files into memory
221+
tmpDir.walkTopDown()
222+
.maxDepth(1) // Only look at direct children, not subdirectories
223+
.drop(1) // Skip the root temp directory itself (first element in the sequence)
224+
.filter { it.isDirectory && it.name.startsWith("bsl-ls-cache-") }
225+
.forEach { cacheDir ->
226+
try {
227+
cacheDir.deleteRecursively()
228+
logger.info("Deleted test cache directory: ${cacheDir.name}")
229+
} catch (e: Exception) {
230+
logger.warn("Failed to delete test cache directory ${cacheDir.name}: ${e.message}")
231+
}
232+
}
233+
} catch (e: Exception) {
234+
// Don't fail the build if cleanup fails
235+
logger.warn("Failed to cleanup test cache directories: ${e.message}")
218236
}
219237
}
220238
}

0 commit comments

Comments
 (0)