Improve daemon client diagnostic and run failure detection
Removing prefiltering of the daemon client reporting - filtering should be performed on the receiver site. And put daemon process output during executioninto INFO category. May make daemon usage more talkative, but will not eat important error messages anymore. Add test with failure condition. Also failed daemon start should not cause timeout anymore.
This commit is contained in:
+4
-3
@@ -339,7 +339,6 @@ object KotlinCompilerClient {
|
||||
}
|
||||
|
||||
private fun DaemonReportingTargets.report(category: DaemonReportCategory, message: String, source: String = "daemon client") {
|
||||
if (category == DaemonReportCategory.DEBUG && !verboseReporting) return
|
||||
out?.println("[$source] ${category.name}: $message")
|
||||
messages?.add(DaemonReportMessage(category, "[$source] $message"))
|
||||
messageCollector?.let {
|
||||
@@ -421,19 +420,21 @@ object KotlinCompilerClient {
|
||||
daemon.inputStream
|
||||
.reader()
|
||||
.forEachLine {
|
||||
reportingTargets.report(DaemonReportCategory.DEBUG, it, "daemon")
|
||||
|
||||
if (it == COMPILE_DAEMON_IS_READY_MESSAGE) {
|
||||
reportingTargets.report(DaemonReportCategory.DEBUG, "Received the message signalling that the daemon is ready")
|
||||
isEchoRead.release()
|
||||
return@forEachLine
|
||||
}
|
||||
else {
|
||||
reportingTargets.report(DaemonReportCategory.INFO, it, "daemon")
|
||||
}
|
||||
}
|
||||
}
|
||||
finally {
|
||||
daemon.inputStream.close()
|
||||
daemon.outputStream.close()
|
||||
daemon.errorStream.close()
|
||||
isEchoRead.release()
|
||||
}
|
||||
}
|
||||
try {
|
||||
|
||||
@@ -208,6 +208,26 @@ class CompilerDaemonTest : KotlinIntegrationTestBase() {
|
||||
}
|
||||
}
|
||||
|
||||
fun testDaemonRunError() {
|
||||
withFlagFile(getTestName(true), ".alive") { flagFile ->
|
||||
val daemonOptions = DaemonOptions(shutdownDelayMilliseconds = 1, verbose = true, runFilesPath = File(tmpdir, getTestName(true)).absolutePath)
|
||||
|
||||
KotlinCompilerClient.shutdownCompileService(compilerId, daemonOptions)
|
||||
|
||||
val daemonJVMOptions = configureDaemonJVMOptions("-abracadabra", inheritMemoryLimits = false, inheritAdditionalProperties = false)
|
||||
|
||||
val messageCollector = TestMessageCollector()
|
||||
|
||||
val daemon = KotlinCompilerClient.connectToCompileService(compilerId, flagFile, daemonJVMOptions, daemonOptions,
|
||||
DaemonReportingTargets(messageCollector = messageCollector), autostart = true)
|
||||
|
||||
assertNull(daemon)
|
||||
|
||||
assertTrue("Expecting error message, actual:\n${messageCollector.messages.joinToString("\n") { it.message }}",
|
||||
messageCollector.messages.any { it.message == "Unrecognized option: --abracadabra" })
|
||||
}
|
||||
}
|
||||
|
||||
fun testDaemonAutoshutdownOnUnused() {
|
||||
withFlagFile(getTestName(true), ".alive") { flagFile ->
|
||||
val daemonOptions = DaemonOptions(autoshutdownUnusedSeconds = 1, shutdownDelayMilliseconds = 1, runFilesPath = File(tmpdir, getTestName(true)).absolutePath)
|
||||
|
||||
Reference in New Issue
Block a user