Skip to content

Instantly share code, notes, and snippets.

@nkpart
Created June 24, 2009 22:56
Show Gist options
  • Save nkpart/135573 to your computer and use it in GitHub Desktop.
Save nkpart/135573 to your computer and use it in GitHub Desktop.
lazy val jsTestServer = task {
val port = "4224"
JsTestDriverServer.main(Array("--port", port))
System.out.println("*****\nNow capture your browser: http://localhost:" + port)
Thread.sleep(86400 * 1000) // Otherwise it exits straight away
None
}
lazy val jsTestClient = task {
JsTestDriverServer.main(Array("--tests", "all", "--verbose"))
None
}
lazy val testJs = task {
val out = "js-tmp"
("rm " +(out / "*.xml")) !;
("rmdir " + out) !;
("mkdir " + out) !;
val jarPath = "project" / "build" / "lib" / "JsTestDriver-1.0b.jar"
val args = Array("--port", "4224", "--browser", "open", "--tests", "all", "--testOutput", out)
var blurg = 0
val processIO = new ProcessIO(_ => (), (inputStream => {
// TODO read input into Seq so it can be printed later
val lines = Source.fromInputStream(inputStream).getLines.toList
val totalLine = lines.filter(_.startsWith("Total")).head
val failCount = "Fails: (\\d+)".r findFirstMatchIn totalLine map (_.group(1).toInt) getOrElse 0
log info failCount.toString
log info (lines reduceLeft(_ + "\n" + _))
blurg = failCount
}), _ => ())
val r = "java -jar " + jarPath + " " + args.reduceLeft(_ + " " + _) run processIO exitValue;
// The result is always 0, so need to check the test outputs.
if (blurg > 0) { Some("FAILED") } else { None }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment