judge: fix analysis default value fallback

This commit is contained in:
undefined committed 2022-03-28 02:21:31 +08:00
1 parent 0e20de9200
commit ab788b3d79
4 files changed
+12 -10

No files matched your search

+1 -1
View File
@@ -1,7 +1,7 @@
{ {
"name": "@hydrooj/hydrojudge", "name": "@hydrooj/hydrojudge",
"bin": "bin/hydrojudge.js", "bin": "bin/hydrojudge.js",
"version": "2.15.2", "version": "2.15.3",
"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",
+3 -3
View File
@@ -206,12 +206,12 @@ export default async function readCases(folder: string, cfg: Record<string, any>
const ymlConfig = path.resolve(folder, 'config.yml'); const ymlConfig = path.resolve(folder, 'config.yml');
let config; let config;
if (fs.existsSync(yamlConfig)) { 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)) { } 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)) { } else if (fs.existsSync(iniConfig)) {
try { try {
config = { ...convertIniConfig(fs.readFileSync(iniConfig).toString()), ...cfg }; config = { ...cfg, ...convertIniConfig(fs.readFileSync(iniConfig).toString()) };
} catch (e) { } catch (e) {
throw changeErrorType(e, FormatError); throw changeErrorType(e, FormatError);
} }
+5 -4
View File
@@ -91,16 +91,17 @@ 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)) { if ([STATUS.STATUS_WRONG_ANSWER, STATUS.STATUS_RUNTIME_ERROR].includes(status) && ctx.config.detail) {
const langConfig = ctx.getLang(ctx.lang); const langConfig = ctx.getLang(ctx.lang);
if (langConfig.analysis && !ctx.analysis) { if (langConfig.analysis && !ctx.analysis) {
ctx.analysis = true; ctx.analysis = true;
run(langConfig.analysis, { run(langConfig.analysis, {
copyIn: { copyIn: {
input: { src: stdin }, ...copyIn,
input: stdin ? { src: stdin } : { content: '' },
[langConfig.code_file || 'foo']: { content: ctx.code }, [langConfig.code_file || 'foo']: { content: ctx.code },
compile: { content: langConfig.compile }, compile: { content: langConfig.compile || '' },
execute: { content: langConfig.execute }, execute: { content: langConfig.execute || '' },
}, },
time: 5000, time: 5000,
memory: 256, memory: 256,
+3 -2
View File
@@ -86,10 +86,11 @@ export const judge = async (ctx: Context) => {
ctx.analysis = true; ctx.analysis = true;
run(langConfig.analysis, { run(langConfig.analysis, {
copyIn: { copyIn: {
...copyIn,
input: { src: stdin }, input: { src: stdin },
[langConfig.code_file || 'foo']: { content: ctx.code }, [langConfig.code_file || 'foo']: { content: ctx.code },
compile: { content: langConfig.compile }, compile: { content: langConfig.compile || '' },
execute: { content: langConfig.execute }, execute: { content: langConfig.execute || '' },
}, },
env: { env: {
...ctx.env, ...ctx.env,