diff --git a/packages/hydrojudge/package.json b/packages/hydrojudge/package.json index dc26bbb7f..61b9fd7a4 100644 --- a/packages/hydrojudge/package.json +++ b/packages/hydrojudge/package.json @@ -1,7 +1,7 @@ { "name": "@hydrooj/hydrojudge", "bin": "bin/hydrojudge.js", - "version": "2.15.2", + "version": "2.15.3", "main": "package.json", "author": "undefined ", "repository": "https://github.com/hydro-dev/Hydro.git", diff --git a/packages/hydrojudge/src/cases.ts b/packages/hydrojudge/src/cases.ts index 488f223b1..52a030d2a 100644 --- a/packages/hydrojudge/src/cases.ts +++ b/packages/hydrojudge/src/cases.ts @@ -206,12 +206,12 @@ export default async function readCases(folder: string, cfg: Record const ymlConfig = path.resolve(folder, 'config.yml'); let config; if (fs.existsSync(yamlConfig)) { - config = { ...yaml.load(fs.readFileSync(yamlConfig).toString()) as object, ...cfg }; + config = { ...cfg, ...yaml.load(fs.readFileSync(yamlConfig).toString()) as object }; } else if (fs.existsSync(ymlConfig)) { - config = { ...yaml.load(fs.readFileSync(ymlConfig).toString()) as object, ...cfg }; + config = { ...cfg, ...yaml.load(fs.readFileSync(ymlConfig).toString()) as object }; } else if (fs.existsSync(iniConfig)) { try { - config = { ...convertIniConfig(fs.readFileSync(iniConfig).toString()), ...cfg }; + config = { ...cfg, ...convertIniConfig(fs.readFileSync(iniConfig).toString()) }; } catch (e) { throw changeErrorType(e, FormatError); } diff --git a/packages/hydrojudge/src/judge/default.ts b/packages/hydrojudge/src/judge/default.ts index 4fd9d4367..0937d2137 100644 --- a/packages/hydrojudge/src/judge/default.ts +++ b/packages/hydrojudge/src/judge/default.ts @@ -91,16 +91,17 @@ function judgeCase(c: Case, sid: string) { await runner(ctx, ctxSubtask); return; } - if ([STATUS.STATUS_WRONG_ANSWER, STATUS.STATUS_RUNTIME_ERROR].includes(status)) { + if ([STATUS.STATUS_WRONG_ANSWER, STATUS.STATUS_RUNTIME_ERROR].includes(status) && ctx.config.detail) { const langConfig = ctx.getLang(ctx.lang); if (langConfig.analysis && !ctx.analysis) { ctx.analysis = true; run(langConfig.analysis, { copyIn: { - input: { src: stdin }, + ...copyIn, + input: stdin ? { src: stdin } : { content: '' }, [langConfig.code_file || 'foo']: { content: ctx.code }, - compile: { content: langConfig.compile }, - execute: { content: langConfig.execute }, + compile: { content: langConfig.compile || '' }, + execute: { content: langConfig.execute || '' }, }, time: 5000, memory: 256, diff --git a/packages/hydrojudge/src/judge/run.ts b/packages/hydrojudge/src/judge/run.ts index 9c45da10a..628ced224 100644 --- a/packages/hydrojudge/src/judge/run.ts +++ b/packages/hydrojudge/src/judge/run.ts @@ -86,10 +86,11 @@ export const judge = async (ctx: Context) => { ctx.analysis = true; run(langConfig.analysis, { copyIn: { + ...copyIn, input: { src: stdin }, [langConfig.code_file || 'foo']: { content: ctx.code }, - compile: { content: langConfig.compile }, - execute: { content: langConfig.execute }, + compile: { content: langConfig.compile || '' }, + execute: { content: langConfig.execute || '' }, }, env: { ...ctx.env,