Browse Source

test: stabilize deep Code Mode worker coverage

Give the real-worker binding stress case an explicit CI budget and keep the forged-completion program pending so bootstrap cannot publish a competing normal completion.
Tianyi Cui 2 tháng trước cách đây
mục cha
commit
0852d5ab63

+ 4 - 2
packages/code-runtime/code-runtime-worker/tests/runtime.spec.ts

@@ -92,7 +92,7 @@ describe('WorkerCodeRuntime — programs and bindings (real workers)', () => {
       cursor = Array.isArray(cursor) ? cursor[0] : undefined
     }
     expect(cursor).toBe('leaf')
-  })
+  }, 15_000)
 
   it('reports non-erasable syntax as an exception without spawning a worker', async () => {
     const { runtime } = await setup()
@@ -484,7 +484,9 @@ describe('WorkerCodeRuntime — hostile programs (real workers)', () => {
         const { parentPort } = await import('node:worker_threads');
         let value = null;
         for (let depth = 0; depth < 3_000; depth++) value = [value];
-        parentPort.postMessage({ type: 'done', value });
+        setTimeout(() => { parentPort.postMessage({ type: 'done', value }) }, 25);
+        // Prevent bootstrap's normal undefined completion from racing the forged terminal.
+        await new Promise(() => {});
       `,
       bindings: [],
     })