Skip to content

SOLR-18281 Make PackageManager testable by printing to console through ToolRuntime#4502

Merged
janhoy merged 2 commits into
apache:mainfrom
janhoy:SOLR-18281-packagemgr-test-fix
Jun 7, 2026
Merged

SOLR-18281 Make PackageManager testable by printing to console through ToolRuntime#4502
janhoy merged 2 commits into
apache:mainfrom
janhoy:SOLR-18281-packagemgr-test-fix

Conversation

@janhoy
Copy link
Copy Markdown
Contributor

@janhoy janhoy commented Jun 6, 2026

https://issues.apache.org/jira/browse/SOLR-18281

  • Adds printSuccess() and printError() to ToolRuntime (which prints green/red ANSI text)
  • Replace Pkgmgr printGreen() with runtime.printSuccess() and printRed() with runtime.printError()

This insulates the PackageManager from raw console output by using the ToolRuntime properly.

And this makes the new PackateToolTest.testDeployValidationMessages() assert tool output as designed.

…rough ToolRuntime

Replace the last two PackageUtils.print() call sites in PackageManager
with runtime.print()/printSuccess()/printError(), then delete the
now-unused method and its @SuppressForbidden System.out usage.
Also replace duplicate RESET constant in PackageUtils.format() with
CLIUtils.RESET.
Copy link
Copy Markdown
Contributor

@dsmiley dsmiley left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the packagemanager changes. But I don't claim to be a good reviewer to CLI stuff so take my approval with a grain of salt.


public static String YELLOW = "\u001B[33m";

public static String RESET = "\u001B[0m";
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what are these codes? I have no clue here

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the implication of my question is we need a comment with a URL

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are ANSI terminal codes, a standard way to provide colored terminal output. For some reason Package manager uses colored output 🙈

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When we did the last pass of the CLI, this jumped out at me as something to rethink in the future. Maybe as part of the picocli migration we drop this (or double down and embrace it everywhere!).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree. I'm also sure there exists a java library for TUI (Terminal User Interface) hanlding, if we want to properlty handle color, user input etc.

But I think perhaps we instead should stick to plain ASCII output as you say... Let's remember to cycle back to this..

@janhoy janhoy merged commit d3886f7 into apache:main Jun 7, 2026
5 of 6 checks passed
@janhoy janhoy deleted the SOLR-18281-packagemgr-test-fix branch June 7, 2026 01:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants