Skip to content

Commit

Permalink
Add batching of testcase updates to protocol; #408
Browse files Browse the repository at this point in the history
  • Loading branch information
Xyene committed Sep 30, 2019
1 parent 0d17306 commit 7d89ffc
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 15 deletions.
3 changes: 3 additions & 0 deletions dmoj/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ def supported_problems_packet(self, problems):
def test_case_status_packet(self, position, result):
pass

def multi_test_case_status_packet(self, updates):
pass

def compile_error_packet(self, log):
pass

Expand Down
39 changes: 24 additions & 15 deletions dmoj/packet.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,23 +234,32 @@ def supported_problems_packet(self, problems):
self._send_packet({'name': 'supported-problems',
'problems': problems})

def test_case_status_packet(self, position, result):
log.info('Test case on %d: #%d, %s [%.3fs | %.2f MB], %.1f/%.0f',
self.judge.current_submission_id, position,
', '.join(result.readable_codes()),
result.execution_time, result.max_memory / 1024.0,
result.points, result.total_points)
def multi_test_case_status_packet(self, updates):
for position, result in updates:
log.info('Test case on %d: #%d, %s [%.3fs | %.2f MB], %.1f/%.0f',
self.judge.current_submission_id, position,
', '.join(result.readable_codes()),
result.execution_time, result.max_memory / 1024.0,
result.points, result.total_points)

self._send_packet({'name': 'test-case-status',
'submission-id': self.judge.current_submission_id,
'position': position,
'status': result.result_flag,
'time': result.execution_time,
'points': result.points,
'total-points': result.total_points,
'memory': result.max_memory,
'output': result.output,
'extended-feedback': result.extended_feedback,
'feedback': result.feedback})
'cases': [
{
'position': position,
'status': result.result_flag,
'time': result.execution_time,
'points': result.points,
'total-points': result.total_points,
'memory': result.max_memory,
'output': result.output,
'extended-feedback': result.extended_feedback,
'feedback': result.feedback,
} for position, result in updates
]})

def test_case_status_packet(self, position, result):
self.multi_test_case_status_packet([(position, result)])

def compile_error_packet(self, message):
log.info('Compile error: %d', self.judge.current_submission_id)
Expand Down
4 changes: 4 additions & 0 deletions dmoj/testsuite.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ def test_case_status_packet(self, position, result):
self.fail('Unexpected feedback: "%s", expected: "%s"' %
(result.feedback, '", "'.join(feedback)))

def multi_test_case_status_packet(self, updates):
for position, result in updates:
self.test_case_status_packet(position, result)

def compile_error_packet(self, log):
if 'CE' not in self.codes_all:
self.fail('Unexpected compile error')
Expand Down

0 comments on commit 7d89ffc

Please sign in to comment.