Clear application in CompilerApiTest
This commit is contained in:
@@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.daemon
|
package org.jetbrains.kotlin.daemon
|
||||||
|
|
||||||
|
import com.intellij.openapi.application.ApplicationManager
|
||||||
import org.jetbrains.kotlin.cli.common.arguments.K2JVMCompilerArguments
|
import org.jetbrains.kotlin.cli.common.arguments.K2JVMCompilerArguments
|
||||||
import org.jetbrains.kotlin.cli.common.messages.CompilerMessageLocation
|
import org.jetbrains.kotlin.cli.common.messages.CompilerMessageLocation
|
||||||
import org.jetbrains.kotlin.cli.common.messages.CompilerMessageSeverity
|
import org.jetbrains.kotlin.cli.common.messages.CompilerMessageSeverity
|
||||||
@@ -29,6 +30,7 @@ import org.jetbrains.kotlin.daemon.common.*
|
|||||||
import org.jetbrains.kotlin.integration.KotlinIntegrationTestBase
|
import org.jetbrains.kotlin.integration.KotlinIntegrationTestBase
|
||||||
import org.jetbrains.kotlin.scripts.captureOut
|
import org.jetbrains.kotlin.scripts.captureOut
|
||||||
import org.jetbrains.kotlin.test.KotlinTestUtils
|
import org.jetbrains.kotlin.test.KotlinTestUtils
|
||||||
|
import org.jetbrains.kotlin.test.testFramework.KtUsefulTestCase
|
||||||
import org.junit.Assert
|
import org.junit.Assert
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.net.URLClassLoader
|
import java.net.URLClassLoader
|
||||||
@@ -45,15 +47,21 @@ class CompilerApiTest : KotlinIntegrationTestBase() {
|
|||||||
val compilerId by lazy(LazyThreadSafetyMode.NONE) { CompilerId.makeCompilerId(compilerClassPath) }
|
val compilerId by lazy(LazyThreadSafetyMode.NONE) { CompilerId.makeCompilerId(compilerClassPath) }
|
||||||
|
|
||||||
private fun compileLocally(messageCollector: TestMessageCollector, vararg args: String): Pair<Int, Collection<OutputMessageUtil.Output>> {
|
private fun compileLocally(messageCollector: TestMessageCollector, vararg args: String): Pair<Int, Collection<OutputMessageUtil.Output>> {
|
||||||
val code = K2JVMCompiler().exec(messageCollector,
|
val application = ApplicationManager.getApplication()
|
||||||
Services.EMPTY,
|
try {
|
||||||
K2JVMCompilerArguments().apply { K2JVMCompiler().parseArguments(args, this) }).code
|
val code = K2JVMCompiler().exec(messageCollector,
|
||||||
val outputs = messageCollector.messages.filter { it.severity == CompilerMessageSeverity.OUTPUT }.mapNotNull {
|
Services.EMPTY,
|
||||||
OutputMessageUtil.parseOutputMessage(it.message)?.let { outs ->
|
K2JVMCompilerArguments().apply { K2JVMCompiler().parseArguments(args, this) }).code
|
||||||
outs.outputFile?.let { OutputMessageUtil.Output(outs.sourceFiles, it) }
|
val outputs = messageCollector.messages.filter { it.severity == CompilerMessageSeverity.OUTPUT }.mapNotNull {
|
||||||
|
OutputMessageUtil.parseOutputMessage(it.message)?.let { outs ->
|
||||||
|
outs.outputFile?.let { OutputMessageUtil.Output(outs.sourceFiles, it) }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
return code to outputs
|
||||||
|
}
|
||||||
|
finally {
|
||||||
|
KtUsefulTestCase.resetApplicationToNull(application)
|
||||||
}
|
}
|
||||||
return code to outputs
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun compileOnDaemon(clientAliveFile: File, compilerId: CompilerId, daemonJVMOptions: DaemonJVMOptions, daemonOptions: DaemonOptions,
|
private fun compileOnDaemon(clientAliveFile: File, compilerId: CompilerId, daemonJVMOptions: DaemonJVMOptions, daemonOptions: DaemonOptions,
|
||||||
|
|||||||
Reference in New Issue
Block a user