@exercode/problem-utils 2.4.3 → 3.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +23 -0
- package/dist/cli/checkAllProblems.cjs +1 -1
- package/dist/cli/checkAllProblems.cjs.map +1 -1
- package/dist/cli/checkAllProblems.js +1 -1
- package/dist/cli/checkAllProblems.js.map +1 -1
- package/dist/cli/exercodeProblem.cjs +8 -2
- package/dist/cli/exercodeProblem.cjs.map +1 -1
- package/dist/cli/exercodeProblem.js +8 -2
- package/dist/cli/exercodeProblem.js.map +1 -1
- package/dist/cli/validateLearningMaterial.cjs +2 -0
- package/dist/cli/validateLearningMaterial.cjs.map +1 -0
- package/dist/cli/validateLearningMaterial.d.ts +7 -0
- package/dist/cli/validateLearningMaterial.js +2 -0
- package/dist/cli/validateLearningMaterial.js.map +1 -0
- package/dist/helpers/checkProblemDirIsolation.cjs +1 -1
- package/dist/helpers/checkProblemDirIsolation.js +1 -1
- package/dist/helpers/cleanWorkingDirectory.cjs +1 -1
- package/dist/helpers/cleanWorkingDirectory.cjs.map +1 -1
- package/dist/helpers/cleanWorkingDirectory.d.ts +2 -6
- package/dist/helpers/cleanWorkingDirectory.js +1 -1
- package/dist/helpers/cleanWorkingDirectory.js.map +1 -1
- package/dist/helpers/compareExpectedOutputFiles.cjs +1 -1
- package/dist/helpers/compareExpectedOutputFiles.cjs.map +1 -1
- package/dist/helpers/compareExpectedOutputFiles.js +1 -1
- package/dist/helpers/compareExpectedOutputFiles.js.map +1 -1
- package/dist/helpers/copyTestCaseFileInput.cjs +1 -1
- package/dist/helpers/copyTestCaseFileInput.cjs.map +1 -1
- package/dist/helpers/copyTestCaseFileInput.js +1 -1
- package/dist/helpers/copyTestCaseFileInput.js.map +1 -1
- package/dist/helpers/judgeByStaticAnalysis.cjs +3 -3
- package/dist/helpers/judgeByStaticAnalysis.js +3 -3
- package/dist/helpers/readOutputFiles.cjs +1 -1
- package/dist/helpers/readOutputFiles.cjs.map +1 -1
- package/dist/helpers/readOutputFiles.d.ts +0 -9
- package/dist/helpers/readOutputFiles.js +1 -1
- package/dist/helpers/readOutputFiles.js.map +1 -1
- package/dist/helpers/runCommandInTemporaryPackageManagerProject.cjs +1 -1
- package/dist/helpers/runCommandInTemporaryPackageManagerProject.cjs.map +1 -1
- package/dist/helpers/runCommandInTemporaryPackageManagerProject.d.ts +0 -3
- package/dist/helpers/runCommandInTemporaryPackageManagerProject.js +1 -1
- package/dist/helpers/runCommandInTemporaryPackageManagerProject.js.map +1 -1
- package/dist/helpers/spawnSyncWithTimeout.cjs +1 -1
- package/dist/helpers/spawnSyncWithTimeout.cjs.map +1 -1
- package/dist/helpers/spawnSyncWithTimeout.d.ts +0 -7
- package/dist/helpers/spawnSyncWithTimeout.js +1 -1
- package/dist/helpers/spawnSyncWithTimeout.js.map +1 -1
- package/dist/helpers/startHttpServer.cjs +1 -1
- package/dist/helpers/startHttpServer.cjs.map +1 -1
- package/dist/helpers/startHttpServer.js +1 -1
- package/dist/helpers/startHttpServer.js.map +1 -1
- package/dist/helpers/stdioJudgeRules.cjs +2 -0
- package/dist/helpers/stdioJudgeRules.cjs.map +1 -0
- package/dist/helpers/stdioJudgeRules.d.ts +4 -0
- package/dist/helpers/stdioJudgeRules.js +2 -0
- package/dist/helpers/stdioJudgeRules.js.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +5 -2
- package/dist/index.js +1 -1
- package/dist/learningMaterial/frontmatter.cjs +2 -0
- package/dist/learningMaterial/frontmatter.cjs.map +1 -0
- package/dist/learningMaterial/frontmatter.d.ts +8 -0
- package/dist/learningMaterial/frontmatter.js +2 -0
- package/dist/learningMaterial/frontmatter.js.map +1 -0
- package/dist/learningMaterial/fsHelpers.cjs +2 -0
- package/dist/learningMaterial/fsHelpers.cjs.map +1 -0
- package/dist/learningMaterial/fsHelpers.d.ts +30 -0
- package/dist/learningMaterial/fsHelpers.js +2 -0
- package/dist/learningMaterial/fsHelpers.js.map +1 -0
- package/dist/learningMaterial/schemas.cjs +2 -0
- package/dist/learningMaterial/schemas.cjs.map +1 -0
- package/dist/learningMaterial/schemas.d.ts +241 -0
- package/dist/learningMaterial/schemas.js +2 -0
- package/dist/learningMaterial/schemas.js.map +1 -0
- package/dist/learningMaterial/validateContest.cjs +2 -0
- package/dist/learningMaterial/validateContest.cjs.map +1 -0
- package/dist/learningMaterial/validateContest.d.ts +16 -0
- package/dist/learningMaterial/validateContest.js +2 -0
- package/dist/learningMaterial/validateContest.js.map +1 -0
- package/dist/learningMaterial/validateCourse.cjs +2 -0
- package/dist/learningMaterial/validateCourse.cjs.map +1 -0
- package/dist/learningMaterial/validateCourse.d.ts +11 -0
- package/dist/learningMaterial/validateCourse.js +2 -0
- package/dist/learningMaterial/validateCourse.js.map +1 -0
- package/dist/learningMaterial/validateMaterial.cjs +4 -0
- package/dist/learningMaterial/validateMaterial.cjs.map +1 -0
- package/dist/learningMaterial/validateMaterial.d.ts +34 -0
- package/dist/learningMaterial/validateMaterial.js +4 -0
- package/dist/learningMaterial/validateMaterial.js.map +1 -0
- package/dist/learningMaterial/validateProblem.cjs +2 -0
- package/dist/learningMaterial/validateProblem.cjs.map +1 -0
- package/dist/learningMaterial/validateProblem.d.ts +6 -0
- package/dist/learningMaterial/validateProblem.js +2 -0
- package/dist/learningMaterial/validateProblem.js.map +1 -0
- package/dist/learningMaterial/validationResult.cjs +3 -0
- package/dist/learningMaterial/validationResult.cjs.map +1 -0
- package/dist/learningMaterial/validationResult.d.ts +9 -0
- package/dist/learningMaterial/validationResult.js +3 -0
- package/dist/learningMaterial/validationResult.js.map +1 -0
- package/dist/presets/command.cjs +1 -1
- package/dist/presets/command.cjs.map +1 -1
- package/dist/presets/command.d.ts +0 -16
- package/dist/presets/command.js +1 -1
- package/dist/presets/command.js.map +1 -1
- package/dist/presets/evaluation.cjs +4 -4
- package/dist/presets/evaluation.cjs.map +1 -1
- package/dist/presets/evaluation.js +4 -4
- package/dist/presets/evaluation.js.map +1 -1
- package/dist/presets/guiCommand.cjs +3 -3
- package/dist/presets/guiCommand.cjs.map +1 -1
- package/dist/presets/guiCommand.d.ts +0 -24
- package/dist/presets/guiCommand.js +3 -3
- package/dist/presets/guiCommand.js.map +1 -1
- package/dist/presets/stdio.cjs +1 -1
- package/dist/presets/stdio.cjs.map +1 -1
- package/dist/presets/stdio.js +1 -1
- package/dist/presets/stdio.js.map +1 -1
- package/dist/types/language.cjs +2 -2
- package/dist/types/language.cjs.map +1 -1
- package/dist/types/language.js +2 -2
- package/dist/types/language.js.map +1 -1
- package/package.json +3 -2
- package/dist/helpers/runCustomRunner.cjs +0 -2
- package/dist/helpers/runCustomRunner.cjs.map +0 -1
- package/dist/helpers/runCustomRunner.d.ts +0 -8
- package/dist/helpers/runCustomRunner.js +0 -2
- package/dist/helpers/runCustomRunner.js.map +0 -1
- package/dist/helpers/safeFs.cjs +0 -2
- package/dist/helpers/safeFs.cjs.map +0 -1
- package/dist/helpers/safeFs.d.ts +0 -29
- package/dist/helpers/safeFs.js +0 -2
- package/dist/helpers/safeFs.js.map +0 -1
- package/dist/helpers/sandboxUser.cjs +0 -3
- package/dist/helpers/sandboxUser.cjs.map +0 -1
- package/dist/helpers/sandboxUser.d.ts +0 -146
- package/dist/helpers/sandboxUser.js +0 -3
- package/dist/helpers/sandboxUser.js.map +0 -1
package/README.md
CHANGED
|
@@ -31,6 +31,29 @@ The all-problem check judges serially by default because time limits are measure
|
|
|
31
31
|
|
|
32
32
|
A standard stdin/stdout problem must NOT commit a `judge.ts` or `debug.ts` that is identical to the default stdio harness: the absence of `judge.ts` marks the problem as standard, and committed copies would drift from the server's defaults. The CLI rejects such files; a file kept intentionally (e.g. to demonstrate the default harness) can add an explanatory comment to be treated as custom.
|
|
33
33
|
|
|
34
|
+
## Validators
|
|
35
|
+
|
|
36
|
+
The CLI also validates learning-material files without running any program, mirroring the checks the Exercode importer applies:
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
# Validate problem directories (problem.md frontmatter, test_cases, model_answers, templates, judge.ts / debug.ts).
|
|
40
|
+
bun x exercode-problem validate-problem <problemDir>...
|
|
41
|
+
# Validate a course directory (course.yaml, lecture materials with embedded questions, problem references).
|
|
42
|
+
bun x exercode-problem validate-course <courseDir> [--problems-dir <dir>]
|
|
43
|
+
# Validate a contest (*.contest.yaml) file.
|
|
44
|
+
bun x exercode-problem validate-contest <contestYamlPath> [--problems-dir <dir>]
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
Each target prints `OK` or `NG` followed by its errors and warnings; the command exits 1 when any target has an error. `--problems-dir` points to the directory holding the referenced problems; a course is always searched at any depth, since Exercode links a material only to the problems inside its course, so for a course the option must name a directory inside it. The validators are also exported (`validateProblemDirectory`, `validateCourseDirectory`, `validateContestFile`, `validateMaterialFile`).
|
|
48
|
+
|
|
49
|
+
## Agent skills
|
|
50
|
+
|
|
51
|
+
The [`skills/`](skills/) directory holds skills for AI coding agents that author and review Exercode learning content: `generate-learning-content` (entry point), `generate-course-materials`, `generate-judge-problems`, `generate-judge-contest`, `review-learning-content`, and `setup-exercode-course-repository`. Agents working in this repository load them through the symlinks under `.claude/skills/`; install them elsewhere with the [skills](https://github.com/vercel-labs/skills) CLI:
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
bun x skills add WillBooster/exercode-problem-utils --agent claude-code --agent codex
|
|
55
|
+
```
|
|
56
|
+
|
|
34
57
|
## Test cases
|
|
35
58
|
|
|
36
59
|
A problem keeps its test cases under `test_cases/`. A test case id is the shared name of the following entries, and each entry is optional:
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../_virtual/_rolldown/runtime.cjs"),t=require("../types/testCaseResult.cjs"),n=require("../helpers/defaultStdioHarness.cjs"),r=require("../helpers/readTestCases.cjs"),i=require("../
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../_virtual/_rolldown/runtime.cjs"),t=require("../types/testCaseResult.cjs"),n=require("../helpers/defaultStdioHarness.cjs"),r=require("../helpers/readTestCases.cjs"),i=require("../helpers/temporaryProblemDirCopy.cjs"),a=require("../helpers/readProblemMarkdownFrontMatter.cjs"),o=require("../types/decisionCode.cjs"),s=require("../helpers/runHarnessProcess.cjs"),c=require("../helpers/findModelAnswerDirs.cjs"),l=require("./runSingleHarness.cjs");let u=require("node:path");u=e.__toESM(u,1);let d=require("node:fs/promises");d=e.__toESM(d,1);const f=1e3,p=new Map(Object.entries(o.DecisionCode).map(([e,t])=>[t,e]));async function m(e){let t=_(e),i=u.default.resolve(t.rootDir),o=e=>(u.default.relative(i,e)||`.`).replaceAll(u.default.sep,`/`),s=await v(i),d=s.filter(e=>{let n=o(e);return t.only.length>0&&!t.only.some(e=>n.includes(e))?!1:!t.skip.some(e=>n.includes(e))});if(d.length===0)return console.error(s.length===0?`No problem directories (containing problem.md or <id>.problem.md) found under ${i}.`:`All ${s.length} problem directories under ${i} were excluded by --only/--skip.`),1;let f=[],p=[];for(let e of d){let t=await n.findDefaultStdioHarnessFiles(e);if(t.length>0){f.push(`${o(e)}: ${l.formatDefaultHarnessError(t)}`);continue}let i=await c.findModelAnswerDirs(e);if(i.length===0){f.push(`${o(e)}: no model answers found under model_answers/`);continue}if(!await b(u.default.join(e,`judge.ts`))&&(await r.readTestCases(u.default.join(e,`test_cases`))).length===0){let t;try{t=await a.readProblemMarkdownFrontMatter(e)}catch(t){f.push(`${o(e)}: failed to read the problem markdown front matter: ${t instanceof Error?t.message:String(t)}`);continue}if(!a.judgesWithoutTestCases(t)){f.push(`${o(e)}: ${l.MISSING_TEST_CASES_ERROR}`);continue}}let s=await c.findFailingModelAnswerDirs(e);p.push(...i.map(t=>({problemDir:e,answerDir:t,expectation:`accepted`})),...s.map(t=>({problemDir:e,answerDir:t,expectation:`rejected`})))}for(let e of f)console.error(`✗ ${e}`);let m=u.default.resolve(process.argv[1]??``),g=0,y=0;return await Promise.all(Array.from({length:Math.max(1,Math.min(t.concurrency,p.length))},async()=>{for(;y<p.length;){let e=p[y++];if(!e)return;let t=`${o(e.problemDir)} ${u.default.relative(e.problemDir,e.answerDir).replaceAll(u.default.sep,`/`)}`,n=await h(e,m);n===void 0?(g++,console.info(`✓ ${t}`)):(f.push(`${t}: ${n}`),console.error(`✗ ${t}: ${n}`))}})),console.info(`\n${g} passed, ${f.length} failed (${p.length} runs, ${d.length} problems)`),f.length===0?0:1}async function h(e,t){let n,r;try{({tempRoot:n,copiedProblemDir:r}=await i.copyProblemDirToTemporaryRoot(e.problemDir))}catch(e){return x(`failed to copy the problem directory to a temporary location: ${e instanceof Error?e.message:String(e)}`)}let a,o;try{a=g(e,await s.runHarnessProcess([`run`,t,`judge`,u.default.relative(e.problemDir,e.answerDir)],{cwd:r,env:process.env,timeoutMs:6e5,maxOutputBytes:67108864,tempRoot:n}))}catch(e){a=x(`harness execution failed: ${e instanceof Error?e.message:String(e)}`)}finally{o=await i.forciblyRemoveDirectory(n)}if(o)return a;let c=`failed to remove the temporary copy at ${n} (judged code may have left permission-locked files)`;return a===void 0?c:x(`${a}; ${c}`)}function g(e,n){let{stdout:r,stderr:i}=n;if(n.failureReason!==void 0)return x(n.failureReason);if(n.exitCode!==0)return x(`harness exited with ${n.exitCode??`a signal`}${i.trim()?`: ${i.trim()}`:``}`);let a=r.split(/\r?\n/).filter(e=>e.startsWith(t.TEST_CASE_RESULT_PREFIX)),s=[];for(let e of a){let n;try{n=t.testCaseResultSchema.safeParse(JSON.parse(e.slice(t.TEST_CASE_RESULT_PREFIX.length)))}catch{n=void 0}if(!n?.success)return x(`malformed test case result line: ${e}`);s.push(n.data)}if(s.length===0)return`no test case results were printed`;if(e.expectation===`accepted`){let e=s.find(e=>e.decisionCode!==o.DecisionCode.ACCEPTED);return e?x(`${p.get(e.decisionCode)??e.decisionCode} on test case ${e.testCaseId}${e.stderr?.trim()?`: ${e.stderr.trim()}`:``}`):void 0}return s.every(e=>e.decisionCode===o.DecisionCode.ACCEPTED)?`expected at least one failing test case, but all test cases were accepted`:void 0}function _(e){let t={rootDir:`.`,concurrency:1,only:[],skip:[]},n=!1;for(let r=0;r<e.length;r++){let i=e[r];if(i===void 0)break;if(i===`--concurrency`||i===`--only`||i===`--skip`){let n=e[++r];if(n===void 0)throw Error(`${i} requires a value`);if(i===`--concurrency`){if(t.concurrency=Number(n),!Number.isInteger(t.concurrency)||t.concurrency<=0)throw Error(`--concurrency requires a positive integer, but got ${n}`)}else i===`--only`?t.only.push(n):t.skip.push(n)}else if(i.startsWith(`--`))throw Error(`Unknown option: ${i}`);else if(n)throw Error(`Only one root directory can be specified, but got both ${t.rootDir} and ${i}`);else t.rootDir=i,n=!0}return t}async function v(e){let t=[];return await y(e,t),t.toSorted()}async function y(e,t){let n=await d.default.readdir(e,{withFileTypes:!0});if(n.some(e=>e.isFile()&&(e.name===`problem.md`||e.name.endsWith(`.problem.md`)))){t.push(e);return}for(let r of n)!r.isDirectory()||r.name===`node_modules`||r.name.startsWith(`.`)||await y(u.default.join(e,r.name),t)}async function b(e){try{return await d.default.stat(e),!0}catch{return!1}}function x(e){return e.length<=f?e:`${e.slice(0,f)}...`}exports.checkAllProblems=m;
|
|
2
2
|
//# sourceMappingURL=checkAllProblems.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"checkAllProblems.cjs","names":["DecisionCode","path","findDefaultStdioHarnessFiles","formatDefaultHarnessError","findModelAnswerDirs","readTestCases","readProblemMarkdownFrontMatter","judgesWithoutTestCases","MISSING_TEST_CASES_ERROR","findFailingModelAnswerDirs","copyProblemDirToTemporaryRoot","runHarnessProcess","forciblyRemoveDirectory","TEST_CASE_RESULT_PREFIX","testCaseResultSchema","fs"],"sources":["../../src/cli/checkAllProblems.ts"],"sourcesContent":["import fs from 'node:fs/promises';\nimport path from 'node:path';\n\nimport { findDefaultStdioHarnessFiles } from '../helpers/defaultStdioHarness.js';\nimport { findFailingModelAnswerDirs, findModelAnswerDirs } from '../helpers/findModelAnswerDirs.js';\nimport { judgesWithoutTestCases, readProblemMarkdownFrontMatter } from '../helpers/readProblemMarkdownFrontMatter.js';\nimport { readTestCases } from '../helpers/readTestCases.js';\nimport { type HarnessProcessResult, runHarnessProcess } from '../helpers/runHarnessProcess.js';\nimport { copyProblemDirToTemporaryRoot, forciblyRemoveDirectory } from '../helpers/temporaryProblemDirCopy.js';\nimport { DecisionCode } from '../types/decisionCode.js';\nimport { TEST_CASE_RESULT_PREFIX, testCaseResultSchema } from '../types/testCaseResult.js';\n\nimport { formatDefaultHarnessError, MISSING_TEST_CASES_ERROR } from './runSingleHarness.js';\n\nconst RUN_TIMEOUT_MS = 600_000;\nconst MAX_RUN_OUTPUT_BYTES = 64 * 1024 * 1024;\nconst MAX_FAILURE_DETAIL_LENGTH = 1000;\n\n// DecisionCode is a plain const object (not a TypeScript enum), so it has no reverse mapping.\nconst decisionCodeNames = new Map<number, string>(Object.entries(DecisionCode).map(([name, code]) => [code, name]));\n\ninterface CheckOptions {\n rootDir: string;\n concurrency: number;\n only: string[];\n skip: string[];\n}\n\ninterface CheckRun {\n problemDir: string;\n answerDir: string;\n /** Whether all test cases must be accepted (`model_answers`) or at least one must fail (`model_answers.fails`). */\n expectation: 'accepted' | 'rejected';\n}\n\n/**\n * Judge all model answers of all problems (directories containing `problem.md` or\n * `<id>.problem.md`) under a root directory: `model_answers/*` must be fully accepted and\n * `model_answers.fails/*` must fail at least one test case. Returns the process exit code.\n */\nexport async function checkAllProblems(args: readonly string[]): Promise<number> {\n const options = parseCheckArgs(args);\n const rootDir = path.resolve(options.rootDir);\n // Normalize to forward slashes so --only / --skip substrings like courses/foo match on Windows.\n const toRelative = (dir: string): string => (path.relative(rootDir, dir) || '.').replaceAll(path.sep, '/');\n\n const allProblemDirs = await findProblemDirs(rootDir);\n const problemDirs = allProblemDirs.filter((problemDir) => {\n const relativeDir = toRelative(problemDir);\n if (options.only.length > 0 && !options.only.some((substring) => relativeDir.includes(substring))) return false;\n return !options.skip.some((substring) => relativeDir.includes(substring));\n });\n if (problemDirs.length === 0) {\n console.error(\n allProblemDirs.length === 0\n ? `No problem directories (containing problem.md or <id>.problem.md) found under ${rootDir}.`\n : `All ${allProblemDirs.length} problem directories under ${rootDir} were excluded by --only/--skip.`\n );\n return 1;\n }\n\n const failures: string[] = [];\n const runs: CheckRun[] = [];\n for (const problemDir of problemDirs) {\n const defaultHarnessFileNames = await findDefaultStdioHarnessFiles(problemDir);\n if (defaultHarnessFileNames.length > 0) {\n failures.push(`${toRelative(problemDir)}: ${formatDefaultHarnessError(defaultHarnessFileNames)}`);\n continue;\n }\n\n const modelAnswerDirs = await findModelAnswerDirs(problemDir);\n if (modelAnswerDirs.length === 0) {\n failures.push(`${toRelative(problemDir)}: no model answers found under model_answers/`);\n continue;\n }\n\n // Without test cases, stdioJudgePreset prints a single accepted sentinel result, so a standard\n // problem with an empty or missing test_cases/ would otherwise pass without being judged —\n // unless static-analysis rules or manual scoring make the problem judgeable without them.\n if (!(await fileExists(path.join(problemDir, 'judge.ts')))) {\n const testCases = await readTestCases(path.join(problemDir, 'test_cases'));\n if (testCases.length === 0) {\n let frontMatter;\n try {\n frontMatter = await readProblemMarkdownFrontMatter(problemDir);\n } catch (error) {\n failures.push(\n `${toRelative(problemDir)}: failed to read the problem markdown front matter: ${error instanceof Error ? error.message : String(error)}`\n );\n continue;\n }\n if (!judgesWithoutTestCases(frontMatter)) {\n failures.push(`${toRelative(problemDir)}: ${MISSING_TEST_CASES_ERROR}`);\n continue;\n }\n }\n }\n\n const failingModelAnswerDirs = await findFailingModelAnswerDirs(problemDir);\n runs.push(\n ...modelAnswerDirs.map((answerDir): CheckRun => ({ problemDir, answerDir, expectation: 'accepted' })),\n ...failingModelAnswerDirs.map((answerDir): CheckRun => ({ problemDir, answerDir, expectation: 'rejected' }))\n );\n }\n for (const failure of failures) console.error(`✗ ${failure}`);\n\n const cliEntryPath = path.resolve(process.argv[1] ?? '');\n let passedCount = 0;\n let nextRunIndex = 0;\n await Promise.all(\n Array.from({ length: Math.max(1, Math.min(options.concurrency, runs.length)) }, async () => {\n while (nextRunIndex < runs.length) {\n const run = runs[nextRunIndex++];\n if (!run) return;\n const label = `${toRelative(run.problemDir)} ${path.relative(run.problemDir, run.answerDir).replaceAll(path.sep, '/')}`;\n const failureDetail = await executeCheckRun(run, cliEntryPath);\n if (failureDetail === undefined) {\n passedCount++;\n console.info(`✓ ${label}`);\n } else {\n failures.push(`${label}: ${failureDetail}`);\n console.error(`✗ ${label}: ${failureDetail}`);\n }\n }\n })\n );\n\n console.info(\n `\\n${passedCount} passed, ${failures.length} failed (${runs.length} runs, ${problemDirs.length} problems)`\n );\n return failures.length === 0 ? 0 : 1;\n}\n\n/**\n * Run one answer directory through the problem's harness and return a failure detail, if any.\n * The problem directory is copied to a temporary location first so that judging (e.g. build\n * artifacts in answer directories) never modifies the checked repository.\n */\nasync function executeCheckRun(run: CheckRun, cliEntryPath: string): Promise<string | undefined> {\n let tempRoot: string;\n let copiedProblemDir: string;\n try {\n ({ tempRoot, copiedProblemDir } = await copyProblemDirToTemporaryRoot(run.problemDir));\n } catch (error) {\n return truncate(\n `failed to copy the problem directory to a temporary location: ${error instanceof Error ? error.message : String(error)}`\n );\n }\n\n let harnessFailureDetail;\n let removedTempRoot;\n try {\n const result = await runHarnessProcess(\n ['run', cliEntryPath, 'judge', path.relative(run.problemDir, run.answerDir)],\n {\n cwd: copiedProblemDir,\n env: createHarnessEnv(),\n timeoutMs: RUN_TIMEOUT_MS,\n maxOutputBytes: MAX_RUN_OUTPUT_BYTES,\n tempRoot,\n }\n );\n harnessFailureDetail = summarizeHarnessFailure(run, result);\n } catch (error) {\n harnessFailureDetail = truncate(\n `harness execution failed: ${error instanceof Error ? error.message : String(error)}`\n );\n } finally {\n removedTempRoot = await forciblyRemoveDirectory(tempRoot);\n }\n if (removedTempRoot) return harnessFailureDetail;\n const removalFailureDetail = `failed to remove the temporary copy at ${tempRoot} (judged code may have left permission-locked files)`;\n return harnessFailureDetail === undefined\n ? removalFailureDetail\n : truncate(`${harnessFailureDetail}; ${removalFailureDetail}`);\n}\n\n/** Return why the harness run failed the check, or `undefined` when it passed. */\nfunction summarizeHarnessFailure(run: CheckRun, result: HarnessProcessResult): string | undefined {\n const { stdout, stderr } = result;\n if (result.failureReason !== undefined) return truncate(result.failureReason);\n if (result.exitCode !== 0) {\n return truncate(`harness exited with ${result.exitCode ?? 'a signal'}${stderr.trim() ? `: ${stderr.trim()}` : ''}`);\n }\n\n const resultLines = stdout.split(/\\r?\\n/).filter((line) => line.startsWith(TEST_CASE_RESULT_PREFIX));\n const testCaseResults = [];\n for (const line of resultLines) {\n let parsedResult;\n try {\n parsedResult = testCaseResultSchema.safeParse(JSON.parse(line.slice(TEST_CASE_RESULT_PREFIX.length)));\n } catch {\n parsedResult = undefined;\n }\n if (!parsedResult?.success) return truncate(`malformed test case result line: ${line}`);\n testCaseResults.push(parsedResult.data);\n }\n if (testCaseResults.length === 0) return 'no test case results were printed';\n\n if (run.expectation === 'accepted') {\n const rejectedResult = testCaseResults.find((result) => result.decisionCode !== DecisionCode.ACCEPTED);\n if (rejectedResult) {\n return truncate(\n `${decisionCodeNames.get(rejectedResult.decisionCode) ?? rejectedResult.decisionCode} on test case ${rejectedResult.testCaseId}${rejectedResult.stderr?.trim() ? `: ${rejectedResult.stderr.trim()}` : ''}`\n );\n }\n return undefined;\n }\n return testCaseResults.every((result) => result.decisionCode === DecisionCode.ACCEPTED)\n ? 'expected at least one failing test case, but all test cases were accepted'\n : undefined;\n}\n\n// The all-problem check runs harnesses concurrently and has no sandbox-delegation contract, while the sandbox\n// helpers assume one harness at a time (their pkill targets every process of the sandbox user), so\n// never forward the sandbox user to judged runs.\nfunction createHarnessEnv(): NodeJS.ProcessEnv {\n const env = { ...process.env };\n delete env.EXERCODE_SANDBOX_USER;\n return env;\n}\n\nfunction parseCheckArgs(args: readonly string[]): CheckOptions {\n const options: CheckOptions = {\n rootDir: '.',\n // Serial by default: judging decides TIME_LIMIT_EXCEEDED from wall-clock time, so parallel\n // runs on a small CI runner could fail timing-sensitive problems non-deterministically.\n concurrency: 1,\n only: [],\n skip: [],\n };\n let hasRootDir = false;\n for (let index = 0; index < args.length; index++) {\n const arg = args[index];\n if (arg === undefined) break;\n if (arg === '--concurrency' || arg === '--only' || arg === '--skip') {\n const value = args[++index];\n if (value === undefined) throw new Error(`${arg} requires a value`);\n if (arg === '--concurrency') {\n options.concurrency = Number(value);\n if (!Number.isInteger(options.concurrency) || options.concurrency <= 0) {\n throw new Error(`--concurrency requires a positive integer, but got ${value}`);\n }\n } else if (arg === '--only') {\n options.only.push(value);\n } else {\n options.skip.push(value);\n }\n } else if (arg.startsWith('--')) {\n throw new Error(`Unknown option: ${arg}`);\n } else if (hasRootDir) {\n throw new Error(`Only one root directory can be specified, but got both ${options.rootDir} and ${arg}`);\n } else {\n options.rootDir = arg;\n hasRootDir = true;\n }\n }\n return options;\n}\n\n/** Find directories containing `problem.md` or `<id>.problem.md`, without descending into found problems. */\nasync function findProblemDirs(rootDir: string): Promise<string[]> {\n const problemDirs: string[] = [];\n await visitDirectory(rootDir, problemDirs);\n return problemDirs.toSorted();\n}\n\nasync function visitDirectory(dir: string, problemDirs: string[]): Promise<void> {\n // Traversal errors (e.g. an unreadable subtree) must fail the check: skipping them silently\n // could report a green result while covering only part of the repository.\n const entries = await fs.readdir(dir, { withFileTypes: true });\n if (entries.some((entry) => entry.isFile() && (entry.name === 'problem.md' || entry.name.endsWith('.problem.md')))) {\n problemDirs.push(dir);\n return;\n }\n for (const entry of entries) {\n if (!entry.isDirectory() || entry.name === 'node_modules' || entry.name.startsWith('.')) continue;\n await visitDirectory(path.join(dir, entry.name), problemDirs);\n }\n}\n\nasync function fileExists(filePath: string): Promise<boolean> {\n try {\n await fs.stat(filePath);\n return true;\n } catch {\n return false;\n }\n}\n\nfunction truncate(text: string): string {\n return text.length <= MAX_FAILURE_DETAIL_LENGTH ? text : `${text.slice(0, MAX_FAILURE_D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DecisionCode","path","findDefaultStdioHarnessFiles","formatDefaultHarnessError","findModelAnswerDirs","readTestCases","readProblemMarkdownFrontMatter","judgesWithoutTestCases","MISSING_TEST_CASES_ERROR","findFailingModelAnswerDirs","copyProblemDirToTemporaryRoot","runHarnessProcess","forciblyRemoveDirectory","TEST_CASE_RESULT_PREFIX","testCaseResultSchema","fs"],"sources":["../../src/cli/checkAllProblems.ts"],"sourcesContent":["import fs from 'node:fs/promises';\nimport path from 'node:path';\n\nimport { findDefaultStdioHarnessFiles } from '../helpers/defaultStdioHarness.js';\nimport { findFailingModelAnswerDirs, findModelAnswerDirs } from '../helpers/findModelAnswerDirs.js';\nimport { judgesWithoutTestCases, readProblemMarkdownFrontMatter } from '../helpers/readProblemMarkdownFrontMatter.js';\nimport { readTestCases } from '../helpers/readTestCases.js';\nimport { type HarnessProcessResult, runHarnessProcess } from '../helpers/runHarnessProcess.js';\nimport { copyProblemDirToTemporaryRoot, forciblyRemoveDirectory } from '../helpers/temporaryProblemDirCopy.js';\nimport { DecisionCode } from '../types/decisionCode.js';\nimport { TEST_CASE_RESULT_PREFIX, testCaseResultSchema } from '../types/testCaseResult.js';\n\nimport { formatDefaultHarnessError, MISSING_TEST_CASES_ERROR } from './runSingleHarness.js';\n\nconst RUN_TIMEOUT_MS = 600_000;\nconst MAX_RUN_OUTPUT_BYTES = 64 * 1024 * 1024;\nconst MAX_FAILURE_DETAIL_LENGTH = 1000;\n\n// DecisionCode is a plain const object (not a TypeScript enum), so it has no reverse mapping.\nconst decisionCodeNames = new Map<number, string>(Object.entries(DecisionCode).map(([name, code]) => [code, name]));\n\ninterface CheckOptions {\n rootDir: string;\n concurrency: number;\n only: string[];\n skip: string[];\n}\n\ninterface CheckRun {\n problemDir: string;\n answerDir: string;\n /** Whether all test cases must be accepted (`model_answers`) or at least one must fail (`model_answers.fails`). */\n expectation: 'accepted' | 'rejected';\n}\n\n/**\n * Judge all model answers of all problems (directories containing `problem.md` or\n * `<id>.problem.md`) under a root directory: `model_answers/*` must be fully accepted and\n * `model_answers.fails/*` must fail at least one test case. Returns the process exit code.\n */\nexport async function checkAllProblems(args: readonly string[]): Promise<number> {\n const options = parseCheckArgs(args);\n const rootDir = path.resolve(options.rootDir);\n // Normalize to forward slashes so --only / --skip substrings like courses/foo match on Windows.\n const toRelative = (dir: string): string => (path.relative(rootDir, dir) || '.').replaceAll(path.sep, '/');\n\n const allProblemDirs = await findProblemDirs(rootDir);\n const problemDirs = allProblemDirs.filter((problemDir) => {\n const relativeDir = toRelative(problemDir);\n if (options.only.length > 0 && !options.only.some((substring) => relativeDir.includes(substring))) return false;\n return !options.skip.some((substring) => relativeDir.includes(substring));\n });\n if (problemDirs.length === 0) {\n console.error(\n allProblemDirs.length === 0\n ? `No problem directories (containing problem.md or <id>.problem.md) found under ${rootDir}.`\n : `All ${allProblemDirs.length} problem directories under ${rootDir} were excluded by --only/--skip.`\n );\n return 1;\n }\n\n const failures: string[] = [];\n const runs: CheckRun[] = [];\n for (const problemDir of problemDirs) {\n const defaultHarnessFileNames = await findDefaultStdioHarnessFiles(problemDir);\n if (defaultHarnessFileNames.length > 0) {\n failures.push(`${toRelative(problemDir)}: ${formatDefaultHarnessError(defaultHarnessFileNames)}`);\n continue;\n }\n\n const modelAnswerDirs = await findModelAnswerDirs(problemDir);\n if (modelAnswerDirs.length === 0) {\n failures.push(`${toRelative(problemDir)}: no model answers found under model_answers/`);\n continue;\n }\n\n // Without test cases, stdioJudgePreset prints a single accepted sentinel result, so a standard\n // problem with an empty or missing test_cases/ would otherwise pass without being judged —\n // unless static-analysis rules or manual scoring make the problem judgeable without them.\n if (!(await fileExists(path.join(problemDir, 'judge.ts')))) {\n const testCases = await readTestCases(path.join(problemDir, 'test_cases'));\n if (testCases.length === 0) {\n let frontMatter;\n try {\n frontMatter = await readProblemMarkdownFrontMatter(problemDir);\n } catch (error) {\n failures.push(\n `${toRelative(problemDir)}: failed to read the problem markdown front matter: ${error instanceof Error ? error.message : String(error)}`\n );\n continue;\n }\n if (!judgesWithoutTestCases(frontMatter)) {\n failures.push(`${toRelative(problemDir)}: ${MISSING_TEST_CASES_ERROR}`);\n continue;\n }\n }\n }\n\n const failingModelAnswerDirs = await findFailingModelAnswerDirs(problemDir);\n runs.push(\n ...modelAnswerDirs.map((answerDir): CheckRun => ({ problemDir, answerDir, expectation: 'accepted' })),\n ...failingModelAnswerDirs.map((answerDir): CheckRun => ({ problemDir, answerDir, expectation: 'rejected' }))\n );\n }\n for (const failure of failures) console.error(`✗ ${failure}`);\n\n const cliEntryPath = path.resolve(process.argv[1] ?? '');\n let passedCount = 0;\n let nextRunIndex = 0;\n await Promise.all(\n Array.from({ length: Math.max(1, Math.min(options.concurrency, runs.length)) }, async () => {\n while (nextRunIndex < runs.length) {\n const run = runs[nextRunIndex++];\n if (!run) return;\n const label = `${toRelative(run.problemDir)} ${path.relative(run.problemDir, run.answerDir).replaceAll(path.sep, '/')}`;\n const failureDetail = await executeCheckRun(run, cliEntryPath);\n if (failureDetail === undefined) {\n passedCount++;\n console.info(`✓ ${label}`);\n } else {\n failures.push(`${label}: ${failureDetail}`);\n console.error(`✗ ${label}: ${failureDetail}`);\n }\n }\n })\n );\n\n console.info(\n `\\n${passedCount} passed, ${failures.length} failed (${runs.length} runs, ${problemDirs.length} problems)`\n );\n return failures.length === 0 ? 0 : 1;\n}\n\n/**\n * Run one answer directory through the problem's harness and return a failure detail, if any.\n * The problem directory is copied to a temporary location first so that judging (e.g. build\n * artifacts in answer directories) never modifies the checked repository.\n */\nasync function executeCheckRun(run: CheckRun, cliEntryPath: string): Promise<string | undefined> {\n let tempRoot: string;\n let copiedProblemDir: string;\n try {\n ({ tempRoot, copiedProblemDir } = await copyProblemDirToTemporaryRoot(run.problemDir));\n } catch (error) {\n return truncate(\n `failed to copy the problem directory to a temporary location: ${error instanceof Error ? error.message : String(error)}`\n );\n }\n\n let harnessFailureDetail;\n let removedTempRoot;\n try {\n const result = await runHarnessProcess(\n ['run', cliEntryPath, 'judge', path.relative(run.problemDir, run.answerDir)],\n {\n cwd: copiedProblemDir,\n env: process.env,\n timeoutMs: RUN_TIMEOUT_MS,\n maxOutputBytes: MAX_RUN_OUTPUT_BYTES,\n tempRoot,\n }\n );\n harnessFailureDetail = summarizeHarnessFailure(run, result);\n } catch (error) {\n harnessFailureDetail = truncate(\n `harness execution failed: ${error instanceof Error ? error.message : String(error)}`\n );\n } finally {\n removedTempRoot = await forciblyRemoveDirectory(tempRoot);\n }\n if (removedTempRoot) return harnessFailureDetail;\n const removalFailureDetail = `failed to remove the temporary copy at ${tempRoot} (judged code may have left permission-locked files)`;\n return harnessFailureDetail === undefined\n ? removalFailureDetail\n : truncate(`${harnessFailureDetail}; ${removalFailureDetail}`);\n}\n\n/** Return why the harness run failed the check, or `undefined` when it passed. */\nfunction summarizeHarnessFailure(run: CheckRun, result: HarnessProcessResult): string | undefined {\n const { stdout, stderr } = result;\n if (result.failureReason !== undefined) return truncate(result.failureReason);\n if (result.exitCode !== 0) {\n return truncate(`harness exited with ${result.exitCode ?? 'a signal'}${stderr.trim() ? `: ${stderr.trim()}` : ''}`);\n }\n\n const resultLines = stdout.split(/\\r?\\n/).filter((line) => line.startsWith(TEST_CASE_RESULT_PREFIX));\n const testCaseResults = [];\n for (const line of resultLines) {\n let parsedResult;\n try {\n parsedResult = testCaseResultSchema.safeParse(JSON.parse(line.slice(TEST_CASE_RESULT_PREFIX.length)));\n } catch {\n parsedResult = undefined;\n }\n if (!parsedResult?.success) return truncate(`malformed test case result line: ${line}`);\n testCaseResults.push(parsedResult.data);\n }\n if (testCaseResults.length === 0) return 'no test case results were printed';\n\n if (run.expectation === 'accepted') {\n const rejectedResult = testCaseResults.find((result) => result.decisionCode !== DecisionCode.ACCEPTED);\n if (rejectedResult) {\n return truncate(\n `${decisionCodeNames.get(rejectedResult.decisionCode) ?? rejectedResult.decisionCode} on test case ${rejectedResult.testCaseId}${rejectedResult.stderr?.trim() ? `: ${rejectedResult.stderr.trim()}` : ''}`\n );\n }\n return undefined;\n }\n return testCaseResults.every((result) => result.decisionCode === DecisionCode.ACCEPTED)\n ? 'expected at least one failing test case, but all test cases were accepted'\n : undefined;\n}\n\nfunction parseCheckArgs(args: readonly string[]): CheckOptions {\n const options: CheckOptions = {\n rootDir: '.',\n // Serial by default: judging decides TIME_LIMIT_EXCEEDED from wall-clock time, so parallel\n // runs on a small CI runner could fail timing-sensitive problems non-deterministically.\n concurrency: 1,\n only: [],\n skip: [],\n };\n let hasRootDir = false;\n for (let index = 0; index < args.length; index++) {\n const arg = args[index];\n if (arg === undefined) break;\n if (arg === '--concurrency' || arg === '--only' || arg === '--skip') {\n const value = args[++index];\n if (value === undefined) throw new Error(`${arg} requires a value`);\n if (arg === '--concurrency') {\n options.concurrency = Number(value);\n if (!Number.isInteger(options.concurrency) || options.concurrency <= 0) {\n throw new Error(`--concurrency requires a positive integer, but got ${value}`);\n }\n } else if (arg === '--only') {\n options.only.push(value);\n } else {\n options.skip.push(value);\n }\n } else if (arg.startsWith('--')) {\n throw new Error(`Unknown option: ${arg}`);\n } else if (hasRootDir) {\n throw new Error(`Only one root directory can be specified, but got both ${options.rootDir} and ${arg}`);\n } else {\n options.rootDir = arg;\n hasRootDir = true;\n }\n }\n return options;\n}\n\n/** Find directories containing `problem.md` or `<id>.problem.md`, without descending into found problems. */\nasync function findProblemDirs(rootDir: string): Promise<string[]> {\n const problemDirs: string[] = [];\n await visitDirectory(rootDir, problemDirs);\n return problemDirs.toSorted();\n}\n\nasync function visitDirectory(dir: string, problemDirs: string[]): Promise<void> {\n // Traversal errors (e.g. an unreadable subtree) must fail the check: skipping them silently\n // could report a green result while covering only part of the repository.\n const entries = await fs.readdir(dir, { withFileTypes: true });\n if (entries.some((entry) => entry.isFile() && (entry.name === 'problem.md' || entry.name.endsWith('.problem.md')))) {\n problemDirs.push(dir);\n return;\n }\n for (const entry of entries) {\n if (!entry.isDirectory() || entry.name === 'node_modules' || entry.name.startsWith('.')) continue;\n await visitDirectory(path.join(dir, entry.name), problemDirs);\n }\n}\n\nasync function fileExists(filePath: string): Promise<boolean> {\n try {\n await fs.stat(filePath);\n return true;\n } catch {\n return false;\n }\n}\n\nfunction truncate(text: string): string {\n return text.length <= MAX_FAILURE_DETAIL_LENGTH ? text : `${text.slice(0, MAX_FAILURE_DETAIL_LENGTH)}...`;\n}\n"],"mappings":"+nBAcA,MAEM,EAA4B,IAG5B,EAAoB,IAAI,IAAoB,OAAO,QAAQA,EAAAA,YAAY,CAAC,CAAC,KAAK,CAAC,EAAM,KAAU,CAAC,EAAM,CAAI,CAAC,CAAC,EAqBlH,eAAsB,EAAiB,EAA0C,CAC/E,IAAM,EAAU,EAAe,CAAI,EAC7B,EAAUC,EAAAA,QAAK,QAAQ,EAAQ,OAAO,EAEtC,EAAc,IAAyBA,EAAAA,QAAK,SAAS,EAAS,CAAG,GAAK,IAAA,CAAK,WAAWA,EAAAA,QAAK,IAAK,GAAG,EAEnG,EAAiB,MAAM,EAAgB,CAAO,EAC9C,EAAc,EAAe,OAAQ,GAAe,CACxD,IAAM,EAAc,EAAW,CAAU,EAEzC,OADI,EAAQ,KAAK,OAAS,GAAK,CAAC,EAAQ,KAAK,KAAM,GAAc,EAAY,SAAS,CAAS,CAAC,EAAU,GACnG,CAAC,EAAQ,KAAK,KAAM,GAAc,EAAY,SAAS,CAAS,CAAC,CAC1E,CAAC,EACD,GAAI,EAAY,SAAW,EAMzB,OALA,QAAQ,MACN,EAAe,SAAW,EACtB,iFAAiF,EAAQ,GACzF,OAAO,EAAe,OAAO,6BAA6B,EAAQ,iCACxE,EACO,EAGT,IAAM,EAAqB,CAAC,EACtB,EAAmB,CAAC,EAC1B,IAAK,IAAM,KAAc,EAAa,CACpC,IAAM,EAA0B,MAAMC,EAAAA,6BAA6B,CAAU,EAC7E,GAAI,EAAwB,OAAS,EAAG,CACtC,EAAS,KAAK,GAAG,EAAW,CAAU,EAAE,IAAIC,EAAAA,0BAA0B,CAAuB,GAAG,EAChG,QACF,CAEA,IAAM,EAAkB,MAAMC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EAAG,CAAyB,EAAE,IACvG"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{TEST_CASE_RESULT_PREFIX as e,testCaseResultSchema as t}from"../types/testCaseResult.js";import{findDefaultStdioHarnessFiles as n}from"../helpers/defaultStdioHarness.js";import{readTestCases as r}from"../helpers/readTestCases.js";import{
|
|
1
|
+
import{TEST_CASE_RESULT_PREFIX as e,testCaseResultSchema as t}from"../types/testCaseResult.js";import{findDefaultStdioHarnessFiles as n}from"../helpers/defaultStdioHarness.js";import{readTestCases as r}from"../helpers/readTestCases.js";import{copyProblemDirToTemporaryRoot as i,forciblyRemoveDirectory as a}from"../helpers/temporaryProblemDirCopy.js";import{judgesWithoutTestCases as o,readProblemMarkdownFrontMatter as s}from"../helpers/readProblemMarkdownFrontMatter.js";import{DecisionCode as c}from"../types/decisionCode.js";import{runHarnessProcess as l}from"../helpers/runHarnessProcess.js";import{findFailingModelAnswerDirs as u,findModelAnswerDirs as d}from"../helpers/findModelAnswerDirs.js";import{MISSING_TEST_CASES_ERROR as f,formatDefaultHarnessError as p}from"./runSingleHarness.js";import m from"node:path";import h from"node:fs/promises";const g=1e3,_=new Map(Object.entries(c).map(([e,t])=>[t,e]));async function v(e){let t=x(e),i=m.resolve(t.rootDir),a=e=>(m.relative(i,e)||`.`).replaceAll(m.sep,`/`),c=await S(i),l=c.filter(e=>{let n=a(e);return t.only.length>0&&!t.only.some(e=>n.includes(e))?!1:!t.skip.some(e=>n.includes(e))});if(l.length===0)return console.error(c.length===0?`No problem directories (containing problem.md or <id>.problem.md) found under ${i}.`:`All ${c.length} problem directories under ${i} were excluded by --only/--skip.`),1;let h=[],g=[];for(let e of l){let t=await n(e);if(t.length>0){h.push(`${a(e)}: ${p(t)}`);continue}let i=await d(e);if(i.length===0){h.push(`${a(e)}: no model answers found under model_answers/`);continue}if(!await w(m.join(e,`judge.ts`))&&(await r(m.join(e,`test_cases`))).length===0){let t;try{t=await s(e)}catch(t){h.push(`${a(e)}: failed to read the problem markdown front matter: ${t instanceof Error?t.message:String(t)}`);continue}if(!o(t)){h.push(`${a(e)}: ${f}`);continue}}let c=await u(e);g.push(...i.map(t=>({problemDir:e,answerDir:t,expectation:`accepted`})),...c.map(t=>({problemDir:e,answerDir:t,expectation:`rejected`})))}for(let e of h)console.error(`✗ ${e}`);let _=m.resolve(process.argv[1]??``),v=0,b=0;return await Promise.all(Array.from({length:Math.max(1,Math.min(t.concurrency,g.length))},async()=>{for(;b<g.length;){let e=g[b++];if(!e)return;let t=`${a(e.problemDir)} ${m.relative(e.problemDir,e.answerDir).replaceAll(m.sep,`/`)}`,n=await y(e,_);n===void 0?(v++,console.info(`✓ ${t}`)):(h.push(`${t}: ${n}`),console.error(`✗ ${t}: ${n}`))}})),console.info(`\n${v} passed, ${h.length} failed (${g.length} runs, ${l.length} problems)`),h.length===0?0:1}async function y(e,t){let n,r;try{({tempRoot:n,copiedProblemDir:r}=await i(e.problemDir))}catch(e){return T(`failed to copy the problem directory to a temporary location: ${e instanceof Error?e.message:String(e)}`)}let o,s;try{o=b(e,await l([`run`,t,`judge`,m.relative(e.problemDir,e.answerDir)],{cwd:r,env:process.env,timeoutMs:6e5,maxOutputBytes:67108864,tempRoot:n}))}catch(e){o=T(`harness execution failed: ${e instanceof Error?e.message:String(e)}`)}finally{s=await a(n)}if(s)return o;let c=`failed to remove the temporary copy at ${n} (judged code may have left permission-locked files)`;return o===void 0?c:T(`${o}; ${c}`)}function b(n,r){let{stdout:i,stderr:a}=r;if(r.failureReason!==void 0)return T(r.failureReason);if(r.exitCode!==0)return T(`harness exited with ${r.exitCode??`a signal`}${a.trim()?`: ${a.trim()}`:``}`);let o=i.split(/\r?\n/).filter(t=>t.startsWith(e)),s=[];for(let n of o){let r;try{r=t.safeParse(JSON.parse(n.slice(e.length)))}catch{r=void 0}if(!r?.success)return T(`malformed test case result line: ${n}`);s.push(r.data)}if(s.length===0)return`no test case results were printed`;if(n.expectation===`accepted`){let e=s.find(e=>e.decisionCode!==c.ACCEPTED);return e?T(`${_.get(e.decisionCode)??e.decisionCode} on test case ${e.testCaseId}${e.stderr?.trim()?`: ${e.stderr.trim()}`:``}`):void 0}return s.every(e=>e.decisionCode===c.ACCEPTED)?`expected at least one failing test case, but all test cases were accepted`:void 0}function x(e){let t={rootDir:`.`,concurrency:1,only:[],skip:[]},n=!1;for(let r=0;r<e.length;r++){let i=e[r];if(i===void 0)break;if(i===`--concurrency`||i===`--only`||i===`--skip`){let n=e[++r];if(n===void 0)throw Error(`${i} requires a value`);if(i===`--concurrency`){if(t.concurrency=Number(n),!Number.isInteger(t.concurrency)||t.concurrency<=0)throw Error(`--concurrency requires a positive integer, but got ${n}`)}else i===`--only`?t.only.push(n):t.skip.push(n)}else if(i.startsWith(`--`))throw Error(`Unknown option: ${i}`);else if(n)throw Error(`Only one root directory can be specified, but got both ${t.rootDir} and ${i}`);else t.rootDir=i,n=!0}return t}async function S(e){let t=[];return await C(e,t),t.toSorted()}async function C(e,t){let n=await h.readdir(e,{withFileTypes:!0});if(n.some(e=>e.isFile()&&(e.name===`problem.md`||e.name.endsWith(`.problem.md`)))){t.push(e);return}for(let r of n)!r.isDirectory()||r.name===`node_modules`||r.name.startsWith(`.`)||await C(m.join(e,r.name),t)}async function w(e){try{return await h.stat(e),!0}catch{return!1}}function T(e){return e.length<=g?e:`${e.slice(0,g)}...`}export{v as checkAllProblems};
|
|
2
2
|
//# sourceMappingURL=checkAllProblems.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"checkAllProblems.js","names":[],"sources":["../../src/cli/checkAllProblems.ts"],"sourcesContent":["import fs from 'node:fs/promises';\nimport path from 'node:path';\n\nimport { findDefaultStdioHarnessFiles } from '../helpers/defaultStdioHarness.js';\nimport { findFailingModelAnswerDirs, findModelAnswerDirs } from '../helpers/findModelAnswerDirs.js';\nimport { judgesWithoutTestCases, readProblemMarkdownFrontMatter } from '../helpers/readProblemMarkdownFrontMatter.js';\nimport { readTestCases } from '../helpers/readTestCases.js';\nimport { type HarnessProcessResult, runHarnessProcess } from '../helpers/runHarnessProcess.js';\nimport { copyProblemDirToTemporaryRoot, forciblyRemoveDirectory } from '../helpers/temporaryProblemDirCopy.js';\nimport { DecisionCode } from '../types/decisionCode.js';\nimport { TEST_CASE_RESULT_PREFIX, testCaseResultSchema } from '../types/testCaseResult.js';\n\nimport { formatDefaultHarnessError, MISSING_TEST_CASES_ERROR } from './runSingleHarness.js';\n\nconst RUN_TIMEOUT_MS = 600_000;\nconst MAX_RUN_OUTPUT_BYTES = 64 * 1024 * 1024;\nconst MAX_FAILURE_DETAIL_LENGTH = 1000;\n\n// DecisionCode is a plain const object (not a TypeScript enum), so it has no reverse mapping.\nconst decisionCodeNames = new Map<number, string>(Object.entries(DecisionCode).map(([name, code]) => [code, name]));\n\ninterface CheckOptions {\n rootDir: string;\n concurrency: number;\n only: string[];\n skip: string[];\n}\n\ninterface CheckRun {\n problemDir: string;\n answerDir: string;\n /** Whether all test cases must be accepted (`model_answers`) or at least one must fail (`model_answers.fails`). */\n expectation: 'accepted' | 'rejected';\n}\n\n/**\n * Judge all model answers of all problems (directories containing `problem.md` or\n * `<id>.problem.md`) under a root directory: `model_answers/*` must be fully accepted and\n * `model_answers.fails/*` must fail at least one test case. Returns the process exit code.\n */\nexport async function checkAllProblems(args: readonly string[]): Promise<number> {\n const options = parseCheckArgs(args);\n const rootDir = path.resolve(options.rootDir);\n // Normalize to forward slashes so --only / --skip substrings like courses/foo match on Windows.\n const toRelative = (dir: string): string => (path.relative(rootDir, dir) || '.').replaceAll(path.sep, '/');\n\n const allProblemDirs = await findProblemDirs(rootDir);\n const problemDirs = allProblemDirs.filter((problemDir) => {\n const relativeDir = toRelative(problemDir);\n if (options.only.length > 0 && !options.only.some((substring) => relativeDir.includes(substring))) return false;\n return !options.skip.some((substring) => relativeDir.includes(substring));\n });\n if (problemDirs.length === 0) {\n console.error(\n allProblemDirs.length === 0\n ? `No problem directories (containing problem.md or <id>.problem.md) found under ${rootDir}.`\n : `All ${allProblemDirs.length} problem directories under ${rootDir} were excluded by --only/--skip.`\n );\n return 1;\n }\n\n const failures: string[] = [];\n const runs: CheckRun[] = [];\n for (const problemDir of problemDirs) {\n const defaultHarnessFileNames = await findDefaultStdioHarnessFiles(problemDir);\n if (defaultHarnessFileNames.length > 0) {\n failures.push(`${toRelative(problemDir)}: ${formatDefaultHarnessError(defaultHarnessFileNames)}`);\n continue;\n }\n\n const modelAnswerDirs = await findModelAnswerDirs(problemDir);\n if (modelAnswerDirs.length === 0) {\n failures.push(`${toRelative(problemDir)}: no model answers found under model_answers/`);\n continue;\n }\n\n // Without test cases, stdioJudgePreset prints a single accepted sentinel result, so a standard\n // problem with an empty or missing test_cases/ would otherwise pass without being judged —\n // unless static-analysis rules or manual scoring make the problem judgeable without them.\n if (!(await fileExists(path.join(problemDir, 'judge.ts')))) {\n const testCases = await readTestCases(path.join(problemDir, 'test_cases'));\n if (testCases.length === 0) {\n let frontMatter;\n try {\n frontMatter = await readProblemMarkdownFrontMatter(problemDir);\n } catch (error) {\n failures.push(\n `${toRelative(problemDir)}: failed to read the problem markdown front matter: ${error instanceof Error ? error.message : String(error)}`\n );\n continue;\n }\n if (!judgesWithoutTestCases(frontMatter)) {\n failures.push(`${toRelative(problemDir)}: ${MISSING_TEST_CASES_ERROR}`);\n continue;\n }\n }\n }\n\n const failingModelAnswerDirs = await findFailingModelAnswerDirs(problemDir);\n runs.push(\n ...modelAnswerDirs.map((answerDir): CheckRun => ({ problemDir, answerDir, expectation: 'accepted' })),\n ...failingModelAnswerDirs.map((answerDir): CheckRun => ({ problemDir, answerDir, expectation: 'rejected' }))\n );\n }\n for (const failure of failures) console.error(`✗ ${failure}`);\n\n const cliEntryPath = path.resolve(process.argv[1] ?? '');\n let passedCount = 0;\n let nextRunIndex = 0;\n await Promise.all(\n Array.from({ length: Math.max(1, Math.min(options.concurrency, runs.length)) }, async () => {\n while (nextRunIndex < runs.length) {\n const run = runs[nextRunIndex++];\n if (!run) return;\n const label = `${toRelative(run.problemDir)} ${path.relative(run.problemDir, run.answerDir).replaceAll(path.sep, '/')}`;\n const failureDetail = await executeCheckRun(run, cliEntryPath);\n if (failureDetail === undefined) {\n passedCount++;\n console.info(`✓ ${label}`);\n } else {\n failures.push(`${label}: ${failureDetail}`);\n console.error(`✗ ${label}: ${failureDetail}`);\n }\n }\n })\n );\n\n console.info(\n `\\n${passedCount} passed, ${failures.length} failed (${runs.length} runs, ${problemDirs.length} problems)`\n );\n return failures.length === 0 ? 0 : 1;\n}\n\n/**\n * Run one answer directory through the problem's harness and return a failure detail, if any.\n * The problem directory is copied to a temporary location first so that judging (e.g. build\n * artifacts in answer directories) never modifies the checked repository.\n */\nasync function executeCheckRun(run: CheckRun, cliEntryPath: string): Promise<string | undefined> {\n let tempRoot: string;\n let copiedProblemDir: string;\n try {\n ({ tempRoot, copiedProblemDir } = await copyProblemDirToTemporaryRoot(run.problemDir));\n } catch (error) {\n return truncate(\n `failed to copy the problem directory to a temporary location: ${error instanceof Error ? error.message : String(error)}`\n );\n }\n\n let harnessFailureDetail;\n let removedTempRoot;\n try {\n const result = await runHarnessProcess(\n ['run', cliEntryPath, 'judge', path.relative(run.problemDir, run.answerDir)],\n {\n cwd: copiedProblemDir,\n env: createHarnessEnv(),\n timeoutMs: RUN_TIMEOUT_MS,\n maxOutputBytes: MAX_RUN_OUTPUT_BYTES,\n tempRoot,\n }\n );\n harnessFailureDetail = summarizeHarnessFailure(run, result);\n } catch (error) {\n harnessFailureDetail = truncate(\n `harness execution failed: ${error instanceof Error ? error.message : String(error)}`\n );\n } finally {\n removedTempRoot = await forciblyRemoveDirectory(tempRoot);\n }\n if (removedTempRoot) return harnessFailureDetail;\n const removalFailureDetail = `failed to remove the temporary copy at ${tempRoot} (judged code may have left permission-locked files)`;\n return harnessFailureDetail === undefined\n ? removalFailureDetail\n : truncate(`${harnessFailureDetail}; ${removalFailureDetail}`);\n}\n\n/** Return why the harness run failed the check, or `undefined` when it passed. */\nfunction summarizeHarnessFailure(run: CheckRun, result: HarnessProcessResult): string | undefined {\n const { stdout, stderr } = result;\n if (result.failureReason !== undefined) return truncate(result.failureReason);\n if (result.exitCode !== 0) {\n return truncate(`harness exited with ${result.exitCode ?? 'a signal'}${stderr.trim() ? `: ${stderr.trim()}` : ''}`);\n }\n\n const resultLines = stdout.split(/\\r?\\n/).filter((line) => line.startsWith(TEST_CASE_RESULT_PREFIX));\n const testCaseResults = [];\n for (const line of resultLines) {\n let parsedResult;\n try {\n parsedResult = testCaseResultSchema.safeParse(JSON.parse(line.slice(TEST_CASE_RESULT_PREFIX.length)));\n } catch {\n parsedResult = undefined;\n }\n if (!parsedResult?.success) return truncate(`malformed test case result line: ${line}`);\n testCaseResults.push(parsedResult.data);\n }\n if (testCaseResults.length === 0) return 'no test case results were printed';\n\n if (run.expectation === 'accepted') {\n const rejectedResult = testCaseResults.find((result) => result.decisionCode !== DecisionCode.ACCEPTED);\n if (rejectedResult) {\n return truncate(\n `${decisionCodeNames.get(rejectedResult.decisionCode) ?? rejectedResult.decisionCode} on test case ${rejectedResult.testCaseId}${rejectedResult.stderr?.trim() ? `: ${rejectedResult.stderr.trim()}` : ''}`\n );\n }\n return undefined;\n }\n return testCaseResults.every((result) => result.decisionCode === DecisionCode.ACCEPTED)\n ? 'expected at least one failing test case, but all test cases were accepted'\n : undefined;\n}\n\n// The all-problem check runs harnesses concurrently and has no sandbox-delegation contract, while the sandbox\n// helpers assume one harness at a time (their pkill targets every process of the sandbox user), so\n// never forward the sandbox user to judged runs.\nfunction createHarnessEnv(): NodeJS.ProcessEnv {\n const env = { ...process.env };\n delete env.EXERCODE_SANDBOX_USER;\n return env;\n}\n\nfunction parseCheckArgs(args: readonly string[]): CheckOptions {\n const options: CheckOptions = {\n rootDir: '.',\n // Serial by default: judging decides TIME_LIMIT_EXCEEDED from wall-clock time, so parallel\n // runs on a small CI runner could fail timing-sensitive problems non-deterministically.\n concurrency: 1,\n only: [],\n skip: [],\n };\n let hasRootDir = false;\n for (let index = 0; index < args.length; index++) {\n const arg = args[index];\n if (arg === undefined) break;\n if (arg === '--concurrency' || arg === '--only' || arg === '--skip') {\n const value = args[++index];\n if (value === undefined) throw new Error(`${arg} requires a value`);\n if (arg === '--concurrency') {\n options.concurrency = Number(value);\n if (!Number.isInteger(options.concurrency) || options.concurrency <= 0) {\n throw new Error(`--concurrency requires a positive integer, but got ${value}`);\n }\n } else if (arg === '--only') {\n options.only.push(value);\n } else {\n options.skip.push(value);\n }\n } else if (arg.startsWith('--')) {\n throw new Error(`Unknown option: ${arg}`);\n } else if (hasRootDir) {\n throw new Error(`Only one root directory can be specified, but got both ${options.rootDir} and ${arg}`);\n } else {\n options.rootDir = arg;\n hasRootDir = true;\n }\n }\n return options;\n}\n\n/** Find directories containing `problem.md` or `<id>.problem.md`, without descending into found problems. */\nasync function findProblemDirs(rootDir: string): Promise<string[]> {\n const problemDirs: string[] = [];\n await visitDirectory(rootDir, problemDirs);\n return problemDirs.toSorted();\n}\n\nasync function visitDirectory(dir: string, problemDirs: string[]): Promise<void> {\n // Traversal errors (e.g. an unreadable subtree) must fail the check: skipping them silently\n // could report a green result while covering only part of the repository.\n const entries = await fs.readdir(dir, { withFileTypes: true });\n if (entries.some((entry) => entry.isFile() && (entry.name === 'problem.md' || entry.name.endsWith('.problem.md')))) {\n problemDirs.push(dir);\n return;\n }\n for (const entry of entries) {\n if (!entry.isDirectory() || entry.name === 'node_modules' || entry.name.startsWith('.')) continue;\n await visitDirectory(path.join(dir, entry.name), problemDirs);\n }\n}\n\nasync function fileExists(filePath: string): Promise<boolean> {\n try {\n await fs.stat(filePath);\n return true;\n } catch {\n return false;\n }\n}\n\nfunction truncate(text: string): string {\n return text.length <= MAX_FAILURE_DETAIL_LENGTH ? text : `${text.slice(0, MAX_FAILURE_DETAIL_LENGTH)}...`;\n}\n"],"mappings":"s1BAcA,MAEM,EAA4B,IAG5B,EAAoB,IAAI,IAAoB,OAAO,QAAQ,CAAY,CAAC,CAAC,KAAK,CAAC,EAA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AAO,GAAK,MAEtG,GAAQ,QAAU,EAClB,EAAa,EAEjB,CACA,OAAO,CACT,CAGA,eAAe,EAAgB,EAAoC,CACjE,IAAM,EAAwB,CAAC,EAE/B,OADA,MAAM,EAAe,EAAS,CAAW,EAClC,EAAY,SAAS,CAC9B,CAEA,eAAe,EAAe,EAAa,EAAsC,CAG/E,IAAM,EAAU,MAAM,EAAG,QAAQ,EAAK,CAAE,cAAe,EAAK,CAAC,EAC7D,GAAI,EAAQ,KAAM,GAAU,EAAM,OAAO,IAAM,EAAM,OAAS,cAAgB,EAAM,KAAK,SAAS,aAAa,EAAE,EAAG,CAClH,EAAY,KAAK,CAAG,EACpB,MACF,CACA,IAAK,IAAM,KAAS,EACd,CAAC,EAAM,YAAY,GAAK,EAAM,OAAS,gBAAkB,EAAM,KAAK,WAAW,GAAG,GACtF,MAAM,EAAe,EAAK,KAAK,EAAK,EAAM,IAAI,EAAG,CAAW,CAEhE,CAEA,eAAe,EAAW,EAAoC,CAC5D,GAAI,CAEF,OADA,MAAM,EAAG,KAAK,CAAQ,EACf,EACT,MAAQ,CACN,MAAO,EACT,CACF,CAEA,SAAS,EAAS,EAAsB,CACtC,OAAO,EAAK,QAAU,EAA4B,EAAO,GAAG,EAAK,MAAM,EAAG,CAAyB,EAAE,IACvG"}
|
|
1
|
+
{"version":3,"file":"checkAllProblems.js","names":[],"sources":["../../src/cli/checkAllProblems.ts"],"sourcesContent":["import fs from 'node:fs/promises';\nimport path from 'node:path';\n\nimport { findDefaultStdioHarnessFiles } from '../helpers/defaultStdioHarness.js';\nimport { findFailingModelAnswerDirs, findModelAnswerDirs } from '../helpers/findModelAnswerDirs.js';\nimport { judgesWithoutTestCases, readProblemMarkdownFrontMatter } from '../helpers/readProblemMarkdownFrontMatter.js';\nimport { readTestCases } from '../helpers/readTestCases.js';\nimport { type HarnessProcessResult, runHarnessProcess } from '../helpers/runHarnessProcess.js';\nimport { copyProblemDirToTemporaryRoot, forciblyRemoveDirectory } from '../helpers/temporaryProblemDirCopy.js';\nimport { DecisionCode } from '../types/decisionCode.js';\nimport { TEST_CASE_RESULT_PREFIX, testCaseResultSchema } from '../types/testCaseResult.js';\n\nimport { formatDefaultHarnessError, MISSING_TEST_CASES_ERROR } from './runSingleHarness.js';\n\nconst RUN_TIMEOUT_MS = 600_000;\nconst MAX_RUN_OUTPUT_BYTES = 64 * 1024 * 1024;\nconst MAX_FAILURE_DETAIL_LENGTH = 1000;\n\n// DecisionCode is a plain const object (not a TypeScript enum), so it has no reverse mapping.\nconst decisionCodeNames = new Map<number, string>(Object.entries(DecisionCode).map(([name, code]) => [code, name]));\n\ninterface CheckOptions {\n rootDir: string;\n concurrency: number;\n only: string[];\n skip: string[];\n}\n\ninterface CheckRun {\n problemDir: string;\n answerDir: string;\n /** Whether all test cases must be accepted (`model_answers`) or at least one must fail (`model_answers.fails`). */\n expectation: 'accepted' | 'rejected';\n}\n\n/**\n * Judge all model answers of all problems (directories containing `problem.md` or\n * `<id>.problem.md`) under a root directory: `model_answers/*` must be fully accepted and\n * `model_answers.fails/*` must fail at least one test case. Returns the process exit code.\n */\nexport async function checkAllProblems(args: readonly string[]): Promise<number> {\n const options = parseCheckArgs(args);\n const rootDir = path.resolve(options.rootDir);\n // Normalize to forward slashes so --only / --skip substrings like courses/foo match on Windows.\n const toRelative = (dir: string): string => (path.relative(rootDir, dir) || '.').replaceAll(path.sep, '/');\n\n const allProblemDirs = await findProblemDirs(rootDir);\n const problemDirs = allProblemDirs.filter((problemDir) => {\n const relativeDir = toRelative(problemDir);\n if (options.only.length > 0 && !options.only.some((substring) => relativeDir.includes(substring))) return false;\n return !options.skip.some((substring) => relativeDir.includes(substring));\n });\n if (problemDirs.length === 0) {\n console.error(\n allProblemDirs.length === 0\n ? `No problem directories (containing problem.md or <id>.problem.md) found under ${rootDir}.`\n : `All ${allProblemDirs.length} problem directories under ${rootDir} were excluded by --only/--skip.`\n );\n return 1;\n }\n\n const failures: string[] = [];\n const runs: CheckRun[] = [];\n for (const problemDir of problemDirs) {\n const defaultHarnessFileNames = await findDefaultStdioHarnessFiles(problemDir);\n if (defaultHarnessFileNames.length > 0) {\n failures.push(`${toRelative(problemDir)}: ${formatDefaultHarnessError(defaultHarnessFileNames)}`);\n continue;\n }\n\n const modelAnswerDirs = await findModelAnswerDirs(problemDir);\n if (modelAnswerDirs.length === 0) {\n failures.push(`${toRelative(problemDir)}: no model answers found under model_answers/`);\n continue;\n }\n\n // Without test cases, stdioJudgePreset prints a single accepted sentinel result, so a standard\n // problem with an empty or missing test_cases/ would otherwise pass without being judged —\n // unless static-analysis rules or manual scoring make the problem judgeable without them.\n if (!(await fileExists(path.join(problemDir, 'judge.ts')))) {\n const testCases = await readTestCases(path.join(problemDir, 'test_cases'));\n if (testCases.length === 0) {\n let frontMatter;\n try {\n frontMatter = await readProblemMarkdownFrontMatter(problemDir);\n } catch (error) {\n failures.push(\n `${toRelative(problemDir)}: failed to read the problem markdown front matter: ${error instanceof Error ? error.message : String(error)}`\n );\n continue;\n }\n if (!judgesWithoutTestCases(frontMatter)) {\n failures.push(`${toRelative(problemDir)}: ${MISSING_TEST_CASES_ERROR}`);\n continue;\n }\n }\n }\n\n const failingModelAnswerDirs = await findFailingModelAnswerDirs(problemDir);\n runs.push(\n ...modelAnswerDirs.map((answerDir): CheckRun => ({ problemDir, answerDir, expectation: 'accepted' })),\n ...failingModelAnswerDirs.map((answerDir): CheckRun => ({ problemDir, answerDir, expectation: 'rejected' }))\n );\n }\n for (const failure of failures) console.error(`✗ ${failure}`);\n\n const cliEntryPath = path.resolve(process.argv[1] ?? '');\n let passedCount = 0;\n let nextRunIndex = 0;\n await Promise.all(\n Array.from({ length: Math.max(1, Math.min(options.concurrency, runs.length)) }, async () => {\n while (nextRunIndex < runs.length) {\n const run = runs[nextRunIndex++];\n if (!run) return;\n const label = `${toRelative(run.problemDir)} ${path.relative(run.problemDir, run.answerDir).replaceAll(path.sep, '/')}`;\n const failureDetail = await executeCheckRun(run, cliEntryPath);\n if (failureDetail === undefined) {\n passedCount++;\n console.info(`✓ ${label}`);\n } else {\n failures.push(`${label}: ${failureDetail}`);\n console.error(`✗ ${label}: ${failureDetail}`);\n }\n }\n })\n );\n\n console.info(\n `\\n${passedCount} passed, ${failures.length} failed (${runs.length} runs, ${problemDirs.length} problems)`\n );\n return failures.length === 0 ? 0 : 1;\n}\n\n/**\n * Run one answer directory through the problem's harness and return a failure detail, if any.\n * The problem directory is copied to a temporary location first so that judging (e.g. build\n * artifacts in answer directories) never modifies the checked repository.\n */\nasync function executeCheckRun(run: CheckRun, cliEntryPath: string): Promise<string | undefined> {\n let tempRoot: string;\n let copiedProblemDir: string;\n try {\n ({ tempRoot, copiedProblemDir } = await copyProblemDirToTemporaryRoot(run.problemDir));\n } catch (error) {\n return truncate(\n `failed to copy the problem directory to a temporary location: ${error instanceof Error ? error.message : String(error)}`\n );\n }\n\n let harnessFailureDetail;\n let removedTempRoot;\n try {\n const result = await runHarnessProcess(\n ['run', cliEntryPath, 'judge', path.relative(run.problemDir, run.answerDir)],\n {\n cwd: copiedProblemDir,\n env: process.env,\n timeoutMs: RUN_TIMEOUT_MS,\n maxOutputBytes: MAX_RUN_OUTPUT_BYTES,\n tempRoot,\n }\n );\n harnessFailureDetail = summarizeHarnessFailure(run, result);\n } catch (error) {\n harnessFailureDetail = truncate(\n `harness execution failed: ${error instanceof Error ? error.message : String(error)}`\n );\n } finally {\n removedTempRoot = await forciblyRemoveDirectory(tempRoot);\n }\n if (removedTempRoot) return harnessFailureDetail;\n const removalFailureDetail = `failed to remove the temporary copy at ${tempRoot} (judged code may have left permission-locked files)`;\n return harnessFailureDetail === undefined\n ? removalFailureDetail\n : truncate(`${harnessFailureDetail}; ${removalFailureDetail}`);\n}\n\n/** Return why the harness run failed the check, or `undefined` when it passed. */\nfunction summarizeHarnessFailure(run: CheckRun, result: HarnessProcessResult): string | undefined {\n const { stdout, stderr } = result;\n if (result.failureReason !== undefined) return truncate(result.failureReason);\n if (result.exitCode !== 0) {\n return truncate(`harness exited with ${result.exitCode ?? 'a signal'}${stderr.trim() ? `: ${stderr.trim()}` : ''}`);\n }\n\n const resultLines = stdout.split(/\\r?\\n/).filter((line) => line.startsWith(TEST_CASE_RESULT_PREFIX));\n const testCaseResults = [];\n for (const line of resultLines) {\n let parsedResult;\n try {\n parsedResult = testCaseResultSchema.safeParse(JSON.parse(line.slice(TEST_CASE_RESULT_PREFIX.length)));\n } catch {\n parsedResult = undefined;\n }\n if (!parsedResult?.success) return truncate(`malformed test case result line: ${line}`);\n testCaseResults.push(parsedResult.data);\n }\n if (testCaseResults.length === 0) return 'no test case results were printed';\n\n if (run.expectation === 'accepted') {\n const rejectedResult = testCaseResults.find((result) => result.decisionCode !== DecisionCode.ACCEPTED);\n if (rejectedResult) {\n return truncate(\n `${decisionCodeNames.get(rejectedResult.decisionCode) ?? rejectedResult.decisionCode} on test case ${rejectedResult.testCaseId}${rejectedResult.stderr?.trim() ? `: ${rejectedResult.stderr.trim()}` : ''}`\n );\n }\n return undefined;\n }\n return testCaseResults.every((result) => result.decisionCode === DecisionCode.ACCEPTED)\n ? 'expected at least one failing test case, but all test cases were accepted'\n : undefined;\n}\n\nfunction parseCheckArgs(args: readonly string[]): CheckOptions {\n const options: CheckOptions = {\n rootDir: '.',\n // Serial by default: judging decides TIME_LIMIT_EXCEEDED from wall-clock time, so parallel\n // runs on a small CI runner could fail timing-sensitive problems non-deterministically.\n concurrency: 1,\n only: [],\n skip: [],\n };\n let hasRootDir = false;\n for (let index = 0; index < args.length; index++) {\n const arg = args[index];\n if (arg === undefined) break;\n if (arg === '--concurrency' || arg === '--only' || arg === '--skip') {\n const value = args[++index];\n if (value === undefined) throw new Error(`${arg} requires a value`);\n if (arg === '--concurrency') {\n options.concurrency = Number(value);\n if (!Number.isInteger(options.concurrency) || options.concurrency <= 0) {\n throw new Error(`--concurrency requires a positive integer, but got ${value}`);\n }\n } else if (arg === '--only') {\n options.only.push(value);\n } else {\n options.skip.push(value);\n }\n } else if (arg.startsWith('--')) {\n throw new Error(`Unknown option: ${arg}`);\n } else if (hasRootDir) {\n throw new Error(`Only one root directory can be specified, but got both ${options.rootDir} and ${arg}`);\n } else {\n options.rootDir = arg;\n hasRootDir = true;\n }\n }\n return options;\n}\n\n/** Find directories containing `problem.md` or `<id>.problem.md`, without descending into found problems. */\nasync function findProblemDirs(rootDir: string): Promise<string[]> {\n const problemDirs: string[] = [];\n await visitDirectory(rootDir, problemDirs);\n return problemDirs.toSorted();\n}\n\nasync function visitDirectory(dir: string, problemDirs: string[]): Promise<void> {\n // Traversal errors (e.g. an unreadable subtree) must fail the check: skipping them silently\n // could report a green result while covering only part of the repository.\n const entries = await fs.readdir(dir, { withFileTypes: true });\n if (entries.some((entry) => entry.isFile() && (entry.name === 'problem.md' || entry.name.endsWith('.problem.md')))) {\n problemDirs.push(dir);\n return;\n }\n for (const entry of entries) {\n if (!entry.isDirectory() || entry.name === 'node_modules' || entry.name.startsWith('.')) continue;\n await visitDirectory(path.join(dir, entry.name), problemDirs);\n }\n}\n\nasync function fileExists(filePath: string): Promise<boolean> {\n try {\n await fs.stat(filePath);\n return true;\n } catch {\n return false;\n }\n}\n\nfunction truncate(text: string): string {\n return text.length <= MAX_FAILURE_DETAIL_LENGTH ? text : `${text.slice(0, MAX_FAILURE_DETAIL_LENGTH)}...`;\n}\n"],"mappings":"s1BAcA,MAEM,EAA4B,IAG5B,EAAoB,IAAI,IAAoB,OAAO,QAAQ,CAAY,CAAC,CAAC,KAAK,CAAC,EAAM,KAAU,CAAC,EAAM,CAAI,CAAC,CAAC,EAqBlH,eAAsB,EAAiB,EAA0C,CAC/E,IAAM,EAAU,EAAe,CAAI,EAC7B,EAAU,EAAK,QAAQ,EAAQ,OAAO,EAEtC,EAAc,IAAyB,EAAK,SAAS,EAAS,CAAG,GAAK,IAAA,CAAK,WAAW,EAAK,IAAK,GAAG,EAEnG,EAAiB,MAAM,EAAgB,CAAO,EAC9C,EAAc,EAAe,OAAQ,GAAe,CACxD,IAAM,EAAc,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pB,MACF,CACA,IAAK,IAAM,KAAS,EACd,CAAC,EAAM,YAAY,GAAK,EAAM,OAAS,gBAAkB,EAAM,KAAK,WAAW,GAAG,GACtF,MAAM,EAAe,EAAK,KAAK,EAAK,EAAM,IAAI,EAAG,CAAW,CAEhE,CAEA,eAAe,EAAW,EAAoC,CAC5D,GAAI,CAEF,OADA,MAAM,EAAG,KAAK,CAAQ,EACf,EACT,MAAQ,CACN,MAAO,EACT,CACF,CAEA,SAAS,EAAS,EAAsB,CACtC,OAAO,EAAK,QAAU,EAA4B,EAAO,GAAG,EAAK,MAAM,EAAG,CAAyB,EAAE,IACvG"}
|
|
@@ -1,9 +1,15 @@
|
|
|
1
|
-
"use strict";const e=require("./runSingleHarness.cjs"),t=require("./checkAllProblems.cjs"),n=`Usage: exercode-problem [rootDir] [--only <substring>]... [--skip <substring>]... [--concurrency <n>]
|
|
1
|
+
"use strict";const e=require("./runSingleHarness.cjs"),t=require("./checkAllProblems.cjs"),n=require("./validateLearningMaterial.cjs"),r=`Usage: exercode-problem [rootDir] [--only <substring>]... [--skip <substring>]... [--concurrency <n>]
|
|
2
2
|
exercode-problem judge <answerDir> [paramsJson]
|
|
3
3
|
exercode-problem debug <answerDir> [paramsJson]
|
|
4
|
+
exercode-problem validate-problem <problemDir>...
|
|
5
|
+
exercode-problem validate-course <courseDir> [--problems-dir <dir>]
|
|
6
|
+
exercode-problem validate-contest <contestYamlPath> [--problems-dir <dir>]
|
|
4
7
|
|
|
5
8
|
Without a subcommand, judge all model answers of all problems under rootDir
|
|
6
9
|
(default: the current directory). Use \`judge\` or \`debug\` in a problem
|
|
7
10
|
directory to run one answer directory, e.g.:
|
|
8
|
-
exercode-problem debug model_answers/python '{ "stdin": "1 2" }'
|
|
11
|
+
exercode-problem debug model_answers/python '{ "stdin": "1 2" }'
|
|
12
|
+
The \`validate-*\` subcommands check problem directories, a course directory
|
|
13
|
+
(course.yaml and lecture materials), or a contest (*.contest.yaml) file
|
|
14
|
+
without running any program.`;i();async function i(){let i=process.argv.slice(2);if(i[0]===`--help`||i[0]===`-h`){console.info(r);return}try{if(i[0]===`judge`||i[0]===`debug`){if(i.length<2){console.error(r),process.exitCode=1;return}process.argv.splice(2,1),process.exitCode=await e.runSingleHarness(i[0])}else a(i[0])?process.exitCode=await n.validateLearningMaterial(i[0],i.slice(1)):process.exitCode=await t.checkAllProblems(i)}catch(e){console.error(e),process.exitCode=1}}function a(e){return n.VALIDATE_SUBCOMMANDS.includes(e??``)}
|
|
9
15
|
//# sourceMappingURL=exercodeProblem.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"exercodeProblem.cjs","names":["runSingleHarness","checkAllProblems"],"sources":["../../src/cli/exercodeProblem.ts"],"sourcesContent":["import { checkAllProblems } from './checkAllProblems.js';\nimport { runSingleHarness } from './runSingleHarness.js';\n\nconst usage = `Usage: exercode-problem [rootDir] [--only <substring>]... [--skip <substring>]... [--concurrency <n>]\n exercode-problem judge <answerDir> [paramsJson]\n exercode-problem debug <answerDir> [paramsJson]\n\nWithout a subcommand, judge all model answers of all problems under rootDir\n(default: the current directory). Use \\`judge\\` or \\`debug\\` in a problem\ndirectory to run one answer directory, e.g.:\n exercode-problem debug model_answers/python '{ \"stdin\": \"1 2\" }'
|
|
1
|
+
{"version":3,"file":"exercodeProblem.cjs","names":["runSingleHarness","validateLearningMaterial","checkAllProblems","VALIDATE_SUBCOMMANDS"],"sources":["../../src/cli/exercodeProblem.ts"],"sourcesContent":["import { checkAllProblems } from './checkAllProblems.js';\nimport { runSingleHarness } from './runSingleHarness.js';\nimport { VALIDATE_SUBCOMMANDS, type ValidateSubcommand, validateLearningMaterial } from './validateLearningMaterial.js';\n\nconst usage = `Usage: exercode-problem [rootDir] [--only <substring>]... [--skip <substring>]... [--concurrency <n>]\n exercode-problem judge <answerDir> [paramsJson]\n exercode-problem debug <answerDir> [paramsJson]\n exercode-problem validate-problem <problemDir>...\n exercode-problem validate-course <courseDir> [--problems-dir <dir>]\n exercode-problem validate-contest <contestYamlPath> [--problems-dir <dir>]\n\nWithout a subcommand, judge all model answers of all problems under rootDir\n(default: the current directory). Use \\`judge\\` or \\`debug\\` in a problem\ndirectory to run one answer directory, e.g.:\n exercode-problem debug model_answers/python '{ \"stdin\": \"1 2\" }'\nThe \\`validate-*\\` subcommands check problem directories, a course directory\n(course.yaml and lecture materials), or a contest (*.contest.yaml) file\nwithout running any program.`;\n\n// oxlint-disable-next-line unicorn/prefer-top-level-await -- the CJS build output does not support top-level await\nvoid main();\n\nasync function main(): Promise<void> {\n const args = process.argv.slice(2);\n if (args[0] === '--help' || args[0] === '-h') {\n // console.log would be stripped from the built CLI, so print the usage with console.info.\n console.info(usage);\n return;\n }\n try {\n if (args[0] === 'judge' || args[0] === 'debug') {\n if (args.length < 2) {\n console.error(usage);\n process.exitCode = 1;\n return;\n }\n // Harness scripts and presets read the answer directory and params from fixed positions in\n // `process.argv`, so drop the subcommand to restore those positions.\n process.argv.splice(2, 1);\n process.exitCode = await runSingleHarness(args[0]);\n } else if (isValidateSubcommand(args[0])) {\n process.exitCode = await validateLearningMaterial(args[0], args.slice(1));\n } else {\n process.exitCode = await checkAllProblems(args);\n }\n } catch (error) {\n // Print the whole error: harness failures need their stack and `cause`, not just the message.\n console.error(error);\n process.exitCode = 1;\n }\n}\n\nfunction isValidateSubcommand(arg: string | undefined): arg is ValidateSubcommand {\n return (VALIDATE_SUBCOMMANDS as readonly string[]).includes(arg ?? '');\n}\n"],"mappings":"uIAIM,EAAQ;;;;;;;;;;;;;8BAgBT,EAAK,EAEV,eAAe,GAAsB,CACnC,IAAM,EAAO,QAAQ,KAAK,MAAM,CAAC,EACjC,GAAI,EAAK,KAAO,UAAY,EAAK,KAAO,KAAM,CAE5C,QAAQ,KAAK,CAAK,EAClB,MACF,CACA,GAAI,CACF,GAAI,EAAK,KAAO,SAAW,EAAK,KAAO,QAAS,CAC9C,GAAI,EAAK,OAAS,EAAG,CACnB,QAAQ,MAAM,CAAK,EACnB,QAAQ,SAAW,EACnB,MACF,CAGA,QAAQ,KAAK,OAAO,EAAG,CAAC,EACxB,QAAQ,SAAW,MAAMA,EAAAA,iBAAiB,EAAK,EAAE,CACnD,MAAW,EAAqB,EAAK,EAAE,EACrC,QAAQ,SAAW,MAAMC,EAAAA,yBAAyB,EAAK,GAAI,EAAK,MAAM,CAAC,CAAC,EAExE,QAAQ,SAAW,MAAMC,EAAAA,iBAAiB,CAAI,CAElD,OAAS,EAAO,CAEd,QAAQ,MAAM,CAAK,EACnB,QAAQ,SAAW,CACrB,CACF,CAEA,SAAS,EAAqB,EAAoD,CAChF,OAAQC,EAAAA,qBAA2C,SAAS,GAAO,EAAE,CACvE"}
|
|
@@ -1,9 +1,15 @@
|
|
|
1
|
-
import{runSingleHarness as e}from"./runSingleHarness.js";import{checkAllProblems as t}from"./checkAllProblems.js";const
|
|
1
|
+
import{runSingleHarness as e}from"./runSingleHarness.js";import{checkAllProblems as t}from"./checkAllProblems.js";import{VALIDATE_SUBCOMMANDS as n,validateLearningMaterial as r}from"./validateLearningMaterial.js";const i=`Usage: exercode-problem [rootDir] [--only <substring>]... [--skip <substring>]... [--concurrency <n>]
|
|
2
2
|
exercode-problem judge <answerDir> [paramsJson]
|
|
3
3
|
exercode-problem debug <answerDir> [paramsJson]
|
|
4
|
+
exercode-problem validate-problem <problemDir>...
|
|
5
|
+
exercode-problem validate-course <courseDir> [--problems-dir <dir>]
|
|
6
|
+
exercode-problem validate-contest <contestYamlPath> [--problems-dir <dir>]
|
|
4
7
|
|
|
5
8
|
Without a subcommand, judge all model answers of all problems under rootDir
|
|
6
9
|
(default: the current directory). Use \`judge\` or \`debug\` in a problem
|
|
7
10
|
directory to run one answer directory, e.g.:
|
|
8
|
-
exercode-problem debug model_answers/python '{ "stdin": "1 2" }'
|
|
11
|
+
exercode-problem debug model_answers/python '{ "stdin": "1 2" }'
|
|
12
|
+
The \`validate-*\` subcommands check problem directories, a course directory
|
|
13
|
+
(course.yaml and lecture materials), or a contest (*.contest.yaml) file
|
|
14
|
+
without running any program.`;a();async function a(){let n=process.argv.slice(2);if(n[0]===`--help`||n[0]===`-h`){console.info(i);return}try{if(n[0]===`judge`||n[0]===`debug`){if(n.length<2){console.error(i),process.exitCode=1;return}process.argv.splice(2,1),process.exitCode=await e(n[0])}else o(n[0])?process.exitCode=await r(n[0],n.slice(1)):process.exitCode=await t(n)}catch(e){console.error(e),process.exitCode=1}}function o(e){return n.includes(e??``)}
|
|
9
15
|
//# sourceMappingURL=exercodeProblem.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"exercodeProblem.js","names":[],"sources":["../../src/cli/exercodeProblem.ts"],"sourcesContent":["import { checkAllProblems } from './checkAllProblems.js';\nimport { runSingleHarness } from './runSingleHarness.js';\n\nconst usage = `Usage: exercode-problem [rootDir] [--only <substring>]... [--skip <substring>]... [--concurrency <n>]\n exercode-problem judge <answerDir> [paramsJson]\n exercode-problem debug <answerDir> [paramsJson]\n\nWithout a subcommand, judge all model answers of all problems under rootDir\n(default: the current directory). Use \\`judge\\` or \\`debug\\` in a problem\ndirectory to run one answer directory, e.g.:\n exercode-problem debug model_answers/python '{ \"stdin\": \"1 2\" }'
|
|
1
|
+
{"version":3,"file":"exercodeProblem.js","names":[],"sources":["../../src/cli/exercodeProblem.ts"],"sourcesContent":["import { checkAllProblems } from './checkAllProblems.js';\nimport { runSingleHarness } from './runSingleHarness.js';\nimport { VALIDATE_SUBCOMMANDS, type ValidateSubcommand, validateLearningMaterial } from './validateLearningMaterial.js';\n\nconst usage = `Usage: exercode-problem [rootDir] [--only <substring>]... [--skip <substring>]... [--concurrency <n>]\n exercode-problem judge <answerDir> [paramsJson]\n exercode-problem debug <answerDir> [paramsJson]\n exercode-problem validate-problem <problemDir>...\n exercode-problem validate-course <courseDir> [--problems-dir <dir>]\n exercode-problem validate-contest <contestYamlPath> [--problems-dir <dir>]\n\nWithout a subcommand, judge all model answers of all problems under rootDir\n(default: the current directory). Use \\`judge\\` or \\`debug\\` in a problem\ndirectory to run one answer directory, e.g.:\n exercode-problem debug model_answers/python '{ \"stdin\": \"1 2\" }'\nThe \\`validate-*\\` subcommands check problem directories, a course directory\n(course.yaml and lecture materials), or a contest (*.contest.yaml) file\nwithout running any program.`;\n\n// oxlint-disable-next-line unicorn/prefer-top-level-await -- the CJS build output does not support top-level await\nvoid main();\n\nasync function main(): Promise<void> {\n const args = process.argv.slice(2);\n if (args[0] === '--help' || args[0] === '-h') {\n // console.log would be stripped from the built CLI, so print the usage with console.info.\n console.info(usage);\n return;\n }\n try {\n if (args[0] === 'judge' || args[0] === 'debug') {\n if (args.length < 2) {\n console.error(usage);\n process.exitCode = 1;\n return;\n }\n // Harness scripts and presets read the answer directory and params from fixed positions in\n // `process.argv`, so drop the subcommand to restore those positions.\n process.argv.splice(2, 1);\n process.exitCode = await runSingleHarness(args[0]);\n } else if (isValidateSubcommand(args[0])) {\n process.exitCode = await validateLearningMaterial(args[0], args.slice(1));\n } else {\n process.exitCode = await checkAllProblems(args);\n }\n } catch (error) {\n // Print the whole error: harness failures need their stack and `cause`, not just the message.\n console.error(error);\n process.exitCode = 1;\n }\n}\n\nfunction isValidateSubcommand(arg: string | undefined): arg is ValidateSubcommand {\n return (VALIDATE_SUBCOMMANDS as readonly string[]).includes(arg ?? '');\n}\n"],"mappings":"qNAIA,MAAM,EAAQ;;;;;;;;;;;;;8BAgBT,EAAK,EAEV,eAAe,GAAsB,CACnC,IAAM,EAAO,QAAQ,KAAK,MAAM,CAAC,EACjC,GAAI,EAAK,KAAO,UAAY,EAAK,KAAO,KAAM,CAE5C,QAAQ,KAAK,CAAK,EAClB,MACF,CACA,GAAI,CACF,GAAI,EAAK,KAAO,SAAW,EAAK,KAAO,QAAS,CAC9C,GAAI,EAAK,OAAS,EAAG,CACnB,QAAQ,MAAM,CAAK,EACnB,QAAQ,SAAW,EACnB,MACF,CAGA,QAAQ,KAAK,OAAO,EAAG,CAAC,EACxB,QAAQ,SAAW,MAAM,EAAiB,EAAK,EAAE,CACnD,MAAW,EAAqB,EAAK,EAAE,EACrC,QAAQ,SAAW,MAAM,EAAyB,EAAK,GAAI,EAAK,MAAM,CAAC,CAAC,EAExE,QAAQ,SAAW,MAAM,EAAiB,CAAI,CAElD,OAAS,EAAO,CAEd,QAAQ,MAAM,CAAK,EACnB,QAAQ,SAAW,CACrB,CACF,CAEA,SAAS,EAAqB,EAAoD,CAChF,OAAQ,EAA2C,SAAS,GAAO,EAAE,CACvE"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../learningMaterial/validationResult.cjs"),t=require("../learningMaterial/validateContest.cjs"),n=require("../learningMaterial/validateCourse.cjs"),r=require("../learningMaterial/validateProblem.cjs"),i=[`validate-problem`,`validate-course`,`validate-contest`];async function a(t,n){let{targets:r,problemsDir:i}=s(n);if(r.length===0)throw Error(`${t} requires at least one path`);if(t===`validate-problem`){if(i!==void 0)throw Error(`${t} does not take --problems-dir`)}else if(r.length>1)throw Error(`${t} accepts exactly one path, but got ${r.length}`);let a=!1;for(let n of r){let r=await o(t,n,i);process.stdout.write(e.formatValidationReport(n,r)),a||=r.errors.length>0}return+!!a}async function o(e,i,a){switch(e){case`validate-problem`:return r.validateProblemDirectory(i);case`validate-course`:return n.validateCourseDirectory(i,{problemsDirectoryPath:a});case`validate-contest`:return t.validateContestFile(i,{problemsDirectoryPath:a})}}function s(e){let t=[],n;for(let r=0;r<e.length;r++){let i=e[r];if(i===void 0)break;if(i===`--problems-dir`){if(n=e[++r],n===void 0)throw Error(`${i} requires a value`)}else if(i.startsWith(`--`))throw Error(`Unknown option: ${i}`);else t.push(i)}return{targets:t,problemsDir:n}}exports.VALIDATE_SUBCOMMANDS=i,exports.validateLearningMaterial=a;
|
|
2
|
+
//# sourceMappingURL=validateLearningMaterial.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validateLearningMaterial.cjs","names":["formatValidationReport","validateProblemDirectory","validateCourseDirectory","validateContestFile"],"sources":["../../src/cli/validateLearningMaterial.ts"],"sourcesContent":["import { validateContestFile } from '../learningMaterial/validateContest.js';\nimport { validateCourseDirectory } from '../learningMaterial/validateCourse.js';\nimport { validateProblemDirectory } from '../learningMaterial/validateProblem.js';\nimport { formatValidationReport, type ValidationResult } from '../learningMaterial/validationResult.js';\n\nexport const VALIDATE_SUBCOMMANDS = ['validate-problem', 'validate-course', 'validate-contest'] as const;\n\nexport type ValidateSubcommand = (typeof VALIDATE_SUBCOMMANDS)[number];\n\n/**\n * Validate learning-material files without running any program and print one report per target.\n * Returns the process exit code: 1 when any target has an error (warnings alone pass).\n */\nexport async function validateLearningMaterial(\n subcommand: ValidateSubcommand,\n args: readonly string[]\n): Promise<number> {\n const { targets, problemsDir } = parseValidateArgs(args);\n if (targets.length === 0) throw new Error(`${subcommand} requires at least one path`);\n if (subcommand === 'validate-problem') {\n if (problemsDir !== undefined) throw new Error(`${subcommand} does not take --problems-dir`);\n } else if (targets.length > 1) {\n throw new Error(`${subcommand} accepts exactly one path, but got ${targets.length}`);\n }\n\n let hasError = false;\n for (const target of targets) {\n const result = await validate(subcommand, target, problemsDir);\n process.stdout.write(formatValidationReport(target, result));\n hasError ||= result.errors.length > 0;\n }\n return hasError ? 1 : 0;\n}\n\nasync function validate(\n subcommand: ValidateSubcommand,\n target: string,\n problemsDirectoryPath: string | undefined\n): Promise<ValidationResult> {\n switch (subcommand) {\n case 'validate-problem': {\n return validateProblemDirectory(target);\n }\n case 'validate-course': {\n return validateCourseDirectory(target, { problemsDirectoryPath });\n }\n case 'validate-contest': {\n return validateContestFile(target, { problemsDirectoryPath });\n }\n }\n}\n\nfunction parseValidateArgs(args: readonly string[]): { targets: string[]; problemsDir: string | undefined } {\n const targets: string[] = [];\n let problemsDir: string | undefined;\n for (let index = 0; index < args.length; index++) {\n const arg = args[index];\n if (arg === undefined) break;\n if (arg === '--problems-dir') {\n problemsDir = args[++index];\n if (problemsDir === undefined) throw new Error(`${arg} requires a value`);\n } else if (arg.startsWith('--')) {\n throw new Error(`Unknown option: ${arg}`);\n } else {\n targets.push(arg);\n }\n }\n return { targets, problemsDir };\n}\n"],"mappings":"0SAKa,EAAuB,CAAC,mBAAoB,kBAAmB,kBAAkB,EAQ9F,eAAsB,EACpB,EACA,EACiB,CACjB,GAAM,CAAE,UAAS,eAAgB,EAAkB,CAAI,EACvD,GAAI,EAAQ,SAAW,EAAG,MAAU,MAAM,GAAG,EAAW,4BAA4B,EACpF,GAAI,IAAe,mBACb,IAAA,IAAgB,IAAA,GAAW,MAAU,MAAM,GAAG,EAAW,8BAA8B,CAAA,MACtF,GAAI,EAAQ,OAAS,EAC1B,MAAU,MAAM,GAAG,EAAW,qCAAqC,EAAQ,QAAQ,EAGrF,IAAI,EAAW,GACf,IAAK,IAAM,KAAU,EAAS,CAC5B,IAAM,EAAS,MAAM,EAAS,EAAY,EAAQ,CAAW,EAC7D,QAAQ,OAAO,MAAMA,EAAAA,uBAAuB,EAAQ,CAAM,CAAC,EAC3D,IAAa,EAAO,OAAO,OAAS,CACtC,CACA,MAAO,IACT,CAEA,eAAe,EACb,EACA,EACA,EAC2B,CAC3B,OAAQ,EAAR,CACE,IAAK,mBACH,OAAOC,EAAAA,yBAAyB,CAAM,EAExC,IAAK,kBACH,OAAOC,EAAAA,wBAAwB,EAAQ,CAAE,uBAAsB,CAAC,EAElE,IAAK,mBACH,OAAOC,EAAAA,oBAAoB,EAAQ,CAAE,uBAAsB,CAAC,CAEhE,CACF,CAEA,SAAS,EAAkB,EAAiF,CAC1G,IAAM,EAAoB,CAAC,EACvB,EACJ,IAAK,IAAI,EAAQ,EAAG,EAAQ,EAAK,OAAQ,IAAS,CAChD,IAAM,EAAM,EAAK,GACjB,GAAI,IAAQ,IAAA,GAAW,MACvB,GAAI,IAAQ,iBAEV,IADA,EAAc,EAAK,EAAE,GACjB,IAAgB,IAAA,GAAW,MAAU,MAAM,GAAG,EAAI,kBAAkB,CAAA,MACnE,GAAI,EAAI,WAAW,IAAI,EAC5B,MAAU,MAAM,mBAAmB,GAAK,OAExC,EAAQ,KAAK,CAAG,CAEpB,CACA,MAAO,CAAE,UAAS,aAAY,CAChC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare const VALIDATE_SUBCOMMANDS: readonly ['validate-problem', 'validate-course', 'validate-contest'];
|
|
2
|
+
export type ValidateSubcommand = (typeof VALIDATE_SUBCOMMANDS)[number];
|
|
3
|
+
/**
|
|
4
|
+
* Validate learning-material files without running any program and print one report per target.
|
|
5
|
+
* Returns the process exit code: 1 when any target has an error (warnings alone pass).
|
|
6
|
+
*/
|
|
7
|
+
export declare function validateLearningMaterial(subcommand: ValidateSubcommand, args: readonly string[]): Promise<number>;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{formatValidationReport as e}from"../learningMaterial/validationResult.js";import{validateContestFile as t}from"../learningMaterial/validateContest.js";import{validateCourseDirectory as n}from"../learningMaterial/validateCourse.js";import{validateProblemDirectory as r}from"../learningMaterial/validateProblem.js";const i=[`validate-problem`,`validate-course`,`validate-contest`];async function a(t,n){let{targets:r,problemsDir:i}=s(n);if(r.length===0)throw Error(`${t} requires at least one path`);if(t===`validate-problem`){if(i!==void 0)throw Error(`${t} does not take --problems-dir`)}else if(r.length>1)throw Error(`${t} accepts exactly one path, but got ${r.length}`);let a=!1;for(let n of r){let r=await o(t,n,i);process.stdout.write(e(n,r)),a||=r.errors.length>0}return+!!a}async function o(e,i,a){switch(e){case`validate-problem`:return r(i);case`validate-course`:return n(i,{problemsDirectoryPath:a});case`validate-contest`:return t(i,{problemsDirectoryPath:a})}}function s(e){let t=[],n;for(let r=0;r<e.length;r++){let i=e[r];if(i===void 0)break;if(i===`--problems-dir`){if(n=e[++r],n===void 0)throw Error(`${i} requires a value`)}else if(i.startsWith(`--`))throw Error(`Unknown option: ${i}`);else t.push(i)}return{targets:t,problemsDir:n}}export{i as VALIDATE_SUBCOMMANDS,a as validateLearningMaterial};
|
|
2
|
+
//# sourceMappingURL=validateLearningMaterial.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validateLearningMaterial.js","names":[],"sources":["../../src/cli/validateLearningMaterial.ts"],"sourcesContent":["import { validateContestFile } from '../learningMaterial/validateContest.js';\nimport { validateCourseDirectory } from '../learningMaterial/validateCourse.js';\nimport { validateProblemDirectory } from '../learningMaterial/validateProblem.js';\nimport { formatValidationReport, type ValidationResult } from '../learningMaterial/validationResult.js';\n\nexport const VALIDATE_SUBCOMMANDS = ['validate-problem', 'validate-course', 'validate-contest'] as const;\n\nexport type ValidateSubcommand = (typeof VALIDATE_SUBCOMMANDS)[number];\n\n/**\n * Validate learning-material files without running any program and print one report per target.\n * Returns the process exit code: 1 when any target has an error (warnings alone pass).\n */\nexport async function validateLearningMaterial(\n subcommand: ValidateSubcommand,\n args: readonly string[]\n): Promise<number> {\n const { targets, problemsDir } = parseValidateArgs(args);\n if (targets.length === 0) throw new Error(`${subcommand} requires at least one path`);\n if (subcommand === 'validate-problem') {\n if (problemsDir !== undefined) throw new Error(`${subcommand} does not take --problems-dir`);\n } else if (targets.length > 1) {\n throw new Error(`${subcommand} accepts exactly one path, but got ${targets.length}`);\n }\n\n let hasError = false;\n for (const target of targets) {\n const result = await validate(subcommand, target, problemsDir);\n process.stdout.write(formatValidationReport(target, result));\n hasError ||= result.errors.length > 0;\n }\n return hasError ? 1 : 0;\n}\n\nasync function validate(\n subcommand: ValidateSubcommand,\n target: string,\n problemsDirectoryPath: string | undefined\n): Promise<ValidationResult> {\n switch (subcommand) {\n case 'validate-problem': {\n return validateProblemDirectory(target);\n }\n case 'validate-course': {\n return validateCourseDirectory(target, { problemsDirectoryPath });\n }\n case 'validate-contest': {\n return validateContestFile(target, { problemsDirectoryPath });\n }\n }\n}\n\nfunction parseValidateArgs(args: readonly string[]): { targets: string[]; problemsDir: string | undefined } {\n const targets: string[] = [];\n let problemsDir: string | undefined;\n for (let index = 0; index < args.length; index++) {\n const arg = args[index];\n if (arg === undefined) break;\n if (arg === '--problems-dir') {\n problemsDir = args[++index];\n if (problemsDir === undefined) throw new Error(`${arg} requires a value`);\n } else if (arg.startsWith('--')) {\n throw new Error(`Unknown option: ${arg}`);\n } else {\n targets.push(arg);\n }\n }\n return { targets, problemsDir };\n}\n"],"mappings":"gUAKA,MAAa,EAAuB,CAAC,mBAAoB,kBAAmB,kBAAkB,EAQ9F,eAAsB,EACpB,EACA,EACiB,CACjB,GAAM,CAAE,UAAS,eAAgB,EAAkB,CAAI,EACvD,GAAI,EAAQ,SAAW,EAAG,MAAU,MAAM,GAAG,EAAW,4BAA4B,EACpF,GAAI,IAAe,mBACb,IAAA,IAAgB,IAAA,GAAW,MAAU,MAAM,GAAG,EAAW,8BAA8B,CAAA,MACtF,GAAI,EAAQ,OAAS,EAC1B,MAAU,MAAM,GAAG,EAAW,qCAAqC,EAAQ,QAAQ,EAGrF,IAAI,EAAW,GACf,IAAK,IAAM,KAAU,EAAS,CAC5B,IAAM,EAAS,MAAM,EAAS,EAAY,EAAQ,CAAW,EAC7D,QAAQ,OAAO,MAAM,EAAuB,EAAQ,CAAM,CAAC,EAC3D,IAAa,EAAO,OAAO,OAAS,CACtC,CACA,MAAO,IACT,CAEA,eAAe,EACb,EACA,EACA,EAC2B,CAC3B,OAAQ,EAAR,CACE,IAAK,mBACH,OAAO,EAAyB,CAAM,EAExC,IAAK,kBACH,OAAO,EAAwB,EAAQ,CAAE,uBAAsB,CAAC,EAElE,IAAK,mBACH,OAAO,EAAoB,EAAQ,CAAE,uBAAsB,CAAC,CAEhE,CACF,CAEA,SAAS,EAAkB,EAAiF,CAC1G,IAAM,EAAoB,CAAC,EACvB,EACJ,IAAK,IAAI,EAAQ,EAAG,EAAQ,EAAK,OAAQ,IAAS,CAChD,IAAM,EAAM,EAAK,GACjB,GAAI,IAAQ,IAAA,GAAW,MACvB,GAAI,IAAQ,iBAEV,IADA,EAAc,EAAK,EAAE,GACjB,IAAgB,IAAA,GAAW,MAAU,MAAM,GAAG,EAAI,kBAAkB,CAAA,MACnE,GAAI,EAAI,WAAW,IAAI,EAC5B,MAAU,MAAM,mBAAmB,GAAK,OAExC,EAAQ,KAAK,CAAG,CAEpB,CACA,MAAO,CAAE,UAAS,aAAY,CAChC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";const e=require("../_virtual/_rolldown/runtime.cjs"),t=require("../types/testCaseResult.cjs"),n=require("
|
|
1
|
+
"use strict";const e=require("../_virtual/_rolldown/runtime.cjs"),t=require("../types/testCaseResult.cjs"),n=require("./temporaryProblemDirCopy.cjs"),r=require("../types/decisionCode.cjs"),i=require("./printDebugBanner.cjs"),a=require("./runHarnessProcess.cjs");let o=require("node:path");o=e.__toESM(o,1);const s=3e4,c=1e4;async function l(e,t,r,l={}){let h=Math.max(s,(l.expectedMaxDurationMs??0)+c),g;try{let s=await n.copyProblemDirToTemporaryRoot(e);g=s.tempRoot;let{copiedProblemDir:c}=s,_=o.default.resolve(e),v=o.default.relative(_,o.default.resolve(t.cwd)),y=o.default.join(c,v),b=p(_);if(b.startsWith(`..`)||o.default.isAbsolute(b))return i.printDebugBanner([`[DEBUG MODE] isolated problem directory check skipped`,``,`The invoked judge script is located outside the problem directory.`,`Script path: ${b}`]),{passed:!0};let x=process.execArgv.filter(d),S=JSON.stringify(f(r)?r:{}),C=await a.runHarnessProcess([...x,b,y,S],{cwd:c,env:process.env,timeoutMs:h,maxOutputBytes:67108864,tempRoot:g});return C.exitCode===0&&m(C.stdout)?(i.printDebugBanner([`[DEBUG MODE] isolated problem directory check passed`,``,`Copied problem dir : ${c}`,`Checked cwd : ${v}`]),{passed:!0}):(i.printDebugBanner([`[DEBUG MODE] isolated problem directory check failed`,``,...u(C,h,l),``,`Copied problem dir : ${c}`,`Checked cwd : ${v}`,`Exit status : ${C.exitCode??C.signal??`unknown`}`,`Failure reason : ${C.failureReason??`<none>`}`,``,`stdout:`,C.stdout.trimEnd()||`<empty>`,``,`stderr:`,C.stderr.trimEnd()||`<empty>`]),{passed:!1})}catch(e){return i.printDebugBanner([`[DEBUG MODE] isolated problem directory check failed due to an unexpected error`,``,e instanceof Error?e.message:String(e)]),{passed:!1}}finally{g&&await n.forciblyRemoveDirectory(g)}}function u(e,t,n){return e.timedOut?[`The judge did not finish within ${t/1e3} seconds after copying only the problem directory to a temporary location.`,...n.expectedMaxDurationMs===void 0?[`This judge declares no run time, so the check uses its fixed ${s/1e3}-second budget.`]:[`The budget is the larger of ${s/1e3} seconds and the build timeout plus the time limit of every test case plus a ${c/1e3}-second overhead.`,`Check timeLimitMs, the number of test cases, and one-off startup costs such as cold caches.`]]:e.failureReason===void 0?e.exitCode===void 0?[`The judge was terminated by ${e.signal??`an unknown signal`} (e.g. an out-of-memory kill or a cancelled job).`]:[`The judge did not complete successfully after copying only the problem directory to a temporary location.`,`Make sure judge.ts imports only files included in the problem directory.`]:[`The judge was stopped before it finished; see the failure reason below.`]}function d(e){return!e.startsWith(`--inspect`)&&!e.startsWith(`--watch`)&&!e.startsWith(`--hot`)}function f(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function p(e){let t=process.argv[1];if(!t)return`.${o.default.sep}judge.ts`;let n=o.default.relative(e,o.default.resolve(t));return o.default.isAbsolute(n)||n.startsWith(`.`)?n:`.${o.default.sep}${n}`}function m(e){let n=e.split(/\r?\n/).filter(e=>e.startsWith(t.TEST_CASE_RESULT_PREFIX));return n.length!==0&&n.every(e=>{try{let n=t.testCaseResultSchema.safeParse(JSON.parse(e.slice(t.TEST_CASE_RESULT_PREFIX.length)));return n.success&&n.data.decisionCode===r.DecisionCode.ACCEPTED}catch{return!1}})}exports.checkProblemDirIsolation=l;
|
|
2
2
|
//# sourceMappingURL=checkProblemDirIsolation.cjs.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{TEST_CASE_RESULT_PREFIX as e,testCaseResultSchema as t}from"../types/testCaseResult.js";import{
|
|
1
|
+
import{TEST_CASE_RESULT_PREFIX as e,testCaseResultSchema as t}from"../types/testCaseResult.js";import{copyProblemDirToTemporaryRoot as n,forciblyRemoveDirectory as r}from"./temporaryProblemDirCopy.js";import{DecisionCode as i}from"../types/decisionCode.js";import{printDebugBanner as a}from"./printDebugBanner.js";import{runHarnessProcess as o}from"./runHarnessProcess.js";import s from"node:path";const c=3e4,l=1e4;async function u(e,t,i,u={}){let g=Math.max(c,(u.expectedMaxDurationMs??0)+l),_;try{let r=await n(e);_=r.tempRoot;let{copiedProblemDir:c}=r,l=s.resolve(e),v=s.relative(l,s.resolve(t.cwd)),y=s.join(c,v),b=m(l);if(b.startsWith(`..`)||s.isAbsolute(b))return a([`[DEBUG MODE] isolated problem directory check skipped`,``,`The invoked judge script is located outside the problem directory.`,`Script path: ${b}`]),{passed:!0};let x=process.execArgv.filter(f),S=JSON.stringify(p(i)?i:{}),C=await o([...x,b,y,S],{cwd:c,env:process.env,timeoutMs:g,maxOutputBytes:67108864,tempRoot:_});return C.exitCode===0&&h(C.stdout)?(a([`[DEBUG MODE] isolated problem directory check passed`,``,`Copied problem dir : ${c}`,`Checked cwd : ${v}`]),{passed:!0}):(a([`[DEBUG MODE] isolated problem directory check failed`,``,...d(C,g,u),``,`Copied problem dir : ${c}`,`Checked cwd : ${v}`,`Exit status : ${C.exitCode??C.signal??`unknown`}`,`Failure reason : ${C.failureReason??`<none>`}`,``,`stdout:`,C.stdout.trimEnd()||`<empty>`,``,`stderr:`,C.stderr.trimEnd()||`<empty>`]),{passed:!1})}catch(e){return a([`[DEBUG MODE] isolated problem directory check failed due to an unexpected error`,``,e instanceof Error?e.message:String(e)]),{passed:!1}}finally{_&&await r(_)}}function d(e,t,n){return e.timedOut?[`The judge did not finish within ${t/1e3} seconds after copying only the problem directory to a temporary location.`,...n.expectedMaxDurationMs===void 0?[`This judge declares no run time, so the check uses its fixed ${c/1e3}-second budget.`]:[`The budget is the larger of ${c/1e3} seconds and the build timeout plus the time limit of every test case plus a ${l/1e3}-second overhead.`,`Check timeLimitMs, the number of test cases, and one-off startup costs such as cold caches.`]]:e.failureReason===void 0?e.exitCode===void 0?[`The judge was terminated by ${e.signal??`an unknown signal`} (e.g. an out-of-memory kill or a cancelled job).`]:[`The judge did not complete successfully after copying only the problem directory to a temporary location.`,`Make sure judge.ts imports only files included in the problem directory.`]:[`The judge was stopped before it finished; see the failure reason below.`]}function f(e){return!e.startsWith(`--inspect`)&&!e.startsWith(`--watch`)&&!e.startsWith(`--hot`)}function p(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function m(e){let t=process.argv[1];if(!t)return`.${s.sep}judge.ts`;let n=s.relative(e,s.resolve(t));return s.isAbsolute(n)||n.startsWith(`.`)?n:`.${s.sep}${n}`}function h(n){let r=n.split(/\r?\n/).filter(t=>t.startsWith(e));return r.length!==0&&r.every(n=>{try{let r=t.safeParse(JSON.parse(n.slice(e.length)));return r.success&&r.data.decisionCode===i.ACCEPTED}catch{return!1}})}export{u as checkProblemDirIsolation};
|
|
2
2
|
//# sourceMappingURL=checkProblemDirIsolation.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";const e=require("../_virtual/_rolldown/runtime.cjs")
|
|
1
|
+
"use strict";const e=require("../_virtual/_rolldown/runtime.cjs");let t=require("node:path");t=e.__toESM(t,1);let n=require("node:fs/promises");n=e.__toESM(n,1);async function r(e){let t=await n.default.readdir(e,{recursive:!0});return new Set(t)}async function i(e,t){await a(e,``,t)}async function a(e,r,i){for(let o of await n.default.readdir(e,{withFileTypes:!0})){let s=t.default.join(r,o.name);i.has(s)?o.isDirectory()&&await a(t.default.join(e,o.name),s,i):await n.default.rm(t.default.join(e,o.name),{force:!0,recursive:!0})}}exports.cleanWorkingDirectory=i,exports.snapshotWorkingDirectory=r;
|
|
2
2
|
//# sourceMappingURL=cleanWorkingDirectory.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cleanWorkingDirectory.cjs","names":["
|
|
1
|
+
{"version":3,"file":"cleanWorkingDirectory.cjs","names":["fs","path"],"sources":["../../src/helpers/cleanWorkingDirectory.ts"],"sourcesContent":["import fs from 'node:fs/promises';\nimport path from 'node:path';\n\n// Currently, it does not support changing file contents and deleting files.\nexport async function snapshotWorkingDirectory(cwd: string): Promise<ReadonlySet<string>> {\n const paths = await fs.readdir(cwd, { recursive: true });\n return new Set(paths);\n}\n\nexport async function cleanWorkingDirectory(cwd: string, snapshot: ReadonlySet<string>): Promise<void> {\n await cleanDirectory(cwd, '', snapshot);\n}\n\nasync function cleanDirectory(dir: string, relativePrefix: string, snapshot: ReadonlySet<string>): Promise<void> {\n for (const entry of await fs.readdir(dir, { withFileTypes: true })) {\n const relativePath = path.join(relativePrefix, entry.name);\n if (!snapshot.has(relativePath)) {\n // An unsnapshotted directory is removed whole, so its contents are never visited.\n await fs.rm(path.join(dir, entry.name), { force: true, recursive: true });\n } else if (entry.isDirectory()) {\n await cleanDirectory(path.join(dir, entry.name), relativePath, snapshot);\n }\n }\n}\n"],"mappings":"iKAIA,eAAsB,EAAyB,EAA2C,CACxF,IAAM,EAAQ,MAAMA,EAAAA,QAAG,QAAQ,EAAK,CAAE,UAAW,EAAK,CAAC,EACvD,OAAO,IAAI,IAAI,CAAK,CACtB,CAEA,eAAsB,EAAsB,EAAa,EAA8C,CACrG,MAAM,EAAe,EAAK,GAAI,CAAQ,CACxC,CAEA,eAAe,EAAe,EAAa,EAAwB,EAA8C,CAC/G,IAAK,IAAM,KAAS,MAAMA,EAAAA,QAAG,QAAQ,EAAK,CAAE,cAAe,EAAK,CAAC,EAAG,CAClE,IAAM,EAAeC,EAAAA,QAAK,KAAK,EAAgB,EAAM,IAAI,EACpD,EAAS,IAAI,CAAY,EAGnB,EAAM,YAAY,GAC3B,MAAM,EAAeA,EAAAA,QAAK,KAAK,EAAK,EAAM,IAAI,EAAG,EAAc,CAAQ,EAFvE,MAAMD,EAAAA,QAAG,GAAGC,EAAAA,QAAK,KAAK,EAAK,EAAM,IAAI,EAAG,CAAE,MAAO,GAAM,UAAW,EAAK,CAAC,CAI5E,CACF"}
|
|
@@ -1,6 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
export
|
|
3
|
-
type WorkingDirectoryEntryKind = 'directory' | 'file' | 'symlink' | 'other';
|
|
4
|
-
export declare function snapshotWorkingDirectory(cwd: string): Promise<WorkingDirectorySnapshot>;
|
|
5
|
-
export declare function cleanWorkingDirectory(cwd: string, snapshot: WorkingDirectorySnapshot): Promise<void>;
|
|
6
|
-
export {};
|
|
1
|
+
export declare function snapshotWorkingDirectory(cwd: string): Promise<ReadonlySet<string>>;
|
|
2
|
+
export declare function cleanWorkingDirectory(cwd: string, snapshot: ReadonlySet<string>): Promise<void>;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import
|
|
1
|
+
import e from"node:path";import t from"node:fs/promises";async function n(e){let n=await t.readdir(e,{recursive:!0});return new Set(n)}async function r(e,t){await i(e,``,t)}async function i(n,r,a){for(let o of await t.readdir(n,{withFileTypes:!0})){let s=e.join(r,o.name);a.has(s)?o.isDirectory()&&await i(e.join(n,o.name),s,a):await t.rm(e.join(n,o.name),{force:!0,recursive:!0})}}export{r as cleanWorkingDirectory,n as snapshotWorkingDirectory};
|
|
2
2
|
//# sourceMappingURL=cleanWorkingDirectory.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cleanWorkingDirectory.js","names":[],"sources":["../../src/helpers/cleanWorkingDirectory.ts"],"sourcesContent":["import fs from 'node:fs';\nimport path from 'node:path';\n\
|
|
1
|
+
{"version":3,"file":"cleanWorkingDirectory.js","names":[],"sources":["../../src/helpers/cleanWorkingDirectory.ts"],"sourcesContent":["import fs from 'node:fs/promises';\nimport path from 'node:path';\n\n// Currently, it does not support changing file contents and deleting files.\nexport async function snapshotWorkingDirectory(cwd: string): Promise<ReadonlySet<string>> {\n const paths = await fs.readdir(cwd, { recursive: true });\n return new Set(paths);\n}\n\nexport async function cleanWorkingDirectory(cwd: string, snapshot: ReadonlySet<string>): Promise<void> {\n await cleanDirectory(cwd, '', snapshot);\n}\n\nasync function cleanDirectory(dir: string, relativePrefix: string, snapshot: ReadonlySet<string>): Promise<void> {\n for (const entry of await fs.readdir(dir, { withFileTypes: true })) {\n const relativePath = path.join(relativePrefix, entry.name);\n if (!snapshot.has(relativePath)) {\n // An unsnapshotted directory is removed whole, so its contents are never visited.\n await fs.rm(path.join(dir, entry.name), { force: true, recursive: true });\n } else if (entry.isDirectory()) {\n await cleanDirectory(path.join(dir, entry.name), relativePath, snapshot);\n }\n }\n}\n"],"mappings":"yDAIA,eAAsB,EAAyB,EAA2C,CACxF,IAAM,EAAQ,MAAM,EAAG,QAAQ,EAAK,CAAE,UAAW,EAAK,CAAC,EACvD,OAAO,IAAI,IAAI,CAAK,CACtB,CAEA,eAAsB,EAAsB,EAAa,EAA8C,CACrG,MAAM,EAAe,EAAK,GAAI,CAAQ,CACxC,CAEA,eAAe,EAAe,EAAa,EAAwB,EAA8C,CAC/G,IAAK,IAAM,KAAS,MAAM,EAAG,QAAQ,EAAK,CAAE,cAAe,EAAK,CAAC,EAAG,CAClE,IAAM,EAAe,EAAK,KAAK,EAAgB,EAAM,IAAI,EACpD,EAAS,IAAI,CAAY,EAGnB,EAAM,YAAY,GAC3B,MAAM,EAAe,EAAK,KAAK,EAAK,EAAM,IAAI,EAAG,EAAc,CAAQ,EAFvE,MAAM,EAAG,GAAG,EAAK,KAAK,EAAK,EAAM,IAAI,EAAG,CAAE,MAAO,GAAM,UAAW,EAAK,CAAC,CAI5E,CACF"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";const e=require("../_virtual/_rolldown/runtime.cjs"),t=require("./compareStdoutAsSpaceSeparatedTokens.cjs"),n=require("./printTestCaseResult.cjs")
|
|
1
|
+
"use strict";const e=require("../_virtual/_rolldown/runtime.cjs"),t=require("./compareStdoutAsSpaceSeparatedTokens.cjs"),n=require("./printTestCaseResult.cjs");let r=require("node:fs");r=e.__toESM(r,1);let i=require("node:path");i=e.__toESM(i,1);const a=8388608;async function o(e,t){let o=[],s=[],c=(await r.default.promises.readdir(t,{withFileTypes:!0,recursive:!0})).filter(e=>e.isFile()).map(e=>({absolutePath:i.default.join(e.parentPath,e.name),relativePath:i.default.posix.join(...i.default.relative(t,e.parentPath).split(i.default.sep),e.name)})).toSorted((e,t)=>e.relativePath<t.relativePath?-1:+(e.relativePath>t.relativePath));for(let{absolutePath:t,relativePath:f}of c){if((await r.default.promises.stat(t)).size>8388608)throw Error(`expected output file ${f} exceeds ${a} bytes`);let c=await r.default.promises.readFile(t),p=await u(i.default.join(e,f));p&&d(c,p)||(o.push(f),c.length<=1048576&&s.push(n.encodeFileForTestCaseResult(l(f,`expected`),c)),p&&p.length<=1048576&&s.push(n.encodeFileForTestCaseResult(l(f,`received`),p)))}return{matches:o.length===0,mismatchedPaths:o,outputFiles:s}}async function s(e){let{stdout:n,expectedStdout:r,fileOutputPath:i,cwd:a}=e,s=[...e.outputFiles],l=r===void 0||t.compareStdoutAsSpaceSeparatedTokens(n,r);if(i!==void 0){let e=await o(a,i);e.matches||(l=!1,s=c(s,e))}return{matches:l,outputFiles:s}}function c(e,t){let n=new Set(t.outputFiles.map(e=>e.path)),r=new Set(t.mismatchedPaths.filter(e=>n.has(l(e,`received`))));return[...e.filter(e=>!r.has(e.path)&&!n.has(e.path)),...t.outputFiles]}function l(e,t){let{dir:n,name:r,ext:a}=i.default.posix.parse(e);return i.default.posix.join(n,`${r}_${t}${a}`)}async function u(e){try{let t=await r.default.promises.stat(e);return!t.isFile()||t.size>8388608?void 0:await r.default.promises.readFile(e)}catch{return}}function d(e,n){return p(e)?p(n)?t.compareStdoutAsSpaceSeparatedTokens(n.toString(`utf8`),e.toString(`utf8`)):!1:n.equals(e)}const f=new TextDecoder(`utf-8`,{fatal:!0});function p(e){if(e.includes(0))return!1;try{return f.decode(e),!0}catch{return!1}}exports.MAX_COMPARED_FILE_BYTES=a,exports.MAX_REPORTED_FILE_BYTES=1048576,exports.compareExpectedOutputFiles=o,exports.judgeAgainstExpectations=s,exports.mergeComparisonOutputFiles=c;
|
|
2
2
|
//# sourceMappingURL=compareExpectedOutputFiles.cjs.map
|