File size: 2,357 Bytes
74bdc1f
4d152fb
74bdc1f
 
6c8fd46
af33bfd
 
74bdc1f
 
 
 
4d152fb
74bdc1f
 
 
 
 
 
 
 
f29eabe
 
 
d3f4b21
6c8fd46
f29eabe
 
 
25d99be
da9ec8b
4d152fb
da9ec8b
f29eabe
da9ec8b
f29eabe
74bdc1f
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import {spawnSync} from "node:child_process";
import {hasPassingTapContracts} from "../check_tap_contracts.mjs";

// Node 26/V8 scope: only reader-document-loader.mjs and the named tests.
// Preserve the baseline floors from the retry and late-script-callback contracts.
// Do not accept an unloaded file as an empty 100% report.
const minimum = [100, 98.65, 97.22];
const result = spawnSync(process.execPath, [
  "--test", "--test-concurrency=1", "--test-reporter=tap", "--experimental-test-coverage",
  "--test-coverage-include=**/static/reader/core/reader-document-loader.mjs",
  ...minimum.map((value, index) => `--test-coverage-${["lines", "branches", "functions"][index]}=${value}`),
  "tests/reader/transport/test_reader_document_loader_contract.mjs", "tests/reader/transport/test_reader_pdf_rate_outer.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 rows = (result.stdout || "").split(/\r?\n/).flatMap(line => {
  const match = /^\s*#\s*reader-document-loader\.mjs\s*\|\s*(\d+(?:\.\d+)?)\s*\|\s*(\d+(?:\.\d+)?)\s*\|\s*(\d+(?:\.\d+)?)\s*\|/.exec(line);
  return match ? [match.slice(1).map(Number)] : [];
});
const text = result.stdout || "";
const required = [
  "retry policy keeps bounded delay and never retries rate-limited or aborted work",
  "proxy-only fetching respects response ownership, cancellation and bucket routing",
  "trusted Bucket chapters recover on one 503 but never retry permanent errors or escape the proxy",
  "preloads are single-owner and fall back on failure or mismatched identity",
  "document preparation preserves failure and byte-limit ownership",
  "script load releases timers, handlers and resources on success, error and close",
  "image load stays on the proxy when the dataset host is unreachable"
].map(name => ({name}));
required.push({name: "tests/reader/transport/test_reader_pdf_rate_outer.mjs",
  marker: "PDF rate-limit retry boundary and generic retry preserved"});
if (result.status !== 0 || rows.length !== 1 || rows[0].some((value, index) => value < minimum[index]) ||
    !hasPassingTapContracts(text, required)) {
  console.error("Document loader coverage requires passing named tests and exactly one source row above each minimum");
  process.exitCode = 1;
}