// Node 26/V8: bounded PDF-search stream transport only, not the Worker. import {spawnSync} from 'node:child_process'; import {hasCompleteFlatTapReport, hasPassingTapContracts} from '../check_tap_contracts.mjs'; const minimum=[100,96,100]; const test='tests/reader/pdf-search/test_pdf_search_stream.mjs'; const required=[ 'streamed UTF-8 spans chunk boundaries and flushes invalid tail', 'exact binary sizes and decoded size limits are enforced', 'abort pending read cancels the source and releases the reader', 'already cancelled signals and read failures are propagated without leaks', 'cancellation rejection is swallowed while abort still settles' ].map(name=>({name})); const result=spawnSync(process.execPath,['--test','--test-concurrency=1','--test-reporter=tap', '--experimental-test-coverage','--test-coverage-include=**/static/reader/search/reader-pdf-search-stream.mjs', ...minimum.map((value,index)=>`--test-coverage-${['lines','branches','functions'][index]}=${value}`),test], {encoding:'utf8',timeout:45000,killSignal:'SIGKILL'}); if(result.stdout)process.stdout.write(result.stdout); if(result.stderr)process.stderr.write(result.stderr); if(result.error)throw result.error; const text=result.stdout||'',lines=text.split(/\r?\n/); const rows=lines.flatMap(line=>{ const match=/^\s*#\s*reader-pdf-search-stream\.mjs\s*\|\s*(\d+(?:\.\d+)?)\s*\|\s*(\d+(?:\.\d+)?)\s*\|\s*(\d+(?:\.\d+)?)\s*\|/.exec(line); return match?[match.slice(1).map(Number)]:[]; }); if(result.status!==0||lines[0]!=='TAP version 13'||rows.length!==1||rows[0].some((value,index)=>valuelines.filter(line=>line===marker).length!==1)){ console.error('PDF search stream requires its named passing contracts and one coverage row above each minimum');process.exitCode=1; }