[Gradle] Fix the verbose rendering for FATAL diagnostics
During the tests we are using the verbose way of render the diagnostic meaning, that we are adding the diagnostic id to the diagnostic message. And we previously didn't have that for one case, so we were unable to detect in tests that diagnostic with FATAL severity was reported
This commit is contained in:
committed by
Space Team
parent
3ee07eb015
commit
955520f69e
+4
-5
@@ -5,7 +5,6 @@
|
||||
|
||||
package org.jetbrains.kotlin.gradle.plugin.diagnostics
|
||||
|
||||
import org.gradle.api.InvalidUserCodeException
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.api.provider.Provider
|
||||
import org.gradle.api.services.BuildService
|
||||
@@ -63,8 +62,10 @@ internal abstract class KotlinToolingDiagnosticsCollector : BuildService<BuildSe
|
||||
}
|
||||
|
||||
private fun saveDiagnostic(project: Project, diagnostic: ToolingDiagnostic) {
|
||||
val isVerbose = project.kotlinPropertiesProvider.internalVerboseDiagnostics
|
||||
|
||||
if (isTransparent) {
|
||||
renderReportedDiagnostic(diagnostic, project.logger, project.kotlinPropertiesProvider.internalVerboseDiagnostics)
|
||||
renderReportedDiagnostic(diagnostic, project.logger, isVerbose)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -73,9 +74,7 @@ internal abstract class KotlinToolingDiagnosticsCollector : BuildService<BuildSe
|
||||
}
|
||||
|
||||
if (diagnostic.severity == ToolingDiagnostic.Severity.FATAL) {
|
||||
if (diagnostic.throwable != null)
|
||||
throw InvalidUserCodeException(diagnostic.message, diagnostic.throwable)
|
||||
else throw InvalidUserCodeException(diagnostic.message)
|
||||
throw diagnostic.createAnExceptionForFatalDiagnostic(isVerbose)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+7
-3
@@ -25,12 +25,16 @@ internal fun renderReportedDiagnostic(
|
||||
|
||||
ERROR -> logger.error("e: ${diagnostic.render(isVerbose)}\n")
|
||||
|
||||
FATAL -> if (diagnostic.throwable != null)
|
||||
throw InvalidUserCodeException(diagnostic.render(isVerbose), diagnostic.throwable)
|
||||
else throw InvalidUserCodeException(diagnostic.render(isVerbose))
|
||||
FATAL -> throw diagnostic.createAnExceptionForFatalDiagnostic(isVerbose)
|
||||
}
|
||||
}
|
||||
|
||||
internal fun ToolingDiagnostic.createAnExceptionForFatalDiagnostic(isVerbose: Boolean): InvalidUserCodeException =
|
||||
if (throwable != null)
|
||||
InvalidUserCodeException(render(isVerbose), throwable)
|
||||
else
|
||||
InvalidUserCodeException(render(isVerbose))
|
||||
|
||||
private fun ToolingDiagnostic.render(isVerbose: Boolean): String = buildString {
|
||||
if (isVerbose) {
|
||||
appendLine(this@render)
|
||||
|
||||
Reference in New Issue
Block a user