async def build(self): self.next(status=STATUS_COMPILING) package, message, _, _ = await shield(build(self.lang, self.code.encode())) self.next(compiler_text=message) if not package: logger.debug('Compile error: %s', message) raise CompileError(message) return package
def do_status(self, expected_status, expected_score, code): package, message, time_usage_ns, memory_usage_bytes = \ run(build('c', code)) self.assertIsNotNone(package, 'Compile failed: ' + message) if message: logger.warning('Compiler output is not empty: %s', message) status, score, time_usage_ns, memory_usage_bytes, stderr = \ run(self.case.judge(package)) self.assertEqual(status, expected_status) self.assertEqual(score, expected_score)
def do_lang(self, lang, code): package, message, time_usage_ns, memory_usage_bytes = \ run(build(lang, code)) self.assertIsNotNone(package, 'Compile failed: ' + message) logger.info('Compiled successfully in %d ms time, %d kb memory', time_usage_ns // 1000000, memory_usage_bytes // 1024) if message: logger.warning('Compiler output is not empty: %s', message) for case in self.cases: status, score, time_usage_ns, memory_usage_bytes, stderr = \ run(case.judge(package)) self.assertEqual(status, STATUS_ACCEPTED) self.assertEqual(score, 10) self.assertEqual(stderr, b'') logger.info('Accepted: %d ms time, %d kb memory', time_usage_ns // 1000000, memory_usage_bytes // 1024)
def do_status(self, expected_status, expected_score, code): package, message, time_usage_ns, memory_usage_bytes = \ run(build('c', code)) self.assertIsNotNone(package, 'Compile failed: ' + message) logger.info('Compiled successfully in %d ms time, %d kb memory', time_usage_ns // 1000000, memory_usage_bytes // 1024) if message: logger.warning('Compiler output is not empty: %s', message) total_status = STATUS_ACCEPTED total_score = 0 for case in self.cases: status, score, time_usage_ns, memory_usage_bytes, stderr = \ run(case.judge(package)) total_status = max(total_status, status) total_score += score self.assertEqual(status, STATUS_ACCEPTED) self.assertEqual(score, 25) self.assertEqual(stderr, b'') logger.info('Accepted: %d ms time, %d kb memory', time_usage_ns // 1000000, memory_usage_bytes // 1024) self.assertEqual(total_status, expected_status) self.assertEqual(total_score, expected_score)