parent
a74e6006f5
commit
f77875ed54
@ -0,0 +1,32 @@ |
|||||||
|
from typing import List, Optional |
||||||
|
|
||||||
|
|
||||||
|
def main(argv: Optional[List[str]] = None) -> int: |
||||||
|
"""CLI wrapper that delegates to scripts.mindmodel.validator.main. |
||||||
|
|
||||||
|
Returns the integer exit code from the delegated main. If the |
||||||
|
validator module is not available or raises, return a non-zero |
||||||
|
exit code. |
||||||
|
""" |
||||||
|
try: |
||||||
|
# Import here to avoid side-effects on module import |
||||||
|
from scripts.mindmodel import validator |
||||||
|
|
||||||
|
# Call the validator.main if present |
||||||
|
if hasattr(validator, "main"): |
||||||
|
result = validator.main(argv) |
||||||
|
# Ensure we return an int |
||||||
|
try: |
||||||
|
return int(result) # type: ignore |
||||||
|
except Exception: |
||||||
|
return 1 |
||||||
|
else: |
||||||
|
return 2 |
||||||
|
except Exception: |
||||||
|
# Import error or runtime error — return non-zero so callers |
||||||
|
# can detect failure (tests expect non-zero on missing manifest) |
||||||
|
return 2 |
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__": |
||||||
|
raise SystemExit(main()) |
||||||
@ -0,0 +1,14 @@ |
|||||||
|
import os |
||||||
|
|
||||||
|
|
||||||
|
def test_cli_with_nonexistent_manifest(): |
||||||
|
"""Calling cli.main with a non-existent manifest should return non-zero.""" |
||||||
|
from scripts.mindmodel import cli |
||||||
|
|
||||||
|
# Provide a path that is extremely unlikely to exist |
||||||
|
fake_manifest = "/this/path/does/not/exist/manifest.json" |
||||||
|
|
||||||
|
code = cli.main([fake_manifest]) |
||||||
|
|
||||||
|
assert isinstance(code, int) |
||||||
|
assert code != 0 |
||||||
Loading…
Reference in new issue