From 13085138a5b07bb78f35666f1a9232592904a7ef Mon Sep 17 00:00:00 2001 From: Tim Harper Date: Mon, 14 May 2018 17:29:20 -0600 Subject: [PATCH] Remove milliseconds from format in order to comply with JUnit spec --- .../src/main/scala/sbt/JUnitXmlTestsListener.scala | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/testing/src/main/scala/sbt/JUnitXmlTestsListener.scala b/testing/src/main/scala/sbt/JUnitXmlTestsListener.scala index 0ac2a6997..33057b6e7 100644 --- a/testing/src/main/scala/sbt/JUnitXmlTestsListener.scala +++ b/testing/src/main/scala/sbt/JUnitXmlTestsListener.scala @@ -10,6 +10,8 @@ package sbt import java.io.{ File, IOException, PrintWriter, StringWriter } import java.net.InetAddress import java.time.LocalDateTime +import java.time.format.DateTimeFormatter +import java.time.temporal.ChronoUnit import java.util.Hashtable import scala.collection.mutable.ListBuffer @@ -84,7 +86,7 @@ class JUnitXmlTestsListener(val outputDir: String) extends TestsListener { ) val result = - + { properties } { for (e <- events) yield * * @@ -201,6 +205,12 @@ class JUnitXmlTestsListener(val outputDir: String) extends TestsListener { // contort the user into not using spaces. private[this] def normalizeName(s: String) = s.replaceAll("""\s+""", "-") + /** + * Format the date, without milliseconds or the timezone, per the JUnit spec. + */ + private[this] def formatISO8601DateTime(d: LocalDateTime): String = + d.truncatedTo(ChronoUnit.SECONDS).format(DateTimeFormatter.ISO_LOCAL_DATE_TIME) + private def writeSuite() = { val file = new File(targetDir, s"${normalizeName(withTestSuite(_.name))}.xml").getAbsolutePath // TODO would be nice to have a logger and log this with level debug