Use KotlinCoreEnvironment.createForTests in test code

createForProduction creates and caches JavaCoreApplicationEnvironment
instance, which can alter behavior of subsequent tests
This commit is contained in:
Alexander Udalov
2017-11-02 17:09:40 +01:00
parent dddd1cdba5
commit 3ead2e9cd4
4 changed files with 4 additions and 11 deletions
@@ -145,7 +145,7 @@ done
put(JVMConfigurationKeys.RETAIN_OUTPUT_IN_MEMORY, true)
}
val environment = KotlinCoreEnvironment.createForProduction(rootDisposable, configuration, EnvironmentConfigFiles.JVM_CONFIG_FILES)
val environment = KotlinCoreEnvironment.createForTests(rootDisposable, configuration, EnvironmentConfigFiles.JVM_CONFIG_FILES)
try {
return KotlinToJVMBytecodeCompiler.compileScript(environment)
@@ -166,12 +166,6 @@ done
}
}
private inline fun <R> ifFailed(default: R, block: () -> R) = try {
block()
} catch (t: Throwable) {
default
}
private fun String.linesSplitTrim() =
split('\n','\r').map(String::trim).filter(String::isNotBlank)