Implemented invocation-level failure diagnostics
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import os
|
||||
import shutil
|
||||
import subprocess
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
@@ -29,3 +30,46 @@ def test_root_launcher_help_smoke():
|
||||
|
||||
assert result.returncode == 0
|
||||
assert result.stdout.startswith("usage: audita ")
|
||||
|
||||
|
||||
def test_root_launcher_writes_error_log_when_uv_is_missing(tmp_path):
|
||||
work_dir = tmp_path / "work"
|
||||
result = subprocess.run(
|
||||
[sys.executable, str(LAUNCHER), "process", "transcript.json", "--glossary", "glossary.yaml", "--work-dir", str(work_dir)],
|
||||
cwd=ROOT,
|
||||
text=True,
|
||||
capture_output=True,
|
||||
env={**os.environ, "PATH": ""},
|
||||
check=False,
|
||||
)
|
||||
|
||||
assert result.returncode == 1
|
||||
assert result.stdout == ""
|
||||
assert "audita: error: uv is required to run this launcher" in result.stderr
|
||||
run_dir = next(work_dir.iterdir())
|
||||
assert f"audita: run directory: {run_dir}" in result.stderr
|
||||
assert (run_dir / "error.log").exists()
|
||||
|
||||
|
||||
def test_root_launcher_preserves_child_exit_code_and_writes_fallback_error_log(tmp_path):
|
||||
work_dir = tmp_path / "work"
|
||||
fake_bin = tmp_path / "bin"
|
||||
fake_bin.mkdir()
|
||||
fake_uv = fake_bin / "uv"
|
||||
fake_uv.write_text("#!/bin/sh\nexit 120\n", encoding="utf-8")
|
||||
fake_uv.chmod(0o755)
|
||||
|
||||
result = subprocess.run(
|
||||
[sys.executable, str(LAUNCHER), "process", "transcript.json", "--glossary", "glossary.yaml", "--work-dir", str(work_dir)],
|
||||
cwd=ROOT,
|
||||
text=True,
|
||||
capture_output=True,
|
||||
env={**os.environ, "PATH": str(fake_bin)},
|
||||
check=False,
|
||||
)
|
||||
|
||||
assert result.returncode == 120
|
||||
assert result.stdout == ""
|
||||
assert "audita: subprocess exited with status 120" in result.stderr
|
||||
run_dir = next(work_dir.iterdir())
|
||||
assert (run_dir / "error.log").exists()
|
||||
|
||||
Reference in New Issue
Block a user