[Test] Add debug names to unnamed test disposables
- This helps to track down disposables which are never disposed, and reduces confusion when printing disposables in general (the names will now be meaningful, instead of endless lists of "newDisposable" and "TestDisposable"). ^KT-64099
This commit is contained in:
committed by
Space Team
parent
bba5447b12
commit
32fe29b8cc
+1
-1
@@ -139,7 +139,7 @@ private fun doTestInBlockModification(
|
|||||||
* @return **true** if out-of-block happens
|
* @return **true** if out-of-block happens
|
||||||
*/
|
*/
|
||||||
private fun LLFirDeclarationModificationService.modifyElement(element: PsiElement): Boolean {
|
private fun LLFirDeclarationModificationService.modifyElement(element: PsiElement): Boolean {
|
||||||
val disposable = Disposer.newDisposable()
|
val disposable = Disposer.newDisposable("${LLFirDeclarationModificationService::class.simpleName}.disposable")
|
||||||
var isOutOfBlock = false
|
var isOutOfBlock = false
|
||||||
try {
|
try {
|
||||||
project.analysisMessageBus.connect(disposable).subscribe(
|
project.analysisMessageBus.connect(disposable).subscribe(
|
||||||
|
|||||||
+1
-1
@@ -214,7 +214,7 @@ class CodegenTestsOnAndroidGenerator private constructor(private val pathManager
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun writeFilesOnDisk() {
|
fun writeFilesOnDisk() {
|
||||||
val disposable = Disposer.newDisposable()
|
val disposable = Disposer.newDisposable("Disposable for ${FilesWriter::class.qualifiedName}.writeFilesOnDisk")
|
||||||
val environment = KotlinCoreEnvironment.createForTests(
|
val environment = KotlinCoreEnvironment.createForTests(
|
||||||
disposable,
|
disposable,
|
||||||
configuration.copy().apply {
|
configuration.copy().apply {
|
||||||
|
|||||||
+1
-1
@@ -46,7 +46,7 @@ class BuiltInsSerializer(
|
|||||||
dependOnOldBuiltIns: Boolean,
|
dependOnOldBuiltIns: Boolean,
|
||||||
onComplete: (totalSize: Int, totalFiles: Int) -> Unit
|
onComplete: (totalSize: Int, totalFiles: Int) -> Unit
|
||||||
) {
|
) {
|
||||||
val rootDisposable = Disposer.newDisposable()
|
val rootDisposable = Disposer.newDisposable("Disposable for ${BuiltInsSerializer::class.simpleName}.analyzeAndSerialize")
|
||||||
val messageCollector = createMessageCollector()
|
val messageCollector = createMessageCollector()
|
||||||
val performanceManager = object : CommonCompilerPerformanceManager(presentableName = "test") {}
|
val performanceManager = object : CommonCompilerPerformanceManager(presentableName = "test") {}
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -97,7 +97,7 @@ abstract class CLICompiler<A : CommonCompilerArguments> : CLITool<A>() {
|
|||||||
val canceledStatus = services[CompilationCanceledStatus::class.java]
|
val canceledStatus = services[CompilationCanceledStatus::class.java]
|
||||||
ProgressIndicatorAndCompilationCanceledStatus.setCompilationCanceledStatus(canceledStatus)
|
ProgressIndicatorAndCompilationCanceledStatus.setCompilationCanceledStatus(canceledStatus)
|
||||||
|
|
||||||
val rootDisposable = Disposer.newDisposable()
|
val rootDisposable = Disposer.newDisposable("Disposable for ${CLICompiler::class.simpleName}.execImpl")
|
||||||
try {
|
try {
|
||||||
setIdeaIoUseFallback()
|
setIdeaIoUseFallback()
|
||||||
|
|
||||||
|
|||||||
@@ -891,7 +891,7 @@ class CompileServiceImpl(
|
|||||||
if (compilationOptions.targetPlatform != CompileService.TargetPlatform.JVM)
|
if (compilationOptions.targetPlatform != CompileService.TargetPlatform.JVM)
|
||||||
CompileService.CallResult.Error("Sorry, only JVM target platform is supported now")
|
CompileService.CallResult.Error("Sorry, only JVM target platform is supported now")
|
||||||
else {
|
else {
|
||||||
val disposable = Disposer.newDisposable()
|
val disposable = Disposer.newDisposable("Disposable for ${CompileServiceImpl::class.simpleName}.leaseReplSession")
|
||||||
val messageCollector = CompileServicesFacadeMessageCollector(servicesFacade, compilationOptions)
|
val messageCollector = CompileServicesFacadeMessageCollector(servicesFacade, compilationOptions)
|
||||||
val repl = KotlinJvmReplService(
|
val repl = KotlinJvmReplService(
|
||||||
disposable, port, compilerId, templateClasspath, templateClassName,
|
disposable, port, compilerId, templateClasspath, templateClassName,
|
||||||
|
|||||||
+1
-1
@@ -153,7 +153,7 @@ class FirResolveModularizedTotalKotlinTest : AbstractFrontendModularizedTest() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun processModule(moduleData: ModuleData): ProcessorAction {
|
override fun processModule(moduleData: ModuleData): ProcessorAction {
|
||||||
val disposable = Disposer.newDisposable()
|
val disposable = Disposer.newDisposable("Disposable for ${FirResolveModularizedTotalKotlinTest::class.simpleName}.processModule")
|
||||||
val configuration = createDefaultConfiguration(moduleData)
|
val configuration = createDefaultConfiguration(moduleData)
|
||||||
configureLanguageVersionSettings(configuration, moduleData, LanguageVersion.fromVersionString(LANGUAGE_VERSION_K2)!!)
|
configureLanguageVersionSettings(configuration, moduleData, LanguageVersion.fromVersionString(LANGUAGE_VERSION_K2)!!)
|
||||||
val environment = KotlinCoreEnvironment.createForTests(disposable, configuration, EnvironmentConfigFiles.JVM_CONFIG_FILES)
|
val environment = KotlinCoreEnvironment.createForTests(disposable, configuration, EnvironmentConfigFiles.JVM_CONFIG_FILES)
|
||||||
|
|||||||
+1
-1
@@ -122,7 +122,7 @@ class NonFirResolveModularizedTotalKotlinTest : AbstractFrontendModularizedTest(
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun processModule(moduleData: ModuleData): ProcessorAction {
|
override fun processModule(moduleData: ModuleData): ProcessorAction {
|
||||||
val disposable = Disposer.newDisposable()
|
val disposable = Disposer.newDisposable("Disposable for ${NonFirResolveModularizedTotalKotlinTest::class.simpleName}.processModule")
|
||||||
val environment = configureAndSetupEnvironment(moduleData, disposable)
|
val environment = configureAndSetupEnvironment(moduleData, disposable)
|
||||||
|
|
||||||
runAnalysis(environment)
|
runAnalysis(environment)
|
||||||
|
|||||||
+1
-1
@@ -100,7 +100,7 @@ open class IncrementalFirJvmCompilerRunner(
|
|||||||
|
|
||||||
val exitCode = ExitCode.OK
|
val exitCode = ExitCode.OK
|
||||||
val allCompiledSources = LinkedHashSet<File>()
|
val allCompiledSources = LinkedHashSet<File>()
|
||||||
val rootDisposable = Disposer.newDisposable()
|
val rootDisposable = Disposer.newDisposable("Disposable for ${IncrementalFirJvmCompilerRunner::class.simpleName}.runCompiler")
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// - configuration
|
// - configuration
|
||||||
|
|||||||
+2
-1
@@ -107,7 +107,8 @@ open class IncrementalJvmCompilerRunner(
|
|||||||
psiFileFactory.createFileFromText(file.nameWithoutExtension, JavaLanguage.INSTANCE, file.readText())
|
psiFileFactory.createFileFromText(file.nameWithoutExtension, JavaLanguage.INSTANCE, file.readText())
|
||||||
|
|
||||||
private val psiFileFactory: PsiFileFactory by lazy {
|
private val psiFileFactory: PsiFileFactory by lazy {
|
||||||
val rootDisposable = Disposer.newDisposable()
|
val rootDisposable =
|
||||||
|
Disposer.newDisposable("Disposable for PSI file factory of ${IncrementalJvmCompilerRunner::class.simpleName}")
|
||||||
val configuration = compilerConfiguration
|
val configuration = compilerConfiguration
|
||||||
val environment =
|
val environment =
|
||||||
KotlinCoreEnvironment.createForProduction(rootDisposable, configuration, EnvironmentConfigFiles.JVM_CONFIG_FILES)
|
KotlinCoreEnvironment.createForProduction(rootDisposable, configuration, EnvironmentConfigFiles.JVM_CONFIG_FILES)
|
||||||
|
|||||||
+1
-1
@@ -30,7 +30,7 @@ fun classesFqNames(files: Set<File>): Set<String> {
|
|||||||
val existingKotlinFiles = files.filter { it.name.endsWith(".kt", ignoreCase = true) && it.isFile }
|
val existingKotlinFiles = files.filter { it.name.endsWith(".kt", ignoreCase = true) && it.isFile }
|
||||||
if (existingKotlinFiles.isEmpty()) return emptySet()
|
if (existingKotlinFiles.isEmpty()) return emptySet()
|
||||||
|
|
||||||
val disposable = Disposer.newDisposable()
|
val disposable = Disposer.newDisposable("Disposable for org.jetbrains.kotlin.incremental.parsing.classesFqNames")
|
||||||
|
|
||||||
return try {
|
return try {
|
||||||
classesFqNames(existingKotlinFiles, disposable)
|
classesFqNames(existingKotlinFiles, disposable)
|
||||||
|
|||||||
+1
-1
@@ -16,7 +16,7 @@ import java.lang.reflect.Field
|
|||||||
|
|
||||||
class ApplicationEnvironmentDisposer : TestExecutionListener {
|
class ApplicationEnvironmentDisposer : TestExecutionListener {
|
||||||
companion object {
|
companion object {
|
||||||
val ROOT_DISPOSABLE: Disposable = Disposer.newDisposable()
|
val ROOT_DISPOSABLE: Disposable = Disposer.newDisposable("${ApplicationEnvironmentDisposer::class.simpleName}.ROOT_DISPOSABLE")
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun testPlanExecutionFinished(testPlan: TestPlan) {
|
override fun testPlanExecutionFinished(testPlan: TestPlan) {
|
||||||
|
|||||||
+1
-1
@@ -50,7 +50,7 @@ class TestConfigurationImpl(
|
|||||||
|
|
||||||
val originalBuilder: TestConfigurationBuilder.ReadOnlyBuilder
|
val originalBuilder: TestConfigurationBuilder.ReadOnlyBuilder
|
||||||
) : TestConfiguration(), TestService {
|
) : TestConfiguration(), TestService {
|
||||||
override val rootDisposable: Disposable = TestDisposable()
|
override val rootDisposable: Disposable = TestDisposable("${TestConfigurationImpl::class.simpleName}.rootDisposable")
|
||||||
override val testServices: TestServices = TestServices()
|
override val testServices: TestServices = TestServices()
|
||||||
|
|
||||||
init {
|
init {
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ package org.jetbrains.kotlin.test.utils
|
|||||||
|
|
||||||
import com.intellij.openapi.Disposable
|
import com.intellij.openapi.Disposable
|
||||||
|
|
||||||
class TestDisposable : Disposable {
|
class TestDisposable(val debugName: String) : Disposable {
|
||||||
@Volatile
|
@Volatile
|
||||||
var isDisposed = false
|
var isDisposed = false
|
||||||
private set
|
private set
|
||||||
@@ -15,4 +15,6 @@ class TestDisposable : Disposable {
|
|||||||
override fun dispose() {
|
override fun dispose() {
|
||||||
isDisposed = true
|
isDisposed = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun toString(): String = debugName
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ object KlibTestUtil {
|
|||||||
configuration.put(CommonConfigurationKeys.MODULE_NAME, libraryName)
|
configuration.put(CommonConfigurationKeys.MODULE_NAME, libraryName)
|
||||||
configuration.addKotlinSourceRoots(sourceFiles.map { it.absolutePath })
|
configuration.addKotlinSourceRoots(sourceFiles.map { it.absolutePath })
|
||||||
|
|
||||||
val rootDisposable = Disposer.newDisposable()
|
val rootDisposable = Disposer.newDisposable("Disposable for ${KlibTestUtil::class.simpleName}.compileCommonSourcesToKlib")
|
||||||
val module = try {
|
val module = try {
|
||||||
val environment = KotlinCoreEnvironment.createForTests(
|
val environment = KotlinCoreEnvironment.createForTests(
|
||||||
parentDisposable = rootDisposable,
|
parentDisposable = rootDisposable,
|
||||||
|
|||||||
@@ -199,7 +199,7 @@ internal class TestRepl(
|
|||||||
) : Closeable {
|
) : Closeable {
|
||||||
val application = ApplicationManager.getApplication()
|
val application = ApplicationManager.getApplication()
|
||||||
|
|
||||||
private val disposable: Disposable by lazy { Disposer.newDisposable() }
|
private val disposable: Disposable by lazy { Disposer.newDisposable("${TestRepl::class.simpleName}.disposable") }
|
||||||
|
|
||||||
val emptyScriptArgs = ScriptArgsWithTypes(arrayOf(emptyArray<String>()), arrayOf(Array<String>::class))
|
val emptyScriptArgs = ScriptArgsWithTypes(arrayOf(emptyArray<String>()), arrayOf(Array<String>::class))
|
||||||
|
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ class FastJarFSTest : TestCase() {
|
|||||||
|
|
||||||
private var fs: FastJarFileSystem? = null
|
private var fs: FastJarFileSystem? = null
|
||||||
private var coreAppEnv: JavaCoreApplicationEnvironment? = null
|
private var coreAppEnv: JavaCoreApplicationEnvironment? = null
|
||||||
private val rootDisposable = Disposer.newDisposable()
|
private val rootDisposable = Disposer.newDisposable("${FastJarFSTest::class.simpleName}.rootDisposable")
|
||||||
|
|
||||||
override fun setUp() {
|
override fun setUp() {
|
||||||
super.setUp()
|
super.setUp()
|
||||||
|
|||||||
+1
-1
@@ -72,7 +72,7 @@ class KotlinJavascriptSerializerTest : TestCaseWithTmpdir() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun serialize(configuration: CompilerConfiguration, metaFile: File) {
|
private fun serialize(configuration: CompilerConfiguration, metaFile: File) {
|
||||||
val rootDisposable = Disposer.newDisposable()
|
val rootDisposable = Disposer.newDisposable("Disposable for ${KotlinJavascriptSerializerTest::class.simpleName}.serialize")
|
||||||
try {
|
try {
|
||||||
val environment = KotlinCoreEnvironment.createForTests(rootDisposable, configuration, EnvironmentConfigFiles.JS_CONFIG_FILES)
|
val environment = KotlinCoreEnvironment.createForTests(rootDisposable, configuration, EnvironmentConfigFiles.JS_CONFIG_FILES)
|
||||||
val files = environment.getSourceFiles()
|
val files = environment.getSourceFiles()
|
||||||
|
|||||||
@@ -82,7 +82,11 @@ abstract class AbstractInvalidationTest(
|
|||||||
|
|
||||||
private val zipAccessor = ZipFileSystemCacheableAccessor(2)
|
private val zipAccessor = ZipFileSystemCacheableAccessor(2)
|
||||||
protected val environment =
|
protected val environment =
|
||||||
KotlinCoreEnvironment.createForParallelTests(TestDisposable(), CompilerConfiguration(), EnvironmentConfigFiles.JS_CONFIG_FILES)
|
KotlinCoreEnvironment.createForParallelTests(
|
||||||
|
TestDisposable("${AbstractInvalidationTest::class.simpleName}.rootDisposable"),
|
||||||
|
CompilerConfiguration(),
|
||||||
|
EnvironmentConfigFiles.JS_CONFIG_FILES,
|
||||||
|
)
|
||||||
|
|
||||||
@AfterEach
|
@AfterEach
|
||||||
protected fun clearZipAccessor() {
|
protected fun clearZipAccessor() {
|
||||||
|
|||||||
+1
-1
@@ -83,7 +83,7 @@ object ExperimentalOptInUsageInSourceChecker {
|
|||||||
|
|
||||||
private fun createProjectForParsing(): Project {
|
private fun createProjectForParsing(): Project {
|
||||||
return KotlinCoreEnvironment.createForProduction(
|
return KotlinCoreEnvironment.createForProduction(
|
||||||
Disposer.newDisposable(),
|
Disposer.newDisposable("Disposable for project of ${ExperimentalOptInUsageInSourceChecker::class.simpleName}"),
|
||||||
CompilerConfiguration(),
|
CompilerConfiguration(),
|
||||||
EnvironmentConfigFiles.JVM_CONFIG_FILES
|
EnvironmentConfigFiles.JVM_CONFIG_FILES
|
||||||
).project
|
).project
|
||||||
|
|||||||
+1
-1
@@ -163,7 +163,7 @@ public class ExecuteKotlinScriptMojo extends AbstractMojo {
|
|||||||
private void executeScriptFile(File scriptFile) throws MojoExecutionException {
|
private void executeScriptFile(File scriptFile) throws MojoExecutionException {
|
||||||
initCompiler();
|
initCompiler();
|
||||||
|
|
||||||
Disposable rootDisposable = Disposer.newDisposable();
|
Disposable rootDisposable = Disposer.newDisposable("Disposable for ExecuteKotlinScriptMojo.executeScriptFile");
|
||||||
|
|
||||||
try {
|
try {
|
||||||
MavenPluginLogMessageCollector messageCollector = new MavenPluginLogMessageCollector(getLog());
|
MavenPluginLogMessageCollector messageCollector = new MavenPluginLogMessageCollector(getLog());
|
||||||
|
|||||||
+1
-1
@@ -20,7 +20,7 @@ abstract class AbstractObjCExportHeaderGeneratorTest(
|
|||||||
fun generateHeaders(disposable: Disposable, root: File): String
|
fun generateHeaders(disposable: Disposable, root: File): String
|
||||||
}
|
}
|
||||||
|
|
||||||
private val testRootDisposable = Disposer.newDisposable()
|
private val testRootDisposable = Disposer.newDisposable("${AbstractObjCExportHeaderGeneratorTest::class.simpleName}.testRootDisposable")
|
||||||
protected val objCExportTestDataDir = testDataDir.resolve("objcexport")
|
protected val objCExportTestDataDir = testDataDir.resolve("objcexport")
|
||||||
|
|
||||||
@After
|
@After
|
||||||
|
|||||||
+1
-1
@@ -31,7 +31,7 @@ import kotlin.test.assertNull
|
|||||||
* The test also acts as quick entry point for debugging the [ObjCExportMapper]
|
* The test also acts as quick entry point for debugging the [ObjCExportMapper]
|
||||||
*/
|
*/
|
||||||
class ObjCExportMapperTest : InlineSourceTestEnvironment {
|
class ObjCExportMapperTest : InlineSourceTestEnvironment {
|
||||||
override val testDisposable = Disposer.newDisposable()
|
override val testDisposable = Disposer.newDisposable("${ObjCExportMapperTest::class.simpleName}.testDisposable")
|
||||||
override val kotlinCoreEnvironment: KotlinCoreEnvironment = createKotlinCoreEnvironment(testDisposable)
|
override val kotlinCoreEnvironment: KotlinCoreEnvironment = createKotlinCoreEnvironment(testDisposable)
|
||||||
|
|
||||||
@TempDir
|
@TempDir
|
||||||
|
|||||||
+1
-1
@@ -35,7 +35,7 @@ import kotlin.test.assertEquals
|
|||||||
*/
|
*/
|
||||||
class ObjCExportNamerTest : InlineSourceTestEnvironment {
|
class ObjCExportNamerTest : InlineSourceTestEnvironment {
|
||||||
|
|
||||||
override val testDisposable = Disposer.newDisposable()
|
override val testDisposable = Disposer.newDisposable("${ObjCExportNamerTest::class.simpleName}.testDisposable")
|
||||||
|
|
||||||
override val kotlinCoreEnvironment = createKotlinCoreEnvironment(testDisposable)
|
override val kotlinCoreEnvironment = createKotlinCoreEnvironment(testDisposable)
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -36,7 +36,7 @@ internal fun makeCompiledModule(generationState: GenerationState) =
|
|||||||
inline fun <T> withMessageCollectorAndDisposable(
|
inline fun <T> withMessageCollectorAndDisposable(
|
||||||
script: SourceCode? = null,
|
script: SourceCode? = null,
|
||||||
parentMessageCollector: MessageCollector? = null,
|
parentMessageCollector: MessageCollector? = null,
|
||||||
disposable: Disposable = Disposer.newDisposable(),
|
disposable: Disposable = Disposer.newDisposable("Default disposable for scripting compiler"),
|
||||||
disposeOnSuccess: Boolean = true,
|
disposeOnSuccess: Boolean = true,
|
||||||
body: (ScriptDiagnosticsMessageCollector, Disposable) -> ResultWithDiagnostics<T>
|
body: (ScriptDiagnosticsMessageCollector, Disposable) -> ResultWithDiagnostics<T>
|
||||||
): ResultWithDiagnostics<T> {
|
): ResultWithDiagnostics<T> {
|
||||||
|
|||||||
+6
-1
@@ -36,7 +36,12 @@ open class GenericReplCompiler(
|
|||||||
scriptDefinition: KotlinScriptDefinition,
|
scriptDefinition: KotlinScriptDefinition,
|
||||||
compilerConfiguration: CompilerConfiguration,
|
compilerConfiguration: CompilerConfiguration,
|
||||||
messageCollector: MessageCollector
|
messageCollector: MessageCollector
|
||||||
) : this(Disposer.newDisposable(), scriptDefinition, compilerConfiguration, messageCollector)
|
) : this(
|
||||||
|
Disposer.newDisposable("Default disposable for ${GenericReplCompiler::class.simpleName}"),
|
||||||
|
scriptDefinition,
|
||||||
|
compilerConfiguration,
|
||||||
|
messageCollector
|
||||||
|
)
|
||||||
|
|
||||||
private val checker =
|
private val checker =
|
||||||
GenericReplChecker(
|
GenericReplChecker(
|
||||||
|
|||||||
+9
-1
@@ -59,7 +59,15 @@ class FirScriptDefinitionProviderService(
|
|||||||
val makeConfigurationProvider = configurationProvider?.let { { it } }
|
val makeConfigurationProvider = configurationProvider?.let { { it } }
|
||||||
?: {
|
?: {
|
||||||
// TODO: check if memory can leak in MockProject (probably not too important, since currently the providers are set externaly in important cases)
|
// TODO: check if memory can leak in MockProject (probably not too important, since currently the providers are set externaly in important cases)
|
||||||
CliScriptDependenciesProvider(MockProject(null, Disposer.newDisposable()))
|
CliScriptDependenciesProvider(
|
||||||
|
MockProject(
|
||||||
|
null,
|
||||||
|
Disposer.newDisposable(
|
||||||
|
"Disposable for project of ${CliScriptDependenciesProvider::class.simpleName} created by" +
|
||||||
|
" ${FirScriptDefinitionProviderService::class.simpleName}"
|
||||||
|
),
|
||||||
|
),
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
return Factory { session -> FirScriptDefinitionProviderService(session, makeDefinitionsProvider, makeConfigurationProvider) }
|
return Factory { session -> FirScriptDefinitionProviderService(session, makeDefinitionsProvider, makeConfigurationProvider) }
|
||||||
|
|||||||
+4
-2
@@ -271,7 +271,7 @@ internal fun <R> withTempDir(keyName: String = "tmp", body: (File) -> R): R {
|
|||||||
}
|
}
|
||||||
|
|
||||||
internal fun <R> withDisposable(body: (Disposable) -> R) {
|
internal fun <R> withDisposable(body: (Disposable) -> R) {
|
||||||
val disposable = Disposer.newDisposable()
|
val disposable = Disposer.newDisposable("Disposable for scripting compiler tests")
|
||||||
try {
|
try {
|
||||||
body(disposable)
|
body(disposable)
|
||||||
} finally {
|
} finally {
|
||||||
@@ -279,7 +279,7 @@ internal fun <R> withDisposable(body: (Disposable) -> R) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class TestDisposable : Disposable {
|
class TestDisposable(val debugName: String) : Disposable {
|
||||||
@Volatile
|
@Volatile
|
||||||
var isDisposed = false
|
var isDisposed = false
|
||||||
private set
|
private set
|
||||||
@@ -287,6 +287,8 @@ class TestDisposable : Disposable {
|
|||||||
override fun dispose() {
|
override fun dispose() {
|
||||||
isDisposed = true
|
isDisposed = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun toString(): String = debugName
|
||||||
}
|
}
|
||||||
|
|
||||||
fun CompilerConfiguration.updateWithBaseCompilerArguments() {
|
fun CompilerConfiguration.updateWithBaseCompilerArguments() {
|
||||||
|
|||||||
+2
-1
@@ -28,7 +28,8 @@ private const val testDataPath = "plugins/scripting/scripting-compiler/testData/
|
|||||||
|
|
||||||
class CollectScriptCompilationDependenciesTest : TestCase() {
|
class CollectScriptCompilationDependenciesTest : TestCase() {
|
||||||
|
|
||||||
protected val testRootDisposable: Disposable = TestDisposable()
|
protected val testRootDisposable: Disposable =
|
||||||
|
TestDisposable("${CollectScriptCompilationDependenciesTest::class.simpleName}.testRootDisposable")
|
||||||
|
|
||||||
fun testCascadeImport() {
|
fun testCascadeImport() {
|
||||||
runTest("imp_imp_leaf.req1.kts", listOf("imp_leaf.req1.kts", "leaf.req1.kts"))
|
runTest("imp_imp_leaf.req1.kts", listOf("imp_leaf.req1.kts", "leaf.req1.kts"))
|
||||||
|
|||||||
+1
-1
@@ -34,7 +34,7 @@ import kotlin.script.experimental.util.filterByAnnotationType
|
|||||||
private const val testDataPath = "plugins/scripting/scripting-compiler/testData/compiler/compileTimeFibonacci"
|
private const val testDataPath = "plugins/scripting/scripting-compiler/testData/compiler/compileTimeFibonacci"
|
||||||
|
|
||||||
class CompileTimeFibonacciTest : TestCase() {
|
class CompileTimeFibonacciTest : TestCase() {
|
||||||
private val testRootDisposable: Disposable = TestDisposable()
|
private val testRootDisposable: Disposable = TestDisposable("${CompileTimeFibonacciTest::class.simpleName}.testRootDisposable")
|
||||||
|
|
||||||
fun testFibonacciWithSupportedNumbersImplementsTheCorrectConstants() {
|
fun testFibonacciWithSupportedNumbersImplementsTheCorrectConstants() {
|
||||||
val outputLines = runScript("supported.fib.kts")
|
val outputLines = runScript("supported.fib.kts")
|
||||||
|
|||||||
+1
-1
@@ -40,7 +40,7 @@ private annotation class TestAnnotation(vararg val options: String)
|
|||||||
private annotation class AnnotationWithVarArgAndArray(vararg val options: String, val moreOptions: Array<String>)
|
private annotation class AnnotationWithVarArgAndArray(vararg val options: String, val moreOptions: Array<String>)
|
||||||
|
|
||||||
class ConstructAnnotationTest : TestCase() {
|
class ConstructAnnotationTest : TestCase() {
|
||||||
private val testRootDisposable: Disposable = TestDisposable()
|
private val testRootDisposable: Disposable = TestDisposable("${ConstructAnnotationTest::class.simpleName}.testRootDisposable")
|
||||||
|
|
||||||
fun testAnnotationEmptyVarArg() {
|
fun testAnnotationEmptyVarArg() {
|
||||||
val annotations = annotations("TestAnnotationEmptyVarArg.kts", TestAnnotation::class)
|
val annotations = annotations("TestAnnotationEmptyVarArg.kts", TestAnnotation::class)
|
||||||
|
|||||||
+1
-1
@@ -35,7 +35,7 @@ private const val testDataPath = "plugins/scripting/scripting-compiler/testData/
|
|||||||
|
|
||||||
class ScriptCliCompilationTest : TestCase() {
|
class ScriptCliCompilationTest : TestCase() {
|
||||||
|
|
||||||
protected val testRootDisposable: Disposable = TestDisposable()
|
protected val testRootDisposable: Disposable = TestDisposable("${ScriptCliCompilationTest::class.simpleName}.testRootDisposable")
|
||||||
|
|
||||||
fun testPrerequisites() {
|
fun testPrerequisites() {
|
||||||
Assert.assertTrue(thisClasspath.isNotEmpty())
|
Assert.assertTrue(thisClasspath.isNotEmpty())
|
||||||
|
|||||||
+1
-1
@@ -362,7 +362,7 @@ class ScriptTemplateTest : TestCase() {
|
|||||||
messageCollector: MessageCollector,
|
messageCollector: MessageCollector,
|
||||||
includeKotlinRuntime: Boolean
|
includeKotlinRuntime: Boolean
|
||||||
): Class<*>? {
|
): Class<*>? {
|
||||||
val rootDisposable = Disposer.newDisposable()
|
val rootDisposable = Disposer.newDisposable("Disposable for ${ScriptTemplateTest::class.simpleName}")
|
||||||
try {
|
try {
|
||||||
val additionalClasspath = System.getProperty("kotlin.test.script.classpath")?.split(File.pathSeparator)
|
val additionalClasspath = System.getProperty("kotlin.test.script.classpath")?.split(File.pathSeparator)
|
||||||
?.mapNotNull { File(it).takeIf { file -> file.exists() } }.orEmpty().toTypedArray()
|
?.mapNotNull { File(it).takeIf { file -> file.exists() } }.orEmpty().toTypedArray()
|
||||||
|
|||||||
+1
-1
@@ -116,7 +116,7 @@ class ScriptTest : TestCase() {
|
|||||||
if (suppressOutput) MessageCollector.NONE
|
if (suppressOutput) MessageCollector.NONE
|
||||||
else PrintingMessageCollector(System.err, MessageRenderer.PLAIN_FULL_PATHS, false)
|
else PrintingMessageCollector(System.err, MessageRenderer.PLAIN_FULL_PATHS, false)
|
||||||
|
|
||||||
val rootDisposable = Disposer.newDisposable()
|
val rootDisposable = Disposer.newDisposable("Disposable for ${ScriptTest::class.simpleName}")
|
||||||
try {
|
try {
|
||||||
val configuration = KotlinTestUtils.newConfiguration(ConfigurationKind.ALL, TestJdkKind.FULL_JDK)
|
val configuration = KotlinTestUtils.newConfiguration(ConfigurationKind.ALL, TestJdkKind.FULL_JDK)
|
||||||
configuration.updateWithBaseCompilerArguments()
|
configuration.updateWithBaseCompilerArguments()
|
||||||
|
|||||||
Reference in New Issue
Block a user