Add run-analysis helper script and tests
This commit is contained in:
parent
b1658d28ba
commit
2e7e75e4ce
3 changed files with 77 additions and 0 deletions
32
tests/test_run_analysis.py
Normal file
32
tests/test_run_analysis.py
Normal file
|
@ -0,0 +1,32 @@
|
|||
import os
|
||||
import subprocess
|
||||
from pathlib import Path
|
||||
|
||||
REPO_ROOT = Path(__file__).resolve().parents[1]
|
||||
SCRIPT = REPO_ROOT / "run-analysis.sh"
|
||||
|
||||
|
||||
def test_script_invokes_commands(tmp_path):
|
||||
# create stub virtualenv so the script skips creation
|
||||
venv = tmp_path / ".venv" / "bin"
|
||||
venv.mkdir(parents=True)
|
||||
(venv / "activate").write_text(":")
|
||||
|
||||
calls = tmp_path / "calls.txt"
|
||||
python_stub = tmp_path / "python"
|
||||
python_stub.write_text(f"#!/usr/bin/env bash\necho \"$*\" >> \"{calls}\"\n")
|
||||
python_stub.chmod(0o755)
|
||||
(tmp_path / "python3").write_text(f"#!/usr/bin/env bash\nexit 0\n")
|
||||
(tmp_path / "python3").chmod(0o755)
|
||||
|
||||
env = os.environ.copy()
|
||||
env["PATH"] = f"{tmp_path}:" + env.get("PATH", "")
|
||||
|
||||
subprocess.run([str(SCRIPT)], cwd=tmp_path, env=env, check=True)
|
||||
|
||||
lines = calls.read_text().strip().splitlines()
|
||||
assert lines == [
|
||||
"scripts/analyze.py check-missing-domains",
|
||||
"scripts/analyze.py suggest-cache",
|
||||
"scripts/analyze.py detect-threats",
|
||||
]
|
Loading…
Add table
Add a link
Reference in a new issue