Download scripts/reader/check_request_manager_coverage.mjs from VoiceOfML/Search: direct link, hf CLI and curl.
- Browser
- Download file 2.16 kB
-
https://huggingface.co/spaces/VoiceOfML/Search/resolve/main/scripts/reader/check_request_manager_coverage.mjs
- Command line
-
hf download hf://spaces/VoiceOfML/Search/scripts/reader/check_request_manager_coverage.mjs
-
curl -L -o check_request_manager_coverage.mjs https://huggingface.co/spaces/VoiceOfML/Search/resolve/main/scripts/reader/check_request_manager_coverage.mjs
2.16 kB
| import {spawnSync} from "node:child_process"; | |
| import {hasPassingTapContracts} from "../check_tap_contracts.mjs"; | |
| // Node 26 V8 report, one source only. Measured with the three named tests: | |
| // 100.00% lines, 95.24% branches, 95.12% functions after strict annotations. | |
| // Compare the printed decimals explicitly: Node floors CLI thresholds, and an | |
| // empty report otherwise passes as 100%. This is not whole-Reader coverage. | |
| const minimum = [100, 95.24, 95.12]; | |
| const result = spawnSync(process.execPath, [ | |
| "--test", "--test-concurrency=1", "--test-reporter=tap", "--experimental-test-coverage", | |
| "--test-coverage-include=**/static/reader/core/reader-request-manager.js", | |
| ...minimum.map((value, index) => `--test-coverage-${["lines", "branches", "functions"][index]}=${value}`), | |
| "tests/reader/transport/test_reader_request_manager.js", "tests/reader/transport/test_reader_initial_recovery.js", | |
| "tests/reader/transport/test_reader_request_manager_edges.js" | |
| ], {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-request-manager\.js\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 || ""; | |
| // Each test logs its completion marker only after its async contract finishes. | |
| const required = [ | |
| ["reader request manager behavior", "reader request manager contracts passed"], | |
| ["reader initial response recovery", "reader initial response recovery contracts passed"], | |
| ["reader request manager edge behavior", "reader request manager edge contracts passed"] | |
| ].map(([name, marker]) => ({name, marker})); | |
| if (result.status !== 0 || rows.length !== 1 || rows[0].some((value, index) => value < minimum[index]) || | |
| !hasPassingTapContracts(text, required)) { | |
| console.error("Request manager coverage gate requires passing named tests and exactly one source coverage row above each minimum"); | |
| process.exitCode = 1; | |
| } | |