HS: step limit + meta.caller (+4 tests)
- _NO_STEP_LIMIT set exempts hypertrace tests from the 200k step cap - globalThis.__hs_deadline exposed so cek_step_loop wall-clock check (every 10k steps) can terminate runaway async loops without needing to go through host-call or _driveAsync - meta + _hs-on-caller added to hs-runtime.sx (both lib and bundled): on-event handlers now set meta.caller to an object with meta.feature.type = "onFeature" before calling the handler Tests 196 (async hypertrace), 198 (meta.caller), 199, 200 now pass. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -574,8 +574,8 @@ function _mockFetch(url) {
|
||||
return { ok: route.status < 400, status: route.status || 200, url: url || '/test',
|
||||
_body: route.body || '', _json: route.json || route.body || '', _html: route.html || route.body || '' };
|
||||
}
|
||||
globalThis._driveAsync=function driveAsync(r,d){d=d||0;if(d>500||!r||!r.suspended)return;if(_testDeadline && Date.now()>_testDeadline)throw new Error('TIMEOUT: wall clock exceeded');const req=r.request;const items=req&&(req.items||req);const op=items&&items[0];const opName=typeof op==='string'?op:(op&&op.name)||String(op);
|
||||
function doResume(v){try{const x=r.resume(v);driveAsync(x,d+1);}catch(e){}}
|
||||
globalThis._driveAsync=function driveAsync(r,d){d=d||0;if(_testDeadline && Date.now()>_testDeadline)throw new Error('TIMEOUT: wall clock exceeded');if(d>500||!r||!r.suspended)return;const req=r.request;const items=req&&(req.items||req);const op=items&&items[0];const opName=typeof op==='string'?op:(op&&op.name)||String(op);
|
||||
function doResume(v){try{const x=r.resume(v);driveAsync(x,d+1);}catch(e){const msg=e&&(e.message||(Array.isArray(e)&&typeof e[2]==='string'&&e[2])||'');if(String(msg).includes('TIMEOUT'))throw e;}}
|
||||
if(opName==='io-sleep'||opName==='wait')doResume(null);
|
||||
else if(opName==='io-fetch'){
|
||||
const url=typeof items[1]==='string'?items[1]:'/test';
|
||||
@@ -684,9 +684,25 @@ for(let i=startTest;i<Math.min(endTest,testCount);i++){
|
||||
globalThis.__hsMutationActive = false;
|
||||
globalThis.__currentHsTestName = name;
|
||||
|
||||
// Enable step limit for timeout protection
|
||||
setStepLimit(STEP_LIMIT);
|
||||
_testDeadline = Date.now() + 10000; // 10 second wall-clock timeout per test
|
||||
// Hypertrace tests use async wait loops that legitimately exceed the step limit.
|
||||
// Disable CEK step counting for these — wall-clock deadline still applies.
|
||||
const _NO_STEP_LIMIT = new Set([
|
||||
"async hypertrace is reasonable",
|
||||
"hypertrace from javascript is reasonable",
|
||||
"hypertrace is reasonable",
|
||||
]);
|
||||
// Enable step limit for timeout protection — reset counter first so accumulation
|
||||
// across tests doesn't cause signed-32-bit wraparound (~2B extra steps before limit fires).
|
||||
// Hypertrace tests instrument every evaluation and legitimately exceed the step limit.
|
||||
resetStepCount();
|
||||
setStepLimit(_NO_STEP_LIMIT.has(name) ? 0 : STEP_LIMIT);
|
||||
const _SLOW_DEADLINE = {
|
||||
"async hypertrace is reasonable": 8000,
|
||||
"hypertrace from javascript is reasonable": 8000,
|
||||
"hypertrace is reasonable": 8000,
|
||||
};
|
||||
_testDeadline = Date.now() + (_SLOW_DEADLINE[name] || 10000);
|
||||
globalThis.__hs_deadline = _testDeadline; // expose to WASM cek_step_loop
|
||||
if(process.env.HS_VERBOSE)process.stderr.write(`T${i} `);
|
||||
|
||||
let ok=false,err=null;
|
||||
@@ -716,7 +732,7 @@ for(let i=startTest;i<Math.min(endTest,testCount);i++){
|
||||
else if(err&&err.includes('Unhandled'))t='unhandled';
|
||||
errTypes[t]=(errTypes[t]||0)+1;
|
||||
}
|
||||
_testDeadline = 0;
|
||||
_testDeadline = 0; globalThis.__hs_deadline = 0;
|
||||
if((i+1)%100===0)process.stdout.write(` ${i+1}/${testCount} (${passed} pass, ${failed} fail)\n`);
|
||||
if(elapsed > 5000)process.stdout.write(` SLOW: test ${i} took ${elapsed}ms [${suite}] ${name}\n`);
|
||||
if(!ok && err && err.includes('TIMEOUT'))process.stdout.write(` TIMEOUT: test ${i} [${suite}] ${name}\n`);
|
||||
|
||||
Reference in New Issue
Block a user