瀏覽代碼

test(ci): preserve the lane budget for invariant verifier children

_Kerman 2 周之前
父節點
當前提交
ef8f166ccc
共有 1 個文件被更改,包括 16 次插入 和 12 次删除
  1. 16 12
      scripts/verify-built-package-invariants.spec.ts

+ 16 - 12
scripts/verify-built-package-invariants.spec.ts

@@ -47,52 +47,56 @@ function fixture(options: {
   return { root, loaderUrl: pathToFileURL(loaderPath).href }
 }
 
-function verify(root: string, loaderUrl: string) {
-  return spawnSync(process.execPath, [
+function verify(root: string, loaderUrl: string, timeout: number) {
+  const result = spawnSync(process.execPath, [
     verifier,
     '--packages-root', root,
     '--loader-url', loaderUrl,
   ], {
     encoding: 'utf8',
-    timeout: 5_000,
+    // Plain-Node startup and staged imports share the runner's platform budget.
+    timeout,
   })
+  expect(result.error).toBeUndefined()
+  expect(result.signal, result.stderr).toBeNull()
+  return result
 }
 
 describe('built package invariant verifier', () => {
-  it('loads the staged compiled self-reference through plain Node and Loader normalization', () => {
+  it('loads the staged compiled self-reference through plain Node and Loader normalization', ({ task }) => {
     const { root, loaderUrl } = fixture()
-    const result = verify(root, loaderUrl)
+    const result = verify(root, loaderUrl, task.timeout)
     expect(result.status, result.stderr).toBe(0)
     expect(result.stdout).toContain('1 compiled companion(s) passed plain-Node Loader checks')
   })
 
-  it('accepts packages that do not publish a companion', () => {
+  it('accepts packages that do not publish a companion', ({ task }) => {
     const { root, loaderUrl } = fixture({ companion: false })
-    const result = verify(root, loaderUrl)
+    const result = verify(root, loaderUrl, task.timeout)
     expect(result.status, result.stderr).toBe(0)
     expect(result.stdout).toContain('0 compiled companion(s) passed plain-Node Loader checks')
   })
 
-  it('rejects a default export and a broken invariant export map', () => {
+  it('rejects a default export and a broken invariant export map', ({ task }) => {
     const withDefault = fixture({
       invariantSource: "export default {}\nexport const name = 'probe-invariant'\nexport const inject = ['invariants']\nexport const apply = () => {}\n",
     })
-    const defaultResult = verify(withDefault.root, withDefault.loaderUrl)
+    const defaultResult = verify(withDefault.root, withDefault.loaderUrl, task.timeout)
     expect(defaultResult.status).toBe(1)
     expect(defaultResult.stderr).toContain('companion has a default export')
 
     const brokenExport = fixture({ invariantExport: './lib/missing.js' })
-    const exportResult = verify(brokenExport.root, brokenExport.loaderUrl)
+    const exportResult = verify(brokenExport.root, brokenExport.loaderUrl, task.timeout)
     expect(exportResult.status).toBe(1)
     expect(exportResult.stderr).toContain('@deepseek-ai/dsh-probe')
   })
 
-  it('rejects an invariant bundle that needs an unstaged runtime chunk', () => {
+  it('rejects an invariant bundle that needs an unstaged runtime chunk', ({ task }) => {
     const { root, loaderUrl } = fixture({
       invariantSource: "export * from './chunk.js'\n",
       runtimeChunk: "export const name = 'probe-invariant'\nexport const inject = ['invariants']\nexport const apply = () => {}\n",
     })
-    const result = verify(root, loaderUrl)
+    const result = verify(root, loaderUrl, task.timeout)
     expect(result.status).toBe(1)
     expect(result.stderr).toContain('chunk.js')
   })