]> Dogcows Code - chaz/sbt-tap/blobdiff - src/main/scala/SbtTapReporting.scala
add ability to set TAP output file path by environment
[chaz/sbt-tap] / src / main / scala / SbtTapReporting.scala
index 966e3a2a46a5feeb93a3049908377871487c59db..14b0576c2e742ff46d06f701ea44539537ec3105 100644 (file)
@@ -5,7 +5,7 @@ import org.scalatools.testing.{Event => TEvent, Result => TResult}
 import java.util.concurrent.atomic.AtomicInteger
 
 object SbtTapReporting extends Plugin {
-  lazy val tapListener = new SbtTapListener
+  def apply() = new SbtTapListener
 }
 
 /**
@@ -23,7 +23,9 @@ class SbtTapListener extends TestsListener {
   override def doInit {
     new File("test-results").mkdirs()
 
-    fileWriter = new FileWriter("test-results/test.tap")
+    fileWriter = new FileWriter(
+      scala.util.Properties.envOrElse("SBT_TAP_OUTPUT", "test-results/test.tap")
+    )
   }
 
   def startGroup(name: String) {}
@@ -34,7 +36,10 @@ class SbtTapListener extends TestsListener {
         case TResult.Success => writeTapFields("ok", testId.incrementAndGet(), "-", e.testName())
         case TResult.Error | TResult.Failure =>
           writeTapFields("not ok", testId.incrementAndGet(), "-", e.testName())
-          writeTapFields(stackTraceForError(e.error()))
+          // According to the TAP spec, as long as there is any kind of whitespace, this output should belong to the
+          // the test that failed and it should get displayed in the UI.
+          // TODO:It would be nice if we could report the exact line in the test where this happened.
+          writeTapFields(" ", stackTraceForError(e.error()))
         case TResult.Skipped =>
           // it doesn't look like this framework distinguishes between pending and ignored.
           writeTapFields("ok", testId.incrementAndGet(), e.testName(), "#", "skip", e.testName())
This page took 0.022555 seconds and 4 git commands to generate.