diff --git a/jvm/core/src/main/scala/org/scalatest/events/Event.scala b/jvm/core/src/main/scala/org/scalatest/events/Event.scala
index 32c5b50540..5a658bff04 100644
--- a/jvm/core/src/main/scala/org/scalatest/events/Event.scala
+++ b/jvm/core/src/main/scala/org/scalatest/events/Event.scala
@@ -22,9 +22,6 @@ import java.io.PrintWriter
import java.io.StringWriter
import java.io.NotSerializableException
import java.util.Date
-// SKIP-SCALATESTJS,NATIVE-START
-import scala.xml.Elem
-// SKIP-SCALATESTJS,NATIVE-END
import exceptions.StackDepthException
import exceptions.NotSerializableWrapperException
@@ -84,124 +81,6 @@ sealed abstract class Event extends Ordered[Event] with Product with Serializabl
private [scalatest] def toJson: String
- // SKIP-SCALATESTJS,NATIVE-START
- private [scalatest] def toXml: Elem
-
- private[events] object EventXmlHelper {
- def stringOption(strOption: Option[String]) = strOption.getOrElse("")
- def longOption(longOption: Option[Long]) = if (longOption.isDefined) longOption.get.toString else ""
- def booleanOption(booleanOption: Option[Boolean]) = if (booleanOption.isDefined) booleanOption.get.toString else ""
- def formatterOption(formatterOption: Option[Formatter]) = {
- formatterOption match {
- case Some(formatter) =>
- formatter match {
- case MotionToSuppress =>
-
- case indentedText: IndentedText =>
-
- { indentedText.formattedText }
- { indentedText.rawText }
- { indentedText.indentationLevel }
-
- }
- case None => ""
- }
- }
- def locationOption(locationOption: Option[Location]) = {
- locationOption match {
- case Some(location) =>
- location match {
- case topOfClass: TopOfClass =>
-
- { topOfClass.className }
-
- case topOfMethod: TopOfMethod =>
-
- { topOfMethod.className }
- { topOfMethod.methodId }
-
- case lineInFile: LineInFile =>
-
- { lineInFile.lineNumber }
- { lineInFile.fileName }
- { filePathnameOption(lineInFile.filePathname) }
-
- case SeeStackDepthException =>
-
- case _ =>
- ""
- }
- case None => ""
- }
- }
- def filePathnameOption(filePathnameOpt: Option[String]) = {
- filePathnameOpt match {
- case Some(filePathname) => filePathname
- case None => ""
- }
- }
- def getThrowableStackDepth(throwable: Throwable) = {
- throwable match {
- case sde: StackDepthException => sde.failedCodeStackDepth
- case _ => -1
- }
- }
- def throwableOption(throwableOption: Option[Throwable]) = {
- throwableOption match {
- case Some(throwable) =>
- { throwable.getMessage }
- { getThrowableStackDepth(throwable) }
-
- {
- val stackTraces = throwable.getStackTrace
- for (stackTrace <- stackTraces) yield {
-
- { stackTrace.getClassName }
- { stackTrace.getMethodName }
- { stackTrace.getFileName }
- { stackTrace.getLineNumber }
- { stackTrace.isNativeMethod }
- { stackTrace.toString }
-
- }
- /*val stringWriter = new StringWriter()
- val writer = new PrintWriter(new BufferedWriter(stringWriter))
- throwable.printStackTrace(writer)
- writer.flush()
- stringWriter.toString*/
- }
-
- case None => ""
- }
- }
- def summaryOption(summaryOption: Option[Summary]) = {
- summaryOption match {
- case Some(summary) =>
- { summary.testsSucceededCount }
- { summary.testsFailedCount }
- { summary.testsIgnoredCount }
- { summary.testsPendingCount }
- { summary.testsCanceledCount }
- { summary.suitesCompletedCount }
- { summary.suitesAbortedCount }
- { summary.scopesPendingCount }
- case None => ""
- }
- }
- def nameInfoOption(nameInfoOption: Option[NameInfo]) = {
- nameInfoOption match {
- case Some(nameInfo) =>
- { nameInfo.suiteName }
- { nameInfo.suiteId }
- { stringOption(nameInfo.suiteClassName) }
- { stringOption(nameInfo.testName) }
- case None =>
- ""
- }
- }
- }
- // SKIP-SCALATESTJS,NATIVE-END
-
private[events] object EventJsonHelper {
def getThrowableStackDepth(throwable: Throwable) = {
@@ -413,27 +292,6 @@ final case class TestStarting (
payload,
threadName)
- // SKIP-SCALATESTJS,NATIVE-START
- private [scalatest] def toXml = {
- import EventXmlHelper._
-
-
- { ordinal.runStamp }
-
- { suiteName }
- { suiteId }
- { stringOption(suiteClassName) }
- { testName }
- { testText }
- { formatterOption(formatter) }
- { locationOption(location) }
- { stringOption(rerunner) }
- { threadName }
- { timeStamp }
-
- }
- // SKIP-SCALATESTJS,NATIVE-END
-
private[scalatest] def toJson: String = {
import EventJsonHelper._
s"""{ "eventType": "TestStarting", "ordinal": ${ordinal.runStamp}, "suiteName": ${string(suiteName)}, "suiteId": ${string(suiteId)}, "suiteClassName": ${stringOption(suiteClassName)}, "testName": ${string(testName)}, "testText": ${string(testText)}, "formatter": ${formatterOption(formatter)}, "location": ${locationOption(location)}, "rerunner": ${stringOption(rerunner)}, "threadName": ${string(threadName)}, "timeStamp": ${timeStamp} }""".stripMargin
@@ -520,29 +378,6 @@ final case class TestSucceeded (
payload,
threadName)
- // SKIP-SCALATESTJS,NATIVE-START
- private [scalatest] def toXml = {
- import EventXmlHelper._
-
-
- { ordinal.runStamp }
-
- { suiteName }
- { suiteId }
- { stringOption(suiteClassName) }
- { longOption(duration) }
- { testName }
- { testText }
- { recordedEvents.map(_.toXml) }
- { formatterOption(formatter) }
- { locationOption(location) }
- { stringOption(rerunner) }
- { threadName }
- { timeStamp }
-
- }
- // SKIP-SCALATESTJS,NATIVE-END
-
private[scalatest] def toJson: String = {
import EventJsonHelper._
s"""{ "eventType": "TestSucceeded", "ordinal": ${ordinal.runStamp}, "suiteName": ${string(suiteName)}, "suiteId": ${string(suiteId)}, "suiteClassName": ${stringOption(suiteClassName)}, "duration": ${duration.getOrElse("null")}, "testName": ${string(testName)}, "testText": ${string(testText)}, "recordedEvents" : [${recordedEvents.map(_.toJson).mkString(", ")}], "formatter": ${formatterOption(formatter)}, "location": ${locationOption(location)}, "rerunner": ${stringOption(rerunner)}, "threadName": ${string(threadName)}, "timeStamp": ${timeStamp} }""".stripMargin
@@ -637,32 +472,6 @@ final case class TestFailed (
payload,
threadName)
- // SKIP-SCALATESTJS,NATIVE-START
- private [scalatest] def toXml = {
- import EventXmlHelper._
-
-
- { ordinal.runStamp }
-
- { message }
- { suiteName }
- { suiteId }
- { stringOption(suiteClassName) }
- { longOption(duration) }
- { testName }
- { testText }
- { recordedEvents.map(_.toXml) }
- analysis.map(a => a)
- { throwableOption(throwable) }
- { formatterOption(formatter) }
- { locationOption(location) }
- { stringOption(rerunner) }
- { threadName }
- { timeStamp }
-
- }
- // SKIP-SCALATESTJS,NATIVE-END
-
private[scalatest] def toJson: String = {
import EventJsonHelper._
s"""{ "eventType": "TestFailed", "ordinal": ${ordinal.runStamp}, "message": ${string(message)}, "suiteName": ${string(suiteName)}, "suiteId": ${string(suiteId)}, "suiteClassName": ${stringOption(suiteClassName)}, "duration": ${duration.getOrElse("null")}, "testName": ${string(testName)}, "testText": ${string(testText)}, "recordedEvents" : [${recordedEvents.map(_.toJson).mkString(", ")}], "throwable": ${throwableOption(throwable)}, "formatter": ${formatterOption(formatter)}, "location": ${locationOption(location)}, "rerunner": ${stringOption(rerunner)}, "threadName": ${string(threadName)}, "timeStamp": ${timeStamp} }""".stripMargin
@@ -745,26 +554,6 @@ final case class TestIgnored (
payload,
threadName)
- // SKIP-SCALATESTJS,NATIVE-START
- private [scalatest] def toXml = {
- import EventXmlHelper._
-
-
- { ordinal.runStamp }
-
- { suiteName }
- { suiteId }
- { stringOption(suiteClassName) }
- { testName }
- { testText }
- { formatterOption(formatter) }
- { locationOption(location) }
- { threadName }
- { timeStamp }
-
- }
- // SKIP-SCALATESTJS,NATIVE-END
-
private[scalatest] def toJson: String = {
import EventJsonHelper._
s"""{ "eventType": "TestIgnored", "ordinal": ${ordinal.runStamp}, "suiteName": ${string(suiteName)}, "suiteId": ${string(suiteId)}, "suiteClassName": ${stringOption(suiteClassName)}, "testName": ${string(testName)}, "testText": ${string(testText)}, "formatter": ${formatterOption(formatter)}, "location": ${locationOption(location)}, "threadName": ${string(threadName)}, "timeStamp": ${timeStamp} }""".stripMargin
@@ -841,28 +630,6 @@ final case class TestPending (
payload,
threadName)
- // SKIP-SCALATESTJS,NATIVE-START
- private [scalatest] def toXml = {
- import EventXmlHelper._
-
-
- { ordinal.runStamp }
-
- { suiteName }
- { suiteId }
- { stringOption(suiteClassName) }
- { longOption(duration) }
- { testName }
- { testText }
- { recordedEvents.map(_.toXml) }
- { formatterOption(formatter) }
- { locationOption(location) }
- { threadName }
- { timeStamp }
-
- }
- // SKIP-SCALATESTJS,NATIVE-END
-
private[scalatest] def toJson: String = {
import EventJsonHelper._
s"""{ "eventType": "TestPending", "ordinal": ${ordinal.runStamp}, "suiteName": ${string(suiteName)}, "suiteId": ${string(suiteId)}, "suiteClassName": ${stringOption(suiteClassName)}, "duration": ${duration.getOrElse("null")}, "testName": ${string(testName)}, "testText": ${string(testText)}, "recordedEvents" : [${recordedEvents.map(_.toJson).mkString(", ")}], "formatter": ${formatterOption(formatter)}, "location": ${locationOption(location)}, "threadName": ${string(threadName)}, "timeStamp": ${timeStamp} }""".stripMargin
@@ -950,31 +717,6 @@ final case class TestCanceled (
payload,
threadName)
- // SKIP-SCALATESTJS,NATIVE-START
- private [scalatest] def toXml = {
- import EventXmlHelper._
-
-
- { ordinal.runStamp }
-
- { message }
- { suiteName }
- { suiteId }
- { stringOption(suiteClassName) }
- { longOption(duration) }
- { testName }
- { testText }
- { recordedEvents.map(_.toXml) }
- { throwableOption(throwable) }
- { formatterOption(formatter) }
- { locationOption(location) }
- { stringOption(rerunner) }
- { threadName }
- { timeStamp }
-
- }
- // SKIP-SCALATESTJS,NATIVE-END
-
private[scalatest] def toJson: String = {
import EventJsonHelper._
s"""{ "eventType": "TestCanceled", "ordinal": ${ordinal.runStamp}, "message": ${string(message)}, "suiteName": ${string(suiteName)}, "suiteId": ${string(suiteId)}, "suiteClassName": ${stringOption(suiteClassName)}, "duration": ${duration.getOrElse("null")}, "testName": ${string(testName)}, "testText": ${string(testText)}, "recordedEvents" : [${recordedEvents.map(_.toJson).mkString(", ")}], "throwable": ${throwableOption(throwable)}, "formatter": ${formatterOption(formatter)}, "location": ${locationOption(location)}, "rerunner": ${stringOption(rerunner)}, "threadName": ${string(threadName)}, "timeStamp": ${timeStamp} }""".stripMargin
@@ -1054,25 +796,6 @@ final case class SuiteStarting (
payload,
threadName)
- // SKIP-SCALATESTJS,NATIVE-START
- private [scalatest] def toXml = {
- import EventXmlHelper._
-
-
- { ordinal.runStamp }
-
- { suiteName }
- { suiteId }
- { stringOption(suiteClassName) }
- { formatterOption(formatter) }
- { locationOption(location) }
- { stringOption(rerunner) }
- { threadName }
- { timeStamp }
-
- }
- // SKIP-SCALATESTJS,NATIVE-END
-
private[scalatest] def toJson: String = {
import EventJsonHelper._
s"""{ "eventType": "SuiteStarting", "ordinal": ${ordinal.runStamp}, "suiteName": ${string(suiteName)}, "suiteId": ${string(suiteId)}, "suiteClassName": ${stringOption(suiteClassName)}, "formatter": ${formatterOption(formatter)}, "location": ${locationOption(location)}, "rerunner": ${stringOption(rerunner)}, "threadName": ${string(threadName)}, "timeStamp": ${timeStamp} }""".stripMargin
@@ -1151,26 +874,6 @@ final case class SuiteCompleted (
payload,
threadName)
- // SKIP-SCALATESTJS,NATIVE-START
- private [scalatest] def toXml = {
- import EventXmlHelper._
-
-
- { ordinal.runStamp }
-
- { suiteName }
- { suiteId }
- { stringOption(suiteClassName) }
- { longOption(duration) }
- { formatterOption(formatter) }
- { locationOption(location) }
- { stringOption(rerunner) }
- { threadName }
- { timeStamp }
-
- }
- // SKIP-SCALATESTJS,NATIVE-END
-
private[scalatest] def toJson: String = {
import EventJsonHelper._
s"""{ "eventType": "SuiteCompleted", "ordinal": ${ordinal.runStamp}, "suiteName": ${string(suiteName)}, "suiteId": ${string(suiteId)}, "suiteClassName": ${stringOption(suiteClassName)}, "duration": ${duration.getOrElse("null")}, "formatter": ${formatterOption(formatter)}, "location": ${locationOption(location)}, "rerunner": ${stringOption(rerunner)}, "threadName": ${string(threadName)}, "timeStamp": ${timeStamp} }""".stripMargin
@@ -1258,28 +961,6 @@ final case class SuiteAborted (
payload,
threadName)
- // SKIP-SCALATESTJS,NATIVE-START
- private [scalatest] def toXml = {
- import EventXmlHelper._
-
-
- { ordinal.runStamp }
-
- { message }
- { suiteName }
- { suiteId }
- { stringOption(suiteClassName) }
- { longOption(duration) }
- { throwableOption(throwable) }
- { formatterOption(formatter) }
- { locationOption(location) }
- { stringOption(rerunner) }
- { threadName }
- { timeStamp }
-
- }
- // SKIP-SCALATESTJS,NATIVE-END
-
private[scalatest] def toJson: String = {
import EventJsonHelper._
s"""{ "eventType": "SuiteAborted", "ordinal": ${ordinal.runStamp}, "message": ${string(message)}, "suiteName": ${string(suiteName)}, "suiteId": ${string(suiteId)}, "suiteClassName": ${stringOption(suiteClassName)}, "duration": ${duration.getOrElse("null")}, "throwable": ${throwableOption(throwable)}, "formatter": ${formatterOption(formatter)}, "location": ${locationOption(location)}, "rerunner": ${stringOption(rerunner)}, "threadName": ${string(threadName)}, "timeStamp": ${timeStamp} }""".stripMargin
@@ -1348,31 +1029,6 @@ final case class RunStarting (
if (testCount < 0)
throw new IllegalArgumentException("testCount was less than zero: " + testCount)
- // SKIP-SCALATESTJS,NATIVE-START
- import EventXmlHelper._
- private [scalatest] def toXml =
-
-
- { ordinal.runStamp }
-
- { testCount }
-
- {
- for ((key, value) <- configMap) yield {
-
- { key }
- { value }
-
- }
- }
-
- { formatterOption(formatter) }
- { locationOption(location) }
- { threadName }
- { timeStamp }
-
- // SKIP-SCALATESTJS,NATIVE-END
-
private[scalatest] def toJson: String = {
import EventJsonHelper._
s"""{ "eventType": "RunStarting", "ordinal": ${ordinal.runStamp}, "testCount": ${testCount}, "configMap": { ${configMap.map(e => string(e._1) + ": " + string(e._2.toString)).mkString(", ")} }, "formatter": ${formatterOption(formatter)}, "location": ${locationOption(location)}, "threadName": ${string(threadName)}, "timeStamp": ${timeStamp} }""".stripMargin
@@ -1448,22 +1104,6 @@ final case class RunCompleted (
payload,
threadName)
- // SKIP-SCALATESTJS,NATIVE-START
- import EventXmlHelper._
- private [scalatest] def toXml =
-
-
- { ordinal.runStamp }
-
- { longOption(duration) }
- { summaryOption(summary) }
- { formatterOption(formatter) }
- { locationOption(location) }
- { threadName }
- { timeStamp }
-
- // SKIP-SCALATESTJS,NATIVE-END
-
private[scalatest] def toJson: String = {
import EventJsonHelper._
s"""{ "eventType": "RunCompleted", "ordinal": ${ordinal.runStamp}, "duration": ${duration.getOrElse(0L)}, "summary": ${summaryOption(summary)}, "formatter": ${formatterOption(formatter)}, "location": ${locationOption(location)}, "threadName": ${string(threadName)}, "timeStamp": ${timeStamp} }""".stripMargin
@@ -1540,22 +1180,6 @@ final case class RunStopped (
payload,
threadName)
- // SKIP-SCALATESTJS,NATIVE-START
- import EventXmlHelper._
- private [scalatest] def toXml =
-
-
- { ordinal.runStamp }
-
- { longOption(duration) }
- { summaryOption(summary) }
- { formatterOption(formatter) }
- { locationOption(location) }
- { threadName }
- { timeStamp }
-
- // SKIP-SCALATESTJS,NATIVE-END
-
private[scalatest] def toJson: String = {
import EventJsonHelper._
s"""{ "eventType": "RunStopped", "ordinal": ${ordinal.runStamp}, "duration": ${duration.getOrElse(0L)}, "summary": ${summaryOption(summary)}, "formatter": ${formatterOption(formatter)}, "location": ${locationOption(location)}, "threadName": ${string(threadName)}, "timeStamp": ${timeStamp} }""".stripMargin
@@ -1629,24 +1253,6 @@ final case class RunAborted (
payload,
threadName)
- // SKIP-SCALATESTJS,NATIVE-START
- import EventXmlHelper._
- private [scalatest] def toXml =
-
-
- { ordinal.runStamp }
-
- { message }
- { throwableOption(throwable) }
- { longOption(duration) }
- { summaryOption(summary) }
- { formatterOption(formatter) }
- { locationOption(location) }
- { threadName }
- { timeStamp }
-
- // SKIP-SCALATESTJS,NATIVE-END
-
private[scalatest] def toJson: String = {
import EventJsonHelper._
s"""{ "eventType": "RunAborted", "ordinal": ${ordinal.runStamp}, "message": ${string(message)}, "throwable": ${throwableOption(throwable)}, "duration": ${duration.getOrElse(0L)}, "summary": ${summaryOption(summary)}, "formatter": ${formatterOption(formatter)}, "location": ${locationOption(location)}, "threadName": ${string(threadName)}, "timeStamp": ${timeStamp} }""".stripMargin
@@ -1719,24 +1325,6 @@ final case class InfoProvided (
payload,
threadName)
- // SKIP-SCALATESTJS,NATIVE-START
- private [scalatest] def toXml = {
- import EventXmlHelper._
-
-
- { ordinal.runStamp }
-
- { message }
- { nameInfoOption(nameInfo) }
- { throwableOption(throwable) }
- { formatterOption(formatter) }
- { locationOption(location) }
- { threadName }
- { timeStamp }
-
- }
- // SKIP-SCALATESTJS,NATIVE-END
-
private[scalatest] def toJson: String = {
import EventJsonHelper._
s"""{ "eventType": "InfoProvided", "ordinal": ${ordinal.runStamp}, "message": ${string(message)}, "nameInfo": ${nameInfoOption(nameInfo)}, "throwable": ${throwableOption(throwable)}, "formatter": ${formatterOption(formatter)}, "location": ${locationOption(location)}, "threadName": ${string(threadName)}, "timeStamp": ${timeStamp} }""".stripMargin
@@ -1819,23 +1407,6 @@ final case class AlertProvided (
payload,
threadName)
- // SKIP-SCALATESTJS,NATIVE-START
- import EventXmlHelper._
- private [scalatest] def toXml =
-
-
- { ordinal.runStamp }
-
- { message }
- { nameInfoOption(nameInfo) }
- { throwableOption(throwable) }
- { formatterOption(formatter) }
- { locationOption(location) }
- { threadName }
- { timeStamp }
-
- // SKIP-SCALATESTJS,NATIVE-END
-
private[scalatest] def toJson: String = {
import EventJsonHelper._
s"""{ "eventType": "AlertProvided", "ordinal": ${ordinal.runStamp}, "message": ${string(message)}, "nameInfo": ${nameInfoOption(nameInfo)}, "throwable": ${throwableOption(throwable)}, "formatter": ${formatterOption(formatter)}, "location": ${locationOption(location)}, "threadName": ${string(threadName)}, "timeStamp": ${timeStamp} }""".stripMargin
@@ -1918,23 +1489,6 @@ final case class NoteProvided (
payload,
threadName)
- // SKIP-SCALATESTJS,NATIVE-START
- import EventXmlHelper._
- private [scalatest] def toXml =
-
-
- { ordinal.runStamp }
-
- { message }
- { nameInfoOption(nameInfo) }
- { throwableOption(throwable) }
- { formatterOption(formatter) }
- { locationOption(location) }
- { threadName }
- { timeStamp }
-
- // SKIP-SCALATESTJS,NATIVE-END
-
private[scalatest] def toJson: String = {
import EventJsonHelper._
s"""{ "eventType": "NoteProvided", "ordinal": ${ordinal.runStamp}, "message": ${string(message)}, "nameInfo": ${nameInfoOption(nameInfo)}, "throwable": ${throwableOption(throwable)}, "formatter": ${formatterOption(formatter)}, "location": ${locationOption(location)}, "threadName": ${string(threadName)}, "timeStamp": ${timeStamp} }""".stripMargin
@@ -2003,22 +1557,6 @@ final case class MarkupProvided (
payload,
threadName)
- // SKIP-SCALATESTJS,NATIVE-START
- import EventXmlHelper._
- private [scalatest] def toXml =
-
-
- { ordinal.runStamp }
-
- { text }
- { nameInfoOption(nameInfo) }
- { formatterOption(formatter) }
- { locationOption(location) }
- { threadName }
- { timeStamp }
-
- // SKIP-SCALATESTJS,NATIVE-END
-
private[scalatest] def toJson: String = {
import EventJsonHelper._
s"""{ "eventType": "MarkupProvided", "ordinal": ${ordinal.runStamp}, "text": ${string(text)}, "nameInfo": ${nameInfoOption(nameInfo)}, "formatter": ${formatterOption(formatter)}, "location": ${locationOption(location)}, "threadName": ${string(threadName)}, "timeStamp": ${timeStamp} }""".stripMargin
@@ -2080,23 +1618,6 @@ final case class ScopeOpened (
payload,
threadName)
- // SKIP-SCALATESTJS,NATIVE-START
- private [scalatest] def toXml = {
- import EventXmlHelper._
-
-
- { ordinal.runStamp }
-
- { message }
- { nameInfoOption(if (nameInfo != null) Some(nameInfo) else None) }
- { formatterOption(formatter) }
- { locationOption(location) }
- { threadName }
- { timeStamp }
-
- }
- // SKIP-SCALATESTJS,NATIVE-END
-
private[scalatest] def toJson: String = {
import EventJsonHelper._
s"""{ "eventType": "ScopeOpened", "ordinal": ${ordinal.runStamp}, "message": ${string(message)}, "nameInfo": ${nmInfo(nameInfo)}, "formatter": ${formatterOption(formatter)}, "location": ${locationOption(location)}, "threadName": ${string(threadName)}, "timeStamp": ${timeStamp} }""".stripMargin
@@ -2158,22 +1679,6 @@ final case class ScopeClosed (
payload,
threadName)
- // SKIP-SCALATESTJS,NATIVE-START
- import EventXmlHelper._
- private [scalatest] def toXml =
-
-
- { ordinal.runStamp }
-
- { message }
- { nameInfoOption(if (nameInfo != null) Some(nameInfo) else None) }
- { formatterOption(formatter) }
- { locationOption(location) }
- { threadName }
- { timeStamp }
-
- // SKIP-SCALATESTJS,NATIVE-END
-
private[scalatest] def toJson: String = {
import EventJsonHelper._
s"""{ "eventType": "ScopeClosed", "ordinal": ${ordinal.runStamp}, "message": ${string(message)}, "nameInfo": ${nmInfo(nameInfo)}, "formatter": ${formatterOption(formatter)}, "location": ${locationOption(location)}, "threadName": ${string(threadName)}, "timeStamp": ${timeStamp} }""".stripMargin
@@ -2233,22 +1738,6 @@ final case class ScopePending (
payload,
threadName)
- // SKIP-SCALATESTJS,NATIVE-START
- import EventXmlHelper._
- private [scalatest] def toXml =
-
-
- { ordinal.runStamp }
-
- { message }
- { nameInfoOption(if (nameInfo != null) Some(nameInfo) else None) }
- { formatterOption(formatter) }
- { locationOption(location) }
- { threadName }
- { timeStamp }
-
- // SKIP-SCALATESTJS,NATIVE-END
-
private[scalatest] def toJson: String = {
import EventJsonHelper._
s"""{ "eventType": "ScopePending", "ordinal": ${ordinal.runStamp}, "message": ${string(message)}, "nameInfo": ${nmInfo(nameInfo)}, "formatter": ${formatterOption(formatter)}, "location": ${locationOption(location)}, "threadName": ${string(threadName)}, "timeStamp": ${timeStamp} }""".stripMargin
@@ -2295,27 +1784,6 @@ final case class DiscoveryStarting (
*/
val formatter: Option[Formatter] = None
- // SKIP-SCALATESTJS,NATIVE-START
- private [scalatest] def toXml =
-
-
- { ordinal.runStamp }
-
-
- {
- for ((key, value) <- configMap) yield {
-
- { key }
- { value }
-
- }
- }
-
- { threadName }
- { timeStamp }
-
- // SKIP-SCALATESTJS,NATIVE-END
-
private[scalatest] def toJson: String = {
import EventJsonHelper._
s"""{ "eventType": "DiscoveryStarting", "ordinal": ${ordinal.runStamp}, "configMap": { ${configMap.map(e => string(e._1) + ": " + string(e._2.toString)).mkString(", ")} }, "threadName": ${string(threadName)}, "timeStamp": ${timeStamp} }""".stripMargin
@@ -2363,18 +1831,6 @@ final case class DiscoveryCompleted (
* Formatter
in a DiscoveryCompleted
is always set to None
.
*/
val formatter: Option[Formatter] = None
- // SKIP-SCALATESTJS,NATIVE-START
- import EventXmlHelper._
- private [scalatest] def toXml =
-
-
- { ordinal.runStamp }
-
- { longOption(duration) }
- { threadName }
- { timeStamp }
-
- // SKIP-SCALATESTJS,NATIVE-END
private[scalatest] def toJson: String = {
import EventJsonHelper._
diff --git a/jvm/core/src/main/scala/org/scalatest/events/EventXmlHelper.scala b/jvm/core/src/main/scala/org/scalatest/events/EventXmlHelper.scala
new file mode 100644
index 0000000000..4d4ded0d4f
--- /dev/null
+++ b/jvm/core/src/main/scala/org/scalatest/events/EventXmlHelper.scala
@@ -0,0 +1,484 @@
+/*
+ * Copyright 2001-2023 Artima, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.scalatest.events
+
+import org.scalatest.exceptions.StackDepthException
+import scala.xml.Elem
+
+private[scalatest] object EventXmlHelper {
+ def stringOption(strOption: Option[String]) = strOption.getOrElse("")
+ def longOption(longOption: Option[Long]) = if (longOption.isDefined) longOption.get.toString else ""
+ def booleanOption(booleanOption: Option[Boolean]) = if (booleanOption.isDefined) booleanOption.get.toString else ""
+ def formatterOption(formatterOption: Option[Formatter]) = {
+ formatterOption match {
+ case Some(formatter) =>
+ formatter match {
+ case MotionToSuppress =>
+
+ case indentedText: IndentedText =>
+
+ { indentedText.formattedText }
+ { indentedText.rawText }
+ { indentedText.indentationLevel }
+
+ }
+ case None => ""
+ }
+ }
+ def locationOption(locationOption: Option[Location]) = {
+ locationOption match {
+ case Some(location) =>
+ location match {
+ case topOfClass: TopOfClass =>
+
+ { topOfClass.className }
+
+ case topOfMethod: TopOfMethod =>
+
+ { topOfMethod.className }
+ { topOfMethod.methodId }
+
+ case lineInFile: LineInFile =>
+
+ { lineInFile.lineNumber }
+ { lineInFile.fileName }
+ { filePathnameOption(lineInFile.filePathname) }
+
+ case SeeStackDepthException =>
+
+ case _ =>
+ ""
+ }
+ case None => ""
+ }
+ }
+ def filePathnameOption(filePathnameOpt: Option[String]) = {
+ filePathnameOpt match {
+ case Some(filePathname) => filePathname
+ case None => ""
+ }
+ }
+ def getThrowableStackDepth(throwable: Throwable) = {
+ throwable match {
+ case sde: StackDepthException => sde.failedCodeStackDepth
+ case _ => -1
+ }
+ }
+ def throwableOption(throwableOption: Option[Throwable]) = {
+ throwableOption match {
+ case Some(throwable) =>
+ { throwable.getMessage }
+ { getThrowableStackDepth(throwable) }
+
+ {
+ val stackTraces = throwable.getStackTrace
+ for (stackTrace <- stackTraces) yield {
+
+ { stackTrace.getClassName }
+ { stackTrace.getMethodName }
+ { stackTrace.getFileName }
+ { stackTrace.getLineNumber }
+ { stackTrace.isNativeMethod }
+ { stackTrace.toString }
+
+ }
+ }
+
+ case None => ""
+ }
+ }
+ def summaryOption(summaryOption: Option[Summary]) = {
+ summaryOption match {
+ case Some(summary) =>
+ { summary.testsSucceededCount }
+ { summary.testsFailedCount }
+ { summary.testsIgnoredCount }
+ { summary.testsPendingCount }
+ { summary.testsCanceledCount }
+ { summary.suitesCompletedCount }
+ { summary.suitesAbortedCount }
+ { summary.scopesPendingCount }
+ case None => ""
+ }
+ }
+ def nameInfoOption(nameInfoOption: Option[NameInfo]) = {
+ nameInfoOption match {
+ case Some(nameInfo) =>
+ { nameInfo.suiteName }
+ { nameInfo.suiteId }
+ { stringOption(nameInfo.suiteClassName) }
+ { stringOption(nameInfo.testName) }
+ case None =>
+ ""
+ }
+ }
+ def toXml(event: Event): Elem =
+ event match {
+ case TestStarting(ordinal, suiteName, suiteId, suiteClassName, testName, testText, formatter, location, rerunner, payload,
+ threadName, timeStamp) =>
+
+
+ { ordinal.runStamp }
+
+ { suiteName }
+ { suiteId }
+ { stringOption(suiteClassName) }
+ { testName }
+ { testText }
+ { formatterOption(formatter) }
+ { locationOption(location) }
+ { stringOption(rerunner) }
+ { threadName }
+ { timeStamp }
+
+
+ case TestSucceeded(ordinal, suiteName, suiteId, suiteClassName, testName, testText, recordedEvents, duration, formatter,
+ location, rerunner, payload, threadName, timeStamp) =>
+
+
+ { ordinal.runStamp }
+
+ { suiteName }
+ { suiteId }
+ { stringOption(suiteClassName) }
+ { longOption(duration) }
+ { testName }
+ { testText }
+ { recordedEvents.map(EventXmlHelper.toXml) }
+ { formatterOption(formatter) }
+ { locationOption(location) }
+ { stringOption(rerunner) }
+ { threadName }
+ { timeStamp }
+
+
+ case TestFailed(ordinal, message, suiteName, suiteId, suiteClassName, testName, testText, recordedEvents, analysis, throwable,
+ duration, formatter, location, rerunner, payload, threadName, timeStamp) =>
+
+
+ { ordinal.runStamp }
+
+ { message }
+ { suiteName }
+ { suiteId }
+ { stringOption(suiteClassName) }
+ { longOption(duration) }
+ { testName }
+ { testText }
+ { recordedEvents.map(EventXmlHelper.toXml) }
+ analysis.map(a => a)
+ { throwableOption(throwable) }
+ { formatterOption(formatter) }
+ { locationOption(location) }
+ { stringOption(rerunner) }
+ { threadName }
+ { timeStamp }
+
+
+ case TestIgnored(ordinal, suiteName, suiteId, suiteClassName, testName, testText, formatter, location, payload,
+ threadName, timeStamp) =>
+
+
+ { ordinal.runStamp }
+
+ { suiteName }
+ { suiteId }
+ { stringOption(suiteClassName) }
+ { testName }
+ { testText }
+ { formatterOption(formatter) }
+ { locationOption(location) }
+ { threadName }
+ { timeStamp }
+
+
+ case TestPending(ordinal, suiteName, suiteId, suiteClassName, testName, testText, recordedEvents, duration, formatter,
+ location, payload, threadName, timeStamp) =>
+
+
+ { ordinal.runStamp }
+
+ { suiteName }
+ { suiteId }
+ { stringOption(suiteClassName) }
+ { longOption(duration) }
+ { testName }
+ { testText }
+ { recordedEvents.map(EventXmlHelper.toXml) }
+ { formatterOption(formatter) }
+ { locationOption(location) }
+ { threadName }
+ { timeStamp }
+
+
+ case TestCanceled(ordinal, message, suiteName, suiteId, suiteClassName, testName, testText, recordedEvents, throwable, duration,
+ formatter, location, rerunner, payload, threadName, timeStamp) =>
+
+
+ { ordinal.runStamp }
+
+ { message }
+ { suiteName }
+ { suiteId }
+ { stringOption(suiteClassName) }
+ { longOption(duration) }
+ { testName }
+ { testText }
+ { recordedEvents.map(EventXmlHelper.toXml) }
+ { throwableOption(throwable) }
+ { formatterOption(formatter) }
+ { locationOption(location) }
+ { stringOption(rerunner) }
+ { threadName }
+ { timeStamp }
+
+
+ case SuiteStarting (ordinal, suiteName, suiteId, suiteClassName, formatter, location, rerunner, payload, threadName, timeStamp) =>
+
+
+ { ordinal.runStamp }
+
+ { suiteName }
+ { suiteId }
+ { stringOption(suiteClassName) }
+ { formatterOption(formatter) }
+ { locationOption(location) }
+ { stringOption(rerunner) }
+ { threadName }
+ { timeStamp }
+
+
+ case SuiteCompleted(ordinal, suiteName, suiteId, suiteClassName, duration, formatter, location, rerunner, payload, threadName, timeStamp) =>
+
+
+ { ordinal.runStamp }
+
+ { suiteName }
+ { suiteId }
+ { stringOption(suiteClassName) }
+ { longOption(duration) }
+ { formatterOption(formatter) }
+ { locationOption(location) }
+ { stringOption(rerunner) }
+ { threadName }
+ { timeStamp }
+
+
+ case SuiteAborted(ordinal, message, suiteName, suiteId, suiteClassName, throwable, duration, formatter, location, rerunner, payload, threadName, timeStamp) =>
+
+
+ { ordinal.runStamp }
+
+ { message }
+ { suiteName }
+ { suiteId }
+ { stringOption(suiteClassName) }
+ { longOption(duration) }
+ { throwableOption(throwable) }
+ { formatterOption(formatter) }
+ { locationOption(location) }
+ { stringOption(rerunner) }
+ { threadName }
+ { timeStamp }
+
+
+ case RunStarting(ordinal, testCount, configMap, formatter, location, payload, threadName, timeStamp) =>
+
+
+ { ordinal.runStamp }
+
+ { testCount }
+
+ {
+ for ((key, value) <- configMap) yield {
+
+ { key }
+ { value }
+
+ }
+ }
+
+ { formatterOption(formatter) }
+ { locationOption(location) }
+ { threadName }
+ { timeStamp }
+
+
+ case RunCompleted(ordinal, duration, summary, formatter, location, payload, threadName, timeStamp) =>
+
+
+ { ordinal.runStamp }
+
+ { longOption(duration) }
+ { summaryOption(summary) }
+ { formatterOption(formatter) }
+ { locationOption(location) }
+ { threadName }
+ { timeStamp }
+
+
+ case RunStopped(ordinal, duration, summary, formatter, location, payload, threadName, timeStamp) =>
+
+
+ { ordinal.runStamp }
+
+ { longOption(duration) }
+ { summaryOption(summary) }
+ { formatterOption(formatter) }
+ { locationOption(location) }
+ { threadName }
+ { timeStamp }
+
+
+ case RunAborted(ordinal, message, throwable, duration, summary, formatter, location, payload, threadName, timeStamp) =>
+
+
+ { ordinal.runStamp }
+
+ { message }
+ { throwableOption(throwable) }
+ { longOption(duration) }
+ { summaryOption(summary) }
+ { formatterOption(formatter) }
+ { locationOption(location) }
+ { threadName }
+ { timeStamp }
+
+
+ case InfoProvided(ordinal, message, nameInfo, throwable, formatter, location, payload, threadName, timeStamp) =>
+
+
+ { ordinal.runStamp }
+
+ { message }
+ { nameInfoOption(nameInfo) }
+ { throwableOption(throwable) }
+ { formatterOption(formatter) }
+ { locationOption(location) }
+ { threadName }
+ { timeStamp }
+
+
+ case AlertProvided(ordinal, message, nameInfo, throwable, formatter, location, payload, threadName, timeStamp) =>
+
+
+ { ordinal.runStamp }
+
+ { message }
+ { nameInfoOption(nameInfo) }
+ { throwableOption(throwable) }
+ { formatterOption(formatter) }
+ { locationOption(location) }
+ { threadName }
+ { timeStamp }
+
+
+ case NoteProvided(ordinal, message, nameInfo, throwable, formatter, location, payload, threadName, timeStamp) =>
+
+
+ { ordinal.runStamp }
+
+ { message }
+ { nameInfoOption(nameInfo) }
+ { throwableOption(throwable) }
+ { formatterOption(formatter) }
+ { locationOption(location) }
+ { threadName }
+ { timeStamp }
+
+
+ case MarkupProvided(ordinal, text, nameInfo, formatter, location, payload, threadName, timeStamp) =>
+
+
+ { ordinal.runStamp }
+
+ { text }
+ { nameInfoOption(nameInfo) }
+ { formatterOption(formatter) }
+ { locationOption(location) }
+ { threadName }
+ { timeStamp }
+
+
+ case ScopeOpened(ordinal, message, nameInfo, formatter, location, payload, threadName, timeStamp) =>
+
+
+ { ordinal.runStamp }
+
+ { message }
+ { nameInfoOption(if (nameInfo != null) Some(nameInfo) else None) }
+ { formatterOption(formatter) }
+ { locationOption(location) }
+ { threadName }
+ { timeStamp }
+
+
+ case ScopeClosed(ordinal, message, nameInfo, formatter, location, payload, threadName, timeStamp) =>
+
+
+ { ordinal.runStamp }
+
+ { message }
+ { nameInfoOption(if (nameInfo != null) Some(nameInfo) else None) }
+ { formatterOption(formatter) }
+ { locationOption(location) }
+ { threadName }
+ { timeStamp }
+
+
+ case ScopePending(ordinal, message, nameInfo, formatter, location, payload, threadName, timeStamp) =>
+
+
+ { ordinal.runStamp }
+
+ { message }
+ { nameInfoOption(if (nameInfo != null) Some(nameInfo) else None) }
+ { formatterOption(formatter) }
+ { locationOption(location) }
+ { threadName }
+ { timeStamp }
+
+
+ case DiscoveryStarting(ordinal, configMap, threadName, timeStamp) =>
+
+
+ { ordinal.runStamp }
+
+
+ {
+ for ((key, value) <- configMap) yield {
+
+ { key }
+ { value }
+
+ }
+ }
+
+ { threadName }
+ { timeStamp }
+
+
+ case DiscoveryCompleted(ordinal, duration, threadName, timeStamp) =>
+
+
+ { ordinal.runStamp }
+
+ { longOption(duration) }
+ { threadName }
+ { timeStamp }
+
+ }
+}
\ No newline at end of file
diff --git a/jvm/core/src/main/scala/org/scalatest/tools/XmlSocketReporter.scala b/jvm/core/src/main/scala/org/scalatest/tools/XmlSocketReporter.scala
index 5476a4059a..a2d5fe1709 100644
--- a/jvm/core/src/main/scala/org/scalatest/tools/XmlSocketReporter.scala
+++ b/jvm/core/src/main/scala/org/scalatest/tools/XmlSocketReporter.scala
@@ -15,7 +15,7 @@
*/
package org.scalatest.tools
-import org.scalatest.events.Event
+import org.scalatest.events.{Event, EventXmlHelper}
import org.scalatest.ResourcefulReporter
import java.net.Socket
import java.io.PrintWriter
@@ -27,7 +27,7 @@ private[scalatest] class XmlSocketReporter(host: String, port: Int) extends Reso
private val out = new PrintWriter(new BufferedOutputStream(socket.getOutputStream))
def apply(event: Event): Unit = {
- out.println(event.toXml.toString)
+ out.println(EventXmlHelper.toXml(event).toString)
out.flush()
}
diff --git a/project/GenScalaTestJS.scala b/project/GenScalaTestJS.scala
index 465166a04e..595debc3d0 100644
--- a/project/GenScalaTestJS.scala
+++ b/project/GenScalaTestJS.scala
@@ -148,7 +148,9 @@ object GenScalaTestJS {
"SpecLike.scala"
),
"org/scalatest/diagrams" -> List.empty,
- "org/scalatest/events" -> List.empty,
+ "org/scalatest/events" -> List(
+ "EventXmlHelper.scala"
+ ),
"org/scalatest/expectations" -> List.empty,
"org/scalatest/matchers" -> List.empty,
"org/scalatest/matchers/dsl" -> List(