| from pathlib import Path | |
| from src.safe_subprocess import run | |
| # 0 β success | |
| # 1 β invalid command-line arguments | |
| # 2 β syntax, parse, or name or type resolution errors | |
| # 3 β compilation errors | |
| # 4 β verification errors | |
| def eval_script(path: Path): | |
| r = run(["dafny", "run", str(path)]) | |
| if r.timeout: | |
| status = "Timeout" | |
| elif r.exit_code == 0: | |
| status = "OK" | |
| elif r.exit_code == 2: | |
| status = "SyntaxError" | |
| elif r.exit_code == 3: | |
| status = "CompilationError" | |
| elif r.exit_code == 4: | |
| status = "VerificationError" | |
| else: | |
| status = "Exception" | |
| return { | |
| "status": status, | |
| "exit_code": r.exit_code, | |
| "stdout": r.stdout, | |
| "stderr": r.stderr, | |
| } | |