Skip to content

Commit a942e8a

Browse files
HollandDMautofix-ci[bot]
andauthoredMar 22, 2025
Test runner indicators backport (#4756)
back port of #4737 --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
1 parent fa87dfe commit a942e8a

File tree

9 files changed

+348
-162
lines changed

9 files changed

+348
-162
lines changed
 

‎main/util/src/mill/util/PromptLoggerUtil.scala

+2-6
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,6 @@ private object PromptLoggerUtil {
6060
(AnsiNav.clearScreen(0) + AnsiNav.up(1) + "\n").getBytes
6161

6262
def spaceNonEmpty(s: String): String = if (s.isEmpty) "" else s" $s"
63-
private def renderSecondsSuffix(millis: Long) = (millis / 1000).toInt match {
64-
case 0 => ""
65-
case n => s" ${n}s"
66-
}
6763

6864
def readTerminalDims(terminfoPath: os.Path): Option[(Option[Int], Option[Int])] = {
6965
try {
@@ -98,7 +94,7 @@ private object PromptLoggerUtil {
9894
val maxWidth = consoleWidth - 1
9995
// -1 to account for header
10096
val maxHeight = math.max(1, consoleHeight / 3 - 1)
101-
val headerSuffix = renderSecondsSuffix(now - startTimeMillis)
97+
val headerSuffix = mill.util.Util.renderSecondsSuffix(now - startTimeMillis)
10298

10399
val header = renderHeader(headerPrefix, titleText, headerSuffix, maxWidth)
104100

@@ -120,7 +116,7 @@ private object PromptLoggerUtil {
120116
status.next
121117
else status.prev
122118
textOpt.map { t =>
123-
val seconds = renderSecondsSuffix(now - t.startTimeMillis)
119+
val seconds = mill.util.Util.renderSecondsSuffix(now - t.startTimeMillis)
124120
val mainText = splitShorten(t.text + seconds, maxWidth)
125121

126122
val detail = splitShorten(spaceNonEmpty(t.detail), maxWidth - mainText.length)

‎main/util/src/mill/util/Util.scala

+5
Original file line numberDiff line numberDiff line change
@@ -105,4 +105,9 @@ object Util {
105105
def leftPad(s: String, targetLength: Int, char: Char): String = {
106106
char.toString * (targetLength - s.length) + s
107107
}
108+
109+
def renderSecondsSuffix(millis: Long): String = (millis / 1000).toInt match {
110+
case 0 => ""
111+
case n => s" ${n}s"
112+
}
108113
}

‎scalalib/src/mill/scalalib/TestModule.scala

+2
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@ trait TestModule
155155
Task.Anon {
156156
val mainClass = "mill.testrunner.entrypoint.TestRunnerMain"
157157
val outputPath = Task.dest / "out.json"
158+
val resultPath = Task.dest / "results.log"
158159
val selectors = Seq.empty
159160

160161
val testArgs = TestArgs(
@@ -163,6 +164,7 @@ trait TestModule
163164
arguments = args(),
164165
sysProps = Map.empty,
165166
outputPath = outputPath,
167+
resultPath = resultPath,
166168
colored = Task.log.colored,
167169
testCp = testClasspath().map(_.path),
168170
home = Task.home,

0 commit comments

Comments
 (0)