From 30ede13a0909406e50c2b7b066328b9dd589bf4b Mon Sep 17 00:00:00 2001 From: Ethan Atkins Date: Sat, 31 Aug 2019 12:46:10 -0700 Subject: [PATCH] Fix task timings I noticed that the reports generated when using sbt.task.timings=true made very little sense. They were displaying timings for tests that couldn't possibly have been run. I tracked this down to the TaskTimings be stored in the progressReport setting which meant they were reused across multiple task runs. After this change, the reports made a lot more sense. --- main/src/main/scala/sbt/EvaluateTask.scala | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/main/src/main/scala/sbt/EvaluateTask.scala b/main/src/main/scala/sbt/EvaluateTask.scala index a056beb0e..359f92291 100644 --- a/main/src/main/scala/sbt/EvaluateTask.scala +++ b/main/src/main/scala/sbt/EvaluateTask.scala @@ -156,12 +156,8 @@ object EvaluateTask { lazy private val sharedProgress = new TaskTimings(reportOnShutdown = true) def taskTimingProgress: Option[ExecuteProgress[Task]] = - if (SysProp.taskTimings) { - if (SysProp.taskTimingsOnShutdown) - Some(sharedProgress) - else - Some(new TaskTimings(reportOnShutdown = false)) - } else None + if (SysProp.taskTimingsOnShutdown) Some(sharedProgress) + else None lazy private val sharedTraceEvent = new TaskTraceEvent() def taskTraceEvent: Option[ExecuteProgress[Task]] = @@ -240,7 +236,8 @@ object EvaluateTask { extracted, structure ) - val reporters = maker map { _.progress } + val reporters = maker.map(_.progress) ++ + (if (SysProp.taskTimings) new TaskTimings(reportOnShutdown = false) :: Nil else Nil) // configure the logger for super shell ConsoleAppender.setShowProgress((reporters collect { case p: TaskProgress => ()