vomebook commited on
Commit ·
4d10c4c
1
Parent(s): 3d781c6
Group search paths and bundle contracts
Browse files- scripts/search/README.txt +4 -3
- scripts/{check_search_record_path_coverage.mjs → search/check_search_record_path_coverage.mjs} +3 -3
- tests/search/build/README.txt +12 -0
- tests/{test_search_record_path_build.mjs → search/build/test_search_record_path_build.mjs} +2 -2
- tests/search/record-path/README.txt +11 -0
- tests/{test_search_record_path.js → search/record-path/test_search_record_path.js} +2 -2
- tests/test_static_checks.py +3 -3
scripts/search/README.txt
CHANGED
|
@@ -5,8 +5,9 @@ Run these from the repository root with Node 26:
|
|
| 5 |
|
| 6 |
node scripts/search/check_search_highlight_coverage.mjs
|
| 7 |
node scripts/search/check_search_size_coverage.mjs
|
|
|
|
| 8 |
|
| 9 |
-
These
|
| 10 |
-
tests/search/
|
| 11 |
-
extracted search module; the shared TAP helper remains in scripts/.
|
| 12 |
Other search gates remain at their existing paths pending separate migration.
|
|
|
|
| 5 |
|
| 6 |
node scripts/search/check_search_highlight_coverage.mjs
|
| 7 |
node scripts/search/check_search_size_coverage.mjs
|
| 8 |
+
node scripts/search/check_search_record_path_coverage.mjs
|
| 9 |
|
| 10 |
+
These gates execute contracts under tests/search/highlight/, tests/search/size/
|
| 11 |
+
and tests/search/record-path/, respectively. Their V8 thresholds cover only the
|
| 12 |
+
specified extracted search module; the shared TAP helper remains in scripts/.
|
| 13 |
Other search gates remain at their existing paths pending separate migration.
|
scripts/{check_search_record_path_coverage.mjs → search/check_search_record_path_coverage.mjs}
RENAMED
|
@@ -1,5 +1,5 @@
|
|
| 1 |
import {spawnSync} from "node:child_process";
|
| 2 |
-
import {hasPassingTapContracts} from "./check_tap_contracts.mjs";
|
| 3 |
|
| 4 |
// Node 26/V8: only the extracted path module and its compatibility vectors.
|
| 5 |
// Require a real source row as well as passing tests and full coverage.
|
|
@@ -7,7 +7,7 @@ const result = spawnSync(process.execPath, [
|
|
| 7 |
"--test", "--test-reporter=tap", "--experimental-test-coverage",
|
| 8 |
"--test-coverage-include=**/static/search/record-path.js",
|
| 9 |
"--test-coverage-lines=100", "--test-coverage-branches=100", "--test-coverage-functions=100",
|
| 10 |
-
"tests/test_search_record_path.js"
|
| 11 |
], {encoding: "utf8"});
|
| 12 |
if (result.stdout) process.stdout.write(result.stdout);
|
| 13 |
if (result.stderr) process.stderr.write(result.stderr);
|
|
@@ -16,7 +16,7 @@ const text = result.stdout || "";
|
|
| 16 |
const lines = text.split(/\r?\n/);
|
| 17 |
const rows = lines.filter(line =>
|
| 18 |
/^\s*#\s*record-path\.js\s*\|\s*100(?:\.0+)?\s*\|\s*100(?:\.0+)?\s*\|\s*100(?:\.0+)?\s*\|/.test(line));
|
| 19 |
-
const required = [{name: "tests/test_search_record_path.js",
|
| 20 |
marker: "search record paths preserve filenames, separators and URL encoding"}];
|
| 21 |
if (result.status !== 0 || rows.length !== 1 || !hasPassingTapContracts(text, required)) {
|
| 22 |
console.error("Search record path coverage gate requires passing named tests and exactly one fully covered source row");
|
|
|
|
| 1 |
import {spawnSync} from "node:child_process";
|
| 2 |
+
import {hasPassingTapContracts} from "../check_tap_contracts.mjs";
|
| 3 |
|
| 4 |
// Node 26/V8: only the extracted path module and its compatibility vectors.
|
| 5 |
// Require a real source row as well as passing tests and full coverage.
|
|
|
|
| 7 |
"--test", "--test-reporter=tap", "--experimental-test-coverage",
|
| 8 |
"--test-coverage-include=**/static/search/record-path.js",
|
| 9 |
"--test-coverage-lines=100", "--test-coverage-branches=100", "--test-coverage-functions=100",
|
| 10 |
+
"tests/search/record-path/test_search_record_path.js"
|
| 11 |
], {encoding: "utf8"});
|
| 12 |
if (result.stdout) process.stdout.write(result.stdout);
|
| 13 |
if (result.stderr) process.stderr.write(result.stderr);
|
|
|
|
| 16 |
const lines = text.split(/\r?\n/);
|
| 17 |
const rows = lines.filter(line =>
|
| 18 |
/^\s*#\s*record-path\.js\s*\|\s*100(?:\.0+)?\s*\|\s*100(?:\.0+)?\s*\|\s*100(?:\.0+)?\s*\|/.test(line));
|
| 19 |
+
const required = [{name: "tests/search/record-path/test_search_record_path.js",
|
| 20 |
marker: "search record paths preserve filenames, separators and URL encoding"}];
|
| 21 |
if (result.status !== 0 || rows.length !== 1 || !hasPassingTapContracts(text, required)) {
|
| 22 |
console.error("Search record path coverage gate requires passing named tests and exactly one fully covered source row");
|
tests/search/build/README.txt
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Search bundle integration contract
|
| 2 |
+
==================================
|
| 3 |
+
|
| 4 |
+
Run from the repository root with Node 26:
|
| 5 |
+
|
| 6 |
+
node tests/search/build/test_search_record_path_build.mjs
|
| 7 |
+
|
| 8 |
+
Despite its historical filename, this checks six search modules against
|
| 9 |
+
compose_app dependencies, HTML script order, bundled stripping, resource lists
|
| 10 |
+
and service-worker precache exclusions. It is a source integration contract,
|
| 11 |
+
not a built-artifact, network or browser test; the production build release
|
| 12 |
+
check remains independent.
|
tests/{test_search_record_path_build.mjs → search/build/test_search_record_path_build.mjs}
RENAMED
|
@@ -1,9 +1,9 @@
|
|
| 1 |
import assert from "node:assert/strict";
|
| 2 |
import {readFileSync} from "node:fs";
|
| 3 |
import {createRequire} from "node:module";
|
| 4 |
-
import {APP_DEPENDENCIES, stripBundledScripts} from "../scripts/build/compose_app.mjs";
|
| 5 |
|
| 6 |
-
const resources = createRequire(import.meta.url)("../static/reader-resources.js");
|
| 7 |
const html = readFileSync("static/index.html", "utf8");
|
| 8 |
const worker = readFileSync("static/sw.js", "utf8");
|
| 9 |
const moduleName = "search/record-path.js";
|
|
|
|
| 1 |
import assert from "node:assert/strict";
|
| 2 |
import {readFileSync} from "node:fs";
|
| 3 |
import {createRequire} from "node:module";
|
| 4 |
+
import {APP_DEPENDENCIES, stripBundledScripts} from "../../../scripts/build/compose_app.mjs";
|
| 5 |
|
| 6 |
+
const resources = createRequire(import.meta.url)("../../../static/reader-resources.js");
|
| 7 |
const html = readFileSync("static/index.html", "utf8");
|
| 8 |
const worker = readFileSync("static/sw.js", "utf8");
|
| 9 |
const moduleName = "search/record-path.js";
|
tests/search/record-path/README.txt
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Search record path contracts
|
| 2 |
+
============================
|
| 3 |
+
|
| 4 |
+
Run from the repository root with Node 26:
|
| 5 |
+
|
| 6 |
+
node scripts/search/check_search_record_path_coverage.mjs
|
| 7 |
+
|
| 8 |
+
The site's original compatibility vectors exercise filenames, separators,
|
| 9 |
+
encoding and app.js link helpers. The V8 100/100/100 threshold applies only
|
| 10 |
+
to static/search/record-path.js; it is not coverage of app.js or a whole site.
|
| 11 |
+
The matching cross-module build/shell contract is under tests/search/build/.
|
tests/{test_search_record_path.js → search/record-path/test_search_record_path.js}
RENAMED
|
@@ -4,9 +4,9 @@ const path = require("node:path");
|
|
| 4 |
const vm = require("node:vm");
|
| 5 |
|
| 6 |
// Expectations were captured from each site's original app.js functions.
|
| 7 |
-
const app = fs.readFileSync(path.join(__dirname, "../static/app.js"), "utf8");
|
| 8 |
const sandbox = vm.createContext({});
|
| 9 |
-
const filename = path.join(__dirname, "../static/search/record-path.js");
|
| 10 |
vm.runInContext(fs.readFileSync(filename, "utf8"), sandbox, {filename});
|
| 11 |
for (const name of ["getRecordLink", "getRecordPath", "getBrowserFileName", "getBrowserFileLink"]) {
|
| 12 |
const match = app.match(new RegExp(`^function ${name}\\([^]*?^}`, "m"));
|
|
|
|
| 4 |
const vm = require("node:vm");
|
| 5 |
|
| 6 |
// Expectations were captured from each site's original app.js functions.
|
| 7 |
+
const app = fs.readFileSync(path.join(__dirname, "../../../static/app.js"), "utf8");
|
| 8 |
const sandbox = vm.createContext({});
|
| 9 |
+
const filename = path.join(__dirname, "../../../static/search/record-path.js");
|
| 10 |
vm.runInContext(fs.readFileSync(filename, "utf8"), sandbox, {filename});
|
| 11 |
for (const name of ["getRecordLink", "getRecordPath", "getBrowserFileName", "getBrowserFileLink"]) {
|
| 12 |
const match = app.match(new RegExp(`^function ${name}\\([^]*?^}`, "m"));
|
tests/test_static_checks.py
CHANGED
|
@@ -740,13 +740,13 @@ class StaticGateTests(unittest.TestCase):
|
|
| 740 |
self.assert_check(self.run_check(*check), False, "TS2322")
|
| 741 |
|
| 742 |
def test_search_record_path_coverage_gate_fails_closed(self):
|
| 743 |
-
paths = ["static/search/record-path.js", "scripts/check_search_record_path_coverage.mjs",
|
| 744 |
-
"tests/test_search_record_path.js", "static/app.js"]
|
| 745 |
for path in [*paths, "scripts/check_tap_contracts.mjs"]:
|
| 746 |
target = self.root / path
|
| 747 |
target.parent.mkdir(parents=True, exist_ok=True)
|
| 748 |
shutil.copyfile(ROOT / path, target)
|
| 749 |
-
check = ["node", "scripts/check_search_record_path_coverage.mjs"]
|
| 750 |
self.assert_check(self.run_check(*check), True, "record-path.js")
|
| 751 |
test = self.root / paths[2]
|
| 752 |
original = test.read_text()
|
|
|
|
| 740 |
self.assert_check(self.run_check(*check), False, "TS2322")
|
| 741 |
|
| 742 |
def test_search_record_path_coverage_gate_fails_closed(self):
|
| 743 |
+
paths = ["static/search/record-path.js", "scripts/search/check_search_record_path_coverage.mjs",
|
| 744 |
+
"tests/search/record-path/test_search_record_path.js", "static/app.js"]
|
| 745 |
for path in [*paths, "scripts/check_tap_contracts.mjs"]:
|
| 746 |
target = self.root / path
|
| 747 |
target.parent.mkdir(parents=True, exist_ok=True)
|
| 748 |
shutil.copyfile(ROOT / path, target)
|
| 749 |
+
check = ["node", "scripts/search/check_search_record_path_coverage.mjs"]
|
| 750 |
self.assert_check(self.run_check(*check), True, "record-path.js")
|
| 751 |
test = self.root / paths[2]
|
| 752 |
original = test.read_text()
|