[build] ZipFileReaderTest: cleanup tempDir after each test

Temp dir deletion fails on Windows after the test with
`java.nio.file.DirectoryNotEmptyException: C:\BuildAgent\temp\buildTmp\junit-15918520044684055433`

As stated in https://github.com/junit-team/junit5/issues/2811, it may happen because
some resource is not closed (try-with-resources is missing)

Let's delete all files in the temp directory after the test file-by-file,
and see which file was not closed properly

GitOrigin-RevId: ac3940c2341234fb93cc72b7d3e8b3b65eb20337
This commit is contained in:
Vladislav Yaroshchuk
2025-02-05 13:47:01 +00:00
committed by intellij-monorepo-bot
parent 0b2c386586
commit 0c30631ce0
@@ -1,18 +1,28 @@
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package org.jetbrains.intellij.build.io
import com.intellij.testFramework.utils.io.deleteChildrenRecursively
import com.intellij.util.io.createDirectories
import com.intellij.util.io.createParentDirectories
import org.junit.jupiter.api.AfterEach
import org.junit.jupiter.api.Assertions
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.io.TempDir
import java.nio.file.Path
import kotlin.io.path.exists
class ZipReaderTest {
@TempDir
lateinit var tempDir: Path
@AfterEach
fun tearDown() {
if (tempDir.exists()) {
tempDir.deleteChildrenRecursively { true }
}
}
@Test
fun testReadEmptyZip() {
val archive = tempDir.resolve("empty.jar")