mirror of https://github.com/sbt/sbt.git
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:
parent
0273e9d2b1
commit
d57e6a8f1a
|
|
@ -170,24 +170,28 @@ private[sbt] class SpecsRunner(val log: Logger, val listeners: Seq[TestReportLis
|
||||||
}
|
}
|
||||||
private def reportSystem(sus: Sus): SystemReportEvent =
|
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 }
|
val toMap =
|
||||||
implicit def elemToDesc(e: Elem): ElemDesc = new ElemDesc(e)
|
try { call(a, "desc") }
|
||||||
|
catch { case e: Exception => call(a, "child") }
|
||||||
for(description <- sus.literateDescription) yield
|
val mapText = (a: AnyRef) => a.getClass.getMethod("text").invoke(a)
|
||||||
{
|
toMap.getClass.getMethod("map", Class.forName("scala.Function1")).invoke(toMap, mapText).asInstanceOf[Seq[String]]
|
||||||
// for source compatibility between specs 1.4.x and 1.5.0:
|
}
|
||||||
// in specs 1.5.0, description is LiterateDescription
|
def call(a: AnyRef, m: String) = a.getClass.getMethod(m).invoke(a)
|
||||||
// in specs < 1.5.0, description is Elem
|
def format: Option[Seq[String]] =
|
||||||
// LiterateDescription.desc is a Node
|
{
|
||||||
// Elem.child is a Seq[Node]
|
val litD = sus.literateDescription
|
||||||
// each has a map[T](f: Node => T): Seq[T] defined so we implicitly convert
|
if(litD.isEmpty) None else Some(formatDescription(litD.get))
|
||||||
// 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
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
// these are for 1.6 compatibility, which removed skippedSus (skipped still exists) and examples (moved to specification)
|
// 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]]
|
def skipped(sus: Sus) = classOf[Sus].getMethod("skipped").invoke(sus).asInstanceOf[Seq[Throwable]]
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue