specs 1.6 support

git-svn-id: https://simple-build-tool.googlecode.com/svn/trunk@1090 d89573ee-9141-11dd-94d4-bdf5e562f29c
This commit is contained in:
dmharrah 2009-10-16 02:05:57 +00:00 committed by Mark Harrah
parent 0273e9d2b1
commit d57e6a8f1a
1 changed files with 21 additions and 17 deletions

View File

@ -170,24 +170,28 @@ private[sbt] class SpecsRunner(val log: Logger, val listeners: Seq[TestReportLis
}
private def reportSystem(sus: Sus): SystemReportEvent =
{
def format =
// for source compatibility between specs 1.4.x and 1.5.0:
// in specs 1.5.0, description is LiterateDescription
// in specs < 1.5.0, description is Elem
// LiterateDescription.desc is a Node
// Elem.child is a Seq[Node]
// each has a map[T](f: Node => T): Seq[T] defined so we use reflection to call the right method
//description.child.map(_.text) // Elem equivalent
//description.desc.map(_.text) // LiterateDescription
def formatDescription(a: AnyRef) =
{
class ElemDesc(e: Elem) { def desc = e.child }
implicit def elemToDesc(e: Elem): ElemDesc = new ElemDesc(e)
for(description <- sus.literateDescription) yield
{
// for source compatibility between specs 1.4.x and 1.5.0:
// in specs 1.5.0, description is LiterateDescription
// in specs < 1.5.0, description is Elem
// LiterateDescription.desc is a Node
// Elem.child is a Seq[Node]
// each has a map[T](f: Node => T): Seq[T] defined so we implicitly convert
// an Elem e to an intermediate object that has desc defined to be e.child
//description.child.map(_.text) // Elem equivalent
description.desc.map(_.text) // LiterateDescription
}
val toMap =
try { call(a, "desc") }
catch { case e: Exception => call(a, "child") }
val mapText = (a: AnyRef) => a.getClass.getMethod("text").invoke(a)
toMap.getClass.getMethod("map", Class.forName("scala.Function1")).invoke(toMap, mapText).asInstanceOf[Seq[String]]
}
def call(a: AnyRef, m: String) = a.getClass.getMethod(m).invoke(a)
def format: Option[Seq[String]] =
{
val litD = sus.literateDescription
if(litD.isEmpty) None else Some(formatDescription(litD.get))
}
// these are for 1.6 compatibility, which removed skippedSus (skipped still exists) and examples (moved to specification)
def skipped(sus: Sus) = classOf[Sus].getMethod("skipped").invoke(sus).asInstanceOf[Seq[Throwable]]