vomebook commited on
Commit ·
4d10c4c
1
Parent(s): 3d781c6
Group search paths and bundle contracts
Browse filesFiles changed (7)
- scripts/search/README.txt+4-3
- scripts/check_search_record_path_coverage.mjs → scripts/search/check_search_record_path_coverage.mjsRenamed+3-3
- tests/search/build/README.txtAdded+12
- tests/test_search_record_path_build.mjs → tests/search/build/test_search_record_path_build.mjsRenamed+2-2
- tests/search/record-path/README.txtAdded+11
- tests/test_search_record_path.js → tests/search/record-path/test_search_record_path.jsRenamed+2-2
- tests/test_static_checks.py+3-3
4 unmodified lines567891011124 unmodified linesnode scripts/search/check_search_highlight_coverage.mjsnode scripts/search/check_search_size_coverage.mjsThese two gates execute contracts under tests/search/highlight/ andtests/search/size/, respectively. Their V8 thresholds cover only the specifiedextracted search module; the shared TAP helper remains in scripts/.Other search gates remain at their existing paths pending separate migration.4 unmodified lines56789101112134 unmodified linesnode scripts/search/check_search_highlight_coverage.mjsnode scripts/search/check_search_size_coverage.mjsnode scripts/search/check_search_record_path_coverage.mjsThese gates execute contracts under tests/search/highlight/, tests/search/size/and tests/search/record-path/, respectively. Their V8 thresholds cover only thespecified extracted search module; the shared TAP helper remains in scripts/.Other search gates remain at their existing paths pending separate migration.
123451 unmodified line789101112132 unmodified lines16171819202122import {spawnSync} from "node:child_process";import {hasPassingTapContracts} from "./check_tap_contracts.mjs";// Node 26/V8: only the extracted path module and its compatibility vectors.// Require a real source row as well as passing tests and full coverage.1 unmodified line"--test", "--test-reporter=tap", "--experimental-test-coverage","--test-coverage-include=**/static/search/record-path.js","--test-coverage-lines=100", "--test-coverage-branches=100", "--test-coverage-functions=100","tests/test_search_record_path.js"], {encoding: "utf8"});if (result.stdout) process.stdout.write(result.stdout);if (result.stderr) process.stderr.write(result.stderr);2 unmodified linesconst lines = text.split(/\r?\n/);const rows = lines.filter(line =>/^\s*#\s*record-path\.js\s*\|\s*100(?:\.0+)?\s*\|\s*100(?:\.0+)?\s*\|\s*100(?:\.0+)?\s*\|/.test(line));const required = [{name: "tests/test_search_record_path.js",marker: "search record paths preserve filenames, separators and URL encoding"}];if (result.status !== 0 || rows.length !== 1 || !hasPassingTapContracts(text, required)) {console.error("Search record path coverage gate requires passing named tests and exactly one fully covered source row");123451 unmodified line789101112132 unmodified lines16171819202122import {spawnSync} from "node:child_process";import {hasPassingTapContracts} from "../check_tap_contracts.mjs";// Node 26/V8: only the extracted path module and its compatibility vectors.// Require a real source row as well as passing tests and full coverage.1 unmodified line"--test", "--test-reporter=tap", "--experimental-test-coverage","--test-coverage-include=**/static/search/record-path.js","--test-coverage-lines=100", "--test-coverage-branches=100", "--test-coverage-functions=100","tests/search/record-path/test_search_record_path.js"], {encoding: "utf8"});if (result.stdout) process.stdout.write(result.stdout);if (result.stderr) process.stderr.write(result.stderr);2 unmodified linesconst lines = text.split(/\r?\n/);const rows = lines.filter(line =>/^\s*#\s*record-path\.js\s*\|\s*100(?:\.0+)?\s*\|\s*100(?:\.0+)?\s*\|\s*100(?:\.0+)?\s*\|/.test(line));const required = [{name: "tests/search/record-path/test_search_record_path.js",marker: "search record paths preserve filenames, separators and URL encoding"}];if (result.status !== 0 || rows.length !== 1 || !hasPassingTapContracts(text, required)) {console.error("Search record path coverage gate requires passing named tests and exactly one fully covered source row");
123456789101112Search bundle integration contract==================================
Run from the repository root with Node 26:
node tests/search/build/test_search_record_path_build.mjs
Despite its historical filename, this checks six search modules againstcompose_app dependencies, HTML script order, bundled stripping, resource listsand service-worker precache exclusions. It is a source integration contract,not a built-artifact, network or browser test; the production build releasecheck remains independent.123456789import assert from "node:assert/strict";import {readFileSync} from "node:fs";import {createRequire} from "node:module";import {APP_DEPENDENCIES, stripBundledScripts} from "../scripts/build/compose_app.mjs";const resources = createRequire(import.meta.url)("../static/reader-resources.js");const html = readFileSync("static/index.html", "utf8");const worker = readFileSync("static/sw.js", "utf8");const moduleName = "search/record-path.js";123456789import assert from "node:assert/strict";import {readFileSync} from "node:fs";import {createRequire} from "node:module";import {APP_DEPENDENCIES, stripBundledScripts} from "../../../scripts/build/compose_app.mjs";const resources = createRequire(import.meta.url)("../../../static/reader-resources.js");const html = readFileSync("static/index.html", "utf8");const worker = readFileSync("static/sw.js", "utf8");const moduleName = "search/record-path.js";
1234567891011Search record path contracts============================
Run from the repository root with Node 26:
node scripts/search/check_search_record_path_coverage.mjs
The site's original compatibility vectors exercise filenames, separators,encoding and app.js link helpers. The V8 100/100/100 threshold applies onlyto static/search/record-path.js; it is not coverage of app.js or a whole site.The matching cross-module build/shell contract is under tests/search/build/.3 unmodified lines4567891011123 unmodified linesconst vm = require("node:vm");// Expectations were captured from each site's original app.js functions.const app = fs.readFileSync(path.join(__dirname, "../static/app.js"), "utf8");const sandbox = vm.createContext({});const filename = path.join(__dirname, "../static/search/record-path.js");vm.runInContext(fs.readFileSync(filename, "utf8"), sandbox, {filename});for (const name of ["getRecordLink", "getRecordPath", "getBrowserFileName", "getBrowserFileLink"]) {const match = app.match(new RegExp(`^function ${name}\\([^]*?^}`, "m"));3 unmodified lines4567891011123 unmodified linesconst vm = require("node:vm");// Expectations were captured from each site's original app.js functions.const app = fs.readFileSync(path.join(__dirname, "../../../static/app.js"), "utf8");const sandbox = vm.createContext({});const filename = path.join(__dirname, "../../../static/search/record-path.js");vm.runInContext(fs.readFileSync(filename, "utf8"), sandbox, {filename});for (const name of ["getRecordLink", "getRecordPath", "getBrowserFileName", "getBrowserFileLink"]) {const match = app.match(new RegExp(`^function ${name}\\([^]*?^}`, "m"));
739 unmodified lines740741742743744745746747748749750751752739 unmodified linesself.assert_check(self.run_check(*check), False, "TS2322")def test_search_record_path_coverage_gate_fails_closed(self):paths = ["static/search/record-path.js", "scripts/check_search_record_path_coverage.mjs","tests/test_search_record_path.js", "static/app.js"]for path in [*paths, "scripts/check_tap_contracts.mjs"]:target = self.root / pathtarget.parent.mkdir(parents=True, exist_ok=True)shutil.copyfile(ROOT / path, target)check = ["node", "scripts/check_search_record_path_coverage.mjs"]self.assert_check(self.run_check(*check), True, "record-path.js")test = self.root / paths[2]original = test.read_text()739 unmodified lines740741742743744745746747748749750751752739 unmodified linesself.assert_check(self.run_check(*check), False, "TS2322")def test_search_record_path_coverage_gate_fails_closed(self):paths = ["static/search/record-path.js", "scripts/search/check_search_record_path_coverage.mjs","tests/search/record-path/test_search_record_path.js", "static/app.js"]for path in [*paths, "scripts/check_tap_contracts.mjs"]:target = self.root / pathtarget.parent.mkdir(parents=True, exist_ok=True)shutil.copyfile(ROOT / path, target)check = ["node", "scripts/search/check_search_record_path_coverage.mjs"]self.assert_check(self.run_check(*check), True, "record-path.js")test = self.root / paths[2]original = test.read_text()
scripts/search/README.txt+4-3
scripts/check_search_record_path_coverage.mjs → scripts/search/check_search_record_path_coverage.mjsRenamed+3-3
tests/search/build/README.txtAdded+12
tests/test_search_record_path_build.mjs → tests/search/build/test_search_record_path_build.mjsRenamed+2-2
tests/search/record-path/README.txtAdded+11
tests/test_search_record_path.js → tests/search/record-path/test_search_record_path.jsRenamed+2-2
tests/test_static_checks.py+3-3