From 0ab266861a34feb576ff8872123b97a366d8359d Mon Sep 17 00:00:00 2001 From: Hassan Abouelela Date: Wed, 2 Jun 2021 04:17:52 +0300 Subject: Reports All Unittest Failure Reasons Records the reason of failure for non-zero exit codes. Signed-off-by: Hassan Abouelela --- backend/routes/forms/submit.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'backend/routes/forms/submit.py') diff --git a/backend/routes/forms/submit.py b/backend/routes/forms/submit.py index 97cf2ac..fe2abd5 100644 --- a/backend/routes/forms/submit.py +++ b/backend/routes/forms/submit.py @@ -178,8 +178,15 @@ class SubmitForm(Route): } if test.return_code == 0: - test_names = [] if test.passed else test.result.split(";") - response_obj.response[test.question_id]["failures"] = test_names + failure_names = [] if test.passed else test.result.split(";") + elif test.return_code == 5: + failure_names = ["Could not parse user code."] + elif test.return_code == 6: + failure_names = ["Could not load user code."] + else: + failure_names = ["Internal error."] + + response_obj.response[test.question_id]["failures"] = failure_names # Report a failure on internal errors, # or if the test suite doesn't allow failures -- cgit v1.2.3