judge: add user_code to checker context (#325)

This commit is contained in:
undefined committed 2022-03-23 18:18:21 +08:00
1 parent 1479a00cad
commit 4ce8439e99
3 files changed
+6 -3

No files matched your search

+1 -1
View File
@@ -1,7 +1,7 @@
{
"name": "@hydrooj/hydrojudge",
"bin": "bin/hydrojudge.js",
"version": "2.14.8",
"version": "2.14.9",
"main": "package.json",
"author": "undefined <i@undefined.moe>",
"repository": "https://github.com/hydro-dev/Hydro.git",
+1 -1
View File
@@ -154,7 +154,7 @@ export const judge = async (ctx: Context) => {
if (['default', 'strict'].includes(ctx.config.checker_type || 'default')) {
return { execute: '', copyIn: {}, clean: () => Promise.resolve(null) };
}
const copyIn = {};
const copyIn = { user_code: { content: ctx.code } };
for (const file of ctx.config.judge_extra_files) {
copyIn[parseFilename(file)] = { src: file };
}
+4 -1
View File
@@ -106,7 +106,10 @@ export const judge = async (ctx: Context) => {
return compile(ctx.getLang(ctx.lang), ctx.code, copyIn, ctx.next);
})(),
(() => {
const copyIn = { 'testlib.h': { src: testlibSrc } };
const copyIn = {
'testlib.h': { src: testlibSrc },
user_code: { content: ctx.code },
};
for (const file of ctx.config.judge_extra_files) {
copyIn[parseFilename(file)] = { src: file };
}