mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 09:46:28 +08:00
judge: testlib builtin checkers
This commit is contained in:
1 parent
79aca189d1
commit
97e282d3ca
3 files changed
+10
-5
No files matched your search
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "@hydrooj/hydrojudge",
|
"name": "@hydrooj/hydrojudge",
|
||||||
"bin": "bin/hydrojudge.js",
|
"bin": "bin/hydrojudge.js",
|
||||||
"version": "2.12.11",
|
"version": "2.12.12",
|
||||||
"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",
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { parseMemoryMB, parseTimeMS } from './utils';
|
import { findFileSync, parseMemoryMB, parseTimeMS } from './utils';
|
||||||
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||||
export default async function readYamlCases(cfg: Record<string, any> = {}, checkFile = (s: string, errMsg: string) => s) {
|
export default async function readYamlCases(cfg: Record<string, any> = {}, checkFile = (s: string, errMsg: string) => s) {
|
||||||
@@ -10,7 +10,12 @@ export default async function readYamlCases(cfg: Record<string, any> = {}, check
|
|||||||
user_extra_files: [],
|
user_extra_files: [],
|
||||||
};
|
};
|
||||||
config.checker_type = cfg.checker_type || 'default';
|
config.checker_type = cfg.checker_type || 'default';
|
||||||
if (cfg.checker) config.checker = checkFile(cfg.checker, 'Cannot find checker {0}.');
|
if (cfg.checker) {
|
||||||
|
if (!cfg.checker.includes('.')) {
|
||||||
|
config.checker = findFileSync(`@hydrojudge/vendor/testlib/checkers/${cfg.checker}.cpp`, false);
|
||||||
|
}
|
||||||
|
if (!config.checker) config.checker = checkFile(cfg.checker, 'Cannot find checker {0}.');
|
||||||
|
}
|
||||||
if (cfg.interactor) config.interactor = checkFile(cfg.interactor, 'Cannot find interactor {0}.');
|
if (cfg.interactor) config.interactor = checkFile(cfg.interactor, 'Cannot find interactor {0}.');
|
||||||
if (cfg.judge_extra_files) {
|
if (cfg.judge_extra_files) {
|
||||||
if (typeof cfg.judge_extra_files === 'string') {
|
if (typeof cfg.judge_extra_files === 'string') {
|
||||||
|
|||||||
@@ -344,7 +344,7 @@ export async function findFile(pathname: string, doThrow = true) {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function findFileSync(pathname: string, doThrow = true) {
|
export function findFileSync(pathname: string, doThrow: boolean | Error = true) {
|
||||||
if (fs.pathExistsSync(path.resolve(pathname))) return path.resolve(pathname);
|
if (fs.pathExistsSync(path.resolve(pathname))) return path.resolve(pathname);
|
||||||
if (fs.pathExistsSync(path.resolve(process.cwd(), pathname))) return path.resolve(process.cwd(), pathname);
|
if (fs.pathExistsSync(path.resolve(process.cwd(), pathname))) return path.resolve(process.cwd(), pathname);
|
||||||
if (fs.pathExistsSync(path.resolve(__dirname, pathname))) return path.resolve(__dirname, pathname);
|
if (fs.pathExistsSync(path.resolve(__dirname, pathname))) return path.resolve(__dirname, pathname);
|
||||||
@@ -364,7 +364,7 @@ export function findFileSync(pathname: string, doThrow = true) {
|
|||||||
if (fs.pathExistsSync(path.resolve(os.homedir(), pathname))) return path.resolve(os.homedir(), pathname);
|
if (fs.pathExistsSync(path.resolve(os.homedir(), pathname))) return path.resolve(os.homedir(), pathname);
|
||||||
if (fs.pathExistsSync(path.resolve(os.homedir(), '.hydro', pathname))) return path.resolve(os.homedir(), '.hydro', pathname);
|
if (fs.pathExistsSync(path.resolve(os.homedir(), '.hydro', pathname))) return path.resolve(os.homedir(), '.hydro', pathname);
|
||||||
if (fs.pathExistsSync(path.resolve(os.homedir(), '.config', 'hydro', pathname))) return path.resolve(os.homedir(), '.config', 'hydro', pathname);
|
if (fs.pathExistsSync(path.resolve(os.homedir(), '.config', 'hydro', pathname))) return path.resolve(os.homedir(), '.config', 'hydro', pathname);
|
||||||
if (doThrow) throw new Error(`File ${pathname} not found`);
|
if (doThrow) throw (typeof doThrow !== 'boolean' ? doThrow : new Error(`File ${pathname} not found`));
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user