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

Commit 804133f

Browse files
authored
Merge pull request scala#5328 from szeiger/wip/better-testAll-results
Improve log output of the `testAll` task
2 parents 3cb45e1 + 0061759 commit 804133f

File tree

1 file changed

+45
-3
lines changed

1 file changed

+45
-3
lines changed

build.sbt

+45-3
Original file line numberDiff line numberDiff line change
@@ -771,7 +771,8 @@ lazy val root: Project = (project in file("."))
771771
testAll := {
772772
val results = ScriptCommands.sequence[Result[Unit]](List(
773773
(Keys.test in Test in junit).result,
774-
(testOnly in IntegrationTest in testP).toTask(" -- run pos neg jvm").result,
774+
(testOnly in IntegrationTest in testP).toTask(" -- run").result,
775+
(testOnly in IntegrationTest in testP).toTask(" -- pos neg jvm").result,
775776
(testOnly in IntegrationTest in testP).toTask(" -- res scalap specialized scalacheck").result,
776777
(testOnly in IntegrationTest in testP).toTask(" -- instrumented presentation").result,
777778
(testOnly in IntegrationTest in testP).toTask(" -- --srcpath scaladoc").result,
@@ -786,11 +787,52 @@ lazy val root: Project = (project in file("."))
786787
doc in Compile in scalap
787788
).result
788789
)).value
789-
val failed = results.map(_.toEither).collect { case Left(i) => i }
790+
// All attempts to define these together with the actual tasks due to the applicative rewriting of `.value`
791+
val descriptions = Vector(
792+
"junit/test",
793+
"partest run",
794+
"partest pos neg jvm",
795+
"partest res scalap specialized scalacheck",
796+
"partest instrumented presentation",
797+
"partest --srcpath scaladoc",
798+
"osgiTestFelix/test",
799+
"osgiTestEclipse/test",
800+
"library/mima",
801+
"reflect/mima",
802+
"doc"
803+
)
804+
val failed = results.map(_.toEither).zip(descriptions).collect { case (Left(i: Incomplete), d) => (i, d) }
790805
if(failed.nonEmpty) {
791806
val log = streams.value.log
807+
def showScopedKey(k: Def.ScopedKey[_]): String =
808+
Vector(
809+
k.scope.project.toOption.map {
810+
case p: ProjectRef => p.project
811+
case p => p
812+
}.map(_ + "/"),
813+
k.scope.config.toOption.map(_.name + ":"),
814+
k.scope.task.toOption.map(_.label + "::")
815+
).flatten.mkString + k.key
816+
def logIncomplete(i: Incomplete, prefix: String): Unit = {
817+
val sk = i.node match {
818+
case Some(t: Task[_]) =>
819+
t.info.attributes.entries.collect { case e if e.key == Keys.taskDefinitionKey => e.value.asInstanceOf[Def.ScopedKey[_]] }
820+
.headOption.map(showScopedKey)
821+
case _ => None
822+
}
823+
val childCount = (if(i.directCause.isDefined) 1 else 0) + i.causes.length
824+
val skip = childCount <= 1 && sk.isEmpty
825+
if(!skip) log.error(s"$prefix- ${sk.getOrElse("?")}")
826+
i.directCause match {
827+
case Some(e) => log.error(s"$prefix - $e")
828+
case None => i.causes.foreach(i => logIncomplete(i, prefix + (if(skip) "" else " ")))
829+
}
830+
}
792831
log.error(s"${failed.size} of ${results.length} test tasks failed:")
793-
failed.foreach(i => log.error(s" - $i"))
832+
failed.foreach { case (i, d) =>
833+
log.error(s"- $d")
834+
logIncomplete(i, " ")
835+
}
794836
throw new RuntimeException
795837
}
796838
},

0 commit comments

Comments
 (0)