|
|
from pathlib import Path |
|
|
import tempfile |
|
|
from src.safe_subprocess import run |
|
|
|
|
|
LANG_NAME = "Scala" |
|
|
LANG_EXT = ".scala" |
|
|
|
|
|
def eval_script(path: Path): |
|
|
with tempfile.TemporaryDirectory() as outdir: |
|
|
|
|
|
|
|
|
|
|
|
build = run(["scalac", "-d", outdir, path], timeout_seconds=45) |
|
|
if build.exit_code != 0: |
|
|
|
|
|
|
|
|
return { |
|
|
"status": "SyntaxError", |
|
|
"exit_code": build.exit_code, |
|
|
"stdout": build.stdout, |
|
|
"stderr": build.stderr, |
|
|
} |
|
|
|
|
|
r = run(["scala", "-cp", f"{outdir}", "Problem"]) |
|
|
if r.timeout: |
|
|
status = "Timeout" |
|
|
elif r.exit_code == 0 and r.stderr == "": |
|
|
status = "OK" |
|
|
else: |
|
|
|
|
|
status = "Exception" |
|
|
return { |
|
|
"status": status, |
|
|
"exit_code": r.exit_code, |
|
|
"stdout": r.stdout, |
|
|
"stderr": r.stderr, |
|
|
} |
|
|
|