New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add timestamp field to JUnitXML report #4154

Merged
merged 4 commits into from May 15, 2018

Conversation

Projects
None yet
3 participants
@timcharper
Contributor

timcharper commented May 12, 2018

Addresses #4153

@@ -59,7 +61,7 @@ class JUnitXmlTestsListener(val outputDir: String) extends TestsListener {
* Gathers data for one Test Suite. We map test groups to TestSuites.
* Each TestSuite gets its own output file.
*/
class TestSuite(val name: String) {
class TestSuite(val name: String, timestamp: Long) {

This comment has been minimized.

@eed3si9n

eed3si9n May 12, 2018

Member

I'd suggest using java.imte.LocalDateTime here.

This comment has been minimized.

@timcharper

timcharper May 13, 2018

Contributor

Ahhh I avoided this because I didn’t know if sbt supports jdk 7 and older.

This comment has been minimized.

@eed3si9n

eed3si9n May 13, 2018

Member

sbt 1 is on Scala 2.12 so we can assume JDK 8 and up.

private val timeFormat = new SimpleDateFormat("HH:mm:ss")
def formattedTimestamp(timestamp: Long): String =
s"${dateFormat.format(timestamp)}T${timeFormat.format(timestamp)}"

This comment has been minimized.

@eed3si9n

eed3si9n May 12, 2018

Member

Here's more JDK 8-ish time formatting code.

scala> import java.time.LocalDateTime
import java.time.LocalDateTime

scala> import java.time.format.DateTimeFormatter
import java.time.format.DateTimeFormatter

scala> import java.time.temporal.ChronoUnit
import java.time.temporal.ChronoUnit

scala> val t = LocalDateTime.now().truncatedTo(ChronoUnit.SECONDS)
t: java.time.LocalDateTime = 2018-05-12T01:39:18

scala> t.format(DateTimeFormatter.ISO_LOCAL_DATE_TIME)
res0: String = 2018-05-12T01:39:18

This comment has been minimized.

@timcharper

timcharper May 14, 2018

Contributor

Hmm, not sure if it's absolutely necessary to truncate to seconds. Wdyt?

This comment has been minimized.

@timcharper
@timcharper

This comment has been minimized.

Contributor

timcharper commented May 14, 2018

@eed3si9n I've switched it to use Java time. Patch is much shorter.

@@ -59,7 +60,7 @@ class JUnitXmlTestsListener(val outputDir: String) extends TestsListener {
* Gathers data for one Test Suite. We map test groups to TestSuites.
* Each TestSuite gets its own output file.
*/
class TestSuite(val name: String) {
class TestSuite(val name: String, timestamp: LocalDateTime) {

This comment has been minimized.

@eed3si9n

eed3si9n May 14, 2018

Member

Mima failed on Travis CI. It's unlikely that sbt plugins would instantiate this class, but adding another constructor that passes in LocalDateTime.now() should be easy to keep the bincompat, so could you plz add it?

This comment has been minimized.

@timcharper

timcharper May 14, 2018

Contributor

@timcharper

This comment has been minimized.

Contributor

timcharper commented May 14, 2018

@dwijnand

LGTM!

@dwijnand dwijnand added this to the 1.2.0 milestone May 14, 2018

@dwijnand

This comment has been minimized.

Member

dwijnand commented May 14, 2018

Leaving it to Eugene to :shipit:

@dwijnand

This comment has been minimized.

Member

dwijnand commented May 14, 2018

I mean 🔀 (found a suitable "merge" emoji)

@timcharper

This comment has been minimized.

Contributor

timcharper commented May 15, 2018

Thanks @dwijnand !

I'm not sure why CI failed the build.

https://travis-ci.org/sbt/sbt/jobs/378977478

:: retrieving :: org.scala-sbt#boot-scala
	confs: [default]
	5 artifacts copied, 0 already retrieved (18986kB/29ms)
Error: Could not retrieve sbt 1.1.4: missing sbt.xMain
restoring stty: 500:5:bf:8a3b:3:1c:7f:15:4:0:1:0:11:13:1a:0:12:f:17:16:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0
The command "sbt -J-XX:ReservedCodeCacheSize=128m -J-Xmx800M -J-Xms800M -J-server "$SBT_CMD"" exited with 1.

🤔

@eed3si9n

LGTM pending Travis CI

@eed3si9n

This comment has been minimized.

Member

eed3si9n commented May 15, 2018

Something looks odd with Travis.

Getting org.scala-sbt sbt 1.1.4  (this may take some time)...
:: retrieving :: org.scala-sbt#boot-app
	confs: [default]
	0 artifacts copied, 76 already retrieved (0kB/67ms)
Error: Could not retrieve sbt 1.1.4: missing sbt.xMain

I am guessing this is unrelated to your change.

@eed3si9n

This comment has been minimized.

Member

eed3si9n commented May 15, 2018

Wiping Travis CI cache seemed to have solved it, so it was corrupt Ivy cache, I am guessing.

@eed3si9n eed3si9n merged commit b72f36f into sbt:1.x May 15, 2018

3 checks passed

Codacy/PR Quality Review Up to standards. A positive pull request.
Details
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details

@eed3si9n eed3si9n referenced this pull request May 15, 2018

Closed

SBT JUnitXmlTestsListener is missing a timestamp field #4153

1 of 1 task complete
@eed3si9n

This comment has been minimized.

Member

eed3si9n commented May 15, 2018

Thanks @timcharper for the contribution.
Check out https://github.com/sbt/sbt/issues for more ideas :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment