judge: 错误详情上报

pull/15/head
undefined 4 years ago
parent 4798153ce9
commit de7223e055

@ -1,9 +1,16 @@
# Hydro # Hydro
[![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2Fhydro-dev%2FHydro.svg?type=shield)](https://app.fossa.com/projects/git%2Bgithub.com%2Fhydro-dev%2FHydro?ref=badge_shield) [![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2Fhydro-dev%2FHydro.svg?type=shield)](https://app.fossa.com/projects/git%2Bgithub.com%2Fhydro-dev%2FHydro?ref=badge_shield)
Hydro是一个高效的信息学在线测评系统。特点易于部署轻量功能强大且易于扩展。 Hydro是一个高效的信息学在线测评系统。特点易于部署轻量功能强大且易于扩展。
使用安装脚本ubuntu18.04
```sh
curl -sSL https://cdn.jsdelivr.net/gh/hydro-dev/Hydro@master/install/ubuntu-1804.sh | bash
```
其他平台请参照文档手动安装。
[中文文档](https://hydro.js.org/) [中文文档](https://hydro.js.org/)
欢迎 star 本项目,这是对开发者的鼓励。 欢迎 star 本项目,这是对开发者的鼓励。

@ -1,7 +1,7 @@
{ {
"name": "@hydrooj/hydrojudge", "name": "@hydrooj/hydrojudge",
"bin": "bin/hydrojudge.js", "bin": "bin/hydrojudge.js",
"version": "2.1.12", "version": "2.1.13",
"main": "package.json", "main": "package.json",
"author": "masnn", "author": "masnn",
"repository": "https://github.com/hydro-dev/Hydro.git", "repository": "https://github.com/hydro-dev/Hydro.git",

@ -59,7 +59,7 @@ function judgeCase(c) {
checker: ctx.config.checker, checker: ctx.config.checker,
checker_type: ctx.config.checker_type, checker_type: ctx.config.checker_type,
score: ctxSubtask.subtask.score, score: ctxSubtask.subtask.score,
detail: ctx.config.detail, detail: ctx.config.detail || true,
}); });
} }
} else if (status === STATUS.STATUS_RUNTIME_ERROR && code) { } else if (status === STATUS.STATUS_RUNTIME_ERROR && code) {
@ -124,7 +124,7 @@ export const judge = async (ctx) => {
})(), })(),
(async () => { (async () => {
if (!ctx.config.checker_type || ctx.config.checker_type === 'default') { if (!ctx.config.checker_type || ctx.config.checker_type === 'default') {
return { execute: '', copyIn: {}, clean: Promise.resolve }; return { execute: '', copyIn: {}, clean: () => Promise.resolve() };
} }
const copyIn = {}; const copyIn = {};
for (const file of ctx.config.judge_extra_files) { for (const file of ctx.config.judge_extra_files) {

@ -86,15 +86,18 @@ async function postInit() {
async function cacheOpen(domainId: string, pid: string, version: string) { async function cacheOpen(domainId: string, pid: string, version: string) {
const filePath = path.join(homedir(), '.cache', 'hydro', 'judge', domainId, pid); const filePath = path.join(homedir(), '.cache', 'hydro', 'judge', domainId, pid);
logger.debug('Cache found at %s', filePath);
if (fs.existsSync(filePath)) { if (fs.existsSync(filePath)) {
let ver: string; let ver: string;
try { try {
ver = fs.readFileSync(path.join(filePath, 'version')).toString(); ver = fs.readFileSync(path.join(filePath, 'version')).toString();
} catch (e) { /* ignore */ } } catch (e) { /* ignore */ }
if (version === ver) return filePath; if (version === ver) {
fs.removeSync(filePath); logger.debug('Cache found at %s', filePath);
return filePath;
}
await fs.remove(filePath);
} }
logger.debug('Downloading testdata to %s', filePath);
fs.ensureDirSync(filePath); fs.ensureDirSync(filePath);
await problemData(domainId, pid, filePath); await problemData(domainId, pid, filePath);
fs.writeFileSync(path.join(filePath, 'version'), version); fs.writeFileSync(path.join(filePath, 'version'), version);
@ -108,15 +111,18 @@ async function postInit() {
logger.debug('Next: %d %o', id, data); logger.debug('Next: %d %o', id, data);
data.domainId = that.domainId; data.domainId = that.domainId;
data.rid = new ObjectID(that.rid); data.rid = new ObjectID(that.rid);
data.time = data.time_ms || data.time; if (data.time_ms) data.time = data.time_ms;
data.memory = data.memory_kb || data.memory; if (data.memory_kb) data.memory = data.memory_kb;
data.compilerText = data.compiler_text || data.compilerText; if (data.compiler_text) data.compilerText = data.compiler_text;
delete data.time_ms;
delete data.memory_kb;
delete data.compiler_text;
if (data.case) { if (data.case) {
data.case = { data.case = {
status: data.case.status, status: data.case.status,
time: data.case.time_ms || data.case.time, time: data.case.time_ms || data.case.time,
memory: data.case.memory_kb || data.case.memory, memory: data.case.memory_kb || data.case.memory,
message: data.message || data.judgeText, message: data.case.message || data.case.judgeText || '',
}; };
} }
if (id) { if (id) {

@ -1,6 +1,6 @@
{ {
"name": "hydrooj", "name": "hydrooj",
"version": "2.13.29", "version": "2.13.30",
"bin": "bin/hydrooj.js", "bin": "bin/hydrooj.js",
"main": "dist/loader.js", "main": "dist/loader.js",
"typings": "dist/loader.d.ts", "typings": "dist/loader.d.ts",

@ -42,7 +42,7 @@ export async function next(body: JudgeResultBody) {
const c: TestCase = { const c: TestCase = {
memory: body.case.memory, memory: body.case.memory,
time: body.case.time, time: body.case.time,
message: body.case.message, message: body.case.message || '',
status: body.case.status, status: body.case.status,
}; };
rdoc.testCases.push(c); rdoc.testCases.push(c);

Loading…
Cancel
Save