Skip to content

Test runner indicators backport #4756

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Mar 22, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 2 additions & 6 deletions main/util/src/mill/util/PromptLoggerUtil.scala
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,6 @@ private object PromptLoggerUtil {
(AnsiNav.clearScreen(0) + AnsiNav.up(1) + "\n").getBytes

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

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

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

Expand All @@ -120,7 +116,7 @@ private object PromptLoggerUtil {
status.next
else status.prev
textOpt.map { t =>
val seconds = renderSecondsSuffix(now - t.startTimeMillis)
val seconds = mill.util.Util.renderSecondsSuffix(now - t.startTimeMillis)
val mainText = splitShorten(t.text + seconds, maxWidth)

val detail = splitShorten(spaceNonEmpty(t.detail), maxWidth - mainText.length)
Expand Down
5 changes: 5 additions & 0 deletions main/util/src/mill/util/Util.scala
Original file line number Diff line number Diff line change
Expand Up @@ -105,4 +105,9 @@ object Util {
def leftPad(s: String, targetLength: Int, char: Char): String = {
char.toString * (targetLength - s.length) + s
}

def renderSecondsSuffix(millis: Long): String = (millis / 1000).toInt match {
case 0 => ""
case n => s" ${n}s"
}
}
2 changes: 2 additions & 0 deletions scalalib/src/mill/scalalib/TestModule.scala
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ trait TestModule
Task.Anon {
val mainClass = "mill.testrunner.entrypoint.TestRunnerMain"
val outputPath = Task.dest / "out.json"
val resultPath = Task.dest / "results.log"
val selectors = Seq.empty

val testArgs = TestArgs(
Expand All @@ -163,6 +164,7 @@ trait TestModule
arguments = args(),
sysProps = Map.empty,
outputPath = outputPath,
resultPath = resultPath,
colored = Task.log.colored,
testCp = testClasspath().map(_.path),
home = Task.home,
Expand Down
Loading
Loading