ojudge

A self-hosted competitive programming site written in OCaml
git clone git://git.laack.co/ojudge.git
Log | Files | Refs | README

commit 7b930daef65e258228f1e1f53eaa008bc62eda01
parent b67942f24b5923bf729bb82dc4a341f83af756a7
Author: Andrew Laack <andrew@laack.co>
Date:   Tue, 17 Nov 2026 11:13:19 -0600

Include new lines in count, add newlines for styling (to be stripped by the judge)

Diffstat:
Mojudge/bin/executor.ml | 19+++++++++++++------
1 file changed, 13 insertions(+), 6 deletions(-)

diff --git a/ojudge/bin/executor.ml b/ojudge/bin/executor.ml @@ -18,6 +18,7 @@ Since these mounts are read only we are expected to: - 0 - 1 - COMPILE ERROR - 2 - TLE + - 3 - RUNTIME ERROR - (there will likely be more in the future) - Print a space - Print the size of the test execution's output in bytes @@ -51,15 +52,21 @@ let copyOcamlToTemp () = None of them should stop subsequent execution though. *) -let printTestOutput st = - print_string ((string_of_int (String.length st)) ^ "\n" ^ st ^ "\n") +let printTestOutput st statusCode = + if statusCode = 0 then + (* We add one to include the \n which should be stripped. This is mostly there for debuggability *) + print_string ("0 " ^(string_of_int ((String.length st)+1)) ^ "\n" ^ st ^ "\n") + else if statusCode = 124 + then + let tleText = "TLE on test case." in + print_string ("2 " ^(string_of_int ((String.length tleText)+1)) ^ "\n" ^ tleText ^ "\n") + else + let runtimeError = ("RE on test case: " ^ st) in + print_string ("3 " ^ (string_of_int ((String.length runtimeError)+1)) ^ "\n" ^ runtimeError ^ "\n") let runTest filename = 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))) + printTestOutput (fst output) (snd output) let runTests () = let arr = Sys.readdir "/inputs" in