refactor(cli): rename vmgui command to vmware

Rename the GUI launcher command from `vmgui` to `vmware` (`ci vmware ...`).
Updates the click command name, function, log-file prefix, __main__
registration, tests and runbook references. Behaviour unchanged.
This commit is contained in:
2026-06-08 00:32:13 +02:00
parent b74e854d48
commit de5348c36c
4 changed files with 45 additions and 45 deletions
+26 -26
View File
@@ -499,11 +499,11 @@ def test_vm_cleanup_backend_unavailable(monkeypatch: pytest.MonkeyPatch, tmp_pat
assert "vmrun not available" in result.output
# ── vmgui ───────────────────────────────────────────────────────────────────
# ── vmware ───────────────────────────────────────────────────────────────────
class _FakeProc:
"""Minimal subprocess.Popen stand-in for vmgui tests."""
"""Minimal subprocess.Popen stand-in for vmware GUI tests."""
def __init__(self, pid: int = 4242, rc: int | None = None) -> None:
self.pid = pid
@@ -533,68 +533,68 @@ def _capture_launch(
return captured
def test_vmgui_missing_vmx_errors(tmp_path: Path) -> None:
result = CliRunner().invoke(cli, ["vmgui", "--vmx", str(tmp_path / "nope.vmx")])
def test_vmware_missing_vmx_errors(tmp_path: Path) -> None:
result = CliRunner().invoke(cli, ["vmware", "--vmx", str(tmp_path / "nope.vmx")])
assert result.exit_code != 0
assert "VMX file not found" in result.output
def test_vmgui_happy_path(monkeypatch: pytest.MonkeyPatch, tmp_path: Path) -> None:
def test_vmware_happy_path(monkeypatch: pytest.MonkeyPatch, tmp_path: Path) -> None:
vmx = tmp_path / "clone.vmx"
vmx.write_text("config")
cap = _capture_launch(monkeypatch)
monkeypatch.setenv("DISPLAY", ":0")
result = CliRunner().invoke(cli, ["vmgui", "--vmx", str(vmx)])
result = CliRunner().invoke(cli, ["vmware", "--vmx", str(vmx)])
assert result.exit_code == 0, result.output
assert cap["argv"][-1] == str(vmx)
assert "-x" not in cap["argv"] and "-X" not in cap["argv"]
assert "pid 4242" in result.output
def test_vmgui_power_on_adds_x(monkeypatch: pytest.MonkeyPatch, tmp_path: Path) -> None:
def test_vmware_power_on_adds_x(monkeypatch: pytest.MonkeyPatch, tmp_path: Path) -> None:
vmx = tmp_path / "clone.vmx"
vmx.write_text("config")
cap = _capture_launch(monkeypatch)
monkeypatch.setenv("DISPLAY", ":0")
result = CliRunner().invoke(cli, ["vmgui", "--vmx", str(vmx), "--power-on"])
result = CliRunner().invoke(cli, ["vmware", "--vmx", str(vmx), "--power-on"])
assert result.exit_code == 0, result.output
assert "-x" in cap["argv"]
def test_vmgui_fullscreen_adds_capital_x(monkeypatch: pytest.MonkeyPatch, tmp_path: Path) -> None:
def test_vmware_fullscreen_adds_capital_x(monkeypatch: pytest.MonkeyPatch, tmp_path: Path) -> None:
vmx = tmp_path / "clone.vmx"
vmx.write_text("config")
cap = _capture_launch(monkeypatch)
monkeypatch.setenv("DISPLAY", ":0")
result = CliRunner().invoke(
cli, ["vmgui", "--vmx", str(vmx), "--fullscreen", "--new-window"]
cli, ["vmware", "--vmx", str(vmx), "--fullscreen", "--new-window"]
)
assert result.exit_code == 0, result.output
assert "-X" in cap["argv"] and "-n" in cap["argv"]
def test_vmgui_display_option_overrides_env(monkeypatch: pytest.MonkeyPatch, tmp_path: Path) -> None:
def test_vmware_display_option_overrides_env(monkeypatch: pytest.MonkeyPatch, tmp_path: Path) -> None:
vmx = tmp_path / "clone.vmx"
vmx.write_text("config")
cap = _capture_launch(monkeypatch)
monkeypatch.delenv("DISPLAY", raising=False)
result = CliRunner().invoke(cli, ["vmgui", "--vmx", str(vmx), "--display", ":1"])
result = CliRunner().invoke(cli, ["vmware", "--vmx", str(vmx), "--display", ":1"])
assert result.exit_code == 0, result.output
assert cap["env"]["DISPLAY"] == ":1"
assert "display=:1" in result.output
def test_vmgui_errors_without_display(monkeypatch: pytest.MonkeyPatch, tmp_path: Path) -> None:
def test_vmware_errors_without_display(monkeypatch: pytest.MonkeyPatch, tmp_path: Path) -> None:
vmx = tmp_path / "clone.vmx"
vmx.write_text("config")
_capture_launch(monkeypatch)
monkeypatch.delenv("DISPLAY", raising=False)
result = CliRunner().invoke(cli, ["vmgui", "--vmx", str(vmx)])
result = CliRunner().invoke(cli, ["vmware", "--vmx", str(vmx)])
assert result.exit_code != 0
assert "no X display" in result.output
def test_vmgui_preflight_failure_reports_xhost(monkeypatch: pytest.MonkeyPatch, tmp_path: Path) -> None:
def test_vmware_preflight_failure_reports_xhost(monkeypatch: pytest.MonkeyPatch, tmp_path: Path) -> None:
vmx = tmp_path / "clone.vmx"
vmx.write_text("config")
_capture_launch(monkeypatch)
@@ -603,35 +603,35 @@ def test_vmgui_preflight_failure_reports_xhost(monkeypatch: pytest.MonkeyPatch,
vm_module, "_x_display_reachable", lambda _env: (False, "cannot open display :0")
)
monkeypatch.setenv("DISPLAY", ":0")
result = CliRunner().invoke(cli, ["vmgui", "--vmx", str(vmx)])
result = CliRunner().invoke(cli, ["vmware", "--vmx", str(vmx)])
assert result.exit_code != 0
assert "xhost +SI:localuser:ci-runner" in result.output
def test_vmgui_drops_unreadable_xauthority(monkeypatch: pytest.MonkeyPatch, tmp_path: Path) -> None:
def test_vmware_drops_unreadable_xauthority(monkeypatch: pytest.MonkeyPatch, tmp_path: Path) -> None:
vmx = tmp_path / "clone.vmx"
vmx.write_text("config")
cap = _capture_launch(monkeypatch)
monkeypatch.setenv("DISPLAY", ":0")
monkeypatch.setenv("XAUTHORITY", str(tmp_path / "missing.Xauthority"))
result = CliRunner().invoke(cli, ["vmgui", "--vmx", str(vmx)])
result = CliRunner().invoke(cli, ["vmware", "--vmx", str(vmx)])
assert result.exit_code == 0, result.output
assert "XAUTHORITY" not in cap["env"]
assert "dropping unreadable XAUTHORITY" in result.output
def test_vmgui_immediate_exit_surfaces_log(monkeypatch: pytest.MonkeyPatch, tmp_path: Path) -> None:
def test_vmware_immediate_exit_surfaces_log(monkeypatch: pytest.MonkeyPatch, tmp_path: Path) -> None:
vmx = tmp_path / "clone.vmx"
vmx.write_text("config")
_capture_launch(monkeypatch, rc=1)
monkeypatch.setenv("DISPLAY", ":0")
result = CliRunner().invoke(cli, ["vmgui", "--vmx", str(vmx)])
result = CliRunner().invoke(cli, ["vmware", "--vmx", str(vmx)])
assert result.exit_code != 0
assert "exited immediately" in result.output
assert "cannot open display" in result.output
def test_vmgui_launch_oserror_is_reported(monkeypatch: pytest.MonkeyPatch, tmp_path: Path) -> None:
def test_vmware_launch_oserror_is_reported(monkeypatch: pytest.MonkeyPatch, tmp_path: Path) -> None:
vmx = tmp_path / "clone.vmx"
vmx.write_text("config")
@@ -642,25 +642,25 @@ def test_vmgui_launch_oserror_is_reported(monkeypatch: pytest.MonkeyPatch, tmp_p
monkeypatch.setattr(vm_module, "_x_display_reachable", lambda _env: (True, ""))
monkeypatch.setattr(vm_module.time, "sleep", lambda _s: None)
monkeypatch.setenv("DISPLAY", ":0")
result = CliRunner().invoke(cli, ["vmgui", "--vmx", str(vmx)])
result = CliRunner().invoke(cli, ["vmware", "--vmx", str(vmx)])
assert result.exit_code != 0
assert "failed to launch VMware GUI" in result.output
def test_vmgui_without_vmx_launches_bare_gui(monkeypatch: pytest.MonkeyPatch) -> None:
def test_vmware_without_vmx_launches_bare_gui(monkeypatch: pytest.MonkeyPatch) -> None:
cap = _capture_launch(monkeypatch)
monkeypatch.setenv("DISPLAY", ":0")
result = CliRunner().invoke(cli, ["vmgui"])
result = CliRunner().invoke(cli, ["vmware"])
assert result.exit_code == 0, result.output
assert cap["argv"][1:] == [] or cap["argv"][1:] == ["-n"]
assert "-x" not in cap["argv"] and "-X" not in cap["argv"]
assert "pid 4242" in result.output
def test_vmgui_power_on_ignored_without_vmx(monkeypatch: pytest.MonkeyPatch) -> None:
def test_vmware_power_on_ignored_without_vmx(monkeypatch: pytest.MonkeyPatch) -> None:
cap = _capture_launch(monkeypatch)
monkeypatch.setenv("DISPLAY", ":0")
result = CliRunner().invoke(cli, ["vmgui", "--power-on"])
result = CliRunner().invoke(cli, ["vmware", "--power-on"])
assert result.exit_code == 0, result.output
assert "-x" not in cap["argv"]
assert "ignored without --vmx" in result.output