37 lines
1.2 KiB
TypeScript
37 lines
1.2 KiB
TypeScript
/**
|
|
* Spec-conformance test for `openspec/specs/crypto-utils/spec.md` —
|
|
* "No vendored code" requirement. Pins the structural invariant that
|
|
* `src/vendored/` does not exist anywhere in this package.
|
|
*/
|
|
import { existsSync, readdirSync, statSync } from "node:fs";
|
|
import { dirname, join } from "node:path";
|
|
import { fileURLToPath } from "node:url";
|
|
import { describe, expect, it } from "@suaveplan/testing/runner";
|
|
|
|
const HERE = dirname(fileURLToPath(import.meta.url));
|
|
|
|
function* walk(dir: string): Generator<string> {
|
|
for (const entry of readdirSync(dir)) {
|
|
const p = join(dir, entry);
|
|
const s = statSync(p);
|
|
if (s.isDirectory()) {
|
|
yield p;
|
|
yield* walk(p);
|
|
}
|
|
}
|
|
}
|
|
|
|
describe("crypto-utils — no vendored code", () => {
|
|
it("src/ contains no vendored directory", { timeout: 5000 }, () => {
|
|
const srcDir = HERE; // already inside src/
|
|
expect(existsSync(srcDir)).toBe(true);
|
|
const offenders: string[] = [];
|
|
for (const dir of walk(srcDir)) {
|
|
if (dir.endsWith("/vendored") || dir.endsWith("\\vendored")) {
|
|
offenders.push(dir);
|
|
}
|
|
}
|
|
expect(offenders).toEqual([]);
|
|
});
|
|
});
|