Skip to content
This repository was archived by the owner on Sep 1, 2020. It is now read-only.

Commit 366f45b

Browse files
committed
Improve log output of the testAll task
It’s a lot of code for little benefit but makes the output more useful when test tasks fail. Unfortunately there doesn’t seem to be any way to get the `summary` reported by a test framework at this point. The arguments of `toTask` for InputTasks with applied arguments have also been lost, so we keep track of the commands separately.
1 parent 961c8be commit 366f45b

File tree

1 file changed

+42
-2
lines changed

1 file changed

+42
-2
lines changed

build.sbt

Lines changed: 42 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -786,11 +786,51 @@ lazy val root: Project = (project in file("."))
786786
doc in Compile in scalap
787787
).result
788788
)).value
789-
val failed = results.map(_.toEither).collect { case Left(i) => i }
789+
// All attempts to define these together with the actual tasks due to the applicative rewriting of `.value`
790+
val descriptions = Vector(
791+
"junit/test",
792+
"partest run pos neg jvm",
793+
"partest res scalap specialized scalacheck",
794+
"partest instrumented presentation",
795+
"partest --srcpath scaladoc",
796+
"osgiTestFelix/test",
797+
"osgiTestEclipse/test",
798+
"library/mima",
799+
"reflect/mima",
800+
"doc"
801+
)
802+
val failed = results.map(_.toEither).zip(descriptions).collect { case (Left(i: Incomplete), d) => (i, d) }
790803
if(failed.nonEmpty) {
791804
val log = streams.value.log
805+
def showScopedKey(k: Def.ScopedKey[_]): String =
806+
Vector(
807+
k.scope.project.toOption.map {
808+
case p: ProjectRef => p.project
809+
case p => p
810+
}.map(_ + "/"),
811+
k.scope.config.toOption.map(_.name + ":"),
812+
k.scope.task.toOption.map(_.label + "::")
813+
).flatten.mkString + k.key
814+
def logIncomplete(i: Incomplete, prefix: String): Unit = {
815+
val sk = i.node match {
816+
case Some(t: Task[_]) =>
817+
t.info.attributes.entries.collect { case e if e.key == Keys.taskDefinitionKey => e.value.asInstanceOf[Def.ScopedKey[_]] }
818+
.headOption.map(showScopedKey)
819+
case _ => None
820+
}
821+
val childCount = (if(i.directCause.isDefined) 1 else 0) + i.causes.length
822+
val skip = childCount <= 1 && sk.isEmpty
823+
if(!skip) log.error(s"$prefix- ${sk.getOrElse("?")}")
824+
i.directCause match {
825+
case Some(e) => log.error(s"$prefix - $e")
826+
case None => i.causes.foreach(i => logIncomplete(i, prefix + (if(skip) "" else " ")))
827+
}
828+
}
792829
log.error(s"${failed.size} of ${results.length} test tasks failed:")
793-
failed.foreach(i => log.error(s" - $i"))
830+
failed.foreach { case (i, d) =>
831+
log.error(s"- $d")
832+
logIncomplete(i, " ")
833+
}
794834
throw new RuntimeException
795835
}
796836
},

0 commit comments

Comments
 (0)