From 0c30631ce0ec2d138abcb04a47c884084ce51551 Mon Sep 17 00:00:00 2001 From: Vladislav Yaroshchuk Date: Tue, 4 Feb 2025 09:46:54 +0000 Subject: [PATCH] [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 --- .../org/jetbrains/intellij/build/io/ZipReaderTest.kt | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/build/tasks/test/org/jetbrains/intellij/build/io/ZipReaderTest.kt b/build/tasks/test/org/jetbrains/intellij/build/io/ZipReaderTest.kt index 509492f85b12..44cc52724210 100644 --- a/build/tasks/test/org/jetbrains/intellij/build/io/ZipReaderTest.kt +++ b/build/tasks/test/org/jetbrains/intellij/build/io/ZipReaderTest.kt @@ -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")