mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
judge: provide 2x limits for pretest
This commit is contained in:
1 parent
5e113d9c7e
commit
511d08c850
1 file changed
+7
-10
@@ -53,16 +53,15 @@ export const judge = async (ctx: Context) => {
|
|||||||
if (filename) copyIn[`${filename}.in`] = { content: ctx.input };
|
if (filename) copyIn[`${filename}.in`] = { content: ctx.input };
|
||||||
const copyOut = filename ? [`${filename}.out?`] : [];
|
const copyOut = filename ? [`${filename}.out?`] : [];
|
||||||
const stdout = path.resolve(ctx.tmpdir, '0.out');
|
const stdout = path.resolve(ctx.tmpdir, '0.out');
|
||||||
const stderr = path.resolve(ctx.tmpdir, '0.err');
|
|
||||||
const res = await run(
|
const res = await run(
|
||||||
ctx.execute.execute,
|
ctx.execute.execute,
|
||||||
{
|
{
|
||||||
stdin: filename ? null : { content: ctx.input },
|
stdin: filename ? null : { content: ctx.input },
|
||||||
stdout: filename ? null : stdout,
|
stdout: filename ? null : stdout,
|
||||||
stderr,
|
|
||||||
copyIn,
|
copyIn,
|
||||||
copyOut,
|
copyOut,
|
||||||
time: parseTimeMS(ctx.config.time || '1s') * ctx.execute.time,
|
// Allow 2x limits for better debugging
|
||||||
|
time: parseTimeMS(ctx.config.time || '1s') * ctx.execute.time * 2,
|
||||||
memory: parseMemoryMB(ctx.config.memory || '128m'),
|
memory: parseMemoryMB(ctx.config.memory || '128m'),
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
@@ -70,19 +69,17 @@ export const judge = async (ctx: Context) => {
|
|||||||
let { status } = res;
|
let { status } = res;
|
||||||
if (!fs.existsSync(stdout)) fs.writeFileSync(stdout, '');
|
if (!fs.existsSync(stdout)) fs.writeFileSync(stdout, '');
|
||||||
const message: string[] = [];
|
const message: string[] = [];
|
||||||
if (status === STATUS.STATUS_ACCEPTED) {
|
if (time > parseTimeMS(ctx.config.time || '1s') * ctx.execute.time) {
|
||||||
if (time > parseTimeMS(ctx.config.time || '1s') * ctx.execute.time) {
|
status = STATUS.STATUS_TIME_LIMIT_EXCEEDED;
|
||||||
status = STATUS.STATUS_TIME_LIMIT_EXCEEDED;
|
} else if (memory > parseMemoryMB(ctx.config.memory || '128m') * 1024) {
|
||||||
} else if (memory > parseMemoryMB(ctx.config.memory || '128m') * 1024) {
|
status = STATUS.STATUS_MEMORY_LIMIT_EXCEEDED;
|
||||||
status = STATUS.STATUS_MEMORY_LIMIT_EXCEEDED;
|
|
||||||
}
|
|
||||||
} else if (code) {
|
} else if (code) {
|
||||||
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}`);
|
||||||
}
|
}
|
||||||
message.push(fs.readFileSync(stdout).toString());
|
message.push(fs.readFileSync(stdout).toString());
|
||||||
message.push(fs.readFileSync(stderr).toString());
|
message.push(res.stderr);
|
||||||
ctx.next({
|
ctx.next({
|
||||||
status,
|
status,
|
||||||
case: {
|
case: {
|
||||||
|
|||||||
Reference in new issue
Block a user