diff --git a/packages/hydrojudge/locales/ko.yaml b/packages/hydrojudge/locales/ko.yaml index 5ba5cd904..d1f613ecd 100644 --- a/packages/hydrojudge/locales/ko.yaml +++ b/packages/hydrojudge/locales/ko.yaml @@ -13,12 +13,12 @@ Found {0} testcases.: 총 {0}개의 TC 찾음 Invalid judge_extra_files config.: judge_extra_files config 오류 Invalid user_extra_files config.: user_extra_files config 오류 Problem data not found.: 문제 데이터 없음 -Read {0}, expect {1}.: '{0}에서 다음을 예상함. {1} +Read {0}, expect {1}.: '{0}에서 다음을 예상함. {1}' Standard answer longer than user output.: 출력이 짧습니다. Testdata configuration incorrect.: TC config 오류 Too many files.: 파일이 너무 많습니다. Too many testcases. Cancelled.: TC가 너무 많습니다. 채점을 취소합니다. -Total time limit longer than 60s. Cancelled.: 총 시간이 60초를 넘습니다. 채점을 취소합니다. +Total time limit longer than {0}s. Cancelled.: 총 시간이 {9}초를 넘습니다. 채점을 취소합니다. Unknown checker type {0}.: Checker 형태 {0}을(를) 식별할 수 없습니다. Unknown language type.: 알려지지 않은 언어. Unsupported language {0}.: '{0}은(는) 지원되지 않습니다.' diff --git a/packages/hydrojudge/locales/zh_CN.yaml b/packages/hydrojudge/locales/zh_CN.yaml index 39fdc910b..7c5c30a6e 100644 --- a/packages/hydrojudge/locales/zh_CN.yaml +++ b/packages/hydrojudge/locales/zh_CN.yaml @@ -18,7 +18,7 @@ Standard answer longer than user output.: 标准输出比选手输出长。 Testdata configuration incorrect.: 题目配置错误。 Too many files.: 文件过多。 Too many testcases. Cancelled.: 测试数据过多。评测取消。 -Total time limit longer than 60s. Cancelled.: 总时限超过60s。评测取消。 +Total time limit longer than {0}s. Cancelled.: 总时限超过{0}s。评测取消。 Unknown checker type {0}.: 未知的比较器类型 {0}。 Unknown language type.: 未知的语言类型。 Unsupported language {0}.: 不支持的语言 {0}。 diff --git a/packages/hydrojudge/package.json b/packages/hydrojudge/package.json index 18f559ff3..1a7f7210b 100644 --- a/packages/hydrojudge/package.json +++ b/packages/hydrojudge/package.json @@ -1,7 +1,7 @@ { "name": "@hydrooj/hydrojudge", "bin": "bin/hydrojudge.js", - "version": "2.1.26", + "version": "2.1.27", "main": "package.json", "author": "masnn", "repository": "https://github.com/hydro-dev/Hydro.git", diff --git a/packages/hydrojudge/src/cases.ts b/packages/hydrojudge/src/cases.ts index a4a68e5a7..ce6d38f8c 100644 --- a/packages/hydrojudge/src/cases.ts +++ b/packages/hydrojudge/src/cases.ts @@ -2,6 +2,7 @@ import fs from 'fs-extra'; import path from 'path'; import yaml from 'js-yaml'; import { Dictionary } from 'lodash'; +import { argv } from 'yargs'; import { FormatError, SystemError } from './error'; import { parseTimeMS, parseMemoryMB, ensureFile } from './utils'; @@ -284,12 +285,14 @@ function convertIniConfig(ini: string) { } function isValidConfig(config) { - if (config.count > 100) throw new FormatError('Too many testcases. Cancelled.'); + if (config.count > (argv.max_testcases_count as string || 100)) throw new FormatError('Too many testcases. Cancelled.'); let total_time = 0; for (const subtask of config.subtasks) { total_time += subtask.time_limit_ms * subtask.cases.length; } - if (total_time > 60 * 1000) throw new FormatError('Total time limit longer than 60s. Cancelled.'); + if (total_time > (+argv.max_time_limit || 60) * 1000) { + throw new FormatError('Total time limit longer than {0}s. Cancelled.', [+argv.max_time_limit || 60]); + } } export default async function readCases(folder: string, cfg: Record = {}, args) { diff --git a/packages/hydrojudge/src/checkers.ts b/packages/hydrojudge/src/checkers.ts index 9d9e4e059..04555fa9a 100644 --- a/packages/hydrojudge/src/checkers.ts +++ b/packages/hydrojudge/src/checkers.ts @@ -153,7 +153,7 @@ const checkers: Record = { ...config.copyIn, }, }); - if (status !== STATUS.STATUS_ACCEPTED) throw new SystemError('Checker returned a non-zero value', [status]); + if (status !== STATUS.STATUS_ACCEPTED) throw new SystemError('Checker returned {0}.', [status]); const score = parseInt(stdout, 10); status = score === config.score ? STATUS.STATUS_ACCEPTED : STATUS.STATUS_WRONG_ANSWER; return { status, score, message: stderr }; diff --git a/packages/hydrojudge/src/config.ts b/packages/hydrojudge/src/config.ts index 98e4f057a..42c751a04 100644 --- a/packages/hydrojudge/src/config.ts +++ b/packages/hydrojudge/src/config.ts @@ -10,9 +10,6 @@ import log from './log'; export let CONFIG_FILE = path.resolve(os.homedir(), '.config', 'hydro', 'judge.yaml'); export let CACHE_DIR = path.resolve(os.homedir(), '.cache', 'hydro', 'judge'); export let FILES_DIR = path.resolve(os.homedir(), '.cache', 'hydro', 'files', 'judge'); -export let SYSTEM_MEMORY_LIMIT_MB = 1024; -export let SYSTEM_TIME_LIMIT_MS = 16000; -export let SYSTEM_PROCESS_LIMIT = 32; export let RETRY_DELAY_SEC = 15; export let TEMP_DIR = path.resolve(os.tmpdir(), 'hydro', 'judge'); export let EXECUTION_HOST = 'http://localhost:5050'; diff --git a/packages/hydrojudge/src/sandbox.ts b/packages/hydrojudge/src/sandbox.ts index 92916519a..908a59bdc 100644 --- a/packages/hydrojudge/src/sandbox.ts +++ b/packages/hydrojudge/src/sandbox.ts @@ -1,11 +1,12 @@ import Axios from 'axios'; import fs from 'fs-extra'; +import { argv } from 'yargs'; import * as STATUS from './status'; import { SystemError } from './error'; import { cmd } from './utils'; const env = ['PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', 'HOME=/w']; -const axios = Axios.create({ baseURL: 'http://localhost:5050' }); +const axios = Axios.create({ baseURL: argv.sandbox as string || 'http://localhost:5050' }); const statusMap = { 'Time Limit Exceeded': STATUS.STATUS_TIME_LIMIT_EXCEEDED,