* refactor(domain): consolidate canonical ordering and digest helpers (#624) * refactor(domain): consolidate canonical ordering and digest helpers Single owner for code-point ordering (domain/canonicalOrdering.ts) and canonical JSON digests (domain/comparisonSemantics.ts). Delete all local compareCodePoints/compareText/digestCanonical duplicates and migrate every importer. No re-export shims. * fix(ci): allow slower real browser startup * chore(config): remove dead eslint, dedupe scripts, cacheable turbo tasks Delete eslint.config.js (oxlint is the linter), drop lint:dead alias, pin smol-toml, fold jscpd/scan:todos into check:pr, make test:run cacheable, align oxlint ignores. * fix(config): hash all test inputs for cached runs * docs: fix architecture diagram and pretty-print tool catalog Drop dangling REPLAY edges, add dotnet/reference/error/evaluation nodes. Emit 2-space JSON from the catalog generator and regenerate. * test: extract shared fixtures, drop knip carve-outs Dedupe android/apple session tests, bundler adapter headers, and reconstruction helpers into tests/support fixtures. Delete unused type aliases and the knip ignoreIssues block. Lower jscpd threshold 2.7 to 2.5. * refactor(app): split Setup and ProcessOwnership modules Extract SetupTypes/SetupHost from Setup.ts and move observation helpers into ProcessOwnershipObservation/ProcessTree. Migrate all importers including CLI commands. No re-export shims. * refactor(runtime): centralize safe JSON parsing and preserve error causes Add domain/safeJson.safeParseJson and migrate all raw JSON.parse call sites. Name catch causes and preserve failure reasons instead of swallowing; annotate genuine best-effort cleanup. * fix(runtime): retain JSON parse error causes
39 lines
1.5 KiB
TypeScript
39 lines
1.5 KiB
TypeScript
import { expect, it } from "vitest";
|
|
|
|
import { parseOtoolLoadCommands } from "../../../../src/native/parsers/otool.js";
|
|
import { parsePlistJson } from "../../../../src/native/parsers/plist.js";
|
|
import { nativeFixture } from "../../../fixtures/nativeCommands.js";
|
|
|
|
const toCrlf = (value: string): string => value.replaceAll("\n", "\r\n");
|
|
|
|
it("keeps section blocks separate under CRLF captures", async () => {
|
|
const lf = parseOtoolLoadCommands(await nativeFixture("otool-load.txt"));
|
|
const crlf = parseOtoolLoadCommands(
|
|
toCrlf(await nativeFixture("otool-load.txt")),
|
|
);
|
|
expect(crlf.segments).toMatchObject(lf.segments);
|
|
const crlfText = crlf.segments.find(({ name }) => name === "__TEXT");
|
|
expect(crlfText?.sections.length).toBeGreaterThan(0);
|
|
expect(crlfText?.sections.map(({ name }) => name)).toContain("__text");
|
|
});
|
|
|
|
it("does not leak section fields into command fields under CRLF captures", async () => {
|
|
const crlf = parseOtoolLoadCommands(
|
|
toCrlf(await nativeFixture("otool-load.txt")),
|
|
);
|
|
const segment = crlf.commands.find(
|
|
(command) => command.kind === "LC_SEGMENT_64",
|
|
);
|
|
expect(segment?.fields.sectname).toBeUndefined();
|
|
expect(segment?.fields["time stamp"]).toBeUndefined();
|
|
});
|
|
|
|
it("accepts a byte-order mark before plist JSON", () => {
|
|
const parsed = parsePlistJson(
|
|
'\uFEFF{"CFBundleIdentifier":"com.owned.fixture"}',
|
|
);
|
|
expect(parsed.ok).toBe(true);
|
|
if (!parsed.ok) throw new Error("expected plist JSON to parse");
|
|
expect(parsed.value.bundle.identifier).toBe("com.owned.fixture");
|
|
});
|