import test from 'node:test'; import assert from 'node:assert/strict'; import { existsSync, readFileSync } from 'node:fs'; import path from 'node:path'; import { parseDocument } from 'yaml'; const treeRoot = path.join(import.meta.dirname, '..'); const labRoot = path.join(treeRoot, '..', '..'); const copyFile = path.join( import.meta.dirname, 'fixtures', 'normative', 'req-single-quality-command.yaml', ); // Нормативное дерево разрешается по реестру лаборатории (D-054): tree — корень дерева продукта // bhs-spec, а нормативный корень — его каталог spec/ (BHL-066). Вне лаборатории реестра нет, и // проверка пропускается: копия принадлежит дереву продукта и проверяется внутри него. function normativeRoot() { const registry = path.join(labRoot, 'products.yaml'); if (!existsSync(registry)) { return null; } const products = parseDocument(readFileSync(registry, 'utf8')).toJS()?.products ?? []; const declared = products.find((product) => product?.id === 'bhs-spec')?.tree; if (typeof declared !== 'string') { return null; } const root = path.join(labRoot, declared, 'spec'); return existsSync(root) ? root : null; } test('копия нормативного требования свежа: байты совпадают с деревом bhs-spec', (t) => { const root = normativeRoot(); if (root === null) { t.skip('нормативное дерево лаборатории недоступно за пределами дерева продукта'); return; } const original = path.join(root, 'requirements', 'req-single-quality-command.yaml'); assert.ok(existsSync(original), `нормативный файл не найден в ${root}/requirements/`); assert.equal( readFileSync(copyFile, 'utf8'), readFileSync(original, 'utf8'), `копия расходится с ${root}/requirements/req-single-quality-command.yaml: обновите её целиком по tests/fixtures/normative/README.md`, ); });