]> Dogcows Code - chaz/sbt-tap/commitdiff
add ability to set TAP output file path by environment
authorCharles McGarvey <chazmcgarvey@brokenzipper.com>
Fri, 11 Jan 2013 17:55:36 +0000 (10:55 -0700)
committerCharles McGarvey <chazmcgarvey@brokenzipper.com>
Fri, 11 Jan 2013 17:55:36 +0000 (10:55 -0700)
README.md [new file with mode: 0644]
readme.md [deleted file]
src/main/scala/SbtTapReporting.scala

diff --git a/README.md b/README.md
new file mode 100644 (file)
index 0000000..50cd097
--- /dev/null
+++ b/README.md
@@ -0,0 +1,45 @@
+This sbt plug-in provides reporting of test success and failure for tests run by
+[simple build tool](https://github.com/harrah/xsbt)
+in [TAP](http://search.cpan.org/perldoc?Test%3A%3AHarness%3A%3ATAP) format.
+
+All the test results will be generated in one file, the path of which may be
+specified in the `SBT_TAP_OUTPUT` environment variable.  If unspecified in the
+environment, the output file path defaults to `test-results/test.tap`.
+
+To use:
+
+1. Add this plug-in to your sbt project by creating a file
+   `project/project/Plugins.scala` that looks something like this:
+
+   ```scala
+   import sbt._
+   // sets up other project dependencies when building our root project
+   object Plugins extends Build {
+     lazy val root = Project("root", file(".")) dependsOn(tapListener)
+     lazy val tapListener = RootProject(uri("git://github.com/mkhettry/sbt-tap.git"))
+   }
+   ```
+
+2. In your `build.sbt` file, add the `SbtTapListener` to the sequence of test
+   listeners.
+
+   ```scala
+   testListeners += SbtTapReporting.tapListener
+   ```
+
+3. Optionally, in a UNIX environment, you can set up a named pipe for
+   collecting the TAP report, for your test harness.
+
+   ```sh
+   #!/bin/sh
+
+   pipe="$PWD/test.tap"    # set where to make the pipe
+
+   rm -f "$pipe"           # clear the path for the new pipe
+   mkfifo "$pipe"          # make the pipe
+   cat "$pipe" &           # redirect the report to stdout
+
+   SBT_TAP_OUTPUT="$pipe" sbt test 2>&1 >/dev/null
+
+   rm -f "$pipe"           # all done - remove the pipe
+   ```
diff --git a/readme.md b/readme.md
deleted file mode 100644 (file)
index ea900b8..0000000
--- a/readme.md
+++ /dev/null
@@ -1,21 +0,0 @@
-Provides reporting of test success and failure for tests run by
-[simple build tool](https://github.com/harrah/xsbt)
-in [TAP](http://en.wikipedia.org/wiki/Test_Anything_Protocol) format
-
-All the test results will be generated in one file: test-results/test.tap
-
-To use
-
-1. Add this plugin to your sbt project. Create project/project/Plugins.scala that looks like this:
-
-        import sbt._
-        // sets up other project dependencies when building our root project
-        object Plugins extends Build {
-          lazy val root = Project("root", file(".")) dependsOn(tapListener)
-          lazy val tapListener = RootProject(uri("git://github.com/mkhettry/sbt-tap.git"))
-        }
-
-2. In your build.sbt, add the SbtTapListener to the sequence of Test Listeners.
-
-        testListeners += SbtTapReporting.tapListener
-
index 9345066996c621c06df72c08b10e2625c85583f4..14b0576c2e742ff46d06f701ea44539537ec3105 100644 (file)
@@ -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) {}
This page took 0.024773 seconds and 4 git commands to generate.