mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-17 09:36:08 +08:00
judge: add --show-sandbox-call option
This commit is contained in:
1 parent
e76459cff6
commit
a6cdee0b6d
4 files changed
+9
-3
No files matched your search
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "@hydrooj/hydrojudge",
|
||||
"bin": "bin/hydrojudge.js",
|
||||
"version": "2.4.2",
|
||||
"version": "2.4.3",
|
||||
"main": "package.json",
|
||||
"author": "undefined <i@undefined.moe>",
|
||||
"repository": "https://github.com/hydro-dev/Hydro.git",
|
||||
|
||||
@@ -180,7 +180,6 @@ const checkers: Record<string, Checker> = {
|
||||
async testlib(config) {
|
||||
const { stderr, status } = await run('${dir}/checker ${dir}/in ${dir}/user_out ${dir}/answer', {
|
||||
copyIn: {
|
||||
'testlib.h': { src: resolve(__dirname, '../files/testlib.h') },
|
||||
in: { src: config.input },
|
||||
user_out: { src: config.user_stdout },
|
||||
answer: { src: config.output },
|
||||
|
||||
@@ -1,10 +1,13 @@
|
||||
import Axios from 'axios';
|
||||
import fs from 'fs-extra';
|
||||
import { argv } from 'yargs';
|
||||
import * as STATUS from './status';
|
||||
import { SystemError } from './error';
|
||||
import { cmd, parseMemoryMB } from './utils';
|
||||
import { getConfig } from './config';
|
||||
import { Logger } from './log';
|
||||
|
||||
const logger = new Logger('sandbox');
|
||||
const env = ['PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', 'HOME=/w'];
|
||||
const axios = Axios.create({ baseURL: getConfig('sandbox_host') });
|
||||
|
||||
@@ -87,7 +90,9 @@ export async function runMultiple(execute) {
|
||||
body.cmd[0].files[1] = null;
|
||||
body.cmd[1].files[0] = null;
|
||||
body.cmd[1].files[1] = null;
|
||||
if (argv['show-sandbox-call']) logger.debug(JSON.stringify(body));
|
||||
res = await axios.post('/run', body);
|
||||
if (argv['show-sandbox-call']) logger.debug(JSON.stringify(res.data));
|
||||
} catch (e) {
|
||||
throw new SystemError('Sandbox Error');
|
||||
}
|
||||
@@ -106,7 +111,9 @@ export async function run(execute, params?) {
|
||||
if (typeof execute === 'object') return await runMultiple(execute);
|
||||
try {
|
||||
const body = { cmd: [proc({ execute, ...params })] };
|
||||
if (argv['show-sandbox-call']) logger.debug(JSON.stringify(body));
|
||||
const res = await axios.post('/run', body);
|
||||
if (argv['show-sandbox-call']) logger.debug(JSON.stringify(res.data));
|
||||
[result] = res.data;
|
||||
} catch (e) {
|
||||
// FIXME request body larger than maxBodyLength limit
|
||||
|
||||
@@ -12,7 +12,7 @@ import Router from 'koa-router';
|
||||
import proxy from 'koa-proxies';
|
||||
import cache from 'koa-static-cache';
|
||||
import sockjs from 'sockjs';
|
||||
import { SetOption } from 'cookies';
|
||||
import type { SetOption } from 'cookies';
|
||||
import serialize, { SerializeJSOptions } from 'serialize-javascript';
|
||||
import { argv } from 'yargs';
|
||||
import { lrucache } from '../utils';
|
||||
|
||||
Reference in new issue
Block a user