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:
@@ -238,13 +238,15 @@ class TestValidateManifest:
|
|||||||
assert any("ref_audio file not found" in w for w in result.warnings)
|
assert any("ref_audio file not found" in w for w in result.warnings)
|
||||||
|
|
||||||
def test_cli_validate_exit_code(self, tmp_dir):
|
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
|
import subprocess
|
||||||
manifest = tmp_dir / "bad.jsonl"
|
manifest = tmp_dir / "bad.jsonl"
|
||||||
_write_manifest(manifest, [{"text": "hi", "audio": "/nonexistent/x.wav"}])
|
_write_manifest(manifest, [{"text": "hi", "audio": "/nonexistent/x.wav"}])
|
||||||
|
|
||||||
proc = subprocess.run(
|
proc = subprocess.run(
|
||||||
[sys.executable, "-m", "voxcpm.cli", "validate", str(manifest)],
|
[sys.executable, "-m", "voxcpm.cli", "validate", "--manifest", str(manifest)],
|
||||||
capture_output=True,
|
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
|
||||||
|
|||||||
Reference in New Issue
Block a user