feat(remote_judger/loj): compile error message

This commit is contained in:
Baoshuo Ren 2023-01-29 16:25:32 +08:00
parent 9bad6f6ec7
commit 72242edbfc
Signed by: baoshuo
GPG Key ID: 00CB9680AB29F51A
2 changed files with 32 additions and 11 deletions

View File

@ -1,8 +1,10 @@
import superagent from 'superagent';
import proxy from 'superagent-proxy';
import { stripVTControlCharacters } from 'util';
import sleep from '../utils/sleep';
import { IBasicProvider, RemoteAccount, USER_AGENT } from '../interface';
import Logger from '../utils/logger';
import { normalize, VERDICT } from '../verdict';
proxy(superagent);
const logger = new Logger('remote/loj');
@ -261,38 +263,43 @@ export default class LibreojProvider implements IBasicProvider {
});
}
await sleep(2000);
await sleep(1000);
const { body, error } = await this.post('/submission/getSubmissionDetail')
.send({ submissionId: String(id), locale: 'zh_CN' })
.retry(3);
if (error) continue;
if (body.progress.progressType !== 'Finished') {
await next({
status: `${body.progress.progressType}`,
});
if (body.progress.progressType !== 'Finished') {
continue;
}
if (body.meta.status === 'CompilationError') {
const status =
VERDICT[
Object.keys(VERDICT).find(k =>
normalize(body.meta.status).includes(k)
)
];
if (status === 'Compile Error') {
await end({
error: true,
id,
status: 'Compile Error',
message: stripVTControlCharacters(body.progress.compile.message),
});
}
if (
['SystemError', 'JudgementFailed', 'ConfigurationError'].includes(
body.meta.status
)
) {
if (status === 'Judgment Failed') {
await end({
error: true,
id,
status: 'Judgment Failed',
message: 'Error occurred on remote online judge.',
});
}

View File

@ -20,6 +20,20 @@ export const VERDICT = new Proxy<Record<string, string>>(
// Codeforces
'HAPPY_NEW_YEAR!': 'Accepted',
// LibreOJ
COMPILATIONERROR: 'Compile Error',
COMPILEERROR: 'Compile Error',
FILEERROR: 'File Error',
RUNTIMEERROR: 'Runtime Error',
TIMELIMITEXCEEDED: 'Time Limit Exceeded',
MEMORYLIMITEXCEEDED: 'Memory Limit Exceeded',
OUTPUTLIMITEXCEEDED: 'Output Limit Exceeded',
WRONGANSWER: 'Wrong Answer',
PARTIALLYCORRECT: 'Partially Correct',
JUDGEMENTFAILED: 'Judgment Failed',
SYSTEMERROR: 'Judgment Failed',
CONFIGURATIONERROR: 'Judgment Failed',
},
{
get(self, key) {