judge: 支持对不同语言设置不同时限

This commit is contained in:
undefined committed 2020-10-31 12:00:42 +08:00
1 parent c553f204ad
commit 3fc5612ca3
4 files changed
+22 -6

No files matched your search

+8 -3
View File
@@ -3,10 +3,11 @@ import * as STATUS from './status';
import { run, del } from './sandbox';
import { CompileError, SystemError } from './error';
import { compilerText } from './utils';
import { Execute } from './interface';
export = async function compile(
lang: string, code: string, target: string, copyIn: any, next?: Function,
) {
): Promise<Execute> {
const LANGS = global.Hydro
? yaml.safeLoad(await global.Hydro.model.system.get('hydrojudge.langs'))
: require('./config').LANGS;
@@ -26,10 +27,14 @@ export = async function compile(
if (!fileIds[target]) throw new CompileError({ stderr: '没有找到可执行文件' });
if (next) next({ compiler_text: compilerText(stdout, stderr) });
f[target] = { fileId: fileIds[target] };
return { execute: info.execute, copyIn: f, clean: () => del(fileIds[target]) };
return {
execute: info.execute, copyIn: f, clean: () => del(fileIds[target]), time: info.time || 1,
};
} if (info.type === 'interpreter') {
f[target] = { content: code };
return { execute: info.execute, copyIn: f, clean: () => Promise.resolve() };
return {
execute: info.execute, copyIn: f, clean: () => Promise.resolve(), time: info.time || 1,
};
}
throw new SystemError('Unknown language type');
}