39 lines
1.5 KiB
Python
39 lines
1.5 KiB
Python
#!/usr/bin/env python3
|
|
"""Final verification for json_syntax_checker.py artifact."""
|
|
|
|
import subprocess
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
def run_check():
|
|
validator = Path("/root/troupe-standup/wizard-work/spark/json_syntax_checker.py")
|
|
valid_test = Path("/root/troupe-standup/wizard-work/spark/ts_valid_demo.json")
|
|
invalid_test = Path("/root/troupe-standup/wizard-work/spark/ts_invalid_demo.json")
|
|
|
|
# Test 1: Valid JSON should return exit code 0
|
|
result = subprocess.run(["python3", str(validator), str(valid_test)], capture_output=True)
|
|
if result.returncode != 0:
|
|
print(f"FAIL: Valid JSON returned {result.returncode}")
|
|
return False
|
|
print("PASS: Valid JSON accepted")
|
|
|
|
# Test 2: Invalid JSON should return exit code 1
|
|
result = subprocess.run(["python3", str(validator), str(invalid_test)], capture_output=True)
|
|
if result.returncode != 1:
|
|
print(f"FAIL: Invalid JSON returned {result.returncode}")
|
|
return False
|
|
print("PASS: Invalid JSON rejected")
|
|
|
|
# Test 3: Non-existent file should return exit code 1
|
|
result = subprocess.run(["python3", str(validator), "/nonexistent.json"], capture_output=True)
|
|
if result.returncode != 1:
|
|
print(f"FAIL: Non-existent file returned {result.returncode}")
|
|
return False
|
|
print("PASS: Non-existent file rejected")
|
|
|
|
print("\nAll verification checks passed!")
|
|
return True
|
|
|
|
if __name__ == "__main__":
|
|
success = run_check()
|
|
sys.exit(0 if success else 1) |