AT-4097: testFramework [rdct-tests]: do not cut report message for diogen processing

while trying to keep test names on TC unchanged

(cherry picked from commit d269d3a79080d9d381b3b6e85da290f4828a5fe5)


(cherry picked from commit 3e06dc913b568671ed7d327d3501e3e9a63c2ae3)

IJ-MR-192896

GitOrigin-RevId: 808dc4ebf63df2cdb772123eb5dd6967a2793df7
This commit is contained in:
Anastasia Katsman
2026-02-18 23:39:09 +01:00
committed by intellij-monorepo-bot
parent dbf6ff4b39
commit b7efdcfad7
3 changed files with 55 additions and 39 deletions

View File

@@ -61,7 +61,7 @@ class DistributedTestModel private constructor(
private val __RdTestSessionNullableSerializer = RdTestSession.nullable()
const val serializationHash = 217769322142192170L
const val serializationHash = -8620132101972150534L
}
override val serializersOwner: ISerializersOwner get() = DistributedTestModel
@@ -935,8 +935,10 @@ class RdTestSession private constructor(
*/
data class RdTestSessionException (
val type: String,
val messageWithStacktrace: String,
val message: String?,
val messageWithDetails: String,
val messageForTestHistoryConsistency: String,
val messageForDiogen: String?,
val printToStringForDiogen: String,
val stacktrace: List<RdTestSessionStackTraceElement>,
val cause: RdTestSessionLightException?,
val suppressedExceptions: List<RdTestSessionLightException>?
@@ -944,8 +946,10 @@ data class RdTestSessionException (
//write-marshaller
private fun write(ctx: SerializationCtx, buffer: AbstractBuffer) {
buffer.writeString(type)
buffer.writeString(messageWithStacktrace)
buffer.writeNullable(message) { buffer.writeString(it) }
buffer.writeString(messageWithDetails)
buffer.writeString(messageForTestHistoryConsistency)
buffer.writeNullable(messageForDiogen) { buffer.writeString(it) }
buffer.writeString(printToStringForDiogen)
buffer.writeList(stacktrace) { v -> RdTestSessionStackTraceElement.write(ctx, buffer, v) }
buffer.writeNullable(cause) { RdTestSessionLightException.write(ctx, buffer, it) }
buffer.writeNullable(suppressedExceptions) { buffer.writeList(it) { v -> RdTestSessionLightException.write(ctx, buffer, v) } }
@@ -959,12 +963,14 @@ data class RdTestSessionException (
@Suppress("UNCHECKED_CAST")
override fun read(ctx: SerializationCtx, buffer: AbstractBuffer): RdTestSessionException {
val type = buffer.readString()
val messageWithStacktrace = buffer.readString()
val message = buffer.readNullable { buffer.readString() }
val messageWithDetails = buffer.readString()
val messageForTestHistoryConsistency = buffer.readString()
val messageForDiogen = buffer.readNullable { buffer.readString() }
val printToStringForDiogen = buffer.readString()
val stacktrace = buffer.readList { RdTestSessionStackTraceElement.read(ctx, buffer) }
val cause = buffer.readNullable { RdTestSessionLightException.read(ctx, buffer) }
val suppressedExceptions = buffer.readNullable { buffer.readList { RdTestSessionLightException.read(ctx, buffer) } }
return RdTestSessionException(type, messageWithStacktrace, message, stacktrace, cause, suppressedExceptions)
return RdTestSessionException(type, messageWithDetails, messageForTestHistoryConsistency, messageForDiogen, printToStringForDiogen, stacktrace, cause, suppressedExceptions)
}
override fun write(ctx: SerializationCtx, buffer: AbstractBuffer, value: RdTestSessionException) {
@@ -985,8 +991,10 @@ data class RdTestSessionException (
other as RdTestSessionException
if (type != other.type) return false
if (messageWithStacktrace != other.messageWithStacktrace) return false
if (message != other.message) return false
if (messageWithDetails != other.messageWithDetails) return false
if (messageForTestHistoryConsistency != other.messageForTestHistoryConsistency) return false
if (messageForDiogen != other.messageForDiogen) return false
if (printToStringForDiogen != other.printToStringForDiogen) return false
if (stacktrace != other.stacktrace) return false
if (cause != other.cause) return false
if (suppressedExceptions != other.suppressedExceptions) return false
@@ -997,8 +1005,10 @@ data class RdTestSessionException (
override fun hashCode(): Int {
var __r = 0
__r = __r*31 + type.hashCode()
__r = __r*31 + messageWithStacktrace.hashCode()
__r = __r*31 + if (message != null) message.hashCode() else 0
__r = __r*31 + messageWithDetails.hashCode()
__r = __r*31 + messageForTestHistoryConsistency.hashCode()
__r = __r*31 + if (messageForDiogen != null) messageForDiogen.hashCode() else 0
__r = __r*31 + printToStringForDiogen.hashCode()
__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
@@ -1009,8 +1019,10 @@ data class RdTestSessionException (
printer.println("RdTestSessionException (")
printer.indent {
print("type = "); type.print(printer); println()
print("messageWithStacktrace = "); messageWithStacktrace.print(printer); println()
print("message = "); message.print(printer); println()
print("messageWithDetails = "); messageWithDetails.print(printer); println()
print("messageForTestHistoryConsistency = "); messageForTestHistoryConsistency.print(printer); println()
print("messageForDiogen = "); messageForDiogen.print(printer); println()
print("printToStringForDiogen = "); printToStringForDiogen.print(printer); println()
print("stacktrace = "); stacktrace.print(printer); println()
print("cause = "); cause.print(printer); println()
print("suppressedExceptions = "); suppressedExceptions.print(printer); println()

View File

@@ -63,8 +63,10 @@ object DistributedTestModel : Ext(TestRoot) {
private val RdTestSessionException = structdef {
field("type", string)
field("messageWithStacktrace", string)
field("message", string.nullable)
field("messageWithDetails", string)
field("messageForTestHistoryConsistency", string)
field("messageForDiogen", string.nullable)
field("printToStringForDiogen", string)
field("stacktrace", immutableList(RdTestSessionStackTraceElement))
field("cause", RdTestSessionLightException.nullable)
field("suppressedExceptions", immutableList(RdTestSessionLightException).nullable)

View File

@@ -3,7 +3,6 @@ package com.intellij.remoteDev.tests.impl
import com.intellij.openapi.diagnostic.DelegatingLogger
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.RdTestSessionLightException
import com.intellij.remoteDev.tests.modelGenerated.RdTestSessionStackTraceElement
@@ -12,32 +11,34 @@ import com.jetbrains.rd.util.string.printToString
open class AgentTestLogger(logger: Logger, private val factory: AgentTestLoggerFactory) : DelegatingLogger<Logger>(logger) {
override fun error(message: String?, t: Throwable?, vararg details: String) {
super.error(message, t, *details)
val messageToTheTestRunner =
if (details.isNotEmpty()) message + "\n Details: \n" + details.joinToString("\n")
else message
factory.testSession.get()
?.let {
sendToTestRunner(it, messageToTheTestRunner, t)
}
?: logger<AgentTestLogger>().warn("Couldn't send exception to the test session: '${message}'.")
}
protected open fun sendToTestRunner(session: RdTestSession, message: String?, t: Throwable?) {
val rdtseMessage: String = getRdtseMessage(message, t)
val rdtseType = getRdtseType(t)
val testSession = factory.testSession.get()
if (testSession == null) {
logger<AgentTestLogger>().warn("Couldn't send exception to the test session: '${message}'.")
return
}
val rdtseType = t?.javaClass?.typeName ?: "<LOG_ERROR>"
val rdtseStackTrace = getRdtseStackTrace(t?.stackTrace)
val rdtseCause = getRdtseCause(t)
val rdtseSuppressedExceptions = getRdtseSuppressedExceptions(t)
val rdTestSessionException = RdTestSessionException(type = rdtseType, messageWithStacktrace = t?.printToString() ?: "", message = rdtseMessage,
stacktrace = rdtseStackTrace, cause = rdtseCause, suppressedExceptions = rdtseSuppressedExceptions)
val details = if (details.isNotEmpty()) "Details: \n" + details.joinToString("\n") else null
val rdTestSessionException = RdTestSessionException(type = rdtseType,
messageForDiogen = message,
messageForTestHistoryConsistency = getRdtseMessage(message, t),
printToStringForDiogen = (t ?: Exception(message)).printToString(),
messageWithDetails = listOfNotNull(message,
details,
t?.printToString()).joinToString("\n"),
stacktrace = rdtseStackTrace,
cause = rdtseCause,
suppressedExceptions = rdtseSuppressedExceptions)
info("Fired ex to the test runner ${rdTestSessionException.message}")
info("Fired ex to the test runner ${rdTestSessionException}")
session.sendException.fire(rdTestSessionException)
testSession.sendException.fire(rdTestSessionException)
}
protected fun getRdtseStackTrace(stackTrace: Array<StackTraceElement>?): List<RdTestSessionStackTraceElement> =
private fun getRdtseStackTrace(stackTrace: Array<StackTraceElement>?): List<RdTestSessionStackTraceElement> =
stackTrace?.map { RdTestSessionStackTraceElement(it.className, it.methodName, it.fileName.orEmpty(), it.lineNumber) }
?: emptyList()
@@ -49,14 +50,15 @@ open class AgentTestLogger(logger: Logger, private val factory: AgentTestLoggerF
listOf(message, t?.message).filter { !it?.trim().isNullOrEmpty() }.joinToString(": ")
}
protected fun getRdtseType(t: Throwable?): String = t?.javaClass?.typeName ?: "<LOG_ERROR>"
protected fun getRdtseCause(t: Throwable?): RdTestSessionLightException? =
private fun getRdtseCause(t: Throwable?): RdTestSessionLightException? =
t?.cause?.let { cause ->
RdTestSessionLightException(cause.javaClass.typeName, cause.message, getRdtseStackTrace(cause.stackTrace))
}
protected fun getRdtseSuppressedExceptions(t: Throwable?): List<RdTestSessionLightException>? =
private fun getRdtseSuppressedExceptions(t: Throwable?): List<RdTestSessionLightException>? =
t?.suppressedExceptions?.map { suppressedException ->
RdTestSessionLightException(suppressedException.javaClass.typeName, suppressedException.message, stacktrace = getRdtseStackTrace(suppressedException.stackTrace))
RdTestSessionLightException(suppressedException.javaClass.typeName,
suppressedException.message,
stacktrace = getRdtseStackTrace(suppressedException.stackTrace))
}
}