Enable assertions for Kotlin daemon in Gradle tests

This commit is contained in:
Alexey Tsvetkov
2019-01-20 20:33:39 +03:00
parent 9176f9b254
commit beabbb95db
4 changed files with 13 additions and 5 deletions
@@ -364,7 +364,7 @@ public class K2JSCompiler extends CLICompiler<K2JSCompilerArguments> {
MessageCollector messageCollector = configuration.getNotNull(CLIConfigurationKeys.MESSAGE_COLLECTOR_KEY);
if (arguments.getTarget() != null) {
assert arguments.getTarget() == "v5" : "Unsupported ECMA version: " + arguments.getTarget();
assert "v5".equals(arguments.getTarget()) : "Unsupported ECMA version: " + arguments.getTarget();
}
configuration.put(JSConfigurationKeys.TARGET, EcmaVersion.defaultVersion());
@@ -609,7 +609,7 @@ abstract class BaseGradleIT {
// Workaround: override a console type set in the user machine gradle.properties (since Gradle 4.3):
add("--console=plain")
add("-Dkotlin.daemon.ea=true")
addAll(options.freeCommandLineArgs)
}
@@ -159,13 +159,19 @@ internal open class GradleCompilerRunner(protected val task: Task) {
sessionIsAliveFlagFile: File,
compilerFullClasspath: List<File>,
messageCollector: MessageCollector,
isDebugEnabled: Boolean
isDebugEnabled: Boolean,
enableAssertions: Boolean
): CompileServiceSession? {
val compilerId = CompilerId.makeCompilerId(compilerFullClasspath)
val additionalJvmParams = arrayListOf<String>()
if (enableAssertions) {
additionalJvmParams.add("ea")
}
return KotlinCompilerRunnerUtils.newDaemonConnection(
compilerId, clientIsAliveFlagFile, sessionIsAliveFlagFile,
messageCollector = messageCollector,
isDebugEnabled = isDebugEnabled
isDebugEnabled = isDebugEnabled,
additionalJvmParams = additionalJvmParams.toTypedArray()
)
}
@@ -134,6 +134,7 @@ internal class GradleKotlinCompilerWork @Inject constructor(
private fun compileWithDaemon(messageCollector: MessageCollector): ExitCode? {
val isDebugEnabled = log.isDebugEnabled || System.getProperty("kotlin.daemon.debug.log")?.toBoolean() ?: false
val enableAssertions = System.getProperty("kotlin.daemon.ea")?.toBoolean() ?: false
val daemonMessageCollector =
if (isDebugEnabled) messageCollector else MessageCollector.NONE
@@ -144,7 +145,8 @@ internal class GradleKotlinCompilerWork @Inject constructor(
sessionFlagFile,
compilerFullClasspath,
daemonMessageCollector,
isDebugEnabled
isDebugEnabled = isDebugEnabled,
enableAssertions = enableAssertions
)
} catch (e: Throwable) {
log.error("Caught an exception trying to connect to Kotlin Daemon:")