diff --git a/dmoj/cli.py b/dmoj/cli.py index b89948928..031901c93 100644 --- a/dmoj/cli.py +++ b/dmoj/cli.py @@ -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 diff --git a/dmoj/packet.py b/dmoj/packet.py index ddbe68132..51038dc8b 100644 --- a/dmoj/packet.py +++ b/dmoj/packet.py @@ -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) diff --git a/dmoj/testsuite.py b/dmoj/testsuite.py index 4431cb7ef..137104ace 100644 --- a/dmoj/testsuite.py +++ b/dmoj/testsuite.py @@ -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')