From bc8051ce9b4dfbe7a351c2e3be3085c0f143ae73 Mon Sep 17 00:00:00 2001 From: Dmitriy Novozhilov Date: Tue, 24 May 2022 10:27:29 +0300 Subject: [PATCH] [Test] Allow to create source files different from .kt and .java in SourceFileProvider --- .../kotlin/test/services/SourceFileProvider.kt | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/compiler/test-infrastructure/tests/org/jetbrains/kotlin/test/services/SourceFileProvider.kt b/compiler/test-infrastructure/tests/org/jetbrains/kotlin/test/services/SourceFileProvider.kt index 41c1f932814..c2bd9f14332 100644 --- a/compiler/test-infrastructure/tests/org/jetbrains/kotlin/test/services/SourceFileProvider.kt +++ b/compiler/test-infrastructure/tests/org/jetbrains/kotlin/test/services/SourceFileProvider.kt @@ -27,6 +27,7 @@ abstract class SourceFileProvider : TestService { abstract val kotlinSourceDirectory: File abstract val javaSourceDirectory: File abstract val javaBinaryDirectory: File + abstract val additionalFilesDirectory: File abstract fun getContentOfSourceFile(testFile: TestFile): String abstract fun getRealFileForSourceFile(testFile: TestFile): File @@ -37,9 +38,10 @@ abstract class SourceFileProvider : TestService { val TestServices.sourceFileProvider: SourceFileProvider by TestServices.testServiceAccessor() class SourceFileProviderImpl(val testServices: TestServices, override val preprocessors: List) : SourceFileProvider() { - override val kotlinSourceDirectory: File = testServices.getOrCreateTempDirectory("kotlin-files") - override val javaSourceDirectory: File = testServices.getOrCreateTempDirectory("java-files") - override val javaBinaryDirectory: File = testServices.getOrCreateTempDirectory("java-binary-files") + override val kotlinSourceDirectory: File by lazy(LazyThreadSafetyMode.NONE) { testServices.getOrCreateTempDirectory("kotlin-files") } + override val javaSourceDirectory: File by lazy(LazyThreadSafetyMode.NONE) { testServices.getOrCreateTempDirectory("java-files") } + override val javaBinaryDirectory: File by lazy(LazyThreadSafetyMode.NONE) { testServices.getOrCreateTempDirectory("java-binary-files") } + override val additionalFilesDirectory: File by lazy(LazyThreadSafetyMode.NONE) { testServices.getOrCreateTempDirectory("additional-files") } private val contentOfFiles = mutableMapOf() private val realFileMap = mutableMapOf() @@ -55,7 +57,7 @@ class SourceFileProviderImpl(val testServices: TestServices, override val prepro val directory = when { testFile.isKtFile -> kotlinSourceDirectory testFile.isJavaFile -> javaSourceDirectory - else -> error("Unknown file type: ${testFile.name}") + else -> additionalFilesDirectory } directory.resolve(testFile.relativePath).also { it.parentFile.mkdirs()