vomebook commited on
Commit ·
c172b70
1
Parent(s): 2db6cf4
Group remaining reader quality gates by domain
Browse files- Dockerfile +4 -4
- scripts/reader/README.txt +8 -1
- scripts/{check_adapter_coverage.mjs → reader/check_adapter_coverage.mjs} +1 -1
- scripts/{check_reader_djvu_contracts.mjs → reader/check_reader_djvu_contracts.mjs} +1 -1
- scripts/{check_reader_dom_search_contracts.py → reader/check_reader_dom_search_contracts.py} +1 -1
- scripts/{check_reader_lifecycle_coverage.mjs → reader/check_reader_lifecycle_coverage.mjs} +1 -1
- scripts/{check_reader_media_coverage.mjs → reader/check_reader_media_coverage.mjs} +1 -1
- scripts/{check_reader_text_coverage.mjs → reader/check_reader_text_coverage.mjs} +1 -1
- scripts/search/README.txt +3 -1
- scripts/{check_reader_navigation_baseline.mjs → search/check_reader_navigation_baseline.mjs} +2 -2
- tests/reader/adapters/README.txt +11 -0
- tests/{test_reader_adapter_registry.js → reader/adapters/test_reader_adapter_registry.js} +1 -1
- tests/reader/djvu/README.txt +1 -1
- tests/reader/dom-search/README.txt +1 -1
- tests/reader/lifecycle/README.txt +1 -1
- tests/reader/media/README.txt +1 -1
- tests/reader/text/README.txt +1 -1
- tests/search/reader-navigation/README.txt +11 -0
- tests/{test_reader_navigation_baseline.mjs → search/reader-navigation/test_reader_navigation_baseline.mjs} +0 -0
- tests/test_reader_dom_search_gate.py +3 -3
- tests/test_static_checks.py +19 -15
- tests/test_static_contract.py +4 -4
Dockerfile
CHANGED
|
@@ -48,13 +48,13 @@ RUN npx --no-install pyright --project pyrightconfig.json \
|
|
| 48 |
&& node --test tests/search/baselines/test_search_stable_id_baseline.mjs \
|
| 49 |
&& node scripts/check_search_filter_equality_baseline.mjs \
|
| 50 |
&& node scripts/check_search_folder_merge_baseline.mjs \
|
| 51 |
-
&& node scripts/check_reader_lifecycle_coverage.mjs \
|
| 52 |
-
&& node scripts/check_reader_media_coverage.mjs \
|
| 53 |
-
&& node scripts/check_reader_text_coverage.mjs \
|
| 54 |
&& node scripts/reader/check_pdf_book_client_coverage.mjs \
|
| 55 |
&& node --test tests/reader/pdf-search/test_pdf_book_worker.mjs \
|
| 56 |
&& node --test tests/reader/pdf-network/test_pdf_range_cache_release.mjs \
|
| 57 |
-
&& node scripts/check_reader_djvu_contracts.mjs \
|
| 58 |
&& node --test tests/test_tap_contracts.mjs \
|
| 59 |
&& node tests/test_dataset_primary_policy.mjs \
|
| 60 |
&& node scripts/check_download_controller_coverage.mjs \
|
|
|
|
| 48 |
&& node --test tests/search/baselines/test_search_stable_id_baseline.mjs \
|
| 49 |
&& node scripts/check_search_filter_equality_baseline.mjs \
|
| 50 |
&& node scripts/check_search_folder_merge_baseline.mjs \
|
| 51 |
+
&& node scripts/reader/check_reader_lifecycle_coverage.mjs \
|
| 52 |
+
&& node scripts/reader/check_reader_media_coverage.mjs \
|
| 53 |
+
&& node scripts/reader/check_reader_text_coverage.mjs \
|
| 54 |
&& node scripts/reader/check_pdf_book_client_coverage.mjs \
|
| 55 |
&& node --test tests/reader/pdf-search/test_pdf_book_worker.mjs \
|
| 56 |
&& node --test tests/reader/pdf-network/test_pdf_range_cache_release.mjs \
|
| 57 |
+
&& node scripts/reader/check_reader_djvu_contracts.mjs \
|
| 58 |
&& node --test tests/test_tap_contracts.mjs \
|
| 59 |
&& node tests/test_dataset_primary_policy.mjs \
|
| 60 |
&& node scripts/check_download_controller_coverage.mjs \
|
scripts/reader/README.txt
CHANGED
|
@@ -10,8 +10,15 @@ Run these commands from the repository root with Node 26:
|
|
| 10 |
node scripts/reader/check_pdf_network_mutations.mjs
|
| 11 |
node scripts/reader/check_reader_core_coverage.mjs
|
| 12 |
node scripts/reader/check_reader_image_loader_coverage.mjs
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
|
| 14 |
-
The image contracts are documented in `tests/reader/
|
|
|
|
| 15 |
The chapter and layout gate is documented in `tests/reader/chapters/README.txt`
|
| 16 |
and `tests/reader/layout/README.txt`.
|
| 17 |
The PDF network gates are documented in `tests/reader/pdf-network/README.txt`.
|
|
|
|
| 10 |
node scripts/reader/check_pdf_network_mutations.mjs
|
| 11 |
node scripts/reader/check_reader_core_coverage.mjs
|
| 12 |
node scripts/reader/check_reader_image_loader_coverage.mjs
|
| 13 |
+
node scripts/reader/check_adapter_coverage.mjs
|
| 14 |
+
node scripts/reader/check_reader_lifecycle_coverage.mjs
|
| 15 |
+
node scripts/reader/check_reader_media_coverage.mjs
|
| 16 |
+
node scripts/reader/check_reader_text_coverage.mjs
|
| 17 |
+
node scripts/reader/check_reader_djvu_contracts.mjs
|
| 18 |
+
python3 -B scripts/reader/check_reader_dom_search_contracts.py
|
| 19 |
|
| 20 |
+
The adapter and image contracts are documented in `tests/reader/adapters/README.txt`
|
| 21 |
+
and `tests/reader/images/README.txt`.
|
| 22 |
The chapter and layout gate is documented in `tests/reader/chapters/README.txt`
|
| 23 |
and `tests/reader/layout/README.txt`.
|
| 24 |
The PDF network gates are documented in `tests/reader/pdf-network/README.txt`.
|
scripts/{check_adapter_coverage.mjs → reader/check_adapter_coverage.mjs}
RENAMED
|
@@ -6,7 +6,7 @@ const result = spawnSync(process.execPath, [
|
|
| 6 |
"--test", "--test-reporter=tap", "--experimental-test-coverage",
|
| 7 |
"--test-coverage-include=**/static/reader/formats/reader-format-adapters.js",
|
| 8 |
"--test-coverage-lines=100", "--test-coverage-branches=100", "--test-coverage-functions=100",
|
| 9 |
-
"tests/test_reader_adapter_registry.js"
|
| 10 |
], { encoding: "utf8", env: { ...process.env, READER_V8_COVERAGE: "1" } });
|
| 11 |
if (result.stdout) process.stdout.write(result.stdout);
|
| 12 |
if (result.stderr) process.stderr.write(result.stderr);
|
|
|
|
| 6 |
"--test", "--test-reporter=tap", "--experimental-test-coverage",
|
| 7 |
"--test-coverage-include=**/static/reader/formats/reader-format-adapters.js",
|
| 8 |
"--test-coverage-lines=100", "--test-coverage-branches=100", "--test-coverage-functions=100",
|
| 9 |
+
"tests/reader/adapters/test_reader_adapter_registry.js"
|
| 10 |
], { encoding: "utf8", env: { ...process.env, READER_V8_COVERAGE: "1" } });
|
| 11 |
if (result.stdout) process.stdout.write(result.stdout);
|
| 12 |
if (result.stderr) process.stderr.write(result.stderr);
|
scripts/{check_reader_djvu_contracts.mjs → reader/check_reader_djvu_contracts.mjs}
RENAMED
|
@@ -1,5 +1,5 @@
|
|
| 1 |
import {spawnSync} from 'node:child_process';
|
| 2 |
-
import {hasPassingTapContracts} from './check_tap_contracts.mjs';
|
| 3 |
|
| 4 |
// These are seven pre-existing file-level Node scripts, not seven unit cases
|
| 5 |
// or a claim of coverage over the complete DjVu implementation.
|
|
|
|
| 1 |
import {spawnSync} from 'node:child_process';
|
| 2 |
+
import {hasPassingTapContracts} from '../check_tap_contracts.mjs';
|
| 3 |
|
| 4 |
// These are seven pre-existing file-level Node scripts, not seven unit cases
|
| 5 |
// or a claim of coverage over the complete DjVu implementation.
|
scripts/{check_reader_dom_search_contracts.py → reader/check_reader_dom_search_contracts.py}
RENAMED
|
@@ -7,7 +7,7 @@ import subprocess
|
|
| 7 |
import sys
|
| 8 |
|
| 9 |
|
| 10 |
-
ROOT = Path(__file__).resolve().parents[
|
| 11 |
MODULE = ROOT / 'static/reader/search/reader-dom-search.mjs'
|
| 12 |
TEST_MODULE = 'tests.test_reader_dom_search_contracts'
|
| 13 |
CONTRACTS = {
|
|
|
|
| 7 |
import sys
|
| 8 |
|
| 9 |
|
| 10 |
+
ROOT = Path(__file__).resolve().parents[2]
|
| 11 |
MODULE = ROOT / 'static/reader/search/reader-dom-search.mjs'
|
| 12 |
TEST_MODULE = 'tests.test_reader_dom_search_contracts'
|
| 13 |
CONTRACTS = {
|
scripts/{check_reader_lifecycle_coverage.mjs → reader/check_reader_lifecycle_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, the lifecycle module only under synthetic contracts; excludes host.
|
| 5 |
const minimum = [100, 97.47, 100];
|
|
|
|
| 1 |
import {spawnSync} from 'node:child_process';
|
| 2 |
+
import {hasPassingTapContracts} from '../check_tap_contracts.mjs';
|
| 3 |
|
| 4 |
// Node 26/V8, the lifecycle module only under synthetic contracts; excludes host.
|
| 5 |
const minimum = [100, 97.47, 100];
|
scripts/{check_reader_media_coverage.mjs → reader/check_reader_media_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 this media-format source under synthetic host/DOM contracts.
|
| 5 |
const minimum = [100, 90.77, 100];
|
|
|
|
| 1 |
import {spawnSync} from 'node:child_process';
|
| 2 |
+
import {hasPassingTapContracts} from '../check_tap_contracts.mjs';
|
| 3 |
|
| 4 |
// Node 26/V8: only this media-format source under synthetic host/DOM contracts.
|
| 5 |
const minimum = [100, 90.77, 100];
|
scripts/{check_reader_text_coverage.mjs → reader/check_reader_text_coverage.mjs}
RENAMED
|
@@ -1,6 +1,6 @@
|
|
| 1 |
// Node 26/V8: only this text-format source under synthetic host/DOM contracts.
|
| 2 |
import {spawnSync} from 'node:child_process';
|
| 3 |
-
import {hasPassingTapContracts} from './check_tap_contracts.mjs';
|
| 4 |
|
| 5 |
const minimum = [100, 91.89, 90.91];
|
| 6 |
const required = [
|
|
|
|
| 1 |
// Node 26/V8: only this text-format source under synthetic host/DOM contracts.
|
| 2 |
import {spawnSync} from 'node:child_process';
|
| 3 |
+
import {hasPassingTapContracts} from '../check_tap_contracts.mjs';
|
| 4 |
|
| 5 |
const minimum = [100, 91.89, 90.91];
|
| 6 |
const required = [
|
scripts/search/README.txt
CHANGED
|
@@ -6,8 +6,10 @@ Run these from the repository root with Node 26:
|
|
| 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;
|
|
|
|
| 13 |
Other search gates remain at their existing paths pending separate migration.
|
|
|
|
| 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 |
+
node scripts/search/check_reader_navigation_baseline.mjs
|
| 10 |
|
| 11 |
These gates execute contracts under tests/search/highlight/, tests/search/size/
|
| 12 |
and tests/search/record-path/, respectively. Their V8 thresholds cover only the
|
| 13 |
+
specified extracted search module; Reader navigation has its own partial baseline
|
| 14 |
+
in tests/search/reader-navigation/. The shared TAP helper remains in scripts/.
|
| 15 |
Other search gates remain at their existing paths pending separate migration.
|
scripts/{check_reader_navigation_baseline.mjs → search/check_reader_navigation_baseline.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 scope: this single file under the synthetic URL/session contracts.
|
| 5 |
// This is a baseline, not a claim that iframe/speech behavior is covered.
|
|
@@ -8,7 +8,7 @@ const result = spawnSync(process.execPath, [
|
|
| 8 |
'--test', '--test-reporter=tap', '--experimental-test-coverage',
|
| 9 |
'--test-coverage-include=**/static/search/reader-navigation.js',
|
| 10 |
...minimum.map((value, index) => `--test-coverage-${['lines', 'branches', 'functions'][index]}=${value}`),
|
| 11 |
-
'tests/test_reader_navigation_baseline.mjs'
|
| 12 |
], {encoding: 'utf8'});
|
| 13 |
if (result.stdout) process.stdout.write(result.stdout);
|
| 14 |
if (result.stderr) process.stderr.write(result.stderr);
|
|
|
|
| 1 |
import {spawnSync} from 'node:child_process';
|
| 2 |
+
import {hasPassingTapContracts} from '../check_tap_contracts.mjs';
|
| 3 |
|
| 4 |
// Node 26/V8 scope: this single file under the synthetic URL/session contracts.
|
| 5 |
// This is a baseline, not a claim that iframe/speech behavior is covered.
|
|
|
|
| 8 |
'--test', '--test-reporter=tap', '--experimental-test-coverage',
|
| 9 |
'--test-coverage-include=**/static/search/reader-navigation.js',
|
| 10 |
...minimum.map((value, index) => `--test-coverage-${['lines', 'branches', 'functions'][index]}=${value}`),
|
| 11 |
+
'tests/search/reader-navigation/test_reader_navigation_baseline.mjs'
|
| 12 |
], {encoding: 'utf8'});
|
| 13 |
if (result.stdout) process.stdout.write(result.stdout);
|
| 14 |
if (result.stderr) process.stderr.write(result.stderr);
|
tests/reader/adapters/README.txt
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Reader format-adapter registry contracts
|
| 2 |
+
========================================
|
| 3 |
+
|
| 4 |
+
From the repository root with Node 26:
|
| 5 |
+
|
| 6 |
+
node scripts/reader/check_adapter_coverage.mjs
|
| 7 |
+
|
| 8 |
+
The named contract exercises registration, validation, activation and disposal
|
| 9 |
+
of the adapter registry. The gate requires 100% lines, branches and functions
|
| 10 |
+
for static/reader/formats/reader-format-adapters.js only, and rejects missing,
|
| 11 |
+
renamed, skipped or unfinished contracts. It is not whole-Reader coverage.
|
tests/{test_reader_adapter_registry.js → reader/adapters/test_reader_adapter_registry.js}
RENAMED
|
@@ -5,7 +5,7 @@ const path = require("node:path");
|
|
| 5 |
const vm = require("node:vm");
|
| 6 |
|
| 7 |
function checkRegistry() {
|
| 8 |
-
const filename = path.resolve(__dirname, "../static/reader/formats/reader-format-adapters.js");
|
| 9 |
const sandbox = {};
|
| 10 |
sandbox.self = sandbox;
|
| 11 |
const source = fs.readFileSync(filename, "utf8");
|
|
|
|
| 5 |
const vm = require("node:vm");
|
| 6 |
|
| 7 |
function checkRegistry() {
|
| 8 |
+
const filename = path.resolve(__dirname, "../../../static/reader/formats/reader-format-adapters.js");
|
| 9 |
const sandbox = {};
|
| 10 |
sandbox.self = sandbox;
|
| 11 |
const source = fs.readFileSync(filename, "utf8");
|
tests/reader/djvu/README.txt
CHANGED
|
@@ -5,7 +5,7 @@ These seven existing scripts cover DjVu and image-manifest contracts, range
|
|
| 5 |
transport and fallback, worker behavior, source integrity and scheduling.
|
| 6 |
Run them from the repository root with:
|
| 7 |
|
| 8 |
-
node scripts/check_reader_djvu_contracts.mjs
|
| 9 |
|
| 10 |
The gate requires each existing script's completion marker, one passing TAP
|
| 11 |
entry per file, a complete summary and zero skipped/TODO results. It also
|
|
|
|
| 5 |
transport and fallback, worker behavior, source integrity and scheduling.
|
| 6 |
Run them from the repository root with:
|
| 7 |
|
| 8 |
+
node scripts/reader/check_reader_djvu_contracts.mjs
|
| 9 |
|
| 10 |
The gate requires each existing script's completion marker, one passing TAP
|
| 11 |
entry per file, a complete summary and zero skipped/TODO results. It also
|
tests/reader/dom-search/README.txt
CHANGED
|
@@ -3,7 +3,7 @@ Reader DOM-search source-module contracts
|
|
| 3 |
|
| 4 |
Run from the repository root after installing Playwright Chromium and Firefox:
|
| 5 |
|
| 6 |
-
python3 -B scripts/check_reader_dom_search_contracts.py
|
| 7 |
|
| 8 |
Seven named contracts each run once in each browser against the actual
|
| 9 |
reader-dom-search.mjs source, using only synthetic local DOM. They cover literal
|
|
|
|
| 3 |
|
| 4 |
Run from the repository root after installing Playwright Chromium and Firefox:
|
| 5 |
|
| 6 |
+
python3 -B scripts/reader/check_reader_dom_search_contracts.py
|
| 7 |
|
| 8 |
Seven named contracts each run once in each browser against the actual
|
| 9 |
reader-dom-search.mjs source, using only synthetic local DOM. They cover literal
|
tests/reader/lifecycle/README.txt
CHANGED
|
@@ -2,7 +2,7 @@ Reader lifecycle contracts
|
|
| 2 |
==========================
|
| 3 |
|
| 4 |
Run the named synthetic contracts and source-only V8 coverage gate from the
|
| 5 |
-
repository root using: node scripts/check_reader_lifecycle_coverage.mjs
|
| 6 |
|
| 7 |
The test exercises cancellation, resource cleanup, dynamic error getters,
|
| 8 |
generation ownership, readiness, disposal and retry behavior. Its coverage
|
|
|
|
| 2 |
==========================
|
| 3 |
|
| 4 |
Run the named synthetic contracts and source-only V8 coverage gate from the
|
| 5 |
+
repository root using: node scripts/reader/check_reader_lifecycle_coverage.mjs
|
| 6 |
|
| 7 |
The test exercises cancellation, resource cleanup, dynamic error getters,
|
| 8 |
generation ownership, readiness, disposal and retry behavior. Its coverage
|
tests/reader/media/README.txt
CHANGED
|
@@ -3,7 +3,7 @@ Reader media format contracts
|
|
| 3 |
|
| 4 |
Run from the repository root with Node 26:
|
| 5 |
|
| 6 |
-
node scripts/check_reader_media_coverage.mjs
|
| 7 |
|
| 8 |
These 15 named contracts use synthetic media elements, fake timers and fixture
|
| 9 |
responses; they cover formatting, dynamic argument forwarding, metadata, retry,
|
|
|
|
| 3 |
|
| 4 |
Run from the repository root with Node 26:
|
| 5 |
|
| 6 |
+
node scripts/reader/check_reader_media_coverage.mjs
|
| 7 |
|
| 8 |
These 15 named contracts use synthetic media elements, fake timers and fixture
|
| 9 |
responses; they cover formatting, dynamic argument forwarding, metadata, retry,
|
tests/reader/text/README.txt
CHANGED
|
@@ -3,7 +3,7 @@ Reader text format contracts
|
|
| 3 |
|
| 4 |
Run from the repository root with Node 26:
|
| 5 |
|
| 6 |
-
node scripts/check_reader_text_coverage.mjs
|
| 7 |
|
| 8 |
The 14 named contracts use synthetic streams, byte sequences, DOM and timers;
|
| 9 |
they cover encoding, incremental preview, byte limits, block boundaries,
|
|
|
|
| 3 |
|
| 4 |
Run from the repository root with Node 26:
|
| 5 |
|
| 6 |
+
node scripts/reader/check_reader_text_coverage.mjs
|
| 7 |
|
| 8 |
The 14 named contracts use synthetic streams, byte sequences, DOM and timers;
|
| 9 |
they cover encoding, incremental preview, byte limits, block boundaries,
|
tests/search/reader-navigation/README.txt
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Search-host Reader navigation baseline
|
| 2 |
+
======================================
|
| 3 |
+
|
| 4 |
+
From the repository root with Node 26:
|
| 5 |
+
|
| 6 |
+
node scripts/search/check_reader_navigation_baseline.mjs
|
| 7 |
+
|
| 8 |
+
These 11 named synthetic contracts cover Reader URL validation, session and
|
| 9 |
+
history behavior. They are a partial baseline for static/search/reader-navigation.js,
|
| 10 |
+
not coverage of iframe, speech, browser integration or the whole module. The
|
| 11 |
+
V8 floors remain 31.96% lines, 81.82% branches and 27.27% functions.
|
tests/{test_reader_navigation_baseline.mjs → search/reader-navigation/test_reader_navigation_baseline.mjs}
RENAMED
|
File without changes
|
tests/test_reader_dom_search_gate.py
CHANGED
|
@@ -9,7 +9,7 @@ import unittest
|
|
| 9 |
|
| 10 |
|
| 11 |
ROOT = Path(__file__).resolve().parents[1]
|
| 12 |
-
SPEC = importlib.util.spec_from_file_location('reader_dom_gate', ROOT / 'scripts/check_reader_dom_search_contracts.py')
|
| 13 |
GATE = importlib.util.module_from_spec(SPEC)
|
| 14 |
SPEC.loader.exec_module(GATE)
|
| 15 |
|
|
@@ -59,7 +59,7 @@ class ReaderDomSearchGateTests(unittest.TestCase):
|
|
| 59 |
# deliberately incomplete suite so the real subprocess path is tested.
|
| 60 |
with tempfile.TemporaryDirectory(prefix='dom-gate-negative-') as directory:
|
| 61 |
root = Path(directory)
|
| 62 |
-
for name in ('scripts/check_reader_dom_search_contracts.py',
|
| 63 |
'static/reader/search/reader-dom-search.mjs'):
|
| 64 |
path = root / name
|
| 65 |
path.parent.mkdir(parents=True, exist_ok=True)
|
|
@@ -73,7 +73,7 @@ class ReaderDomSearchContracts(unittest.TestCase):
|
|
| 73 |
@unittest.skip("synthetic unavailable browser")
|
| 74 |
def test_literal_escape_snippets_and_pagination(self): pass
|
| 75 |
''')
|
| 76 |
-
result = subprocess.run([sys.executable, '-B', str(root / 'scripts/check_reader_dom_search_contracts.py')],
|
| 77 |
cwd=root, capture_output=True, text=True, timeout=30)
|
| 78 |
self.assertNotEqual(result.returncode, 0)
|
| 79 |
self.assertIn('DOM-search browser contracts incomplete: chromium', result.stdout + result.stderr)
|
|
|
|
| 9 |
|
| 10 |
|
| 11 |
ROOT = Path(__file__).resolve().parents[1]
|
| 12 |
+
SPEC = importlib.util.spec_from_file_location('reader_dom_gate', ROOT / 'scripts/reader/check_reader_dom_search_contracts.py')
|
| 13 |
GATE = importlib.util.module_from_spec(SPEC)
|
| 14 |
SPEC.loader.exec_module(GATE)
|
| 15 |
|
|
|
|
| 59 |
# deliberately incomplete suite so the real subprocess path is tested.
|
| 60 |
with tempfile.TemporaryDirectory(prefix='dom-gate-negative-') as directory:
|
| 61 |
root = Path(directory)
|
| 62 |
+
for name in ('scripts/reader/check_reader_dom_search_contracts.py',
|
| 63 |
'static/reader/search/reader-dom-search.mjs'):
|
| 64 |
path = root / name
|
| 65 |
path.parent.mkdir(parents=True, exist_ok=True)
|
|
|
|
| 73 |
@unittest.skip("synthetic unavailable browser")
|
| 74 |
def test_literal_escape_snippets_and_pagination(self): pass
|
| 75 |
''')
|
| 76 |
+
result = subprocess.run([sys.executable, '-B', str(root / 'scripts/reader/check_reader_dom_search_contracts.py')],
|
| 77 |
cwd=root, capture_output=True, text=True, timeout=30)
|
| 78 |
self.assertNotEqual(result.returncode, 0)
|
| 79 |
self.assertIn('DOM-search browser contracts incomplete: chromium', result.stdout + result.stderr)
|
tests/test_static_checks.py
CHANGED
|
@@ -177,11 +177,13 @@ class StaticGateTests(unittest.TestCase):
|
|
| 177 |
source = self.root / "static/reader/formats/reader-format-adapters.js"
|
| 178 |
source.parent.mkdir(parents=True, exist_ok=True)
|
| 179 |
shutil.copyfile(ROOT / "static/reader/formats/reader-format-adapters.js", source)
|
| 180 |
-
|
| 181 |
-
|
| 182 |
-
|
|
|
|
|
|
|
|
|
|
| 183 |
self.assert_check(self.run_check(*check), True, "reader-format-adapters.js")
|
| 184 |
-
test = self.root / "tests/test_reader_adapter_registry.js"
|
| 185 |
original = test.read_text()
|
| 186 |
name = "reader adapter registry"
|
| 187 |
anchor = 'require("node:test")("' + name + '", runContracts)'
|
|
@@ -1397,8 +1399,8 @@ class StaticGateTests(unittest.TestCase):
|
|
| 1397 |
self.assert_check(self.run_check(*check), False, "TS2322")
|
| 1398 |
|
| 1399 |
def test_reader_navigation_baseline_gate_fails_closed(self):
|
| 1400 |
-
paths = ["static/search/reader-navigation.js", "scripts/check_reader_navigation_baseline.mjs",
|
| 1401 |
-
"tests/test_reader_navigation_baseline.mjs", "scripts/check_tap_contracts.mjs"]
|
| 1402 |
for path in paths:
|
| 1403 |
target = self.root / path
|
| 1404 |
target.parent.mkdir(parents=True, exist_ok=True)
|
|
@@ -1426,8 +1428,8 @@ class StaticGateTests(unittest.TestCase):
|
|
| 1426 |
self.assert_check(self.run_check(*check), False, "all named baseline contracts")
|
| 1427 |
|
| 1428 |
def test_reader_navigation_coverage_gate_requires_exact_source_row_and_thresholds(self):
|
| 1429 |
-
paths = ["static/search/reader-navigation.js", "scripts/check_reader_navigation_baseline.mjs",
|
| 1430 |
-
"tests/test_reader_navigation_baseline.mjs", "scripts/check_tap_contracts.mjs"]
|
| 1431 |
for path in paths:
|
| 1432 |
target = self.root / path
|
| 1433 |
target.parent.mkdir(parents=True, exist_ok=True)
|
|
@@ -1544,7 +1546,7 @@ class StaticGateTests(unittest.TestCase):
|
|
| 1544 |
|
| 1545 |
def test_reader_text_coverage_gate_fails_closed(self):
|
| 1546 |
paths = ['static/reader/formats/reader-text-format.mjs',
|
| 1547 |
-
'scripts/check_reader_text_coverage.mjs', 'scripts/check_tap_contracts.mjs',
|
| 1548 |
'tests/reader/text/test_reader_text_baseline.mjs',
|
| 1549 |
'tests/reader/text/test_reader_text_faults.mjs']
|
| 1550 |
for path in paths:
|
|
@@ -1586,7 +1588,7 @@ class StaticGateTests(unittest.TestCase):
|
|
| 1586 |
|
| 1587 |
def test_reader_media_coverage_gate_fails_closed(self):
|
| 1588 |
paths = ['static/reader/formats/reader-media-format.mjs',
|
| 1589 |
-
'scripts/check_reader_media_coverage.mjs', 'scripts/check_tap_contracts.mjs',
|
| 1590 |
'tests/reader/media/test_reader_media_baseline.mjs',
|
| 1591 |
'tests/reader/media/test_reader_media_metadata.mjs']
|
| 1592 |
for path in paths:
|
|
@@ -1626,8 +1628,10 @@ class StaticGateTests(unittest.TestCase):
|
|
| 1626 |
self.assert_check(self.run_check(*check), False, message)
|
| 1627 |
|
| 1628 |
def test_reader_djvu_contract_gate_fails_closed(self):
|
| 1629 |
-
for name in ('check_reader_djvu_contracts.mjs', 'check_tap_contracts.mjs'):
|
| 1630 |
-
|
|
|
|
|
|
|
| 1631 |
# V8 resolves symlinks before applying coverage includes. Copy the
|
| 1632 |
# source into the fixture so the exact source row is really measured.
|
| 1633 |
shutil.copytree(ROOT / 'static/reader', self.root / 'static/reader')
|
|
@@ -1639,7 +1643,7 @@ class StaticGateTests(unittest.TestCase):
|
|
| 1639 |
directory / f'test_reader_djvu_{name}.mjs')
|
| 1640 |
boundary = directory / 'test_reader_djvu_range_boundaries.mjs'
|
| 1641 |
shutil.copyfile(ROOT / 'tests/reader/djvu/test_reader_djvu_range_boundaries.mjs', boundary)
|
| 1642 |
-
check = ['node', 'scripts/check_reader_djvu_contracts.mjs']
|
| 1643 |
message = 'DjVu contracts require seven named scripts'
|
| 1644 |
self.assert_check(self.run_check(*check), True, '# pass 7')
|
| 1645 |
worker = directory / 'test_reader_djvu_worker.mjs'
|
|
@@ -1657,7 +1661,7 @@ class StaticGateTests(unittest.TestCase):
|
|
| 1657 |
worker.write_text(source.replace("console.log('" + marker + "'", "console.log('" + summary + "');\nconsole.log('" + marker + "'"))
|
| 1658 |
self.assert_check(self.run_check(*check), False, message)
|
| 1659 |
worker.write_text(source)
|
| 1660 |
-
gate = self.root / 'scripts/check_reader_djvu_contracts.mjs'
|
| 1661 |
original = gate.read_text()
|
| 1662 |
anchor = '...required.map(({name}) => name)'
|
| 1663 |
self.assertEqual(original.count(anchor), 1)
|
|
@@ -1689,7 +1693,7 @@ class StaticGateTests(unittest.TestCase):
|
|
| 1689 |
self.assert_check(self.run_check(*check), False, message)
|
| 1690 |
|
| 1691 |
def test_reader_lifecycle_coverage_gate_fails_closed(self):
|
| 1692 |
-
paths = ["static/reader/core/reader-lifecycle.mjs", "scripts/check_reader_lifecycle_coverage.mjs",
|
| 1693 |
"scripts/check_tap_contracts.mjs", "tests/reader/lifecycle/test_reader_lifecycle.mjs"]
|
| 1694 |
for path in paths:
|
| 1695 |
target = self.root / path
|
|
|
|
| 177 |
source = self.root / "static/reader/formats/reader-format-adapters.js"
|
| 178 |
source.parent.mkdir(parents=True, exist_ok=True)
|
| 179 |
shutil.copyfile(ROOT / "static/reader/formats/reader-format-adapters.js", source)
|
| 180 |
+
test = self.root / "tests/reader/adapters/test_reader_adapter_registry.js"
|
| 181 |
+
gate = self.root / "scripts/reader/check_adapter_coverage.mjs"
|
| 182 |
+
for path in (test, gate):
|
| 183 |
+
path.parent.mkdir(parents=True, exist_ok=True)
|
| 184 |
+
shutil.copyfile(ROOT / path.relative_to(self.root), path)
|
| 185 |
+
check = ["node", "scripts/reader/check_adapter_coverage.mjs"]
|
| 186 |
self.assert_check(self.run_check(*check), True, "reader-format-adapters.js")
|
|
|
|
| 187 |
original = test.read_text()
|
| 188 |
name = "reader adapter registry"
|
| 189 |
anchor = 'require("node:test")("' + name + '", runContracts)'
|
|
|
|
| 1399 |
self.assert_check(self.run_check(*check), False, "TS2322")
|
| 1400 |
|
| 1401 |
def test_reader_navigation_baseline_gate_fails_closed(self):
|
| 1402 |
+
paths = ["static/search/reader-navigation.js", "scripts/search/check_reader_navigation_baseline.mjs",
|
| 1403 |
+
"tests/search/reader-navigation/test_reader_navigation_baseline.mjs", "scripts/check_tap_contracts.mjs"]
|
| 1404 |
for path in paths:
|
| 1405 |
target = self.root / path
|
| 1406 |
target.parent.mkdir(parents=True, exist_ok=True)
|
|
|
|
| 1428 |
self.assert_check(self.run_check(*check), False, "all named baseline contracts")
|
| 1429 |
|
| 1430 |
def test_reader_navigation_coverage_gate_requires_exact_source_row_and_thresholds(self):
|
| 1431 |
+
paths = ["static/search/reader-navigation.js", "scripts/search/check_reader_navigation_baseline.mjs",
|
| 1432 |
+
"tests/search/reader-navigation/test_reader_navigation_baseline.mjs", "scripts/check_tap_contracts.mjs"]
|
| 1433 |
for path in paths:
|
| 1434 |
target = self.root / path
|
| 1435 |
target.parent.mkdir(parents=True, exist_ok=True)
|
|
|
|
| 1546 |
|
| 1547 |
def test_reader_text_coverage_gate_fails_closed(self):
|
| 1548 |
paths = ['static/reader/formats/reader-text-format.mjs',
|
| 1549 |
+
'scripts/reader/check_reader_text_coverage.mjs', 'scripts/check_tap_contracts.mjs',
|
| 1550 |
'tests/reader/text/test_reader_text_baseline.mjs',
|
| 1551 |
'tests/reader/text/test_reader_text_faults.mjs']
|
| 1552 |
for path in paths:
|
|
|
|
| 1588 |
|
| 1589 |
def test_reader_media_coverage_gate_fails_closed(self):
|
| 1590 |
paths = ['static/reader/formats/reader-media-format.mjs',
|
| 1591 |
+
'scripts/reader/check_reader_media_coverage.mjs', 'scripts/check_tap_contracts.mjs',
|
| 1592 |
'tests/reader/media/test_reader_media_baseline.mjs',
|
| 1593 |
'tests/reader/media/test_reader_media_metadata.mjs']
|
| 1594 |
for path in paths:
|
|
|
|
| 1628 |
self.assert_check(self.run_check(*check), False, message)
|
| 1629 |
|
| 1630 |
def test_reader_djvu_contract_gate_fails_closed(self):
|
| 1631 |
+
for name in ('scripts/reader/check_reader_djvu_contracts.mjs', 'scripts/check_tap_contracts.mjs'):
|
| 1632 |
+
target = self.root / name
|
| 1633 |
+
target.parent.mkdir(parents=True, exist_ok=True)
|
| 1634 |
+
shutil.copyfile(ROOT / name, target)
|
| 1635 |
# V8 resolves symlinks before applying coverage includes. Copy the
|
| 1636 |
# source into the fixture so the exact source row is really measured.
|
| 1637 |
shutil.copytree(ROOT / 'static/reader', self.root / 'static/reader')
|
|
|
|
| 1643 |
directory / f'test_reader_djvu_{name}.mjs')
|
| 1644 |
boundary = directory / 'test_reader_djvu_range_boundaries.mjs'
|
| 1645 |
shutil.copyfile(ROOT / 'tests/reader/djvu/test_reader_djvu_range_boundaries.mjs', boundary)
|
| 1646 |
+
check = ['node', 'scripts/reader/check_reader_djvu_contracts.mjs']
|
| 1647 |
message = 'DjVu contracts require seven named scripts'
|
| 1648 |
self.assert_check(self.run_check(*check), True, '# pass 7')
|
| 1649 |
worker = directory / 'test_reader_djvu_worker.mjs'
|
|
|
|
| 1661 |
worker.write_text(source.replace("console.log('" + marker + "'", "console.log('" + summary + "');\nconsole.log('" + marker + "'"))
|
| 1662 |
self.assert_check(self.run_check(*check), False, message)
|
| 1663 |
worker.write_text(source)
|
| 1664 |
+
gate = self.root / 'scripts/reader/check_reader_djvu_contracts.mjs'
|
| 1665 |
original = gate.read_text()
|
| 1666 |
anchor = '...required.map(({name}) => name)'
|
| 1667 |
self.assertEqual(original.count(anchor), 1)
|
|
|
|
| 1693 |
self.assert_check(self.run_check(*check), False, message)
|
| 1694 |
|
| 1695 |
def test_reader_lifecycle_coverage_gate_fails_closed(self):
|
| 1696 |
+
paths = ["static/reader/core/reader-lifecycle.mjs", "scripts/reader/check_reader_lifecycle_coverage.mjs",
|
| 1697 |
"scripts/check_tap_contracts.mjs", "tests/reader/lifecycle/test_reader_lifecycle.mjs"]
|
| 1698 |
for path in paths:
|
| 1699 |
target = self.root / path
|
tests/test_static_contract.py
CHANGED
|
@@ -458,13 +458,13 @@ class StaticFrontendContractTests(unittest.TestCase):
|
|
| 458 |
self.assertIn("node scripts/check_download_controller_coverage.mjs", dockerfile)
|
| 459 |
self.assertIn("node scripts/check_search_filter_equality_baseline.mjs", dockerfile)
|
| 460 |
self.assertIn("node scripts/check_search_folder_merge_baseline.mjs", dockerfile)
|
| 461 |
-
self.assertIn("node scripts/check_reader_lifecycle_coverage.mjs", dockerfile)
|
| 462 |
-
self.assertIn("node scripts/check_reader_media_coverage.mjs", dockerfile)
|
| 463 |
-
self.assertIn("node scripts/check_reader_text_coverage.mjs", dockerfile)
|
| 464 |
self.assertIn("node scripts/reader/check_pdf_book_client_coverage.mjs", dockerfile)
|
| 465 |
self.assertIn("node --test tests/reader/pdf-search/test_pdf_book_worker.mjs", dockerfile)
|
| 466 |
self.assertIn("node --test tests/reader/pdf-network/test_pdf_range_cache_release.mjs", dockerfile)
|
| 467 |
-
self.assertIn("node scripts/check_reader_djvu_contracts.mjs", dockerfile)
|
| 468 |
self.assertIn("node --test tests/search/baselines/test_search_response_validation_baseline.mjs", dockerfile)
|
| 469 |
self.assertIn("node --test tests/search/baselines/test_search_stable_id_baseline.mjs", dockerfile)
|
| 470 |
self.assertIn("COPY --from=source-check-node /check/ /check/", dockerfile)
|
|
|
|
| 458 |
self.assertIn("node scripts/check_download_controller_coverage.mjs", dockerfile)
|
| 459 |
self.assertIn("node scripts/check_search_filter_equality_baseline.mjs", dockerfile)
|
| 460 |
self.assertIn("node scripts/check_search_folder_merge_baseline.mjs", dockerfile)
|
| 461 |
+
self.assertIn("node scripts/reader/check_reader_lifecycle_coverage.mjs", dockerfile)
|
| 462 |
+
self.assertIn("node scripts/reader/check_reader_media_coverage.mjs", dockerfile)
|
| 463 |
+
self.assertIn("node scripts/reader/check_reader_text_coverage.mjs", dockerfile)
|
| 464 |
self.assertIn("node scripts/reader/check_pdf_book_client_coverage.mjs", dockerfile)
|
| 465 |
self.assertIn("node --test tests/reader/pdf-search/test_pdf_book_worker.mjs", dockerfile)
|
| 466 |
self.assertIn("node --test tests/reader/pdf-network/test_pdf_range_cache_release.mjs", dockerfile)
|
| 467 |
+
self.assertIn("node scripts/reader/check_reader_djvu_contracts.mjs", dockerfile)
|
| 468 |
self.assertIn("node --test tests/search/baselines/test_search_response_validation_baseline.mjs", dockerfile)
|
| 469 |
self.assertIn("node --test tests/search/baselines/test_search_stable_id_baseline.mjs", dockerfile)
|
| 470 |
self.assertIn("COPY --from=source-check-node /check/ /check/", dockerfile)
|