From 637dd6d0ebefca1472cbdadbdd12ac8332e3502f Mon Sep 17 00:00:00 2001 From: Nick Shirokov Date: Fri, 17 Jul 2026 20:12:42 +0300 Subject: [PATCH] =?UTF-8?q?test(hooks):=20=D0=BF=D0=BE=D1=80=D1=82=D0=B8?= =?UTF-8?q?=D1=80=D1=83=D0=B5=D0=BC=D1=8B=D0=B9=20REPO/CORPUS=20=D0=B2=20r?= =?UTF-8?q?un.mjs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit REPO выводится из расположения самого файла (import.meta.url), а не хардкодом 'C:/WS/tasks/skills'. На POSIX 'C:/…'-строка не абсолютна, и resolve(cwd, path) в support-guard/skill-suggester склеивал её в удвоенный несуществующий путь — из-за чего 8 кейсов ложно «падали» на Mac (guard/suggester не находили фикстуры). Production-логика корректна; чинится только тестовая обвязка. CORPUS теперь env-переопределяем (CC_1C_CFSRC), дефолт прежний; acc/erp-кейсы под existsSync → SKIP без корпуса. Co-Authored-By: Claude Opus 4.8 --- hooks/test/run.mjs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/hooks/test/run.mjs b/hooks/test/run.mjs index e29e5884..e2bb77f3 100644 --- a/hooks/test/run.mjs +++ b/hooks/test/run.mjs @@ -1,4 +1,4 @@ -// run.mjs v1.0 — standalone tests for hook common/ modules against the cfsrc corpus +// run.mjs v1.1 — standalone tests for hook common/ modules against the cfsrc corpus // Source: https://github.com/Nikolay-Shirokov/cc-1c-skills // // No live hook registration needed: exercises decideSupport / getEditMode / findConfigRoot @@ -10,13 +10,19 @@ import { processInput as guard } from '../support-guard.mjs'; import { processInput as suggest } from '../skill-suggester.mjs'; import { execFileSync } from 'node:child_process'; import { rmSync } from 'node:fs'; -import { join } from 'node:path'; +import { dirname, join, resolve } from 'node:path'; +import { fileURLToPath } from 'node:url'; import { existsSync, mkdirSync, writeFileSync } from 'node:fs'; -const CORPUS = 'C:/WS/tasks/cfsrc'; +// Repo root derived from this file's own location (/hooks/test/run.mjs) so the +// suite is portable — hardcoding 'C:/WS/tasks/skills' broke on POSIX, where a 'C:/…' +// string is not absolute and resolve(cwd, path) doubled it into a non-existent path. +const REPO = resolve(dirname(fileURLToPath(import.meta.url)), '..', '..'); +// External vendor corpus (acc/erp): Windows-only by default, env-overridable. The +// acc/erp cases below are existsSync-guarded → they SKIP when the corpus is absent. +const CORPUS = process.env.CC_1C_CFSRC || 'C:/WS/tasks/cfsrc'; const ACC = join(CORPUS, 'acc_8.3.24'); // G=1 — whole config locked const ERP = join(CORPUS, 'erp_8.3.24'); // K=0 — support removed -const REPO = 'C:/WS/tasks/skills'; let pass = 0, fail = 0; function check(name, cond, detail = '') {