Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix failing tests. #55

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions cms/grading/scoretypes/abc.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,11 @@ def __init__(self, parameters, public_testcases):
if hasattr(self, "score_column_headers"):
self.public_score_header, self.private_score_header = \
self.score_column_headers()
else:
# HTML templates require these to be set; otherwise, the server crashes.
# As we only ever use SubtaskGroup, it is not clear whether this makes sense:
self.public_score_header = "Sample Score"
self.private_score_header = "Actual Score"
except Exception as e:
raise ValueError(
"Unable to instantiate score type (probably due to invalid "
Expand Down
5 changes: 3 additions & 2 deletions cms/grading/tasktypes/Communication.py
Original file line number Diff line number Diff line change
Expand Up @@ -384,8 +384,9 @@ def evaluate(self, job, file_cacher):
if self._uses_fifos():
args.extend([sandbox_fifo_manager_to_user[i],
sandbox_fifo_user_to_manager[i]])
stdin_redirect = sandbox_fifo_manager_to_user[i]
stdout_redirect = sandbox_fifo_user_to_manager[i]
else:
stdin_redirect = sandbox_fifo_manager_to_user[i]
stdout_redirect = sandbox_fifo_user_to_manager[i]
if self.num_processes != 1:
args.append(str(i))
if self._uses_stub():
Expand Down
8 changes: 4 additions & 4 deletions cmscontrib/updaters/update_29.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,15 @@ def run(self):
json.loads(v["score_type_parameters"])

if v["_class"] == "SubmissionResult":
if v["score_details"] is not None:
if v.get("score_details") is not None:
v["score_details"] = json.loads(v["score_details"])
if v["public_score_details"] is not None:
if v.get("public_score_details") is not None:
v["public_score_details"] = \
json.loads(v["public_score_details"])
if v["unit_test_score_details"] is not None:
if v.get("unit_test_score_details") is not None:
v["unit_test_score_details"] = \
json.loads(v["unit_test_score_details"])
if v["ranking_score_details"] is not None:
if v.get("ranking_score_details") is not None:
v["ranking_score_details"] = \
json.loads(v["ranking_score_details"])
v["compilation_text"] = fix_text(v["compilation_text"])
Expand Down
4 changes: 3 additions & 1 deletion cmstestsuite/RunFunctionalTests.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,9 @@ def main():
write_test_case_list(
[(test, lang) for test, lang, _ in failures],
FAILED_TEST_FILENAME)
except TestException:
except TestException as e:
print("\n\n===== FAILURE =====")
print(e)
if os.path.exists("./log/cms/last.log"):
print("\n\n===== START OF LOG DUMP =====\n\n")
with open("./log/cms/last.log", "rt", encoding="utf-8") as f:
Expand Down
16 changes: 16 additions & 0 deletions cmstestsuite/functionaltestframework.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,14 @@ def add_contest(self, **kwargs):
page)
if match is not None:
contest_id = int(match.groups()[0])

#Query for group ID of the 'default' group
r = self.admin_req('contest/%s/users' % contest_id)
g = re.search(r'<select name="group_id">\s+<option value="null" selected>Select a group</option>\s+<option value="([0-9]+)">\s+default\s+</option>\s+</select>', r.text)
if g:
kwargs["main_group_id"] = int(g.group(1))
else:
raise TestException("Unable to find any group.")
self.admin_req('contest/%s' % contest_id, args=kwargs)
return contest_id
else:
Expand Down Expand Up @@ -288,6 +296,14 @@ def add_user(self, **kwargs):
else:
raise TestException("Unable to create user.")

#Query for group ID of the 'default' group
r = self.admin_req('contest/%s/users' % kwargs["contest_id"])
g = re.search(r'<select name="group_id">\s+<option value="null" selected>Select a group</option>\s+<option value="([0-9]+)">\s+default\s+</option>\s+</select>', r.text)
if g:
kwargs["group_id"] = int(g.group(1))
else:
raise TestException("Unable to find any group.")

kwargs["user_id"] = user_id
r = self.admin_req('contest/%s/users/add' % kwargs["contest_id"],
args=kwargs)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -371,8 +371,9 @@ def test_single_process_success(self):
sandbox_mgr.create_file_from_storage.assert_has_calls([
call("manager", "digest of manager", executable=True),
call("input.txt", "digest of input"),
call("ok.txt", "digest of correct output"),
], any_order=True)
self.assertEqual(sandbox_mgr.create_file_from_storage.call_count, 2)
self.assertEqual(sandbox_mgr.create_file_from_storage.call_count, 3)
sandbox_usr.create_file_from_storage.assert_has_calls([
call("foo", "digest of foo", executable=True),
], any_order=True)
Expand Down Expand Up @@ -617,8 +618,9 @@ def test_many_processes_success(self):
sandbox_mgr.create_file_from_storage.assert_has_calls([
call("manager", "digest of manager", executable=True),
call("input.txt", "digest of input"),
call("ok.txt", "digest of correct output"),
], any_order=True)
self.assertEqual(sandbox_mgr.create_file_from_storage.call_count, 2)
self.assertEqual(sandbox_mgr.create_file_from_storage.call_count, 3)
# Same content in both user sandboxes.
for s in [sandbox_usr0, sandbox_usr1]:
s.create_file_from_storage.assert_has_calls([
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ def call(self):
return accept_submission(
self.session, self.file_cacher, self.participation, self.task,
self.timestamp, self.tornado_files, self.language_name,
self.official, True)
self.official)

def assertSubmissionIsValid(self, submission, timestamp, language, files,
official):
Expand Down
Loading