[Test] Properly delete temporary directories after test run
This commit is contained in:
committed by
TeamCityServer
parent
ce44a2a7e4
commit
5382e68180
@@ -9,6 +9,7 @@ import com.intellij.openapi.util.Disposer
|
||||
import com.intellij.testFramework.TestDataFile
|
||||
import org.jetbrains.kotlin.test.model.*
|
||||
import org.jetbrains.kotlin.test.services.*
|
||||
import java.io.IOException
|
||||
|
||||
class TestRunner(private val testConfiguration: TestConfiguration) {
|
||||
private val failedAssertions = mutableListOf<AssertionError>()
|
||||
@@ -17,6 +18,11 @@ class TestRunner(private val testConfiguration: TestConfiguration) {
|
||||
try {
|
||||
runTestImpl(testDataFileName)
|
||||
} finally {
|
||||
try {
|
||||
testConfiguration.testServices.temporaryDirectoryManager.cleanupTemporaryDirectories()
|
||||
} catch (_: IOException) {
|
||||
// ignored
|
||||
}
|
||||
Disposer.dispose(testConfiguration.rootDisposable)
|
||||
}
|
||||
}
|
||||
|
||||
+3
-3
@@ -25,9 +25,9 @@ abstract class SourceFileProvider : TestService {
|
||||
|
||||
val TestServices.sourceFileProvider: SourceFileProvider by TestServices.testServiceAccessor()
|
||||
|
||||
class SourceFileProviderImpl(val preprocessors: List<SourceFilePreprocessor>) : SourceFileProvider() {
|
||||
override val kotlinSourceDirectory: File = KtTestUtil.tmpDir("kotlin-files")
|
||||
override val javaSourceDirectory: File = KtTestUtil.tmpDir("java-files")
|
||||
class SourceFileProviderImpl(val testServices: TestServices, val preprocessors: List<SourceFilePreprocessor>) : SourceFileProvider() {
|
||||
override val kotlinSourceDirectory: File = testServices.createTempDirectory("kotlin-files")
|
||||
override val javaSourceDirectory: File = testServices.createTempDirectory("java-files")
|
||||
|
||||
private val contentOfFiles = mutableMapOf<TestFile, String>()
|
||||
private val realFileMap = mutableMapOf<TestFile, File>()
|
||||
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
/*
|
||||
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.test.services
|
||||
|
||||
import java.io.File
|
||||
|
||||
abstract class TemporaryDirectoryManager(protected val testServices: TestServices) : TestService {
|
||||
abstract fun createTempDirectory(name: String): File
|
||||
abstract fun cleanupTemporaryDirectories()
|
||||
}
|
||||
|
||||
val TestServices.temporaryDirectoryManager: TemporaryDirectoryManager by TestServices.testServiceAccessor()
|
||||
|
||||
fun TestServices.createTempDirectory(name: String): File {
|
||||
return temporaryDirectoryManager.createTempDirectory(name)
|
||||
}
|
||||
Reference in New Issue
Block a user