diff --git a/l4d2host/instances.py b/l4d2host/instances.py index 4b2285e..68aceb3 100644 --- a/l4d2host/instances.py +++ b/l4d2host/instances.py @@ -32,6 +32,7 @@ def initialize_instance( root = get_left4me_root() if root is None else Path(root) spec = load_spec(spec_path) + _emit_step("creating instance directories...", on_stdout, passthrough) instance_dir = root / "instances" / name runtime_dir = root / "runtime" / name (runtime_dir / "upper").mkdir(parents=True, exist_ok=True) @@ -42,6 +43,7 @@ def initialize_instance( lowerdirs = [str(overlay_path(overlay, root=root)) for overlay in spec.overlays] lowerdirs.append(str(root / "installation")) + _emit_step("writing instance.env...", on_stdout, passthrough) instance_env = "\n".join( [ f"L4D2_PORT={spec.port}", @@ -51,8 +53,10 @@ def initialize_instance( ) + "\n" (instance_dir / "instance.env").write_text(instance_env) + _emit_step("writing server.cfg...", on_stdout, passthrough) server_cfg = "\n".join(spec.config) if spec.config else "" (instance_dir / "server.cfg").write_text(server_cfg) + _emit_step("initialization complete.", on_stdout, passthrough) def _load_instance_env(path: Path) -> dict[str, str]: diff --git a/l4d2host/tests/test_initialize.py b/l4d2host/tests/test_initialize.py index 3252b98..303859f 100644 --- a/l4d2host/tests/test_initialize.py +++ b/l4d2host/tests/test_initialize.py @@ -51,3 +51,17 @@ def test_emit_step_uses_passthrough_stdout(monkeypatch) -> None: def test_emit_step_does_nothing_if_no_target() -> None: _emit_step("silent step", on_stdout=None, passthrough=False) + +def test_initialize_instance_emits_steps(tmp_path: Path) -> None: + spec = tmp_path / "spec.yaml" + spec.write_text("port: 27015\noverlays: [standard]\n") + + steps: list[str] = [] + initialize_instance("alpha", spec, root=tmp_path, on_stdout=steps.append) + + assert steps == [ + "Step: creating instance directories...", + "Step: writing instance.env...", + "Step: writing server.cfg...", + "Step: initialization complete.", + ]