[rdct-tests] add suppressed exceptions info to the exceptions sent from ide to the test process

GitOrigin-RevId: 38ad64ca1336a5734be0638685bc7563432058b3
This commit is contained in:
Anastasia.Katsman
2025-07-29 18:18:26 +00:00
committed by intellij-monorepo-bot
parent 4358c0c90d
commit 5955fe1975
3 changed files with 35 additions and 23 deletions
@@ -31,7 +31,7 @@ class DistributedTestModel private constructor(
serializers.register(LazyCompanionMarshaller(RdId(552672907393700794), classLoader, "com.intellij.remoteDev.tests.modelGenerated.RdAgentType"))
serializers.register(LazyCompanionMarshaller(RdId(-3824320616986309148), classLoader, "com.intellij.remoteDev.tests.modelGenerated.RdProductType"))
serializers.register(LazyCompanionMarshaller(RdId(-4029698853809470560), classLoader, "com.intellij.remoteDev.tests.modelGenerated.RdTestSessionStackTraceElement"))
serializers.register(LazyCompanionMarshaller(RdId(3844250127064816121), classLoader, "com.intellij.remoteDev.tests.modelGenerated.RdTestSessionExceptionCause"))
serializers.register(LazyCompanionMarshaller(RdId(-2964405344154034056), classLoader, "com.intellij.remoteDev.tests.modelGenerated.RdTestSessionLightException"))
serializers.register(LazyCompanionMarshaller(RdId(-6820612235039581104), classLoader, "com.intellij.remoteDev.tests.modelGenerated.RdTestSessionException"))
serializers.register(LazyCompanionMarshaller(RdId(8999514109111023287), classLoader, "com.intellij.remoteDev.tests.modelGenerated.RdTestActionParameters"))
serializers.register(LazyCompanionMarshaller(RdId(1797576418817339312), classLoader, "com.intellij.remoteDev.tests.modelGenerated.RdTestComponentData"))
@@ -58,7 +58,7 @@ class DistributedTestModel private constructor(
private val __RdTestSessionNullableSerializer = RdTestSession.nullable()
const val serializationHash = 1161112409833170567L
const val serializationHash = 4116578669314861084L
}
override val serializersOwner: ISerializersOwner get() = DistributedTestModel
@@ -681,7 +681,8 @@ data class RdTestSessionException (
val originalType: String?,
val message: String?,
val stacktrace: List<RdTestSessionStackTraceElement>,
val cause: RdTestSessionExceptionCause?
val cause: RdTestSessionLightException?,
val suppressedExceptions: List<RdTestSessionLightException>?
) : IPrintable {
//companion
@@ -695,8 +696,9 @@ data class RdTestSessionException (
val originalType = buffer.readNullable { buffer.readString() }
val message = buffer.readNullable { buffer.readString() }
val stacktrace = buffer.readList { RdTestSessionStackTraceElement.read(ctx, buffer) }
val cause = buffer.readNullable { RdTestSessionExceptionCause.read(ctx, buffer) }
return RdTestSessionException(type, originalType, message, stacktrace, cause)
val cause = buffer.readNullable { RdTestSessionLightException.read(ctx, buffer) }
val suppressedExceptions = buffer.readNullable { buffer.readList { RdTestSessionLightException.read(ctx, buffer) } }
return RdTestSessionException(type, originalType, message, stacktrace, cause, suppressedExceptions)
}
override fun write(ctx: SerializationCtx, buffer: AbstractBuffer, value: RdTestSessionException) {
@@ -704,7 +706,8 @@ data class RdTestSessionException (
buffer.writeNullable(value.originalType) { buffer.writeString(it) }
buffer.writeNullable(value.message) { buffer.writeString(it) }
buffer.writeList(value.stacktrace) { v -> RdTestSessionStackTraceElement.write(ctx, buffer, v) }
buffer.writeNullable(value.cause) { RdTestSessionExceptionCause.write(ctx, buffer, it) }
buffer.writeNullable(value.cause) { RdTestSessionLightException.write(ctx, buffer, it) }
buffer.writeNullable(value.suppressedExceptions) { buffer.writeList(it) { v -> RdTestSessionLightException.write(ctx, buffer, v) } }
}
@@ -725,6 +728,7 @@ data class RdTestSessionException (
if (message != other.message) return false
if (stacktrace != other.stacktrace) return false
if (cause != other.cause) return false
if (suppressedExceptions != other.suppressedExceptions) return false
return true
}
@@ -736,6 +740,7 @@ data class RdTestSessionException (
__r = __r*31 + if (message != null) message.hashCode() else 0
__r = __r*31 + stacktrace.hashCode()
__r = __r*31 + if (cause != null) cause.hashCode() else 0
__r = __r*31 + if (suppressedExceptions != null) suppressedExceptions.hashCode() else 0
return __r
}
//pretty print
@@ -747,6 +752,7 @@ data class RdTestSessionException (
print("message = "); message.print(printer); println()
print("stacktrace = "); stacktrace.print(printer); println()
print("cause = "); cause.print(printer); println()
print("suppressedExceptions = "); suppressedExceptions.print(printer); println()
}
printer.print(")")
}
@@ -759,26 +765,26 @@ data class RdTestSessionException (
/**
* #### Generated from [DistributedTestModel.kt]
*/
data class RdTestSessionExceptionCause (
data class RdTestSessionLightException (
val type: String,
val message: String?,
val stacktrace: List<RdTestSessionStackTraceElement>
) : IPrintable {
//companion
companion object : IMarshaller<RdTestSessionExceptionCause> {
override val _type: KClass<RdTestSessionExceptionCause> = RdTestSessionExceptionCause::class
override val id: RdId get() = RdId(3844250127064816121)
companion object : IMarshaller<RdTestSessionLightException> {
override val _type: KClass<RdTestSessionLightException> = RdTestSessionLightException::class
override val id: RdId get() = RdId(-2964405344154034056)
@Suppress("UNCHECKED_CAST")
override fun read(ctx: SerializationCtx, buffer: AbstractBuffer): RdTestSessionExceptionCause {
override fun read(ctx: SerializationCtx, buffer: AbstractBuffer): RdTestSessionLightException {
val type = buffer.readString()
val message = buffer.readNullable { buffer.readString() }
val stacktrace = buffer.readList { RdTestSessionStackTraceElement.read(ctx, buffer) }
return RdTestSessionExceptionCause(type, message, stacktrace)
return RdTestSessionLightException(type, message, stacktrace)
}
override fun write(ctx: SerializationCtx, buffer: AbstractBuffer, value: RdTestSessionExceptionCause) {
override fun write(ctx: SerializationCtx, buffer: AbstractBuffer, value: RdTestSessionLightException) {
buffer.writeString(value.type)
buffer.writeNullable(value.message) { buffer.writeString(it) }
buffer.writeList(value.stacktrace) { v -> RdTestSessionStackTraceElement.write(ctx, buffer, v) }
@@ -795,7 +801,7 @@ data class RdTestSessionExceptionCause (
if (this === other) return true
if (other == null || other::class != this::class) return false
other as RdTestSessionExceptionCause
other as RdTestSessionLightException
if (type != other.type) return false
if (message != other.message) return false
@@ -813,7 +819,7 @@ data class RdTestSessionExceptionCause (
}
//pretty print
override fun print(printer: PrettyPrinter) {
printer.println("RdTestSessionExceptionCause (")
printer.println("RdTestSessionLightException (")
printer.indent {
print("type = "); type.print(printer); println()
print("message = "); message.print(printer); println()
@@ -40,7 +40,7 @@ object DistributedTestModel : Ext(TestRoot) {
field("lineNumber", int)
}
private val RdTestSessionExceptionCause = structdef {
private val RdTestSessionLightException = structdef {
field("type", string)
field("message", string.nullable)
field("stacktrace", immutableList(RdTestSessionStackTraceElement))
@@ -51,7 +51,8 @@ object DistributedTestModel : Ext(TestRoot) {
field("originalType", string.nullable)
field("message", string.nullable)
field("stacktrace", immutableList(RdTestSessionStackTraceElement))
field("cause", RdTestSessionExceptionCause.nullable)
field("cause", RdTestSessionLightException.nullable)
field("suppressedExceptions", immutableList(RdTestSessionLightException).nullable)
}
@@ -5,7 +5,7 @@ import com.intellij.openapi.diagnostic.Logger
import com.intellij.openapi.diagnostic.logger
import com.intellij.remoteDev.tests.modelGenerated.RdTestSession
import com.intellij.remoteDev.tests.modelGenerated.RdTestSessionException
import com.intellij.remoteDev.tests.modelGenerated.RdTestSessionExceptionCause
import com.intellij.remoteDev.tests.modelGenerated.RdTestSessionLightException
import com.intellij.remoteDev.tests.modelGenerated.RdTestSessionStackTraceElement
open class AgentTestLogger(logger: Logger, private val factory: AgentTestLoggerFactory) : DelegatingLogger<Logger>(logger) {
@@ -27,8 +27,9 @@ open class AgentTestLogger(logger: Logger, private val factory: AgentTestLoggerF
val rdtseType = getRdtseType(t)
val rdtseStackTrace = getRdtseStackTrace(t?.stackTrace)
val rdtseCause = getRdtseCause(t)
val rdtseSuppressedExceptions = getRdtseSuppressedExceptions(t)
val rdTestSessionException = RdTestSessionException(type = rdtseType, originalType = null, message = rdtseMessage,
stacktrace = rdtseStackTrace, cause = rdtseCause)
stacktrace = rdtseStackTrace, cause = rdtseCause, suppressedExceptions = rdtseSuppressedExceptions)
info("Fired ex to the test runner ${rdTestSessionException.message}")
@@ -39,7 +40,7 @@ open class AgentTestLogger(logger: Logger, private val factory: AgentTestLoggerF
stackTrace?.map { RdTestSessionStackTraceElement(it.className, it.methodName, it.fileName.orEmpty(), it.lineNumber) }
?: emptyList()
protected fun getRdtseMessage(message: String?, t: Throwable?) =
protected fun getRdtseMessage(message: String?, t: Throwable?): String =
when (message) {
t?.message ->
message ?: "There was an error of type ${t?.javaClass?.name}"
@@ -47,10 +48,14 @@ open class AgentTestLogger(logger: Logger, private val factory: AgentTestLoggerF
listOf(message, t?.message).filter { !it?.trim().isNullOrEmpty() }.joinToString(": ")
}
protected fun getRdtseType(t: Throwable?) = t?.javaClass?.typeName ?: "<LOG_ERROR>"
protected fun getRdtseCause(t: Throwable?) =
protected fun getRdtseType(t: Throwable?): String = t?.javaClass?.typeName ?: "<LOG_ERROR>"
protected fun getRdtseCause(t: Throwable?): RdTestSessionLightException? =
t?.cause?.let { cause ->
RdTestSessionExceptionCause(cause.javaClass.typeName, cause.message, getRdtseStackTrace(cause.stackTrace))
RdTestSessionLightException(cause.javaClass.typeName, cause.message, getRdtseStackTrace(cause.stackTrace))
}
protected fun getRdtseSuppressedExceptions(t: Throwable?): List<RdTestSessionLightException>? =
t?.suppressedExceptions?.map { suppressedException ->
RdTestSessionLightException(suppressedException.javaClass.typeName, suppressedException.message, stacktrace = getRdtseStackTrace(suppressedException.stackTrace))
}
}