mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
judge: common analysis
This commit is contained in:
1 parent
d225be35c9
commit
ac67be96e0
5 files changed
+33
-23
No files matched your search
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "@hydrooj/hydrojudge",
|
"name": "@hydrooj/hydrojudge",
|
||||||
"bin": "bin/hydrojudge.js",
|
"bin": "bin/hydrojudge.js",
|
||||||
"version": "2.15.0",
|
"version": "2.15.1",
|
||||||
"main": "package.json",
|
"main": "package.json",
|
||||||
"author": "undefined <i@undefined.moe>",
|
"author": "undefined <i@undefined.moe>",
|
||||||
"repository": "https://github.com/hydro-dev/Hydro.git",
|
"repository": "https://github.com/hydro-dev/Hydro.git",
|
||||||
|
|||||||
@@ -82,22 +82,6 @@ function judgeCase(c: Case, sid: string) {
|
|||||||
} else if (status === STATUS.STATUS_RUNTIME_ERROR && code) {
|
} else if (status === STATUS.STATUS_RUNTIME_ERROR && code) {
|
||||||
if (code < 32) message = signals[code];
|
if (code < 32) message = signals[code];
|
||||||
else message = { message: 'Your program returned {0}.', params: [code] };
|
else message = { message: 'Your program returned {0}.', params: [code] };
|
||||||
const langConfig = ctx.getLang(ctx.lang);
|
|
||||||
if (langConfig.runtimeErrorAnalysis && !this.runtimeErrorAnalysis) {
|
|
||||||
this.runtimeErrorAnalysis = true;
|
|
||||||
run(langConfig.runtimeErrorAnalysis, {
|
|
||||||
copyIn: {
|
|
||||||
input: { src: stdin },
|
|
||||||
[langConfig.code_file || 'foo']: { content: ctx.code },
|
|
||||||
compile: { content: langConfig.compile },
|
|
||||||
execute: { content: langConfig.execute },
|
|
||||||
},
|
|
||||||
time: 5000,
|
|
||||||
memory: 256,
|
|
||||||
})
|
|
||||||
.then((r) => ctx.next({ compiler_text: r.stdout.toString().substring(0, 1024) }))
|
|
||||||
.catch((e) => console.error(e));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
await Promise.all(
|
await Promise.all(
|
||||||
Object.values(res.fileIds).map((id) => del(id)),
|
Object.values(res.fileIds).map((id) => del(id)),
|
||||||
@@ -107,6 +91,25 @@ function judgeCase(c: Case, sid: string) {
|
|||||||
await runner(ctx, ctxSubtask);
|
await runner(ctx, ctxSubtask);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if ([STATUS.STATUS_WRONG_ANSWER, STATUS.STATUS_RUNTIME_ERROR].includes(status)) {
|
||||||
|
const langConfig = ctx.getLang(ctx.lang);
|
||||||
|
if (langConfig.analysis && !ctx.analysis) {
|
||||||
|
ctx.analysis = true;
|
||||||
|
run(langConfig.analysis, {
|
||||||
|
copyIn: {
|
||||||
|
input: { src: stdin },
|
||||||
|
[langConfig.code_file || 'foo']: { content: ctx.code },
|
||||||
|
compile: { content: langConfig.compile },
|
||||||
|
execute: { content: langConfig.execute },
|
||||||
|
},
|
||||||
|
time: 5000,
|
||||||
|
memory: 256,
|
||||||
|
}).then((r) => {
|
||||||
|
ctx.next({ compiler_text: r.stdout.toString().substring(0, 1024) });
|
||||||
|
if (process.env.DEV) console.log(r);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
ctxSubtask.score = Score[ctxSubtask.subtask.type](ctxSubtask.score, score);
|
ctxSubtask.score = Score[ctxSubtask.subtask.type](ctxSubtask.score, score);
|
||||||
ctxSubtask.status = Math.max(ctxSubtask.status, status);
|
ctxSubtask.status = Math.max(ctxSubtask.status, status);
|
||||||
if (ctxSubtask.status > STATUS.STATUS_ACCEPTED) ctx.failed[sid] = true;
|
if (ctxSubtask.status > STATUS.STATUS_ACCEPTED) ctx.failed[sid] = true;
|
||||||
|
|||||||
@@ -46,6 +46,7 @@ export interface RuntimeContext {
|
|||||||
queue?: PQueue;
|
queue?: PQueue;
|
||||||
errored?: boolean;
|
errored?: boolean;
|
||||||
rerun?: number;
|
rerun?: number;
|
||||||
|
analysis?: boolean;
|
||||||
failed?: Record<string, boolean>;
|
failed?: Record<string, boolean>;
|
||||||
|
|
||||||
execute?: Execute;
|
execute?: Execute;
|
||||||
|
|||||||
@@ -79,9 +79,12 @@ export const judge = async (ctx: Context) => {
|
|||||||
status = STATUS.STATUS_RUNTIME_ERROR;
|
status = STATUS.STATUS_RUNTIME_ERROR;
|
||||||
if (code < 32) message.push(`ExitCode: ${code} (${signals[code]})`);
|
if (code < 32) message.push(`ExitCode: ${code} (${signals[code]})`);
|
||||||
else message.push(`ExitCode: ${code}`);
|
else message.push(`ExitCode: ${code}`);
|
||||||
|
}
|
||||||
|
if ([STATUS.STATUS_WRONG_ANSWER, STATUS.STATUS_RUNTIME_ERROR].includes(status)) {
|
||||||
const langConfig = ctx.getLang(ctx.lang);
|
const langConfig = ctx.getLang(ctx.lang);
|
||||||
if (langConfig.runtimeErrorAnalysis) {
|
if (langConfig.analysis) {
|
||||||
run(langConfig.runtimeErrorAnalysis, {
|
ctx.analysis = true;
|
||||||
|
run(langConfig.analysis, {
|
||||||
copyIn: {
|
copyIn: {
|
||||||
input: { src: stdin },
|
input: { src: stdin },
|
||||||
[langConfig.code_file || 'foo']: { content: ctx.code },
|
[langConfig.code_file || 'foo']: { content: ctx.code },
|
||||||
@@ -90,9 +93,10 @@ export const judge = async (ctx: Context) => {
|
|||||||
},
|
},
|
||||||
time: 5000,
|
time: 5000,
|
||||||
memory: 256,
|
memory: 256,
|
||||||
})
|
}).then((r) => {
|
||||||
.then((r) => ctx.next({ compiler_text: r.stdout.toString().substring(0, 1024) }))
|
ctx.next({ compiler_text: r.stdout.toString().substring(0, 1024) });
|
||||||
.catch((e) => console.error(e));
|
if (process.env.DEV) console.log(r);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
message.push(fs.readFileSync(stdout).toString());
|
message.push(fs.readFileSync(stdout).toString());
|
||||||
|
|||||||
@@ -62,9 +62,11 @@ int main(){
|
|||||||
return parseInt(a[a.length - 2], 10);
|
return parseInt(a[a.length - 2], 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const stackPromise = stackSize();
|
||||||
|
|
||||||
export async function get() {
|
export async function get() {
|
||||||
const info = await _get();
|
const info = await _get();
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
info.stack = await stackSize();
|
info.stack = await stackPromise;
|
||||||
return info;
|
return info;
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user