test: fix test_cli_validate_exit_code to use --manifest flag and assert specific exit code

Pass manifest path via --manifest flag (required) instead of as a
positional argument, so the test exercises cmd_validate rather than
argparse error handling.  Also assert returncode==1 and check stderr
for the FAILED/error message to prevent false positives.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
supermario_leo
2026-04-24 10:15:57 +08:00
parent 4509becfde
commit 29577d57f8
+5 -3
View File
@@ -238,13 +238,15 @@ class TestValidateManifest:
assert any("ref_audio file not found" in w for w in result.warnings)
def test_cli_validate_exit_code(self, tmp_dir):
"""validate subcommand must exit non-zero on error."""
"""validate subcommand must exit 1 on validation error (missing audio)."""
import subprocess
manifest = tmp_dir / "bad.jsonl"
_write_manifest(manifest, [{"text": "hi", "audio": "/nonexistent/x.wav"}])
proc = subprocess.run(
[sys.executable, "-m", "voxcpm.cli", "validate", str(manifest)],
[sys.executable, "-m", "voxcpm.cli", "validate", "--manifest", str(manifest)],
capture_output=True,
text=True,
)
assert proc.returncode != 0
assert proc.returncode == 1, f"Expected exit 1, got {proc.returncode}"
assert "FAILED" in proc.stderr or "Audio file not found" in proc.stderr