import {spawnSync} from "node:child_process"; import {hasPassingTapContracts} from "../check_tap_contracts.mjs"; // Require original host contracts and exact coverage of the extracted rule. const result = spawnSync(process.execPath, [ "--test", "--test-reporter=tap", "--experimental-test-coverage", "--test-coverage-include=**/static/search/shared/domain/stable-stringify.js", "--test-coverage-lines=100", "--test-coverage-branches=100", "--test-coverage-functions=100", "tests/search/baselines/test_search_stable_stringify_baseline.mjs" ], {encoding: "utf8"}); if (result.stdout) process.stdout.write(result.stdout); if (result.stderr) process.stderr.write(result.stderr); if (result.error) throw result.error; const text = result.stdout || ""; const rows = text.split(/\r?\n/).filter(line => /^\s*#\s*stable-stringify\.js\s*\|\s*100(?:\.0+)?\s*\|\s*100(?:\.0+)?\s*\|\s*100(?:\.0+)?\s*\|/.test(line)); const required = [ "stable object keys are sorted recursively while arrays retain order", "primitive values preserve the original JSON semantics", "undefined, functions and sparse arrays retain the exact original representation", "property access order and exception propagation remain observable", "original global binding can be replaced and recursive calls resolve through it" ].map(name => ({name})); if (result.status !== 0 || rows.length !== 1 || !hasPassingTapContracts(text, required)) { console.error("Search stable stringify coverage requires passing named contracts and exactly one fully covered source row"); process.exitCode = 1; }