Skip to content

Comments

Fix for Issue #2559#2696

Closed
cdandeneau wants to merge 3 commits intobeeware:mainfrom
cdandeneau:WarningMessageHelper
Closed

Fix for Issue #2559#2696
cdandeneau wants to merge 3 commits intobeeware:mainfrom
cdandeneau:WarningMessageHelper

Conversation

@cdandeneau
Copy link

Summary

This PR introduces a reusable helper for formatting boxed console messages and migrates the JAVA_HOME warnings in the Java integration to use it.

What changed

  • Added format_message_box(message, title=None) in briefcase.console to:

    • generate consistently sized *-border boxes,
    • support an optional title line,
    • wrap and indent body text automatically.
  • Replaced two manually aligned triple-quoted warning blocks in JDK.verify_install() with format_message_box():

    1. JAVA_HOME points to the wrong Java major version.
    2. JAVA_HOME does not point to a JDK.
  • Added tests for the helper to verify:

    • title alignment with borders,
    • wrapped/indented body content formatting.

Why

This avoids brittle hand-spacing in warning strings, keeps surrounding code indentation clean, and makes variable-content warnings (like Java versions/paths) format correctly without manual padding.

Testing

  • ruff check src/briefcase/console.py src/briefcase/integrations/java.py tests/console/test_format_message_box.py
  • pytest -q tests/console/test_format_message_box.py
  • pytest -q tests/integrations/java/test_JDK__verify.py

Issue

Fixes #2559.

Fix inconsistent indentation and fragile hand-aligned triple-quoted warning blocks by centralizing boxed message formatting.
Make it easier to construct warning text with variable content (e.g. Java version strings) without manual spacing hacks.
Description
Add format_message_box(message, title=None) to briefcase.console to produce star-bordered boxed messages with consistent border width, optional title, and wrapped/indented body text.
Replace two JAVA_HOME warning branches in JDK.verify_install() (wrong major version and JAVA_HOME does not point to a JDK) to use format_message_box() instead of large triple-quoted strings.
Add unit tests for the helper in tests/console/test_format_message_box.py to validate title alignment and content wrapping.
Testing
python -m compileall on modified files succeeded.
ruff checks on src/briefcase/console.py, src/briefcase/integrations/java.py, and the new test file passed.
pytest runs were attempted; running the integration test set was blocked by the test environment lacking project package metadata and a test dependency (httpx_retries), so full pytest validation could not be completed in this environment.
The changes are intentionally applied to a subset of warning sites (Java integration) to demonstrate the helper; further conversions can follow in subsequent PRs.
@freakboy3742
Copy link
Member

Thanks for the PR, but I'm going to close this.

Firstly - there's an existing PR in flight for this issue (#2563) that is nearing completion. The discussion history of #2559 points this out. It would not be fair to the original contributor to void their work by accepting this PR.

Secondly - the implementation has some interesting choices, including the introduction of a submodule for no obvious reason.

Lastly - it has included an empty changenote. That's not what our contribution guide requests.

I have reason to suspect that this PR has been generated with the assistance of an LLM. We don't prohibit the use of LLMs, but we do ask that you declare when they are used so that we are able to make an assessment on the provenance of the code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add helper for formatting long warning messages

2 participants