diff --git a/manage.sh b/manage.sh index ba2ade4..8360008 100755 --- a/manage.sh +++ b/manage.sh @@ -1550,7 +1550,7 @@ UPGRADEEOF fi echo "✓ Configuration preserved" if [[ -n "$container_note" ]]; then - echo "$container_note" + printf '%b\n' "$container_note" fi else show_info "Upgrade Complete" "Upgrade completed successfully!\n\nVersion: $current_version → $new_version\n\n✓ Configuration preserved${container_note}" diff --git a/tests/test_manage_upgrade_output.py b/tests/test_manage_upgrade_output.py new file mode 100644 index 0000000..0ddc228 --- /dev/null +++ b/tests/test_manage_upgrade_output.py @@ -0,0 +1,46 @@ +"""Exercise the upgrade summary without running installation/service commands.""" + +import os +import subprocess +from pathlib import Path + +import pytest + + +@pytest.mark.parametrize("service_running", [0, 1]) +def test_silent_upgrade_container_warning_renders_newlines(service_running): + script = (Path(__file__).resolve().parents[1] / "manage.sh").read_text() + start = script.index(' local container_note=""') + end = script.index("\n return 0\n}", start) + summary = script[start:end] + # The nonempty container variable selects the warning without depending on + # the test host. Only the final output block runs, not manage.sh itself. + probe = ( + "set -eu\nrender() {\n" + "local silent=true container=test current_version=old new_version=new\n" + f"local service_was_running={service_running} service_was_enabled=0\n" + f"{summary}\n}}\nrender\n" + ) + env = os.environ.copy() + env.pop("BASH_ENV", None) + result = subprocess.run( + ["bash", "--noprofile", "--norc"], + input=probe, + text=True, + capture_output=True, + check=True, + env=env, + ) + expected = "Upgrade completed successfully!\nVersion: old -> new\n" + if service_running: + expected += "✓ Service is running\n" + expected += ( + "✓ Configuration preserved\n\n\n" + "⚠ CONTAINER DETECTED:\n" + "USB udev rules must be set on the HOST, not here.\n" + "CH341 host-side setup: " + "https://docs.openhop.dev/projects/openhop-repeater/hardware-setup/#ch341-usb-spi-hosts\n" + "=== Upgrade Complete ===\n" + ) + assert result.stdout == expected + assert result.stderr == ""