From 108dd372422623b6167bfb8c5983e5d85a0390e5 Mon Sep 17 00:00:00 2001 From: Roman Golyshev Date: Fri, 11 Jun 2021 14:36:43 +0300 Subject: [PATCH] Add possibility to use baseDir in `CoroutineHelpersSourceFilesProvider` --- .../test/runners/AbstractFirDiagnosticTest.kt | 2 +- .../CoroutineHelpersSourceFilesProvider.kt | 19 +++++++++---------- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/runners/AbstractFirDiagnosticTest.kt b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/runners/AbstractFirDiagnosticTest.kt index ea35fb54980..df2c805a04c 100644 --- a/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/runners/AbstractFirDiagnosticTest.kt +++ b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/runners/AbstractFirDiagnosticTest.kt @@ -62,7 +62,7 @@ fun TestConfigurationBuilder.baseFirDiagnosticTestConfiguration(baseDir: String useAdditionalSourceProviders( ::AdditionalDiagnosticsSourceFilesProvider.bind(baseDir), - ::CoroutineHelpersSourceFilesProvider, + ::CoroutineHelpersSourceFilesProvider.bind(baseDir), ) useFrontendFacades(::FirFrontendFacade) useFrontendHandlers( diff --git a/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/services/sourceProviders/CoroutineHelpersSourceFilesProvider.kt b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/services/sourceProviders/CoroutineHelpersSourceFilesProvider.kt index 431f7369e21..c6af8690e8e 100644 --- a/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/services/sourceProviders/CoroutineHelpersSourceFilesProvider.kt +++ b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/services/sourceProviders/CoroutineHelpersSourceFilesProvider.kt @@ -17,13 +17,12 @@ import org.jetbrains.kotlin.test.services.AdditionalSourceProvider import org.jetbrains.kotlin.test.services.TestServices import java.io.File -class CoroutineHelpersSourceFilesProvider(testServices: TestServices) : AdditionalSourceProvider(testServices) { - companion object { - private const val HELPERS_PATH = "./compiler/testData/diagnostics/helpers/coroutines" - private const val COROUTINE_HELPERS_PATH = "$HELPERS_PATH/CoroutineHelpers.kt" - private const val STATE_MACHINE_CHECKER_PATH = "$HELPERS_PATH/StateMachineChecker.kt" - private const val TAIL_CALL_OPTIMIZATION_CHECKER_PATH = "$HELPERS_PATH/TailCallOptimizationChecker.kt" - } +class CoroutineHelpersSourceFilesProvider(testServices: TestServices, testDataPath: String = ".") : AdditionalSourceProvider(testServices) { + private val helpersPath = "$testDataPath/compiler/testData/diagnostics/helpers/coroutines" + + private val coroutineHelpersPath = "$helpersPath/CoroutineHelpers.kt" + private val stateMachineCheckerPath = "$helpersPath/StateMachineChecker.kt" + private val tailCallOptimizationCheckerPath = "$helpersPath/TailCallOptimizationChecker.kt" override val directives: List = listOf(AdditionalFilesDirectives) @@ -32,12 +31,12 @@ class CoroutineHelpersSourceFilesProvider(testServices: TestServices) : Addition override fun produceAdditionalFiles(globalDirectives: RegisteredDirectives, module: TestModule): List { if (WITH_COROUTINES !in module.directives) return emptyList() return buildList { - add(File(COROUTINE_HELPERS_PATH).toTestFile()) + add(File(coroutineHelpersPath).toTestFile()) if (CHECK_STATE_MACHINE in module.directives) { - add(File(STATE_MACHINE_CHECKER_PATH).toTestFile()) + add(File(stateMachineCheckerPath).toTestFile()) } if (CHECK_TAIL_CALL_OPTIMIZATION in module.directives) { - add(File(TAIL_CALL_OPTIMIZATION_CHECKER_PATH).toTestFile()) + add(File(tailCallOptimizationCheckerPath).toTestFile()) } } }