mirror of
https://github.com/dredx/prole.git
synced 2026-09-23 11:03:59 +00:00
31 lines
1000 B
Python
31 lines
1000 B
Python
from __future__ import annotations
|
|
|
|
from pathlib import Path
|
|
|
|
|
|
def test_controller_run_script_expands_shell_vars(monkeypatch, tmp_path: Path):
|
|
"""Regression: `run_script` must expand `$HOME`/`$KNOE_HOME` before mkdir/copy.
|
|
|
|
Without this, setting `KNOE_HOME=$HOME/knoe` can create a literal `$HOME`
|
|
directory in the current working directory.
|
|
"""
|
|
|
|
monkeypatch.chdir(tmp_path)
|
|
|
|
home_dir = tmp_path / "home"
|
|
home_dir.mkdir(parents=True, exist_ok=True)
|
|
monkeypatch.setenv("HOME", str(home_dir))
|
|
|
|
proj = tmp_path / "project_root"
|
|
(proj / "etc").mkdir(parents=True, exist_ok=True)
|
|
(proj / "etc" / "dummy.sh").write_text("#!/usr/bin/env bash\necho ok\n")
|
|
|
|
from knoe.core.controller import KnoeController
|
|
|
|
controller = KnoeController(project_root=proj)
|
|
rc = controller.run_script("dummy.sh", env={"KNOE_HOME": "$HOME/knoe"})
|
|
assert rc == 0
|
|
|
|
assert (home_dir / "knoe" / "etc" / "dummy.sh").is_file()
|
|
assert not (tmp_path / "$HOME").exists()
|