commit b67942f24b5923bf729bb82dc4a341f83af756a7 parent 85f0ba4460e7e7c22f8ff22083a3f881573f1c32 Author: Andrew Laack <andrew@laack.co> Date: Tue, 17 Nov 2026 11:00:55 -0600 Standardize outputs of executor Diffstat:
| M | ojudge/bin/executor.ml | | | 20 | +++++++++++++++++++- |
1 file changed, 19 insertions(+), 1 deletion(-)
diff --git a/ojudge/bin/executor.ml b/ojudge/bin/executor.ml @@ -40,8 +40,26 @@ let copyOcamlToTemp () = (* TODO: Handle failures *) let _ = execCmd "cp /code/main.ml /tmp/" in () + +(* + TODO: Define a type that describes the test status. + - success + - tle + - runtime error (RE?) + These are the only things that can happen here. + + None of them should stop subsequent execution though. +*) + +let printTestOutput st = + print_string ((string_of_int (String.length st)) ^ "\n" ^ st ^ "\n") + let runTest filename = - let output = execCmd ("cat /inputs/" ^ filename ^ "| /tmp/exe.out") in print_string (fst output) + let output = execCmd ("cat /inputs/" ^ filename ^ "| timeout 2 /tmp/exe.out") in + if (snd output) = 0 then + printTestOutput (fst output) + else + printTestOutput ("Failed with status code: " ^ (string_of_int (snd output))) let runTests () = let arr = Sys.readdir "/inputs" in