vitest-pool-assemblyscript 0.4.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -2
- package/dist/{ast-visitor-lTahoS9R.mjs → ast-visitor-DJLJd5dt.mjs} +2 -2
- package/dist/{ast-visitor-lTahoS9R.mjs.map → ast-visitor-DJLJd5dt.mjs.map} +1 -1
- package/dist/{compile-runner-C2eh_xLp.mjs → compile-runner-BJ_ZF3Ma.mjs} +11 -8
- package/dist/compile-runner-BJ_ZF3Ma.mjs.map +1 -0
- package/dist/compiler/transforms/strip-inline.mjs +2 -2
- package/dist/{compiler-BaNECXMW.mjs → compiler-CscxCJw3.mjs} +78 -38
- package/dist/compiler-CscxCJw3.mjs.map +1 -0
- package/dist/config/index-v3.d.mts +2 -2
- package/dist/config/index.d.mts +3 -3
- package/dist/config/index.mjs +5 -5
- package/dist/{constants-DX9yo-el.mjs → constants-DuBLuMjt.mjs} +9 -9
- package/dist/constants-DuBLuMjt.mjs.map +1 -0
- package/dist/{coverage-merge-0WqdC-dq.mjs → coverage-merge-DCEwyjMy.mjs} +1 -1
- package/dist/{coverage-merge-0WqdC-dq.mjs.map → coverage-merge-DCEwyjMy.mjs.map} +1 -1
- package/dist/coverage-provider/index.mjs +35 -28
- package/dist/coverage-provider/index.mjs.map +1 -1
- package/dist/{custom-provider-options-CVLz0nAp.d.mts → custom-provider-options-i_O0OSTV.d.mts} +2 -2
- package/dist/{custom-provider-options-CVLz0nAp.d.mts.map → custom-provider-options-i_O0OSTV.d.mts.map} +1 -1
- package/dist/{debug-Cf2jt1kg.mjs → debug-Cm1VFmaz.mjs} +16 -13
- package/dist/{debug-Cf2jt1kg.mjs.map → debug-Cm1VFmaz.mjs.map} +1 -1
- package/dist/index-internal.d.mts +1 -14
- package/dist/index-internal.d.mts.map +1 -1
- package/dist/index-internal.mjs +3 -3
- package/dist/index-v3.mjs +4 -4
- package/dist/index-v3.mjs.map +1 -1
- package/dist/index.d.mts +2 -2
- package/dist/index.mjs +5 -5
- package/dist/{load-user-imports-eGZuxeNp.mjs → load-user-imports-CYTTU22Q.mjs} +30 -149
- package/dist/load-user-imports-CYTTU22Q.mjs.map +1 -0
- package/dist/node-check-CooGQMLH.mjs +16 -0
- package/dist/node-check-CooGQMLH.mjs.map +1 -0
- package/dist/{pool-runner-init-Cdpz_B-F.mjs → pool-runner-init-D1QamWkS.mjs} +5 -5
- package/dist/{pool-runner-init-Cdpz_B-F.mjs.map → pool-runner-init-D1QamWkS.mjs.map} +1 -1
- package/dist/{pool-runner-init-8vx-5Pb4.d.mts → pool-runner-init-D56aVMMD.d.mts} +2 -2
- package/dist/pool-runner-init-D56aVMMD.d.mts.map +1 -0
- package/dist/pool-thread/compile-worker-thread.d.mts +1 -1
- package/dist/pool-thread/compile-worker-thread.d.mts.map +1 -1
- package/dist/pool-thread/compile-worker-thread.mjs +11 -9
- package/dist/pool-thread/compile-worker-thread.mjs.map +1 -1
- package/dist/pool-thread/test-worker-thread.d.mts +1 -1
- package/dist/pool-thread/test-worker-thread.d.mts.map +1 -1
- package/dist/pool-thread/test-worker-thread.mjs +10 -8
- package/dist/pool-thread/test-worker-thread.mjs.map +1 -1
- package/dist/pool-thread/v3-tinypool-thread.d.mts +1 -1
- package/dist/pool-thread/v3-tinypool-thread.d.mts.map +1 -1
- package/dist/pool-thread/v3-tinypool-thread.mjs +14 -12
- package/dist/pool-thread/v3-tinypool-thread.mjs.map +1 -1
- package/dist/{resolve-config-BKjJQyy5.mjs → resolve-config-BFNr7LW7.mjs} +9 -3
- package/dist/resolve-config-BFNr7LW7.mjs.map +1 -0
- package/dist/{test-runner-vGpTcXsw.mjs → test-runner-CfhzcYNS.mjs} +5 -5
- package/dist/{test-runner-vGpTcXsw.mjs.map → test-runner-CfhzcYNS.mjs.map} +1 -1
- package/dist/{types-DasF0_PX.d.mts → types-DmyeERkL.d.mts} +15 -5
- package/dist/types-DmyeERkL.d.mts.map +1 -0
- package/dist/{vitest-tasks-Cbri6MWZ.mjs → vitest-tasks-ByPK8DvF.mjs} +3 -3
- package/dist/{vitest-tasks-Cbri6MWZ.mjs.map → vitest-tasks-ByPK8DvF.mjs.map} +1 -1
- package/dist/wasm-names-CydfYzQK.mjs +124 -0
- package/dist/wasm-names-CydfYzQK.mjs.map +1 -0
- package/package.json +11 -5
- package/prebuilds/darwin-arm64/vitest-pool-assemblyscript.glibc.node +0 -0
- package/prebuilds/darwin-x64/vitest-pool-assemblyscript.glibc.node +0 -0
- package/prebuilds/linux-arm64/vitest-pool-assemblyscript.glibc.node +0 -0
- package/prebuilds/linux-x64/vitest-pool-assemblyscript.glibc.node +0 -0
- package/prebuilds/linux-x64/vitest-pool-assemblyscript.musl.node +0 -0
- package/prebuilds/win32-arm64/vitest-pool-assemblyscript.glibc.node +0 -0
- package/prebuilds/win32-x64/vitest-pool-assemblyscript.glibc.node +0 -0
- package/src/native-instrumentation/addon.cpp +28 -2
- package/dist/compile-runner-C2eh_xLp.mjs.map +0 -1
- package/dist/compiler-BaNECXMW.mjs.map +0 -1
- package/dist/constants-DX9yo-el.mjs.map +0 -1
- package/dist/load-user-imports-eGZuxeNp.mjs.map +0 -1
- package/dist/pool-runner-init-8vx-5Pb4.d.mts.map +0 -1
- package/dist/resolve-config-BKjJQyy5.mjs.map +0 -1
- package/dist/types-DasF0_PX.d.mts.map +0 -1
package/dist/index-v3.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index-v3.mjs","names":[],"sources":["../src/pool/v3-process-pool.ts","../src/index-v3.ts"],"sourcesContent":["/**\n * AssemblyScript Pool for Vitest\n */\n\nimport { resolve, basename } from 'node:path';\nimport { access } from 'node:fs/promises';\nimport Tinypool from 'tinypool';\nimport type { SerializedConfig } from 'vitest';\nimport type { Vitest, ProcessPool, TestSpecification } from 'vitest/node';\nimport type { Test } from '@vitest/runner/types';\n\nimport {\n AS_POOL_WORKER_MSG_FLAG,\n ASSEMBLYSCRIPT_POOL_NAME,\n POOL_ERROR_NAMES,\n} from '../types/constants.js';\nimport type {\n ResolvedHybridProviderOptions,\n ProcessPoolRunFileTask,\n WASMCompilation,\n TestRunRecord,\n AssemblyScriptPoolWorkerMessage,\n WorkerThreadInitData,\n} from '../types/types.js';\nimport { setGlobalDebugMode, debug } from '../util/debug.js';\nimport { createWorkerRPCChannel } from './worker-rpc-channel.js';\nimport {\n createPoolErrorFromAnyError,\n isAbortError,\n} from '../util/pool-errors.js';\nimport {\n failTestWithTimeoutError,\n flagTestTerminated,\n} from '../util/vitest-tasks.js';\nimport { createInitialFileTask } from '../util/vitest-file-tasks.js';\nimport { getProjectSerializedOrGlobalConfig, resolvePoolOptions } from '../util/resolve-config.js';\n\n// path assumes that we're running from dist/\nconst WORKER_PATH = resolve(import.meta.dirname, 'pool-thread/v3-tinypool-thread.mjs');\n\nconst POOL_THREAD_IDLE_TIMEOUT_MS = 3_600_000;\n\nasync function dispatchFullWorkerRun(\n spec: TestSpecification,\n config: SerializedConfig,\n isCollectTestsMode: boolean,\n pool: Tinypool,\n poolAbortSignal: AbortSignal,\n fileCache: Map<string, WASMCompilation>,\n testTimeoutCache: Map<string, TestRunRecord>,\n previousTimedOutTest?: Test,\n): Promise<Test | undefined> {\n const fileRunStart = Date.now();\n const testFilePath: string = spec.moduleId; // absolute path\n const base = basename(testFilePath);\n\n debug(`[Pool] ${base} - Starting file worker run at ${fileRunStart} for \"${testFilePath}\"`);\n\n let fileCompilation: WASMCompilation | undefined = fileCache.get(spec.moduleId);\n const isTimeoutRedispatch: boolean = !!previousTimedOutTest && !!fileCompilation;\n\n let timedOutTestThisRun: Test | undefined;\n\n try {\n const fileAbortController = new AbortController();\n const file = isTimeoutRedispatch\n ? previousTimedOutTest!.file\n : createInitialFileTask(spec.moduleId, spec.project.name, config.root, config.testTimeout, config.retry);\n\n const { workerPort, poolPort } = createWorkerRPCChannel(spec.project, isCollectTestsMode);\n\n // Enforce test timeout using setTimeout() and worker messages.\n // 1. worker sends a start message to indicate when the test has started\n // 2. pool starts a timer using setTimeout() when worker start message is received\n // 3. worker sends an end message to indicate when the test has completed\n // - if test completes before the timeout expires, the timer is cleared and everything proceeds\n // - if timeout expires, the test worker is actively aborted using the test-specific AbortController\n //\n // Monitoring from the pool main thread and actively aborting the runner allows for accurate enforcement of the test timeout,\n // which is much harder/impossible to control from within the worker thread itself, which is busy/blocked running \n // the long-running WASM test.\n poolPort.on('message', event => {\n if (!event[AS_POOL_WORKER_MSG_FLAG]) return;\n\n const msg = event as AssemblyScriptPoolWorkerMessage;\n if (msg.type === 'file-compiled') {\n const { compilation } = msg;\n fileCache.set(compilation.filePath, compilation);\n debug(`[Pool] ${basename(compilation.filePath)} - Got compiled file cache for \"${compilation.filePath}\"`);\n } else if (msg.type === 'execution-start') {\n const poolReceivedExecutionStart = Date.now();\n const { executionStart, test } = msg;\n\n const transitDuration = poolReceivedExecutionStart - executionStart;\n const adjustedTimeout = Math.max(test.timeout - transitDuration, 0);\n\n debug(`[Pool] ${base} - \"${test.name}\": Received worker execution start (transit ${transitDuration} ms)`\n + ` - Beginning test timeout timer ${test.timeout} ms (adjusted timeout: ${adjustedTimeout} ms)`\n );\n \n // Enforce test timeout\n const testTimeoutId = setTimeout(async () => {\n const poolTimeoutTime = Date.now();\n const record = testTimeoutCache.get(test.id);\n testTimeoutCache.delete(test.id);\n\n if (record) {\n const elapsedFromWorkerExecutionStart = poolTimeoutTime - record.executionStart;\n\n failTestWithTimeoutError(record.test, poolTimeoutTime, elapsedFromWorkerExecutionStart);\n\n flagTestTerminated(record.test);\n\n timedOutTestThisRun = test;\n fileAbortController.abort(POOL_ERROR_NAMES.WASMExecutionTimeoutError);\n\n debug(`[Pool] ${base} - \"${record.test.name}\" timed out (threshold ${record.test.timeout} ms)`\n + ` - Aborted worker job (duration before abort: ${elapsedFromWorkerExecutionStart} ms)`\n );\n }\n }, adjustedTimeout);\n\n testTimeoutCache.set(test.id, {\n test: test,\n executionStart: executionStart,\n timeoutId: testTimeoutId,\n });\n\n } else if (msg.type === 'execution-end') {\n const poolReceivedExecutionEnd = Date.now();\n const { executionEnd, testTaskId } = msg;\n const record = testTimeoutCache.get(testTaskId);\n testTimeoutCache.delete(testTaskId);\n\n if (record) {\n clearTimeout(record.timeoutId);\n\n const elapsedFromWorkerExecutionStart = executionEnd - record.executionStart!;\n const transitDuration = poolReceivedExecutionEnd - executionEnd;\n debug(`[Pool] ${base} - \"${record.test.name}\": Received worker execution end (transit: ${transitDuration} ms)`\n + ` - Clearing test timeout timer - Actual duration from worker exection start: ${elapsedFromWorkerExecutionStart} ms`\n );\n }\n }\n });\n \n const workerTaskData: ProcessPoolRunFileTask = {\n dispatchStart: Date.now(),\n port: workerPort,\n file,\n config,\n isCollectTestsMode,\n timedOutTest: previousTimedOutTest,\n timedOutCompilation: fileCompilation\n };\n\n try {\n await pool.run(workerTaskData, {\n name: 'runTestFile',\n transferList: [workerPort],\n signal: AbortSignal.any([poolAbortSignal, fileAbortController.signal]),\n });\n } finally {\n workerPort.close();\n poolPort.close();\n }\n \n return;\n } catch (error) {\n if (isAbortError(error)) {\n debug(`[Pool] ${base} - file worker aborted during run: ${String(error)}`);\n \n if (!!timedOutTestThisRun) {\n // swallow abort error, return timed out test so worker can be re-launched\n return timedOutTestThisRun;\n } else {\n // swallow abort error, this file worker run is done\n return;\n }\n }\n\n throw createPoolErrorFromAnyError(`${base} - unhandled file worker failure`, POOL_ERROR_NAMES.PoolError, error);\n } finally {\n debug(`[Pool] ${base} - Finished File Worker Execution`);\n }\n}\n\n/**\n * Run / Collect tests\n */\nasync function runTests(\n specs: TestSpecification[],\n isCollectTestsMode: boolean,\n pool: Tinypool,\n poolAbortController: AbortController,\n _invalidatedFiles?: string[]\n): Promise<void> {\n const mode = isCollectTestsMode ? 'collectTests' : 'runTests';\n debug(`[Pool] -------- ${mode} called for ${specs.length} specs --------`);\n\n // TODO - invalidation\n // const invalidCount = invalidatedFiles?.length ?? 0;\n // debug('[Pool] Invalidated files:', invalidCount);\n\n // if (invalidCount > 0) {\n // // probably:\n // // 0. pre-build a cached map of source files to specs that import them (using debuginfo?)\n // // 1. check if invalidated file is in map: if NOT ignore & continue loop to next file\n // // 2. create file worker for each spec the invalidated file maps to\n // }\n\n const fileCache: Map<string, WASMCompilation> = new Map();\n const testTimeoutCache: Map<string, TestRunRecord> = new Map();\n\n // Create worker for each file\n const fileWorkers: Promise<void>[] = specs.map(async (spec: TestSpecification): Promise<void> => {\n const { serializedConfig } = spec.project;\n let timedOutTest = await dispatchFullWorkerRun(spec, serializedConfig, isCollectTestsMode, pool, poolAbortController.signal, fileCache, testTimeoutCache);\n \n while (timedOutTest) {\n timedOutTest = await dispatchFullWorkerRun(spec, serializedConfig, isCollectTestsMode, pool, poolAbortController.signal, fileCache, testTimeoutCache, timedOutTest);\n }\n });\n\n if (isCollectTestsMode) {\n try {\n await Promise.all(fileWorkers);\n debug('[Pool] collectTests - All file workers resolved');\n } catch (err) {\n debug('[Pool] collectTests - File worker REJECTED, Calling Pool Abort to bail this collectTests run');\n poolAbortController.abort();\n }\n } else {\n const results = await Promise.allSettled(fileWorkers);\n const unexpectedErrors: any[] = [];\n results.forEach(r => {\n if (r.status === 'rejected') {\n unexpectedErrors.push(r.reason);\n }\n });\n\n if (unexpectedErrors.length === 0) {\n debug(`[Pool] ${mode} - All file workers resolved`);\n } else {\n debug(`[Pool] ${mode} - Some file workers REJECTED unexpectedly. Throwing error(s) to vitest:`, unexpectedErrors);\n throw {\n name: POOL_ERROR_NAMES.PoolError,\n message: `Unexpected AssemblyScript Pool Error(s) Encountered during ${mode}`,\n cause: unexpectedErrors[0]\n };\n }\n }\n\n debug(`[Pool] Timeout Cache Size: ${testTimeoutCache.size}`);\n testTimeoutCache.forEach((record: TestRunRecord, testId: string) => {\n if (record) {\n debug(`[Pool] Leftover timeout entry for task: ${record.test.name}`);\n clearTimeout(record.timeoutId);\n } else {\n debug(`[Pool] Empty test timeout entry for task: ${testId}`);\n }\n });\n\n debug(`[Pool] -------- ${mode} completed --------`);\n}\n\nexport function createAssemblyScriptProcessPool(ctx: Vitest): ProcessPool {\n const { config, foundProjectSerializedConfig } = getProjectSerializedOrGlobalConfig(ctx);\n \n // Resolve pool options and initialize debug mode\n // @ts-ignore - we build with v4, but this is correct for v3 (has Config.poolOptions)\n const poolOptions = resolvePoolOptions(config?.poolOptions);\n setGlobalDebugMode(poolOptions.debug);\n\n debug('[Pool] Initializing AssemblyScript Pool');\n\n if (foundProjectSerializedConfig) {\n debug(`[Pool] Multi-project mode: Using config from project: \"${config.name}\"`);\n } else {\n debug('[Pool] Single-project mode: No project config found using vitest-pool-assemblyscript pool - Using global config with AssemblyScript pool defaults');\n }\n\n debug(`[Pool] Worker thread path: \"${WORKER_PATH}\"`);\n debug(`[Pool] Worker thread configuration - maxThreads: ${poolOptions.maxThreadsV3}`);\n\n setImmediate(async () => {\n const userImportsFactoryPath = resolve(config.root, poolOptions.wasmImportsFactory ?? '');\n const results = await Promise.allSettled([\n access(WORKER_PATH),\n poolOptions.wasmImportsFactory ? access(userImportsFactoryPath) : Promise.resolve()\n ]);\n\n if (results[0].status === 'rejected') {\n throw new Error(`Cannot access worker thread file at path: \"${WORKER_PATH}\"`);\n }\n if (results[1].status === 'rejected') {\n throw new Error(`Cannot access user WasmImportsFactory at path: \"${userImportsFactoryPath}\".`\n + ` Ensure that your module path is relative to the project root (location of shallowest vitest config),`\n + ` and that it has a default export matching () => WebAssembly.Imports`\n );\n }\n });\n\n // Initialize Tinypool for worker management\n const pool = new Tinypool({\n filename: WORKER_PATH,\n minThreads: 1,\n maxThreads: poolOptions.maxThreadsV3,\n idleTimeout: POOL_THREAD_IDLE_TIMEOUT_MS,\n isolateWorkers: false,\n workerData: {\n asPoolOptions: poolOptions,\n asCoverageOptions: config.coverage as ResolvedHybridProviderOptions,\n projectRoot: config.root,\n } satisfies WorkerThreadInitData,\n });\n\n // For explicitly terminating all worker threads because of\n // ctrl+c in terminal, or bail after test failures exceed bail count\n const poolAbortController = new AbortController();\n ctx.onCancel(reason => {\n const reasonMsg = reason === 'test-failure' ? 'Bail after test failure' : reason;\n console.log(`${ASSEMBLYSCRIPT_POOL_NAME} - Aborting all tests: ${reasonMsg}`);\n poolAbortController.abort();\n });\n\n return {\n name: ASSEMBLYSCRIPT_POOL_NAME,\n\n // runs when executing vitest list\n async collectTests(specs: TestSpecification[]) {\n const isCollectTestsMode = true;\n return runTests(specs, isCollectTestsMode, pool, poolAbortController);\n },\n\n async runTests(specs: TestSpecification[], invalidates?: string[]) {\n const isCollectTestsMode = false;\n return runTests(specs, isCollectTestsMode, pool, poolAbortController, invalidates);\n },\n\n // Cleanup when shutting down\n async close() {\n debug('[Pool] AbortController called');\n poolAbortController.abort();\n \n debug('[Pool] Tinypool destroyed');\n await pool.destroy();\n\n debug('[Pool] Exiting');\n },\n };\n}\n","// default export for v3 pool\nimport { createAssemblyScriptProcessPool } from './pool/v3-process-pool.js';\nexport default createAssemblyScriptProcessPool;\n"],"mappings":";;;;;;;;;;;;;;AAsCA,MAAM,cAAc,QAAQ,OAAO,KAAK,SAAS,qCAAqC;AAEtF,MAAM,8BAA8B;AAEpC,eAAe,sBACb,MACA,QACA,oBACA,MACA,iBACA,WACA,kBACA,sBAC2B;CAC3B,MAAM,eAAe,KAAK,KAAK;CAC/B,MAAM,eAAuB,KAAK;CAClC,MAAM,OAAO,SAAS,aAAa;AAEnC,OAAM,UAAU,KAAK,iCAAiC,aAAa,QAAQ,aAAa,GAAG;CAE3F,IAAI,kBAA+C,UAAU,IAAI,KAAK,SAAS;CAC/E,MAAM,sBAA+B,CAAC,CAAC,wBAAwB,CAAC,CAAC;CAEjE,IAAI;AAEJ,KAAI;EACF,MAAM,sBAAsB,IAAI,iBAAiB;EACjD,MAAM,OAAO,sBACT,qBAAsB,OACtB,sBAAsB,KAAK,UAAU,KAAK,QAAQ,MAAM,OAAO,MAAM,OAAO,aAAa,OAAO,MAAM;EAE1G,MAAM,EAAE,YAAY,aAAa,uBAAuB,KAAK,S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MAAM,8CAA8C,YAAY,GAAG;AAE/E,MAAI,QAAQ,GAAG,WAAW,WACxB,OAAM,IAAI,MAAM,mDAAmD,uBAAuB,6KAGzF;GAEH;CAGF,MAAM,OAAO,IAAI,SAAS;EACxB,UAAU;EACV,YAAY;EACZ,YAAY,YAAY;EACxB,aAAa;EACb,gBAAgB;EAChB,YAAY;GACV,eAAe;GACf,mBAAmB,OAAO;GAC1B,aAAa,OAAO;GACrB;EACF,CAAC;CAIF,MAAM,sBAAsB,IAAI,iBAAiB;AACjD,KAAI,UAAS,WAAU;EACrB,MAAM,YAAY,WAAW,iBAAiB,4BAA4B;AAC1E,UAAQ,IAAI,oBAA4B,yBAAyB,YAAY;AAC7E,sBAAoB,OAAO;GAC3B;AAEF,QAAO;EACL;EAGA,MAAM,aAAa,OAA4B;AAE7C,UAAO,SAAS,OADW,MACgB,MAAM,oBAAoB;;EAGvE,MAAM,SAAS,OAA4B,aAAwB;AAEjE,UAAO,SAAS,OADW,OACgB,MAAM,qBAAqB,YAAY;;EAIpF,MAAM,QAAQ;AACZ,SAAM,gCAAgC;AACtC,uBAAoB,OAAO;AAE3B,SAAM,4BAA4B;AAClC,SAAM,KAAK,SAAS;AAEpB,SAAM,iBAAiB;;EAE1B;;;;;AC5VH,uBAAe"}
|
|
1
|
+
{"version":3,"file":"index-v3.mjs","names":[],"sources":["../src/pool/v3-process-pool.ts","../src/index-v3.ts"],"sourcesContent":["/**\n * AssemblyScript Pool for Vitest\n */\n\nimport { resolve, basename } from 'node:path';\nimport { access } from 'node:fs/promises';\nimport Tinypool from 'tinypool';\nimport type { SerializedConfig } from 'vitest';\nimport type { Vitest, ProcessPool, TestSpecification } from 'vitest/node';\nimport type { Test } from '@vitest/runner/types';\n\nimport {\n AS_POOL_WORKER_MSG_FLAG,\n ASSEMBLYSCRIPT_POOL_NAME,\n POOL_ERROR_NAMES,\n} from '../types/constants.js';\nimport type {\n ResolvedHybridProviderOptions,\n ProcessPoolRunFileTask,\n WASMCompilation,\n TestRunRecord,\n AssemblyScriptPoolWorkerMessage,\n WorkerThreadInitData,\n} from '../types/types.js';\nimport { setGlobalDebugMode, debug } from '../util/debug.js';\nimport { createWorkerRPCChannel } from './worker-rpc-channel.js';\nimport {\n createPoolErrorFromAnyError,\n isAbortError,\n} from '../util/pool-errors.js';\nimport {\n failTestWithTimeoutError,\n flagTestTerminated,\n} from '../util/vitest-tasks.js';\nimport { createInitialFileTask } from '../util/vitest-file-tasks.js';\nimport { getProjectSerializedOrGlobalConfig, resolvePoolOptions } from '../util/resolve-config.js';\n\n// path assumes that we're running from dist/\nconst WORKER_PATH = resolve(import.meta.dirname, 'pool-thread/v3-tinypool-thread.mjs');\n\nconst POOL_THREAD_IDLE_TIMEOUT_MS = 3_600_000;\n\nasync function dispatchFullWorkerRun(\n spec: TestSpecification,\n config: SerializedConfig,\n isCollectTestsMode: boolean,\n pool: Tinypool,\n poolAbortSignal: AbortSignal,\n fileCache: Map<string, WASMCompilation>,\n testTimeoutCache: Map<string, TestRunRecord>,\n previousTimedOutTest?: Test,\n): Promise<Test | undefined> {\n const fileRunStart = Date.now();\n const testFilePath: string = spec.moduleId; // absolute path\n const base = basename(testFilePath);\n\n debug(`[Pool] ${base} - Starting file worker run at ${fileRunStart} for \"${testFilePath}\"`);\n\n let fileCompilation: WASMCompilation | undefined = fileCache.get(spec.moduleId);\n const isTimeoutRedispatch: boolean = !!previousTimedOutTest && !!fileCompilation;\n\n let timedOutTestThisRun: Test | undefined;\n\n try {\n const fileAbortController = new AbortController();\n const file = isTimeoutRedispatch\n ? previousTimedOutTest!.file\n : createInitialFileTask(spec.moduleId, spec.project.name, config.root, config.testTimeout, config.retry);\n\n const { workerPort, poolPort } = createWorkerRPCChannel(spec.project, isCollectTestsMode);\n\n // Enforce test timeout using setTimeout() and worker messages.\n // 1. worker sends a start message to indicate when the test has started\n // 2. pool starts a timer using setTimeout() when worker start message is received\n // 3. worker sends an end message to indicate when the test has completed\n // - if test completes before the timeout expires, the timer is cleared and everything proceeds\n // - if timeout expires, the test worker is actively aborted using the test-specific AbortController\n //\n // Monitoring from the pool main thread and actively aborting the runner allows for accurate enforcement of the test timeout,\n // which is much harder/impossible to control from within the worker thread itself, which is busy/blocked running \n // the long-running WASM test.\n poolPort.on('message', event => {\n if (!event[AS_POOL_WORKER_MSG_FLAG]) return;\n\n const msg = event as AssemblyScriptPoolWorkerMessage;\n if (msg.type === 'file-compiled') {\n const { compilation } = msg;\n fileCache.set(compilation.filePath, compilation);\n debug(`[Pool] ${basename(compilation.filePath)} - Got compiled file cache for \"${compilation.filePath}\"`);\n } else if (msg.type === 'execution-start') {\n const poolReceivedExecutionStart = Date.now();\n const { executionStart, test } = msg;\n\n const transitDuration = poolReceivedExecutionStart - executionStart;\n const adjustedTimeout = Math.max(test.timeout - transitDuration, 0);\n\n debug(`[Pool] ${base} - \"${test.name}\": Received worker execution start (transit ${transitDuration} ms)`\n + ` - Beginning test timeout timer ${test.timeout} ms (adjusted timeout: ${adjustedTimeout} ms)`\n );\n \n // Enforce test timeout\n const testTimeoutId = setTimeout(async () => {\n const poolTimeoutTime = Date.now();\n const record = testTimeoutCache.get(test.id);\n testTimeoutCache.delete(test.id);\n\n if (record) {\n const elapsedFromWorkerExecutionStart = poolTimeoutTime - record.executionStart;\n\n failTestWithTimeoutError(record.test, poolTimeoutTime, elapsedFromWorkerExecutionStart);\n\n flagTestTerminated(record.test);\n\n timedOutTestThisRun = test;\n fileAbortController.abort(POOL_ERROR_NAMES.WASMExecutionTimeoutError);\n\n debug(`[Pool] ${base} - \"${record.test.name}\" timed out (threshold ${record.test.timeout} ms)`\n + ` - Aborted worker job (duration before abort: ${elapsedFromWorkerExecutionStart} ms)`\n );\n }\n }, adjustedTimeout);\n\n testTimeoutCache.set(test.id, {\n test: test,\n executionStart: executionStart,\n timeoutId: testTimeoutId,\n });\n\n } else if (msg.type === 'execution-end') {\n const poolReceivedExecutionEnd = Date.now();\n const { executionEnd, testTaskId } = msg;\n const record = testTimeoutCache.get(testTaskId);\n testTimeoutCache.delete(testTaskId);\n\n if (record) {\n clearTimeout(record.timeoutId);\n\n const elapsedFromWorkerExecutionStart = executionEnd - record.executionStart!;\n const transitDuration = poolReceivedExecutionEnd - executionEnd;\n debug(`[Pool] ${base} - \"${record.test.name}\": Received worker execution end (transit: ${transitDuration} ms)`\n + ` - Clearing test timeout timer - Actual duration from worker exection start: ${elapsedFromWorkerExecutionStart} ms`\n );\n }\n }\n });\n \n const workerTaskData: ProcessPoolRunFileTask = {\n dispatchStart: Date.now(),\n port: workerPort,\n file,\n config,\n isCollectTestsMode,\n timedOutTest: previousTimedOutTest,\n timedOutCompilation: fileCompilation\n };\n\n try {\n await pool.run(workerTaskData, {\n name: 'runTestFile',\n transferList: [workerPort],\n signal: AbortSignal.any([poolAbortSignal, fileAbortController.signal]),\n });\n } finally {\n workerPort.close();\n poolPort.close();\n }\n \n return;\n } catch (error) {\n if (isAbortError(error)) {\n debug(`[Pool] ${base} - file worker aborted during run: ${String(error)}`);\n \n if (!!timedOutTestThisRun) {\n // swallow abort error, return timed out test so worker can be re-launched\n return timedOutTestThisRun;\n } else {\n // swallow abort error, this file worker run is done\n return;\n }\n }\n\n throw createPoolErrorFromAnyError(`${base} - unhandled file worker failure`, POOL_ERROR_NAMES.PoolError, error);\n } finally {\n debug(`[Pool] ${base} - Finished File Worker Execution`);\n }\n}\n\n/**\n * Run / Collect tests\n */\nasync function runTests(\n specs: TestSpecification[],\n isCollectTestsMode: boolean,\n pool: Tinypool,\n poolAbortController: AbortController,\n _invalidatedFiles?: string[]\n): Promise<void> {\n const mode = isCollectTestsMode ? 'collectTests' : 'runTests';\n debug(`[Pool] -------- ${mode} called for ${specs.length} specs --------`);\n\n // TODO - invalidation\n // const invalidCount = invalidatedFiles?.length ?? 0;\n // debug('[Pool] Invalidated files:', invalidCount);\n\n // if (invalidCount > 0) {\n // // probably:\n // // 0. pre-build a cached map of source files to specs that import them (using debuginfo?)\n // // 1. check if invalidated file is in map: if NOT ignore & continue loop to next file\n // // 2. create file worker for each spec the invalidated file maps to\n // }\n\n const fileCache: Map<string, WASMCompilation> = new Map();\n const testTimeoutCache: Map<string, TestRunRecord> = new Map();\n\n // Create worker for each file\n const fileWorkers: Promise<void>[] = specs.map(async (spec: TestSpecification): Promise<void> => {\n const { serializedConfig } = spec.project;\n let timedOutTest = await dispatchFullWorkerRun(spec, serializedConfig, isCollectTestsMode, pool, poolAbortController.signal, fileCache, testTimeoutCache);\n \n while (timedOutTest) {\n timedOutTest = await dispatchFullWorkerRun(spec, serializedConfig, isCollectTestsMode, pool, poolAbortController.signal, fileCache, testTimeoutCache, timedOutTest);\n }\n });\n\n if (isCollectTestsMode) {\n try {\n await Promise.all(fileWorkers);\n debug('[Pool] collectTests - All file workers resolved');\n } catch (err) {\n debug('[Pool] collectTests - File worker REJECTED, Calling Pool Abort to bail this collectTests run');\n poolAbortController.abort();\n }\n } else {\n const results = await Promise.allSettled(fileWorkers);\n const unexpectedErrors: any[] = [];\n results.forEach(r => {\n if (r.status === 'rejected') {\n unexpectedErrors.push(r.reason);\n }\n });\n\n if (unexpectedErrors.length === 0) {\n debug(`[Pool] ${mode} - All file workers resolved`);\n } else {\n debug(`[Pool] ${mode} - Some file workers REJECTED unexpectedly. Throwing error(s) to vitest:`, unexpectedErrors);\n throw {\n name: POOL_ERROR_NAMES.PoolError,\n message: `Unexpected AssemblyScript Pool Error(s) Encountered during ${mode}`,\n cause: unexpectedErrors[0]\n };\n }\n }\n\n debug(`[Pool] Timeout Cache Size: ${testTimeoutCache.size}`);\n testTimeoutCache.forEach((record: TestRunRecord, testId: string) => {\n if (record) {\n debug(`[Pool] Leftover timeout entry for task: ${record.test.name}`);\n clearTimeout(record.timeoutId);\n } else {\n debug(`[Pool] Empty test timeout entry for task: ${testId}`);\n }\n });\n\n debug(`[Pool] -------- ${mode} completed --------`);\n}\n\nexport function createAssemblyScriptProcessPool(ctx: Vitest): ProcessPool {\n const { config, foundProjectSerializedConfig } = getProjectSerializedOrGlobalConfig(ctx);\n \n // Resolve pool options and initialize debug mode\n // @ts-ignore - we build with v4, but this is correct for v3 (has Config.poolOptions)\n const poolOptions = resolvePoolOptions(config?.poolOptions);\n setGlobalDebugMode(poolOptions.debug);\n\n debug('[Pool] Initializing AssemblyScript Pool');\n\n if (foundProjectSerializedConfig) {\n debug(`[Pool] Multi-project mode: Using config from project: \"${config.name}\"`);\n } else {\n debug('[Pool] Single-project mode: No project config found using vitest-pool-assemblyscript pool - Using global config with AssemblyScript pool defaults');\n }\n\n debug(`[Pool] Worker thread path: \"${WORKER_PATH}\"`);\n debug(`[Pool] Worker thread configuration - maxThreads: ${poolOptions.maxThreadsV3}`);\n\n setImmediate(async () => {\n const userImportsFactoryPath = resolve(config.root, poolOptions.wasmImportsFactory ?? '');\n const results = await Promise.allSettled([\n access(WORKER_PATH),\n poolOptions.wasmImportsFactory ? access(userImportsFactoryPath) : Promise.resolve()\n ]);\n\n if (results[0].status === 'rejected') {\n throw new Error(`Cannot access worker thread file at path: \"${WORKER_PATH}\"`);\n }\n if (results[1].status === 'rejected') {\n throw new Error(`Cannot access user WasmImportsFactory at path: \"${userImportsFactoryPath}\".`\n + ` Ensure that your module path is relative to the project root (location of shallowest vitest config),`\n + ` and that it has a default export matching () => WebAssembly.Imports`\n );\n }\n });\n\n // Initialize Tinypool for worker management\n const pool = new Tinypool({\n filename: WORKER_PATH,\n minThreads: 1,\n maxThreads: poolOptions.maxThreadsV3,\n idleTimeout: POOL_THREAD_IDLE_TIMEOUT_MS,\n isolateWorkers: false,\n workerData: {\n asPoolOptions: poolOptions,\n asCoverageOptions: config.coverage as ResolvedHybridProviderOptions,\n projectRoot: config.root,\n } satisfies WorkerThreadInitData,\n });\n\n // For explicitly terminating all worker threads because of\n // ctrl+c in terminal, or bail after test failures exceed bail count\n const poolAbortController = new AbortController();\n ctx.onCancel(reason => {\n const reasonMsg = reason === 'test-failure' ? 'Bail after test failure' : reason;\n console.log(`${ASSEMBLYSCRIPT_POOL_NAME} - Aborting all tests: ${reasonMsg}`);\n poolAbortController.abort();\n });\n\n return {\n name: ASSEMBLYSCRIPT_POOL_NAME,\n\n // runs when executing vitest list\n async collectTests(specs: TestSpecification[]) {\n const isCollectTestsMode = true;\n return runTests(specs, isCollectTestsMode, pool, poolAbortController);\n },\n\n async runTests(specs: TestSpecification[], invalidates?: string[]) {\n const isCollectTestsMode = false;\n return runTests(specs, isCollectTestsMode, pool, poolAbortController, invalidates);\n },\n\n // Cleanup when shutting down\n async close() {\n debug('[Pool] AbortController called');\n poolAbortController.abort();\n \n debug('[Pool] Tinypool destroyed');\n await pool.destroy();\n\n debug('[Pool] Exiting');\n },\n };\n}\n","// default export for v3 pool\nimport { createAssemblyScriptProcessPool } from './pool/v3-process-pool.js';\nexport default createAssemblyScriptProcessPool;\n"],"mappings":";;;;;;;;;;;;;;AAsCA,MAAM,cAAc,QAAQ,OAAO,KAAK,SAAS,qCAAqC;AAEtF,MAAM,8BAA8B;AAEpC,eAAe,sBACb,MACA,QACA,oBACA,MACA,iBACA,WACA,kBACA,sBAC2B;CAC3B,MAAM,eAAe,KAAK,KAAK;CAC/B,MAAM,eAAuB,KAAK;CAClC,MAAM,OAAO,SAAS,aAAa;AAEnC,OAAM,UAAU,KAAK,iCAAiC,aAAa,QAAQ,aAAa,GAAG;CAE3F,IAAI,kBAA+C,UAAU,IAAI,KAAK,SAAS;CAC/E,MAAM,sBAA+B,CAAC,CAAC,wBAAwB,CAAC,CAAC;CAEjE,IAAI;AAEJ,KAAI;EACF,MAAM,sBAAsB,IAAI,iBAAiB;EACjD,MAAM,OAAO,sBACT,qBAAsB,OACtB,sBAAsB,KAAK,UAAU,KAAK,QAAQ,MAAM,OAAO,MAAM,OAAO,aAAa,OAAO,MAAM;EAE1G,MAAM,EAAE,YAAY,aAAa,uBAAuB,KAAK,SAAS,mBAAmB;AAYzF,WAAS,GAAG,YAAW,UAAS;AAC9B,OAAI,CAAC,qBAAgC;GAErC,MAAM,MAAM;AACZ,OAAI,IAAI,SA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EH;CAGF,MAAM,OAAO,IAAI,SAAS;EACxB,UAAU;EACV,YAAY;EACZ,YAAY,YAAY;EACxB,aAAa;EACb,gBAAgB;EAChB,YAAY;GACV,eAAe;GACf,mBAAmB,OAAO;GAC1B,aAAa,OAAO;GACrB;EACF,CAAC;CAIF,MAAM,sBAAsB,IAAI,iBAAiB;AACjD,KAAI,UAAS,WAAU;EACrB,MAAM,YAAY,WAAW,iBAAiB,4BAA4B;AAC1E,UAAQ,IAAI,oBAA4B,yBAAyB,YAAY;AAC7E,sBAAoB,OAAO;GAC3B;AAEF,QAAO;EACL;EAGA,MAAM,aAAa,OAA4B;AAE7C,UAAO,SAAS,OADW,MACgB,MAAM,oBAAoB;;EAGvE,MAAM,SAAS,OAA4B,aAAwB;AAEjE,UAAO,SAAS,OADW,OACgB,MAAM,qBAAqB,YAAY;;EAIpF,MAAM,QAAQ;AACZ,SAAM,gCAAgC;AACtC,uBAAoB,OAAO;AAE3B,SAAM,4BAA4B;AAClC,SAAM,KAAK,SAAS;AAEpB,SAAM,iBAAiB;;EAE1B;;;;;AC5VH,uBAAe"}
|
package/dist/index.d.mts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import "./types-
|
|
2
|
-
import { createAssemblyScriptPool } from "./pool-runner-init-
|
|
1
|
+
import "./types-DmyeERkL.mjs";
|
|
2
|
+
import { createAssemblyScriptPool } from "./pool-runner-init-D56aVMMD.mjs";
|
|
3
3
|
export { createAssemblyScriptPool };
|
package/dist/index.mjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import "./constants-
|
|
2
|
-
import "./resolve-config-
|
|
3
|
-
import "./debug-
|
|
1
|
+
import "./constants-DuBLuMjt.mjs";
|
|
2
|
+
import "./resolve-config-BFNr7LW7.mjs";
|
|
3
|
+
import "./debug-Cm1VFmaz.mjs";
|
|
4
4
|
import "./vitest-file-tasks-BUwzh375.mjs";
|
|
5
|
-
import "./vitest-tasks-
|
|
5
|
+
import "./vitest-tasks-ByPK8DvF.mjs";
|
|
6
6
|
import "./worker-rpc-channel-lbhK7Qz8.mjs";
|
|
7
|
-
import { createAssemblyScriptPool } from "./pool-runner-init-
|
|
7
|
+
import { createAssemblyScriptPool } from "./pool-runner-init-D1QamWkS.mjs";
|
|
8
8
|
|
|
9
9
|
export { createAssemblyScriptPool };
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { COVERAGE_PAYLOAD_FORMATS, POOL_ERROR_NAMES, POOL_INTERNAL_PATHS, TEST_ERROR_NAMES } from "./constants-
|
|
2
|
-
import { createPoolError, createPoolErrorFromAnyError, debug,
|
|
3
|
-
import { createAfterSuiteRunMeta, createSuiteTask, createTestTask, createWebAssemblyCallSite, extractCallStack, failTest, getTaskLogLabel, isSuiteOwnFile, parseSourceMap } from "./vitest-tasks-
|
|
1
|
+
import { COVERAGE_PAYLOAD_FORMATS, POOL_ERROR_NAMES, POOL_INTERNAL_PATHS, TEST_ERROR_NAMES } from "./constants-DuBLuMjt.mjs";
|
|
2
|
+
import { createPoolError, createPoolErrorFromAnyError, debug, debugOverride, getSourceCodeFrameString, toPlaintextStackFrameString, toVitestLikeStackFrameString } from "./debug-Cm1VFmaz.mjs";
|
|
3
|
+
import { createAfterSuiteRunMeta, createSuiteTask, createTestTask, createWebAssemblyCallSite, extractCallStack, failTest, getTaskLogLabel, isSuiteOwnFile, parseSourceMap } from "./vitest-tasks-ByPK8DvF.mjs";
|
|
4
|
+
import { getShortFunctionName } from "./wasm-names-CydfYzQK.mjs";
|
|
4
5
|
import { basename, resolve } from "node:path";
|
|
5
6
|
import { createBirpc } from "birpc";
|
|
6
7
|
import { diff } from "@vitest/utils/diff";
|
|
@@ -332,127 +333,6 @@ function createTestExecutionImports(memory, module, test, handleLog, logPrefix,
|
|
|
332
333
|
};
|
|
333
334
|
}
|
|
334
335
|
|
|
335
|
-
//#endregion
|
|
336
|
-
//#region src/wasm-executor/wasm-names.ts
|
|
337
|
-
/**
|
|
338
|
-
* Extracts the short name from a WASM function table name identifier.
|
|
339
|
-
*/
|
|
340
|
-
function getShortFunctionName(fullName) {
|
|
341
|
-
if (!fullName) return "";
|
|
342
|
-
let decoded;
|
|
343
|
-
try {
|
|
344
|
-
decoded = decodeURIComponent(fullName);
|
|
345
|
-
} catch {
|
|
346
|
-
decoded = fullName;
|
|
347
|
-
}
|
|
348
|
-
let angleBracketDepth = 0;
|
|
349
|
-
let parenDepth = 0;
|
|
350
|
-
let lastSlashOutsideBrackets = -1;
|
|
351
|
-
for (let i = 0; i < decoded.length; i++) {
|
|
352
|
-
const char = decoded[i];
|
|
353
|
-
if (char === "<") angleBracketDepth++;
|
|
354
|
-
else if (char === ">" && decoded[i - 1] !== "=") angleBracketDepth--;
|
|
355
|
-
else if (char === "(") parenDepth++;
|
|
356
|
-
else if (char === ")") parenDepth--;
|
|
357
|
-
else if (char === "/" && angleBracketDepth === 0 && parenDepth === 0) lastSlashOutsideBrackets = i;
|
|
358
|
-
}
|
|
359
|
-
const functionPart = lastSlashOutsideBrackets >= 0 ? decoded.substring(lastSlashOutsideBrackets + 1) : decoded;
|
|
360
|
-
const anonymousMatch = functionPart.match(/^.+~(anonymous\|\d+)$/);
|
|
361
|
-
if (anonymousMatch) return anonymousMatch[1];
|
|
362
|
-
return shortenTypePart(functionPart);
|
|
363
|
-
}
|
|
364
|
-
/**
|
|
365
|
-
* Finds the index of the closing '>' that matches the opening '<' at openIndex.
|
|
366
|
-
*/
|
|
367
|
-
function findMatchingCloseBracket(str, openIndex) {
|
|
368
|
-
let angleBracketDepth = 1;
|
|
369
|
-
for (let i = openIndex + 1; i < str.length; i++) {
|
|
370
|
-
const char = str[i];
|
|
371
|
-
if (char === "<") angleBracketDepth++;
|
|
372
|
-
else if (char === ">" && str[i - 1] !== "=") {
|
|
373
|
-
angleBracketDepth--;
|
|
374
|
-
if (angleBracketDepth === 0) return i;
|
|
375
|
-
}
|
|
376
|
-
}
|
|
377
|
-
return str.length - 1;
|
|
378
|
-
}
|
|
379
|
-
/**
|
|
380
|
-
* Finds the index of the closing ')' that matches the opening '(' at openIndex.
|
|
381
|
-
*/
|
|
382
|
-
function findMatchingCloseParen(str, openIndex) {
|
|
383
|
-
let parenDepth = 1;
|
|
384
|
-
let angleBracketDepth = 0;
|
|
385
|
-
for (let i = openIndex + 1; i < str.length; i++) {
|
|
386
|
-
const char = str[i];
|
|
387
|
-
if (char === "(") parenDepth++;
|
|
388
|
-
else if (char === ")") {
|
|
389
|
-
parenDepth--;
|
|
390
|
-
if (parenDepth === 0) return i;
|
|
391
|
-
} else if (char === "<") angleBracketDepth++;
|
|
392
|
-
else if (char === ">" && str[i - 1] !== "=") angleBracketDepth--;
|
|
393
|
-
}
|
|
394
|
-
return str.length - 1;
|
|
395
|
-
}
|
|
396
|
-
/**
|
|
397
|
-
* Splits a string by commas at the top level (not inside <> or ()).
|
|
398
|
-
*/
|
|
399
|
-
function splitByTopLevelComma(str) {
|
|
400
|
-
const parts = [];
|
|
401
|
-
let current = "";
|
|
402
|
-
let angleBracketDepth = 0;
|
|
403
|
-
let parenDepth = 0;
|
|
404
|
-
for (let i = 0; i < str.length; i++) {
|
|
405
|
-
const char = str[i];
|
|
406
|
-
if (char === "<") angleBracketDepth++;
|
|
407
|
-
else if (char === ">" && str[i - 1] !== "=") angleBracketDepth--;
|
|
408
|
-
else if (char === "(") parenDepth++;
|
|
409
|
-
else if (char === ")") parenDepth--;
|
|
410
|
-
else if (char === "," && angleBracketDepth === 0 && parenDepth === 0) {
|
|
411
|
-
parts.push(current);
|
|
412
|
-
current = "";
|
|
413
|
-
continue;
|
|
414
|
-
}
|
|
415
|
-
current += char;
|
|
416
|
-
}
|
|
417
|
-
parts.push(current);
|
|
418
|
-
return parts;
|
|
419
|
-
}
|
|
420
|
-
/**
|
|
421
|
-
* Processes the content inside generic brackets or function args.
|
|
422
|
-
*/
|
|
423
|
-
function shortenGenericContent(content) {
|
|
424
|
-
return splitByTopLevelComma(content).map((part) => shortenTypePart(part.trim())).join(",");
|
|
425
|
-
}
|
|
426
|
-
/**
|
|
427
|
-
* Shortens a function type like (args)=>returnType.
|
|
428
|
-
*/
|
|
429
|
-
function shortenFunctionType(part) {
|
|
430
|
-
const closeParenIndex = findMatchingCloseParen(part, 0);
|
|
431
|
-
const argsContent = part.substring(1, closeParenIndex);
|
|
432
|
-
const afterParen = part.substring(closeParenIndex + 1);
|
|
433
|
-
const shortenedArgs = argsContent ? shortenGenericContent(argsContent) : "";
|
|
434
|
-
let returnPart = afterParen;
|
|
435
|
-
if (afterParen.startsWith("=>") && afterParen.length > 2) returnPart = "=>" + shortenTypePart(afterParen.substring(2));
|
|
436
|
-
return "(" + shortenedArgs + ")" + returnPart;
|
|
437
|
-
}
|
|
438
|
-
/**
|
|
439
|
-
* Shortens a type/function part, processing paths and generics recursively.
|
|
440
|
-
*/
|
|
441
|
-
function shortenTypePart(part) {
|
|
442
|
-
if (part.startsWith("(")) return shortenFunctionType(part);
|
|
443
|
-
const openBracket = part.indexOf("<");
|
|
444
|
-
if (openBracket === -1) {
|
|
445
|
-
if (!part.includes("/")) return part;
|
|
446
|
-
return part.substring(part.lastIndexOf("/") + 1);
|
|
447
|
-
}
|
|
448
|
-
const namePart = part.substring(0, openBracket);
|
|
449
|
-
const closeBracket = findMatchingCloseBracket(part, openBracket);
|
|
450
|
-
const genericContent = part.substring(openBracket + 1, closeBracket);
|
|
451
|
-
const name = namePart.includes("/") ? namePart.substring(namePart.lastIndexOf("/") + 1) : namePart;
|
|
452
|
-
const shortenedContent = shortenGenericContent(genericContent);
|
|
453
|
-
return name + "<" + shortenedContent + ">";
|
|
454
|
-
}
|
|
455
|
-
|
|
456
336
|
//#endregion
|
|
457
337
|
//#region src/wasm-executor/wasm-errors.ts
|
|
458
338
|
const POOL_INTERNAL_PATHS_SET = new Set(POOL_INTERNAL_PATHS);
|
|
@@ -521,7 +401,6 @@ async function enhanceTestError(error, task, sourceMap, valuesProvided, logPrefi
|
|
|
521
401
|
//#endregion
|
|
522
402
|
//#region src/wasm-executor/index.ts
|
|
523
403
|
const SIG_MISMATCH_ERROR_MSG = "WASM RuntimeError indicates function signature type mismatch during test suite collection. This is likely caused by passing a non-void callback to expect(). Use braces to ensure it returns void e.g. `expect(() => { failingFunction(); }).toThrowError()`. Look for the failing expect() within the describe() block indicated in the stack trace.";
|
|
524
|
-
function covDebug(...args) {}
|
|
525
404
|
function createExecutorPoolError(testFileBasename, context, reason, cause) {
|
|
526
405
|
return createPoolError(`${testFileBasename} - ${context} WASM executor: ${reason}`, POOL_ERROR_NAMES.WASMExecutionHarnessError, void 0, cause);
|
|
527
406
|
}
|
|
@@ -531,7 +410,7 @@ function createExecutorPoolError(testFileBasename, context, reason, cause) {
|
|
|
531
410
|
async function executeWASMDiscovery(binary, sourceMap, testFileBasename, poolOptions, isBinaryInstrumented, handleLog, file, moduleLabel, threadImports, diffOptions) {
|
|
532
411
|
const logPrefix = `[${moduleLabel} Exec] ${getTaskLogLabel(basename(file.filepath), file)}`;
|
|
533
412
|
const wasmModule = await WebAssembly.compile(binary);
|
|
534
|
-
const importObject = createDiscoveryImports(createMemory(poolOptions.testMemoryPagesInitial, poolOptions.testMemoryPagesMax), wasmModule, file, handleLog, logPrefix, isBinaryInstrumented ? createMemory(poolOptions.coverageMemoryPagesInitial, poolOptions.coverageMemoryPagesMax) : void 0, threadImports.
|
|
413
|
+
const importObject = createDiscoveryImports(createMemory(poolOptions.testMemoryPagesInitial, poolOptions.testMemoryPagesMax), wasmModule, file, handleLog, logPrefix, isBinaryInstrumented ? createMemory(poolOptions.coverageMemoryPagesInitial, poolOptions.coverageMemoryPagesMax) : void 0, threadImports.createUserWasmImports);
|
|
535
414
|
const exports = new WebAssembly.Instance(wasmModule, importObject).exports;
|
|
536
415
|
if (typeof exports._start === "function") try {
|
|
537
416
|
exports._start();
|
|
@@ -569,10 +448,13 @@ async function executeWASMTest(test, compilation, testFileBasename, poolOptions,
|
|
|
569
448
|
};
|
|
570
449
|
const base = basename(test.file.filepath);
|
|
571
450
|
const logPrefix = `[${`${moduleLabel} Exec`}] ${getTaskLogLabel(base, test)}`;
|
|
451
|
+
function covDebug(...args) {
|
|
452
|
+
if (poolOptions.debugCoverageExtract) debugOverride(...args);
|
|
453
|
+
}
|
|
572
454
|
const wasmModule = await WebAssembly.compile(compilation.binary);
|
|
573
455
|
const memory = createMemory(poolOptions.testMemoryPagesInitial, poolOptions.testMemoryPagesMax);
|
|
574
456
|
const coverageMemory = collectCoverage ? createMemory(poolOptions.coverageMemoryPagesInitial, poolOptions.coverageMemoryPagesMax) : void 0;
|
|
575
|
-
const { imports, provideFunctionTable } = createTestExecutionImports(memory, wasmModule, test, handleLog, logPrefix, coverageMemory, threadImports.
|
|
457
|
+
const { imports, provideFunctionTable } = createTestExecutionImports(memory, wasmModule, test, handleLog, logPrefix, coverageMemory, threadImports.createUserWasmImports);
|
|
576
458
|
const exports = new WebAssembly.Instance(wasmModule, imports).exports;
|
|
577
459
|
const table = exports.table;
|
|
578
460
|
if (table && typeof table.get === "function") provideFunctionTable(table);
|
|
@@ -613,16 +495,19 @@ async function executeWASMTest(test, compilation, testFileBasename, poolOptions,
|
|
|
613
495
|
coverage.hitCountsByFileAndPosition[filePath] = {};
|
|
614
496
|
covDebug(`${logPrefix} - Extracting hits for source file "${filePath}"`);
|
|
615
497
|
}
|
|
616
|
-
for (const [positionKey,
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
498
|
+
for (const [positionKey, funcInfos] of Object.entries(debugFunctions)) {
|
|
499
|
+
let positionHitCount = 0;
|
|
500
|
+
for (const funcInfo of funcInfos) {
|
|
501
|
+
if (funcInfo.coverageMemoryIndex === void 0) {
|
|
502
|
+
debug(`${logPrefix} - WARNING: NO COVERAGE MEMORY INDEX - func "${funcInfo.name}" (${positionKey}) Skipping hit extraction`);
|
|
503
|
+
continue;
|
|
504
|
+
}
|
|
505
|
+
const hitCount = extractedHitCounters[funcInfo.coverageMemoryIndex] ?? 0;
|
|
506
|
+
covDebug(`${logPrefix} - func "${funcInfo.name}" (${positionKey}) [idx: ${funcInfo.coverageMemoryIndex}]: ${hitCount} hits`);
|
|
507
|
+
positionHitCount += hitCount;
|
|
620
508
|
}
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
if (coverage.hitCountsByFileAndPosition[filePath][positionKey] !== void 0) debug(`${logPrefix} - WARNING: DUPLICATE POSITION - func "${funcInfo.name}" (${positionKey}) already extracted to coverage for ${filePath}`);
|
|
624
|
-
coverage.hitCountsByFileAndPosition[filePath][positionKey] = hitCount;
|
|
625
|
-
if (hitCount > 0) functionsHit++;
|
|
509
|
+
coverage.hitCountsByFileAndPosition[filePath][positionKey] = positionHitCount;
|
|
510
|
+
if (positionHitCount > 0) functionsHit++;
|
|
626
511
|
}
|
|
627
512
|
}
|
|
628
513
|
meta.coverageData = coverage;
|
|
@@ -637,10 +522,6 @@ async function executeWASMTest(test, compilation, testFileBasename, poolOptions,
|
|
|
637
522
|
|
|
638
523
|
//#endregion
|
|
639
524
|
//#region src/pool-thread/rpc-reporter.ts
|
|
640
|
-
const DEBUG_RPC = isDebugModeEnabled();
|
|
641
|
-
function rpcDebug(...args) {
|
|
642
|
-
if (DEBUG_RPC) debug(...args);
|
|
643
|
-
}
|
|
644
525
|
/** Create RPC client from MessagePort */
|
|
645
526
|
function createRpcClient(port) {
|
|
646
527
|
return createBirpc({ onCancel: (_reason) => void 0 }, {
|
|
@@ -651,12 +532,12 @@ function createRpcClient(port) {
|
|
|
651
532
|
/** Report file as queued (before compilation & discovery starts) */
|
|
652
533
|
async function reportFileQueued(rpc, fileTask, logModule, logLabel) {
|
|
653
534
|
await rpc.onQueued(fileTask);
|
|
654
|
-
|
|
535
|
+
debug(`[${logModule} RPC] ${logLabel} - Reported onQueued for file "${fileTask.filepath}" | mode: "${fileTask.mode}" | state: "${fileTask.result ? fileTask.result.state : "--"}"`);
|
|
655
536
|
}
|
|
656
537
|
/** Report file collection complete with full task tree */
|
|
657
538
|
async function reportFileCollected(rpc, fileTask, logModule, logLabel) {
|
|
658
539
|
await rpc.onCollected([fileTask]);
|
|
659
|
-
|
|
540
|
+
debug(`[${logModule} RPC] ${logLabel} - Reported onCollected for file "${fileTask.filepath}" | ${fileTask.tasks.length} tasks | mode: "${fileTask.mode}" | state: "${fileTask.result?.state}"`);
|
|
660
541
|
}
|
|
661
542
|
/** Report file-level error (compilation/discovery failure) as "suite-failed-early" */
|
|
662
543
|
async function reportFileError(rpc, fileTask, logModule, logLabel) {
|
|
@@ -671,7 +552,7 @@ async function reportFileError(rpc, fileTask, logModule, logLabel) {
|
|
|
671
552
|
void 0
|
|
672
553
|
];
|
|
673
554
|
await rpc.onTaskUpdate([taskPack], [eventPack]);
|
|
674
|
-
|
|
555
|
+
debug(`[${logModule} RPC] ${logLabel} - Reported "suite-failed-early" task update for "${fileTask.filepath}"`);
|
|
675
556
|
}
|
|
676
557
|
/** Report suite-prepare event */
|
|
677
558
|
async function reportSuitePrepare(rpc, suite, logModule, base) {
|
|
@@ -686,7 +567,7 @@ async function reportSuitePrepare(rpc, suite, logModule, base) {
|
|
|
686
567
|
void 0
|
|
687
568
|
];
|
|
688
569
|
await rpc.onTaskUpdate([taskPack], [eventPack]);
|
|
689
|
-
|
|
570
|
+
debug(`[${logModule} RPC] ${getTaskLogLabel(base, suite)} - Reported "suite-prepare" task update | state: "${suite.result?.state}"`);
|
|
690
571
|
}
|
|
691
572
|
/** Report suite-finished event */
|
|
692
573
|
async function reportSuiteFinished(rpc, suite, logModule, base, vitestVersion = "v4") {
|
|
@@ -715,7 +596,7 @@ async function reportSuiteFinished(rpc, suite, logModule, base, vitestVersion =
|
|
|
715
596
|
void 0
|
|
716
597
|
];
|
|
717
598
|
await Promise.all([coveragePromise, rpc.onTaskUpdate([taskPack], [eventPack])]);
|
|
718
|
-
|
|
599
|
+
debug(`${rpcLogPrefix} - Reported "suite-finished" task update | state: "${suite.result?.state}" | duration: ${suite.result?.duration?.toFixed(2) ?? "--"} ms`);
|
|
719
600
|
}
|
|
720
601
|
async function reportTestTaskUpdate(rpc, test, logModule, base, updateEvent) {
|
|
721
602
|
const taskPack = [
|
|
@@ -728,9 +609,9 @@ async function reportTestTaskUpdate(rpc, test, logModule, base, updateEvent) {
|
|
|
728
609
|
updateEvent,
|
|
729
610
|
void 0
|
|
730
611
|
];
|
|
731
|
-
|
|
612
|
+
debug(`[${logModule} RPC] ${getTaskLogLabel(base, test)} - Reporting "${updateEvent}" task update... | state: "${test.result?.state}"${updateEvent === "test-prepare" ? "" : ` | duration: ${test.result?.duration?.toFixed(2) ?? "--"} ms`}`);
|
|
732
613
|
await rpc.onTaskUpdate([taskPack], [eventPack]);
|
|
733
|
-
|
|
614
|
+
debug(`[${logModule} RPC] ${getTaskLogLabel(base, test)} - Reported "${updateEvent}" task update | state: "${test.result?.state}"${updateEvent === "test-prepare" ? "" : ` | duration: ${test.result?.duration?.toFixed(2) ?? "--"} ms`}`);
|
|
734
615
|
}
|
|
735
616
|
/** Report test starting execution */
|
|
736
617
|
async function reportTestPrepare(rpc, test, logModule, base) {
|
|
@@ -773,7 +654,7 @@ async function reportUserConsoleLogs(rpc, logs, logModule, base, task) {
|
|
|
773
654
|
if (stdContent.length > 0) reportPromises.push(rpc.onUserConsoleLog(stdLog));
|
|
774
655
|
if (errorContent.length > 0) reportPromises.push(rpc.onUserConsoleLog(errorLog));
|
|
775
656
|
await Promise.all(reportPromises);
|
|
776
|
-
|
|
657
|
+
debug(`[${logModule} RPC] ${getTaskLogLabel(base, task)} - Reported onUserConsoleLog | ${logs.length} messages`);
|
|
777
658
|
}
|
|
778
659
|
/** Flush any pending RPC updates */
|
|
779
660
|
async function flushRpcUpdates(rpc) {
|
|
@@ -799,4 +680,4 @@ async function loadUserWasmImportsFactory(relativePath, projectRoot, logModule)
|
|
|
799
680
|
|
|
800
681
|
//#endregion
|
|
801
682
|
export { createRpcClient, executeWASMDiscovery, executeWASMTest, flushRpcUpdates, loadUserWasmImportsFactory, reportFileCollected, reportFileError, reportFileQueued, reportSuiteFinished, reportSuitePrepare, reportTestFinished, reportTestPrepare, reportTestRetried, reportUserConsoleLogs };
|
|
802
|
-
//# sourceMappingURL=load-user-imports-
|
|
683
|
+
//# sourceMappingURL=load-user-imports-CYTTU22Q.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"load-user-imports-CYTTU22Q.mjs","names":[],"sources":["../src/util/assemblyscript/binding-helpers.ts","../src/wasm-executor/wasm-memory.ts","../src/wasm-executor/wasm-console.ts","../src/wasm-executor/collect-options.ts","../src/wasm-executor/wasm-imports.ts","../src/wasm-executor/wasm-errors.ts","../src/wasm-executor/index.ts","../src/pool-thread/rpc-reporter.ts","../src/pool-thread/load-user-imports.ts"],"sourcesContent":["const STRING_EXTRACT_CHUNK_SIZE = 1024 as const;\n\n/**\n * Decode an AssemblyScript string from WASM memory, using the length stored at\n * the beginning of the string.\n *\n * This approach is borrowed from AssemblyScript with changes for clarity.\n * AssemblyScript is released under the Apache 2.0 license, included here.\n * \n * When a string argument crosses the boundary to JS, we get a pointer to the\n * string data in WASM memory. WASM strings store their length in the 4 bytes\n * before the string data pointer so we know how much to read from memory.\n *\n * @param memory - WebAssembly memory instance\n * @param pointer - Pointer to the start of the string\n * @returns Decoded string\n */\nexport function liftString(\n memory: WebAssembly.Memory,\n pointer: number,\n): string | undefined {\n if (!pointer) return undefined;\n\n const unsigned = pointer >>> 0;\n \n const lengthPtr = unsigned - 4;\n\n // convert byte-based lengthPtr to uint32-based index for Uint32Array\n // with: bytes / 4 (=== bytes >>> 2) and read length\n const uint32LengthPtr = lengthPtr >>> 2;\n const byteOffsetLength = new Uint32Array(memory.buffer)[uint32LengthPtr];\n\n if (byteOffsetLength === 0) return '';\n \n // calculate end pointer, and convert byte-based start and end pointers\n // to uint16-based indexes for Uint16Array with: bytes / 2 (=== bytes >>> 1) \n const uint16EndPtr = (unsigned + byteOffsetLength!) >>> 1;\n let uint16StartPtr = unsigned >>> 1;\n\n const memoryU16 = new Uint16Array(memory.buffer);\n let string = '';\n\n // extract in 1024-character chunks to avoid hitting spread operator limit\n while (uint16EndPtr - uint16StartPtr > STRING_EXTRACT_CHUNK_SIZE) {\n string += String.fromCharCode(\n ...memoryU16.subarray(uint16StartPtr, uint16StartPtr += STRING_EXTRACT_CHUNK_SIZE)\n );\n }\n\n return string + String.fromCharCode(...memoryU16.subarray(uint16StartPtr, uint16EndPtr));\n}\n","import { liftString } from '../util/assemblyscript/binding-helpers.js';\n\n/**\n * Create a WebAssembly memory instance\n * Used for imported memory pattern (matches --importMemory flag)\n */\nexport function createMemory(initialPages: number, maximumPages?: number): WebAssembly.Memory {\n return new WebAssembly.Memory({ initial: initialPages, maximum: maximumPages });\n}\n\n/**\n * Decode AssemblyScript abort information\n *\n * Helper for handling abort() calls from AssemblyScript runtime.\n * Decodes the error message and file path from WASM memory.\n *\n * @param memory - WebAssembly memory instance\n * @param msgPtr - Pointer to error message string (or 0 if none)\n * @param filePtr - Pointer to file path string (or 0 if none)\n * @param line - Line number where abort occurred\n * @param column - Column number where abort occurred\n * @returns Decoded message and location (null if no meaningful location info)\n */\nexport function decodeAbortInfo(\n memory: WebAssembly.Memory,\n msgPtr: number,\n filePtr: number,\n line: number,\n column: number\n): { message: string; location: string | null } {\n const errorMsg = liftString(memory, msgPtr) ?? 'Unknown error'; \n const filePath = liftString(memory, filePtr);\n\n // Only include location if we have meaningful file info (not null/empty and not at 0:0)\n const hasLocation = filePath && filePath !== 'unknown' && (line !== 0 || column !== 0);\n const location = hasLocation ? `${filePath}:${line}:${column}` : null;\n\n return {\n message: errorMsg,\n location: location,\n };\n}\n","import type { AssemblyScriptConsoleLogHandler } from '../types/types.js';\nimport { liftString } from '../util/assemblyscript/binding-helpers.js';\n\nexport function createWasmConsole(\n memory: WebAssembly.Memory,\n handleLog: AssemblyScriptConsoleLogHandler\n) {\n const getMessage = (msgPtr: number, memory: WebAssembly.Memory, prefix: string = ''): string => {\n return `${prefix}${msgPtr ? liftString(memory, msgPtr) : '<no message>'}`;\n };\n\n const timersByLabel: { [label: string]: number } = {};\n\n // provides the AssemblyScript \"brower-like console\" from AS std lib\n // see https://github.com/AssemblyScript/assemblyscript/blob/v0.28.9/std/assembly/index.d.ts#L2609\n return {\n 'console.assert': <T>(assertion: T, msgPtr: number): void => {\n if (!assertion) {\n const msg = getMessage(msgPtr, memory);\n handleLog(`Assertion failed${msg ? `: ${msg}` : ''}`);\n }\n },\n 'console.log': (msgPtr: number): void => {\n handleLog(getMessage(msgPtr, memory));\n },\n 'console.debug': (msgPtr: number): void => {\n handleLog(getMessage(msgPtr, memory, 'Debug: '));\n },\n 'console.info': (msgPtr: number): void => {\n handleLog(getMessage(msgPtr, memory, 'Info: '));\n },\n 'console.warn': (msgPtr: number): void => {\n handleLog(getMessage(msgPtr, memory, 'Warning: '), true);\n },\n 'console.error': (msgPtr: number): void => {\n handleLog(getMessage(msgPtr, memory, 'Error: '), true);\n },\n 'console.time': (labelPtr?: number): void => {\n const label = labelPtr ? liftString(memory, labelPtr) ?? 'default' : 'default';\n timersByLabel[label] = performance.now();\n },\n 'console.timeLog': (labelPtr?: number): void => {\n const label = labelPtr ? liftString(memory, labelPtr) ?? 'default' : 'default';\n const start = timersByLabel[label];\n let msg = '';\n if (start === undefined) {\n msg = `Warning: No such label '${label}' for console.timeLog()`;\n } else {\n msg = `${label}: ${(performance.now() - start).toFixed(3)}ms`;\n }\n handleLog(msg);\n },\n 'console.timeEnd': (labelPtr?: number): void => {\n const label = labelPtr ? liftString(memory, labelPtr) ?? 'default' : 'default';\n const start = timersByLabel[label];\n let msg = '';\n if (start === undefined) {\n msg = `Warning: No such label '${label}' for console.timeLog()`;\n } else {\n msg = `${label}: ${(performance.now() - start).toFixed(3)}ms`;\n }\n handleLog(msg);\n delete timersByLabel[label];\n },\n\n trace(msgPtr: number, n: number, a0: any, a1: any, a2: any, a3: any): void {\n const msg = liftString(memory, msgPtr);\n const args: any[] = [a0, a1, a2, a3];\n const nArgs: any[] = n && n > 0 ? args.slice(0, n) : args;\n\n console.trace(`WASM Trace:${msg ? ` ${msg}` : ''}`, ...nArgs);\n },\n };\n}\n","import { AssemblyScriptTestOptions } from '../types/types.js';\n\nconst TEST_OPTION_UNDEFINED: number = -1;\nconst TEST_OPTION_TRUE: number = 1;\n\nexport function mergeAssemblyScriptTestOptions(\n baseOptions: AssemblyScriptTestOptions,\n timeout: number,\n retry: number,\n skip: number,\n only: number,\n fails: number,\n): AssemblyScriptTestOptions {\n const options: AssemblyScriptTestOptions = { ...baseOptions };\n \n // numerical options\n if (timeout > TEST_OPTION_UNDEFINED) {\n options.timeout = timeout;\n }\n if (retry > TEST_OPTION_UNDEFINED) {\n options.retry = retry;\n }\n\n // boolean options\n if (skip > TEST_OPTION_UNDEFINED) {\n options.skip = skip === TEST_OPTION_TRUE ? true : false;\n }\n if (only > TEST_OPTION_UNDEFINED) {\n options.only = only === TEST_OPTION_TRUE ? true : false;\n }\n if (fails > TEST_OPTION_UNDEFINED) {\n options.fails = fails === TEST_OPTION_TRUE ? true : false;\n }\n\n return options;\n}\n","import type { File, Suite, Test } from '@vitest/runner/types';\n\nimport type {\n AssemblyScriptConsoleLogHandler,\n AssemblyScriptSuiteTaskMeta,\n AssemblyScriptTestError,\n AssemblyScriptTestTaskMeta,\n FailedAssertion,\n WasmImportsFactory,\n} from '../types/types.js';\nimport { AS_POOL_WASM_IMPORTS_ENV, POOL_ERROR_NAMES, TEST_ERROR_NAMES } from '../types/constants.js';\nimport { debug } from '../util/debug.js';\nimport { createPoolError, createPoolErrorFromAnyError } from '../util/pool-errors.js';\nimport { liftString } from '../util/assemblyscript/binding-helpers.js';\nimport { extractCallStack } from './source-maps.js';\nimport { decodeAbortInfo } from './wasm-memory.js';\nimport { createWasmConsole } from './wasm-console.js';\nimport { mergeAssemblyScriptTestOptions } from './collect-options.js';\nimport { createSuiteTask, createTestTask, failTest } from '../util/vitest-tasks.js';\n\nfunction createUserWasmImports(\n createWasmImports: WasmImportsFactory | undefined,\n memory: WebAssembly.Memory,\n module: WebAssembly.Module,\n logPrefix: string\n) {\n let userEnvImports: WebAssembly.ModuleImports | undefined;\n let userCustomEnvImports: WebAssembly.Imports | undefined;\n\n if (createWasmImports) {\n try {\n const start = performance.now();\n const userImports: WebAssembly.Imports = createWasmImports({\n memory,\n module,\n utils: {\n liftString: (stringPtr: number) => liftString(memory, stringPtr)\n }\n });\n debug(`${logPrefix} Created user WASM imports for test execution in ${(performance.now() - start).toFixed(2)} ms`);\n\n userEnvImports = userImports?.env;\n \n if (userEnvImports) {\n userCustomEnvImports = { ...userImports };\n delete userCustomEnvImports.env;\n }\n } catch (error) {\n throw createPoolErrorFromAnyError(\n `Error creating user WASM Imports`,\n POOL_ERROR_NAMES.PoolConfigError,\n error\n );\n }\n }\n\n return { userEnvImports, userCustomEnvImports };\n}\n\n/**\n * Create import object for test discovery\n */\nexport function createDiscoveryImports(\n memory: WebAssembly.Memory,\n module: WebAssembly.Module,\n file: File,\n handleLog: AssemblyScriptConsoleLogHandler,\n logPrefix: string,\n coverageMemory?: WebAssembly.Memory,\n createWasmImports?: WasmImportsFactory,\n): WebAssembly.Imports {\n const suiteStack: Suite[] = [file];\n\n const {\n userEnvImports,\n userCustomEnvImports\n } = createUserWasmImports(createWasmImports, memory, module, logPrefix);\n \n return {\n env: {\n // users can choose to hide these with their own\n ...createWasmConsole(memory, handleLog),\n\n // user imports for \"env\"\n ...(userEnvImports ?? {}),\n\n memory,\n\n // handle runtime aborts, which are always unexpected during discovery\n abort(msgPtr: number, filePtr: number, line: number, column: number) {\n const { message, location } = decodeAbortInfo(memory, msgPtr, filePtr, line, column);\n const msgAtLoc = `${message}${location ? ` at ${location}` : ''}`;\n \n debug(`${logPrefix} - Unexpected abort during test discovery: ${msgAtLoc}`);\n\n // Create error to capture V8 stack trace and extract V8 call stack before throwing.\n // This gives us WAT line:column positions that can be mapped to AS source\n const rawCallStack = extractCallStack(new Error());\n\n // Send the test error that we will report to vitest in the PoolError's `cause` field.\n // The rawCallStack will be enahnced and deleted by the executor, with the parsed result\n // added to the reported test error.\n const testError: AssemblyScriptTestError = {\n message,\n name: TEST_ERROR_NAMES.WASMRuntimeError,\n };\n\n throw createPoolError(\n msgAtLoc,\n POOL_ERROR_NAMES.WASMExecutionAbortError,\n undefined, // stack\n testError, // cause\n rawCallStack\n );\n },\n },\n\n [AS_POOL_WASM_IMPORTS_ENV]: {\n\n ...(coverageMemory ? { __coverage_memory: coverageMemory } : {}),\n\n // stubs during discovery\n __assertion_pass() {},\n __assertion_fail() {},\n __expect_throw() {},\n __end_expect_throw() {},\n\n __begin_register_suite(\n namePtr: number,\n timeout: number,\n retry: number,\n skip: number,\n only: number,\n fails: number,\n ) {\n const parentSuite = suiteStack[suiteStack.length - 1]!;\n const defaultTestOptions = (parentSuite.meta as AssemblyScriptSuiteTaskMeta).defaultTestOptions;\n const suiteName = liftString(memory, namePtr) ?? 'unknown suite';\n const options = mergeAssemblyScriptTestOptions(defaultTestOptions, timeout, retry, skip, only, fails);\n const suite = createSuiteTask(suiteName, file, parentSuite, options);\n suiteStack.push(suite);\n\n debug(\n `${logPrefix} - Registering Suite \"${suite.name}\" | timeout: ${options.timeout} ms | retry: ${options.retry}`\n + ` | skip: ${options.skip} | only: ${options.only} | fails: ${options.fails} `\n + ` | parent: \"${suite.suite?.name}\" (parent idx: ${(suite.meta as AssemblyScriptSuiteTaskMeta).idxInParentTasks})`\n );\n },\n \n __end_register_suite(_namePtr: number) {\n const suite = suiteStack.pop();\n\n debug(\n `${logPrefix} - Registered Suite \"${suite?.name}\" | ${suite?.tasks.length} top-level tasks | mode: \"${suite?.mode}\"`\n + ` | parent: \"${suite?.suite?.name}\" (parent idx: ${(suite?.meta as AssemblyScriptSuiteTaskMeta)?.idxInParentTasks})`\n );\n },\n\n // called by test() to register test names and function indices\n __register_test(\n namePtr: number,\n fnIndex: number,\n timeout: number,\n retry: number,\n skip: number,\n only: number,\n fails: number,\n ) {\n const parentSuite = suiteStack[suiteStack.length - 1]!;\n const defaultTestOptions = (parentSuite.meta as AssemblyScriptSuiteTaskMeta).defaultTestOptions;\n const testName = liftString(memory, namePtr) ?? 'unknown test';\n const options = mergeAssemblyScriptTestOptions(defaultTestOptions, timeout, retry, skip, only, fails);\n const test = createTestTask(testName, fnIndex, file, parentSuite, options);\n \n debug(`${logPrefix} - Registered test \"${test.name}\" | mode (pre-interp): \"${test.mode}\"`\n + ` | fnIndex ${fnIndex} | timeout: ${options.timeout} ms | retry: ${options.retry} | skip: ${options.skip}`\n + ` | only: ${options.only} | fails: ${options.fails} | suite: \"${test.suite?.name}\"`\n + ` (parent idx: ${(test.meta as AssemblyScriptTestTaskMeta).idxInParentTasks})`\n );\n },\n },\n\n // user imports for any other environments they defined\n ...(userCustomEnvImports ?? {}),\n };\n}\n\n/**\n * Create import object for test execution\n *\n * Used during test execution to capture test results / assertions, and to handle\n * runtime aborts as expected cases for test execution by capturing the error on the test meta.\n */\nexport function createTestExecutionImports(\n memory: WebAssembly.Memory,\n module: WebAssembly.Module,\n test: Test,\n handleLog: AssemblyScriptConsoleLogHandler,\n logPrefix: string,\n coverageMemory?: WebAssembly.Memory,\n createWasmImports?: WasmImportsFactory,\n): { imports: WebAssembly.Imports; provideFunctionTable: (table: WebAssembly.Table) => void; } {\n // execution imports are created per-test, so these represent per-test state\n let isExpectingError: boolean = false;\n let expectedErrorMsgStr: string | undefined;\n let wasmFunctionTable: WebAssembly.Table | undefined;\n\n const {\n userEnvImports,\n userCustomEnvImports\n } = createUserWasmImports(createWasmImports, memory, module, logPrefix);\n\n const imports = {\n env: {\n // users can choose to hide these with their own\n ...createWasmConsole(memory, handleLog),\n\n // user imports for \"env\"\n ...(userEnvImports ?? {}),\n\n memory,\n\n abort(msgPtr: number, filePtr: number, line: number, column: number) {\n const { message, location } = decodeAbortInfo(memory, msgPtr, filePtr, line, column);\n const msgAtLoc = `${message}${location ? ` at ${location}` : ''}`;\n \n debug(`${logPrefix} - Handling test execution abort: ${msgAtLoc}`);\n\n let failureMessage = message;\n\n if (isExpectingError) {\n if (!expectedErrorMsgStr || message.includes(expectedErrorMsgStr)) {\n (test.meta as AssemblyScriptTestTaskMeta).assertionsPassedCount++;\n \n debug(`${logPrefix} - Thrown error matches expected - assertion passes`);\n\n throw createPoolError(\n `AssemblyScript abort() import called for expected error throw in test \"${test.name}\"`,\n POOL_ERROR_NAMES.WASMExecutionAbortError\n );\n } else {\n failureMessage = `expected function to throw \"${expectedErrorMsgStr}\" error but received \"${message}\"`;\n\n (test.meta as AssemblyScriptTestTaskMeta).assertionsFailed.push({\n message: failureMessage,\n typeName: 'Error',\n valuesProvided: true,\n actual: message,\n expected: expectedErrorMsgStr\n } satisfies FailedAssertion);\n\n const errStr = `Thrown error does not match expected | Expected: \"${expectedErrorMsgStr}\" | Actual: \"${message}\"`\n debug(`${logPrefix} - Assertion failed: ${errStr}`);\n }\n }\n\n // Create error to capture V8 stack trace and extract V8 call stack before throwing.\n // This gives us WAT line:column positions that can be mapped to AS source\n const capturedError = new Error();\n\n failTest(test, failureMessage, capturedError, logPrefix);\n\n // Must throw here to halt WASM execution on an assertion or runtime failure for this test.\n // This will be caught by the executor and reported as an appropriate test error\n // using test.meta.lastError value set in failTest()\n throw createPoolError(\n `AssemblyScript abort() import called during test execution for ${test.name}`,\n POOL_ERROR_NAMES.WASMExecutionAbortError,\n );\n },\n },\n\n [AS_POOL_WASM_IMPORTS_ENV]: {\n \n ...(coverageMemory ? { __coverage_memory: coverageMemory } : {}),\n\n // stubs during execution\n __register_test() {},\n __begin_register_suite() {},\n __end_register_suite() {},\n\n __assertion_pass() {\n (test.meta as AssemblyScriptTestTaskMeta).assertionsPassedCount++;\n },\n\n __assertion_fail(msgPtr: number, typeNamePtr: number, valuesProvided: boolean, actualPtr?: number, expectedPtr?: number) {\n const errorMsg = liftString(memory, msgPtr);\n const assertionValueType = liftString(memory, typeNamePtr);\n let actual: string | undefined;\n let expected: string | undefined;\n \n const assertionFailure: FailedAssertion = {\n message: errorMsg,\n typeName: assertionValueType,\n valuesProvided: Boolean(valuesProvided)\n };\n \n if (valuesProvided && actualPtr && expectedPtr) {\n assertionFailure.actual = liftString(memory, actualPtr);\n assertionFailure.expected = liftString(memory, expectedPtr);\n }\n \n (test.meta as AssemblyScriptTestTaskMeta).assertionsFailed.push(assertionFailure);\n \n const valuesMsg = valuesProvided ? ` | Value Type: ${assertionValueType}`\n + ` | Expected: \\`${expected !== undefined ? expected : ''}\\` | Actual: \\`${actual !== undefined ? actual : ''}\\``\n : '';\n debug(`${logPrefix} - Assertion failed: ${errorMsg}${valuesMsg}`);\n },\n\n __expect_throw(fnIndex: number, expectedErrorMsgPtr?: number) {\n isExpectingError = true;\n if (expectedErrorMsgPtr) {\n expectedErrorMsgStr = liftString(memory, expectedErrorMsgPtr);\n }\n\n debug(`${logPrefix} - Registered expected error throw: ${expectedErrorMsgStr !== undefined\n ? `\"${expectedErrorMsgStr}\"` : '<any>'}`\n );\n\n if (wasmFunctionTable && typeof wasmFunctionTable.get === 'function') {\n const fn = wasmFunctionTable.get(fnIndex);\n if (!fn) {\n throw createPoolError(\n `Could not access function (fnPtr ${fnIndex}) which is expected to throw in test \"${test.name}\"`,\n POOL_ERROR_NAMES.WASMExecutionHarnessError,\n );\n }\n\n // successful:\n // - throws in WASM, calls abort handler\n // - abort handler confirms error matches expected, does NOT fail test, halts execution with WASMExecutionAbortError\n // - executor catches WASMExecutionAbortError as 'known' and proceeds to process & report passed test\n // failure (wrong error):\n // - throws in WASM, calls abort handler\n // - abort handler confirms error matches mismatch, failTest packages up an appropriate test error\n // - abort handler halts execution with WASMExecutionAbortError containing test error\n // - executor catches WASMExecutionAbortError as 'known' and proceeds to process & report test error\n // failure (no error):\n // - does NOT throw in WASM\n // - WASM continues executing and calls __end_expect_throw\n // - __end_expect_throw sees it is STILL expecting an error, failTest packages up an appropriate test error\n // - __end_expect_throw halts execution with WASMExecutionAbortError containing test error\n // - executor catches WASMExecutionAbortError as 'known' and proceeds to process & report test error\n debug(`${logPrefix} - Calling function (idx ${fnIndex})`);\n fn();\n } else {\n throw createPoolError(\n `Could not access WASM function table to call function expected to throw in test \"${test.name}\"`,\n POOL_ERROR_NAMES.WASMExecutionHarnessError,\n );\n }\n },\n\n __end_expect_throw() {\n if (isExpectingError) {\n const isAnyErr: boolean = !!expectedErrorMsgStr;\n const failureMessage = `expected function to throw ${isAnyErr ?\n `\"${expectedErrorMsgStr}\"` : 'any'\n } error - did not throw`;\n\n (test.meta as AssemblyScriptTestTaskMeta).assertionsFailed.push({\n message: failureMessage,\n typeName: 'Error',\n valuesProvided: !isAnyErr,\n actual: undefined,\n expected: expectedErrorMsgStr\n } satisfies FailedAssertion);\n\n const errStr = `Expected thrown error but got none | Expected: \"${expectedErrorMsgStr}\"`\n debug(`${logPrefix} - Assertion failed: ${errStr}`);\n\n failTest(test, failureMessage, new Error(), logPrefix);\n\n // Must throw here to halt WASM execution on an assertion or runtime failure for this test.\n // This will be caught by the executor and reported as an appropriate test error\n // using test.meta.lastError value set in failTest()\n throw createPoolError(\n `AssemblyScript __end_expect_throw() import called during test execution for ${test.name}`,\n POOL_ERROR_NAMES.WASMExecutionAbortError,\n );\n }\n },\n },\n\n // user imports for any other environments they defined\n ...(userCustomEnvImports ?? {}),\n };\n\n return {\n imports,\n provideFunctionTable: (table: WebAssembly.Table) => {\n debug(`${logPrefix} - Got WASM function table | length: ${table.length}`);\n wasmFunctionTable = table;\n },\n };\n}\n","/**\n * Error Enhancement and Source Mapping\n *\n * This module handles mapping WASM errors to AssemblyScript source locations\n * using source maps. It enhances error messages and stack traces with accurate\n * file:line:column information for better developer experience.\n */\n\nimport { type ParsedStack } from '@vitest/utils';\nimport { diff, type SerializedDiffOptions } from '@vitest/utils/diff';\nimport type { Test, Suite } from '@vitest/runner/types';\nimport { type RawSourceMap, SourceMapConsumer } from 'source-map';\n\nimport type { AssemblyScriptTestError, HighlightFunc, WebAssemblyCallSite } from '../types/types.js';\nimport { debug } from '../util/debug.js';\nimport { POOL_INTERNAL_PATHS, TEST_ERROR_NAMES } from '../types/constants.js';\nimport { createWebAssemblyCallSite, parseSourceMap } from './source-maps.js';\nimport { getShortFunctionName } from './wasm-names.js';\nimport {\n getSourceCodeFrameString,\n toPlaintextStackFrameString,\n toVitestLikeStackFrameString,\n} from '../util/test-error-formatting.js';\n\nconst POOL_INTERNAL_PATHS_SET = new Set(POOL_INTERNAL_PATHS);\n\nasync function sourceMapRawCallStack(\n rawCallStack: NodeJS.CallSite[],\n sourceMap: RawSourceMap,\n loggingPrefix: string,\n): Promise<WebAssemblyCallSite[]> {\n const mappedStack: WebAssemblyCallSite[] = [];\n\n if (!rawCallStack || rawCallStack.length === 0) {\n return mappedStack;\n }\n\n const sourceMapConsumer = await new SourceMapConsumer(sourceMap);\n \n // map stack call sites from raw WASM locations to source locations \n rawCallStack.forEach(callSite => {\n const mappedCallSite = createWebAssemblyCallSite(callSite, sourceMapConsumer, loggingPrefix);\n if (mappedCallSite) {\n mappedStack.push(mappedCallSite);\n }\n }); \n \n sourceMapConsumer.destroy();\n\n return mappedStack;\n}\n\n// Parse source-mapped stack array to Vitest TestError reporting format\nfunction parseMappedStack(mappedStack: WebAssemblyCallSite[]): ParsedStack[] {\n return mappedStack\n // filter out frames for internal assertion framework calls\n // (e.g. assert(), assertEqual(), etc) by known location, for more concise/meaningful error stack report\n .filter(frame => !(POOL_INTERNAL_PATHS_SET.has(frame.location.filePath)))\n \n // map to format that vitest reporter can display\n .map(frame => ({\n method: getShortFunctionName(frame.functionName),\n file: frame.location.filePath,\n line: frame.location.line,\n column: frame.location.column + 1, // Convert from raw 0-indexed to 1-indexed for display\n }));\n}\n\nexport async function processWASMErrorStack(\n rawCallStack: NodeJS.CallSite[],\n sourceMap: string,\n loggingPrefix: string,\n): Promise<{ parsedStack: ParsedStack[], parsedSourceMap: RawSourceMap }> {\n const sourceMapObj = parseSourceMap(sourceMap);\n\n // map stack call sites from WASM locations to source code locations \n const sourceMappedStack = await sourceMapRawCallStack(rawCallStack, sourceMapObj, loggingPrefix);\n\n debug(`${loggingPrefix} - Mapped ${rawCallStack.length} call sites to ${sourceMappedStack.length} source locations`);\n\n return {\n parsedStack: parseMappedStack(sourceMappedStack),\n parsedSourceMap: sourceMapObj,\n };\n}\n\n/**\n * Enhance reportable test error on the provided test result with source mapped stack locations\n * and a formatted diff based on the error type\n */\nexport async function enhanceTestError(\n error: AssemblyScriptTestError,\n task: Test | Suite,\n sourceMap: string,\n valuesProvided: boolean,\n logPrefix: string,\n highlight: HighlightFunc,\n rawCallStack?: NodeJS.CallSite[],\n diffOptions?: SerializedDiffOptions\n): Promise<AssemblyScriptTestError> {\n const isAssertionFailure = error.name === TEST_ERROR_NAMES.AssertionError;\n let expectedVsActualDiffString: string = '';\n\n if (isAssertionFailure && valuesProvided) {\n // remain undefined if there were no expected/actual values provided with the assertion failure\n expectedVsActualDiffString = diff(error.expected, error.actual, diffOptions) ?? '';\n }\n\n // if there's no stack to map, set the expected vs actual diff (if any) and return\n if (!rawCallStack || rawCallStack.length === 0) {\n error.diff = expectedVsActualDiffString;\n\n // stack is used by vitest for error deduplication, so make sure it is set\n error.stack = `${task.name} - ${error.message}`;\n\n return error;\n }\n\n // map stack call sites from WASM locations to source locations\n const { parsedStack, parsedSourceMap } = await processWASMErrorStack(rawCallStack, sourceMap, logPrefix);\n \n // build additional strings to add to test error's `diff` field based on parsed stack contents\n let primaryStackFrameString: string | undefined;\n let highlightedSourceCodeFrameString: string | undefined;\n \n if (parsedStack.length > 0) {\n const primaryStackFrame = parsedStack[0]!;\n \n primaryStackFrameString = toVitestLikeStackFrameString(primaryStackFrame);\n \n // Test error is set to rest of the stack without the first frame.\n // Vitest will report the ParsedError[] on TestError.stacks below the diff we set.\n error.stacks = parsedStack.slice(1);\n\n // get source code diff from source map source content\n highlightedSourceCodeFrameString = getSourceCodeFrameString(parsedSourceMap, primaryStackFrame, highlight);\n\n debug(`${logPrefix} - Enhanced ${error.name} error with parsed source stack`);\n }\n\n // Use the diff field as our way to show all output (other than result.error.stacks)\n if (isAssertionFailure) {\n error.diff = [\n `${expectedVsActualDiffString}${expectedVsActualDiffString ? '\\n\\n' : ''}`,\n `${primaryStackFrameString}\\n`,\n `${highlightedSourceCodeFrameString}`,\n ].join('');\n } else {\n error.diff = [\n `${primaryStackFrameString}\\n`,\n `${highlightedSourceCodeFrameString}`,\n ].join('');\n }\n\n // stack is used by vitest for error deduplication, so make sure it is set\n error.stack = parsedStack.map(toPlaintextStackFrameString).join('\\n');\n \n debug(`[${logPrefix} - Enhanced ${error.name} error with diffs`);\n\n return error;\n}\n","import { basename } from 'node:path';\nimport type { SerializedDiffOptions } from '@vitest/utils/diff';\nimport type { File, Test } from '@vitest/runner/types';\n\nimport type {\n AssemblyScriptConsoleLogHandler,\n AssemblyScriptPoolError,\n AssemblyScriptTestError,\n AssemblyScriptTestTaskMeta,\n CoverageData,\n ResolvedAssemblyScriptPoolOptions,\n ThreadImports,\n WASMCompilation,\n WASMExecutorPerfTimings,\n} from '../types/types.js';\nimport { POOL_ERROR_NAMES, TEST_ERROR_NAMES } from '../types/constants.js';\nimport { debug, debugOverride } from '../util/debug.js';\nimport { createMemory } from './wasm-memory.js';\nimport { createDiscoveryImports, createTestExecutionImports } from './wasm-imports.js';\nimport { enhanceTestError } from './wasm-errors.js';\nimport { createPoolError, createPoolErrorFromAnyError } from '../util/pool-errors.js';\nimport { getTaskLogLabel } from '../util/vitest-tasks.js';\nimport { extractCallStack } from './source-maps.js';\n\nconst SIG_MISMATCH_ERROR_MSG = `WASM RuntimeError indicates function signature type mismatch during test suite collection.`\n + ` This is likely caused by passing a non-void callback to expect().`\n + ` Use braces to ensure it returns void e.g. \\`expect(() => { failingFunction(); }).toThrowError()\\`.`\n + ` Look for the failing expect() within the describe() block indicated in the stack trace.`;\n\nfunction createExecutorPoolError(\n testFileBasename: string,\n context: string,\n reason: string,\n cause?: any,\n): AssemblyScriptPoolError {\n return createPoolError(\n `${testFileBasename} - ${context} WASM executor: ${reason}`,\n POOL_ERROR_NAMES.WASMExecutionHarnessError,\n undefined,\n cause\n );\n}\n\n/**\n * Discover tests via test() and suites via describe() registration calls\n */\nexport async function executeWASMDiscovery(\n binary: Uint8Array,\n sourceMap: string,\n testFileBasename: string,\n poolOptions: ResolvedAssemblyScriptPoolOptions,\n isBinaryInstrumented: boolean,\n handleLog: AssemblyScriptConsoleLogHandler,\n file: File,\n moduleLabel: string,\n threadImports: ThreadImports,\n diffOptions?: SerializedDiffOptions,\n): Promise<void> {\n const base = basename(file.filepath);\n const logPrefix = `[${moduleLabel} Exec] ${getTaskLogLabel(base, file)}`;\n const wasmModule = await WebAssembly.compile(binary as BufferSource);\n const memory = createMemory(poolOptions.testMemoryPagesInitial, poolOptions.testMemoryPagesMax);\n\n // Create coverage memory matching instrumentation expections (from user config).\n // While this memory will not be used, discovery instantiates the same binary,\n // and WebAssembly.Instance will throw if the expected memory sizes don't match\n const coverageMemory = isBinaryInstrumented ?\n createMemory(poolOptions.coverageMemoryPagesInitial, poolOptions.coverageMemoryPagesMax)\n : undefined;\n\n const importObject = createDiscoveryImports(\n memory,\n wasmModule,\n file,\n handleLog,\n logPrefix,\n coverageMemory,\n threadImports.createUserWasmImports\n );\n\n // Instantiate WASM module\n const instance = new WebAssembly.Instance(wasmModule, importObject);\n const exports = instance.exports as Record<string, unknown>;\n\n // Call _start to run top-level test() and describe()\n if (typeof exports._start === 'function') {\n try {\n exports._start();\n } catch (error) {\n const thrownErrAny: any = error as any;\n\n const isFunctionSignatureMismatch: boolean = error instanceof WebAssembly.RuntimeError\n && thrownErrAny?.message.includes('null function or function signature mismatch');\n if (isFunctionSignatureMismatch) {\n const runtimeError = error as WebAssembly.RuntimeError;\n const stack = extractCallStack(runtimeError);\n const testError = await enhanceTestError(\n {\n name: TEST_ERROR_NAMES.WASMRuntimeError,\n message: runtimeError.message\n } satisfies AssemblyScriptTestError,\n file,\n sourceMap,\n false,\n logPrefix,\n threadImports.highlight,\n stack,\n diffOptions\n );\n\n throw createPoolError(\n `${SIG_MISMATCH_ERROR_MSG}\\n Caused by: ${runtimeError.name}: ${runtimeError.message}`,\n POOL_ERROR_NAMES.PoolSyntaxError,\n undefined,\n testError\n );\n }\n\n // Check to see if error came from the discovery abort() handler\n // For discovery abort, test error is set on PoolError's `cause`,\n // and the raw call stack is on PoolError's `rawCallStack`\n if (\n thrownErrAny?.name === POOL_ERROR_NAMES.WASMExecutionAbortError\n && thrownErrAny?.cause?.name === TEST_ERROR_NAMES.WASMRuntimeError\n && (error as AssemblyScriptPoolError).rawCallStack\n ) {\n const thrownPoolErr = thrownErrAny as AssemblyScriptPoolError;\n thrownPoolErr.cause = await enhanceTestError(\n thrownPoolErr.cause as AssemblyScriptTestError,\n file,\n sourceMap,\n false,\n logPrefix,\n threadImports.highlight,\n thrownPoolErr.rawCallStack,\n diffOptions\n );\n thrownPoolErr.causeIsEnhancedError = true;\n\n // delete the raw stack so vitest doesn't complain about unexpected error values\n delete thrownPoolErr.rawCallStack;\n\n // rethrow it with the enhanced test error\n throw thrownPoolErr;\n } else {\n throw createPoolErrorFromAnyError(\n `${testFileBasename} - Unexpected discovery error`,\n POOL_ERROR_NAMES.WASMExecutionHarnessError,\n error\n );\n }\n }\n } else {\n throw createExecutorPoolError(testFileBasename, 'discoverTests', 'no _start() export');\n }\n\n debug(`${logPrefix} - Discovered ${file.tasks.length} top-level tasks`);\n return;\n}\n\n/**\n * Execute a single test with crash isolation\n */\nexport async function executeWASMTest(\n test: Test,\n compilation: WASMCompilation,\n testFileBasename: string,\n poolOptions: ResolvedAssemblyScriptPoolOptions,\n collectCoverage: boolean,\n handleLog: AssemblyScriptConsoleLogHandler,\n moduleLabel: string,\n threadImports: ThreadImports,\n diffOptions?: SerializedDiffOptions,\n): Promise<{ test: Test, testTimings: WASMExecutorPerfTimings }> {\n const testTimings: WASMExecutorPerfTimings = {\n fnInit: performance.now(),\n execStart: 0,\n execEnd: 0,\n fnfinal: 0\n };\n const base = basename(test.file.filepath);\n const fullModuleLabel = `${moduleLabel} Exec`;\n const taskLabel = getTaskLogLabel(base, test);\n const logPrefix = `[${fullModuleLabel}] ${taskLabel}`;\n\n function covDebug(...args: any[]): void {\n if (poolOptions.debugCoverageExtract) {\n debugOverride(...args);\n }\n };\n\n // Compile the binary to usable WASM module\n const wasmModule = await WebAssembly.compile(compilation.binary as BufferSource);\n\n // Create fresh memory for this test instance\n const memory = createMemory(poolOptions.testMemoryPagesInitial, poolOptions.testMemoryPagesMax);\n\n // Create coverage memory if collecting coverage (instrumented binary)\n const coverageMemory = collectCoverage ?\n createMemory(poolOptions.coverageMemoryPagesInitial, poolOptions.coverageMemoryPagesMax)\n : undefined;\n\n // Create import object with pool-side functions for capturing test execution results\n const { imports, provideFunctionTable } = createTestExecutionImports(\n memory,\n wasmModule,\n test,\n handleLog,\n logPrefix,\n coverageMemory,\n threadImports.createUserWasmImports\n );\n\n // Instantiate fresh WASM instance for this test\n const instance = new WebAssembly.Instance(wasmModule, imports);\n const exports = instance.exports as Record<string, unknown>;\n\n // Func table accessable because we're using the AS compiler --exportTable flag\n const table = exports.table as WebAssembly.Table | undefined;\n \n // allow imports to access table\n if (table && typeof table.get === 'function') {\n provideFunctionTable(table);\n }\n\n // Call _start to run top-level code. Test registration is stubbed/noop duing execution,\n // but this call is still needed to initialize any user-defined globals / other top level code.\n if (typeof exports._start === 'function') {\n // Not explicitly handling with try-catch here because failures in _start should be\n // caught during discovery and source-mapped. If this somehow fails, the worker still catches it.\n exports._start();\n } else {\n throw createExecutorPoolError(testFileBasename, 'executeWASMTest', 'no _start() export');\n }\n\n let testFn: (() => void) | null | undefined;\n \n if (table && typeof table.get === 'function') {\n const idx = (test.meta as AssemblyScriptTestTaskMeta).fnIndex;\n testFn = table.get(idx) as (() => void) | null;\n\n if (!testFn) {\n throw createExecutorPoolError(\n testFileBasename,\n 'executeWASMTest',\n `Test function at index ${idx} not found in function table`\n );\n }\n } else {\n throw createExecutorPoolError(\n testFileBasename,\n 'executeWASMTest',\n 'Function table not found in WASM exports (missing --exportTable flag?)'\n );\n }\n\n // try-catch to ensure we capture known test errors to report\n // as AssemblyScriptTestErrors to vitest\n try {\n // Execute this test\n testTimings.execStart = performance.now();\n testFn();\n testTimings.execEnd = performance.now();\n\n // If we reach here, test passed, i.e. No abort occurred.\n // Proceed below to prepare the test result\n } catch (error) {\n testTimings.execEnd = performance.now();\n\n const thrownErrAny = error as any;\n // If this is NOT a WASMExecutionAbort error, it means it did NOT originate from the\n // wasm abort() import and is unexpected, so we throw as a PoolError.\n //\n // Otherwise this IS a WASMExecutionAbort error and the wasm abort() import threw it as a\n // known test error (assertion or wasm runtime), so we continue to prepare the test result \n const isUnexpectedError = thrownErrAny?.name !== POOL_ERROR_NAMES.WASMExecutionAbortError;\n\n if (isUnexpectedError) {\n throw createExecutorPoolError(\n testFileBasename,\n 'executeWASMTest',\n `Unexpected execution error: ${error instanceof Error ? `${error.name}: ${error.message}` : String(error)}`,\n (error as any)?.cause\n );\n }\n }\n\n const meta = test.meta as AssemblyScriptTestTaskMeta;\n \n // If error is present, apply source mapping to make stack locations\n // useful, and add nicely-formatted diffs for reporting through vitest\n if (meta.lastError) {\n const enhancedError = await enhanceTestError(\n meta.lastError,\n test,\n compilation.sourceMap,\n meta.lastErrorValuesProvided ?? false,\n logPrefix,\n threadImports.highlight,\n meta.lastErrorRawCallStack,\n diffOptions\n );\n\n if (test.result) {\n if (test.result.errors) {\n test.result.errors.push(enhancedError);\n } else {\n test.result.errors = [enhancedError];\n }\n }\n\n delete meta.lastError;\n delete meta.lastErrorValuesProvided;\n delete meta.lastErrorRawCallStack;\n }\n\n // Extract coverage hits from coverage memory\n if (collectCoverage) {\n if (!coverageMemory) {\n throw createExecutorPoolError(\n testFileBasename,\n 'executeWASMTest',\n 'Coverage memory not created despite collectCoverage=true'\n );\n }\n\n if (!compilation.debugInfo) {\n throw createExecutorPoolError(\n testFileBasename,\n 'executeWASMTest',\n 'debugInfo is required when collectCoverage=true'\n );\n }\n\n const coverage: CoverageData = {\n hitCountsByFileAndPosition: {},\n };\n\n // Read counters from coverage memory\n const extractedHitCounters = new Uint32Array(coverageMemory.buffer, 0, compilation.debugInfo.instrumentedFunctionCount);\n covDebug(`${logPrefix} - Read coverage memory for ${compilation.debugInfo.instrumentedFunctionCount} instrumented functions`);\n\n // Iterate all instrumented functions and build coverage data with hit counts extracted from coverage memory\n let functionsHit = 0;\n for (const [filePath, debugFunctions] of Object.entries(compilation.debugInfo.functionsByFileAndPosition)) {\n if (!coverage.hitCountsByFileAndPosition[filePath]) {\n coverage.hitCountsByFileAndPosition[filePath] = {};\n covDebug(`${logPrefix} - Extracting hits for source file \"${filePath}\"`);\n }\n\n for (const [positionKey, funcInfos] of Object.entries(debugFunctions)) {\n // Sum hit counts across all functions at this position (multiple for generic monomorphizations)\n let positionHitCount = 0;\n for (const funcInfo of funcInfos) {\n if (funcInfo.coverageMemoryIndex === undefined) {\n debug(`${logPrefix} - WARNING: NO COVERAGE MEMORY INDEX`\n + ` - func \"${funcInfo.name}\" (${positionKey}) Skipping hit extraction`\n );\n continue;\n }\n\n const hitCount = extractedHitCounters[funcInfo.coverageMemoryIndex] ?? 0;\n covDebug(`${logPrefix} - func \"${funcInfo.name}\" (${positionKey}) `\n + `[idx: ${funcInfo.coverageMemoryIndex}]: ${hitCount} hits`\n );\n positionHitCount += hitCount;\n }\n\n coverage.hitCountsByFileAndPosition[filePath][positionKey] = positionHitCount;\n\n if (positionHitCount > 0) {\n functionsHit++;\n }\n }\n }\n\n meta.coverageData = coverage;\n debug(`${logPrefix} - Extracted coverage data | ${functionsHit} functions hit`);\n }\n\n testTimings.fnfinal = performance.now();\n\n return { test, testTimings };\n}\n","/**\n * RPC Reporting Helpers\n *\n * This module provides helper functions for reporting test lifecycle events\n * to Vitest via RPC. All helpers are designed to be composable and reusable.\n */\n\nimport type { MessagePort } from 'node:worker_threads';\nimport { createBirpc } from 'birpc';\nimport type { RunnerRPC, RuntimeRPC, UserConsoleLog } from 'vitest';\nimport type {\n File,\n Suite,\n Test,\n Task,\n TaskEventPack, \n TaskResultPack,\n CancelReason,\n} from '@vitest/runner/types';\n\nimport type {\n AssemblyScriptConsoleLog,\n AssemblyScriptCoveragePayload,\n AssemblyScriptSuiteTaskMeta,\n VitestVersion,\n WorkerRPC\n} from '../types/types.js';\nimport { debug } from '../util/debug.js';\nimport { COVERAGE_PAYLOAD_FORMATS } from '../types/constants.js';\nimport {\n createAfterSuiteRunMeta,\n getTaskLogLabel,\n isSuiteOwnFile\n} from '../util/vitest-tasks.js';\n\n// ============================================================================\n// RPC Client Factory\n// ============================================================================\n\n/** Create RPC client from MessagePort */\nexport function createRpcClient(port: MessagePort): WorkerRPC {\n return createBirpc<RuntimeRPC, RunnerRPC>(\n {\n onCancel: (_reason: CancelReason) => void { }\n },\n {\n post: (v) => port.postMessage(v),\n on: (fn) => port.on('message', fn),\n }\n );\n}\n\n// ============================================================================\n// File Task Reporting\n// ============================================================================\n\n/** Report file as queued (before compilation & discovery starts) */\nexport async function reportFileQueued(\n rpc: WorkerRPC,\n fileTask: File,\n logModule: string,\n logLabel: string,\n): Promise<void> {\n await rpc.onQueued(fileTask);\n debug(`[${logModule} RPC] ${logLabel} - Reported onQueued for file \"${fileTask.filepath}\"`\n + ` | mode: \"${fileTask.mode}\" | state: \"${fileTask.result ? fileTask.result.state : '--'}\"`\n );\n}\n\n/** Report file collection complete with full task tree */\nexport async function reportFileCollected(\n rpc: WorkerRPC,\n fileTask: File,\n logModule: string,\n logLabel: string,\n): Promise<void> {\n await rpc.onCollected([fileTask]);\n debug(`[${logModule} RPC] ${logLabel} - Reported onCollected for file \"${fileTask.filepath}\"`\n + ` | ${fileTask.tasks.length} tasks | mode: \"${fileTask.mode}\" | state: \"${fileTask.result?.state}\"`\n );\n}\n\n/** Report file-level error (compilation/discovery failure) as \"suite-failed-early\" */\nexport async function reportFileError(\n rpc: WorkerRPC,\n fileTask: File, \n logModule: string,\n logLabel: string,\n): Promise<void> {\n const taskPack: TaskResultPack = [fileTask.id, fileTask.result, {}];\n const eventPack: TaskEventPack = [fileTask.id, \"suite-failed-early\", undefined];\n await rpc.onTaskUpdate([taskPack], [eventPack]);\n\n debug(`[${logModule} RPC] ${logLabel} - Reported \"suite-failed-early\" task update for \"${fileTask.filepath}\"`);\n}\n\n// ============================================================================\n// Suite Lifecycle Reporting\n// ============================================================================\n\n/** Report suite-prepare event */\nexport async function reportSuitePrepare(\n rpc: WorkerRPC,\n suite: Suite,\n logModule: string,\n base: string,\n): Promise<void> {\n // Report suite event (without the custom task meta so reporters won't log it)\n const taskPack: TaskResultPack = [suite.id, suite.result, {}];\n const eventPack: TaskEventPack = [suite.id, 'suite-prepare', undefined];\n\n await rpc.onTaskUpdate([taskPack], [eventPack]);\n\n debug(`[${logModule} RPC] ${getTaskLogLabel(base, suite)} - Reported \"suite-prepare\" task update`\n + ` | state: \"${suite.result?.state}\"`\n );\n}\n\n/** Report suite-finished event */\nexport async function reportSuiteFinished(\n rpc: WorkerRPC,\n suite: Suite,\n logModule: string,\n base: string,\n vitestVersion: VitestVersion = 'v4',\n): Promise<void> {\n const suiteLabel = getTaskLogLabel(base, suite);\n const rpcLogPrefix = `[${logModule} RPC] ${suiteLabel}`;\n const meta = suite.meta as AssemblyScriptSuiteTaskMeta;\n const coverageKeys: number = Object.keys(meta.coverageData?.hitCountsByFileAndPosition ?? {}).length;\n let coveragePromise: Promise<void> = Promise.resolve();\n \n // Report coverage if this is a file task, and coverage is available\n if (isSuiteOwnFile(suite) && coverageKeys > 0) {\n const coverage: AssemblyScriptCoveragePayload = {\n __format: COVERAGE_PAYLOAD_FORMATS.AssemblyScript,\n coverageData: meta.coverageData!,\n suiteLogLabel: suiteLabel\n };\n \n const afterSuiteMeta = createAfterSuiteRunMeta(\n coverage,\n [suite.file.filepath],\n suite.file.projectName,\n vitestVersion\n );\n coveragePromise = rpc.onAfterSuiteRun(afterSuiteMeta);\n\n debug(`${rpcLogPrefix} - onAfterSuiteRun: Reported suite coverage (${coverageKeys} unique positions)`);\n } else if (coverageKeys === 0) {\n debug(`${rpcLogPrefix} - onAfterSuiteRun: No suite coverage to report`);\n }\n\n // Report suite event (without the custom task meta so reporters won't log it)\n const taskPack: TaskResultPack = [suite.id, suite.result, {}];\n const eventPack: TaskEventPack = [suite.id, \"suite-finished\", undefined];\n\n await Promise.all([\n coveragePromise,\n rpc.onTaskUpdate([taskPack], [eventPack])\n ]);\n\n debug(`${rpcLogPrefix} - Reported \"suite-finished\" task update | state: \"${suite.result?.state}\"`\n + ` | duration: ${suite.result?.duration?.toFixed(2) ?? '--'} ms`\n );\n}\n\n// ============================================================================\n// Test Lifecycle Reporting\n// ============================================================================\n\nasync function reportTestTaskUpdate(\n rpc: WorkerRPC,\n test: Test,\n logModule: string,\n base: string,\n updateEvent: 'test-prepare' | 'test-finished' | 'test-retried'\n): Promise<void> {\n // Report test event (without the custom task meta so reporters won't log it)\n const taskPack: TaskResultPack = [test.id, test.result, {}];\n const eventPack: TaskEventPack = [test.id, updateEvent, undefined];\n\n debug(`[${logModule} RPC] ${getTaskLogLabel(base, test)} - Reporting \"${updateEvent}\" task update...`\n + ` | state: \"${test.result?.state}\"`\n + `${updateEvent === 'test-prepare' ? '' : ` | duration: ${test.result?.duration?.toFixed(2) ?? '--'} ms`}`\n );\n await rpc.onTaskUpdate([taskPack], [eventPack]);\n debug(`[${logModule} RPC] ${getTaskLogLabel(base, test)} - Reported \"${updateEvent}\" task update`\n + ` | state: \"${test.result?.state}\"`\n + `${updateEvent === 'test-prepare' ? '' : ` | duration: ${test.result?.duration?.toFixed(2) ?? '--'} ms`}`\n );\n}\n\n/** Report test starting execution */\nexport async function reportTestPrepare(\n rpc: WorkerRPC,\n test: Test,\n logModule: string,\n base: string,\n): Promise<void> {\n return reportTestTaskUpdate(rpc, test, logModule, base, 'test-prepare');\n}\n\n/** Report test finished execution */\nexport async function reportTestFinished(\n rpc: WorkerRPC,\n test: Test,\n logModule: string,\n base: string,\n): Promise<void> {\n return reportTestTaskUpdate(rpc, test, logModule, base, 'test-finished');\n}\n\n/** Report test retried (sent when test failed and is going to be retried) */\nexport async function reportTestRetried(\n rpc: WorkerRPC,\n test: Test,\n logModule: string,\n base: string,\n): Promise<void> {\n return reportTestTaskUpdate(rpc, test, logModule, base, 'test-retried');\n}\n\n// ============================================================================\n// Other Reporting\n// ============================================================================\n\n/** Report user console log messages */\nexport async function reportUserConsoleLogs(\n rpc: WorkerRPC,\n logs: AssemblyScriptConsoleLog[],\n logModule: string,\n base: string,\n task: Task,\n): Promise<void> {\n if (logs.length === 0) {\n return;\n }\n\n const stdLogs = logs.filter(l => !l.isError);\n const errorLogs = logs.filter(l => l.isError);\n\n const stdContent: string = stdLogs.map(l => `${l.msg}`).join('\\n');\n const errorContent: string = errorLogs.filter(l => l.isError).map(l => `${l.msg}`).join('\\n');\n\n const stdLog: UserConsoleLog = {\n content: `${stdContent}\\n`,\n size: stdContent.length,\n browser: false,\n type: 'stdout',\n time: stdLogs.length > 0 ? stdLogs[0]!.time : Date.now(),\n taskId: task.id,\n origin: task.id\n };\n \n const errorLog: UserConsoleLog = {\n content: `${errorContent}\\n`,\n size: errorContent.length,\n browser: false,\n type: 'stderr',\n time: errorLogs.length > 0 ? errorLogs[0]!.time : Date.now(),\n taskId: task.id,\n origin: task.id\n };\n\n const reportPromises: Promise<void>[] = [];\n if (stdContent.length > 0) {\n reportPromises.push(rpc.onUserConsoleLog(stdLog));\n }\n if (errorContent.length > 0) {\n reportPromises.push(rpc.onUserConsoleLog(errorLog));\n }\n\n await Promise.all(reportPromises);\n\n debug(`[${logModule} RPC] ${getTaskLogLabel(base, task)} - Reported onUserConsoleLog | ${logs.length} messages`);\n}\n\n// ============================================================================\n// Final Flush\n// ============================================================================\n\n/** Flush any pending RPC updates */\nexport async function flushRpcUpdates(\n rpc: WorkerRPC,\n): Promise<void> {\n await rpc.onTaskUpdate([], []);\n}\n","import { resolve } from 'node:path';\nimport { pathToFileURL } from 'node:url';\n\nimport type { WasmImportsFactory } from '../types/types.js';\nimport { debug } from '../util/debug.js';\nimport { AS_POOL_ERROR_TYPE_FLAG } from '../types/constants.js';\n\nexport async function loadUserWasmImportsFactory(\n relativePath: string | undefined,\n projectRoot: string,\n logModule: string,\n): Promise<WasmImportsFactory | undefined> {\n if (!relativePath) {\n return undefined;\n }\n\n const path = resolve(projectRoot, relativePath);\n const safeUrl = pathToFileURL(path).href;\n\n try {\n const start = performance.now();\n const createWasmImports = (await import(safeUrl)).default;\n debug(`[${logModule}] TIMING Imported user WasmImportsFactory in ${(performance.now() - start).toFixed(2)} ms`);\n\n if (typeof createWasmImports !== 'function') {\n throw new Error(\n `User config for \\`wasmImportsFactor\\` must be the path to a module with a default export matching () => WebAssembly.Imports `\n + `- Imported: \"${typeof createWasmImports}\": ${String(createWasmImports)}`\n );\n } else {\n return createWasmImports;\n }\n } catch (error) {\n if ((error as any)[AS_POOL_ERROR_TYPE_FLAG]) {\n throw error;\n }\n \n throw new Error(\n `Could not load user WasmImportsFactory from \"${safeUrl}\".`\n + ` Ensure that your module path is relative to the project root (location of shallowest vitest config),`\n + ` and that it has a default export matching () => WebAssembly.Imports`,\n { cause: error }\n );\n }\n};\n"],"mappings":";;;;;;;;;;;AAAA,MAAM,4BAA4B;;;;;;;;;;;;;;;;AAiBlC,SAAgB,WACd,QACA,SACoB;AACpB,KAAI,CAAC,QAAS,QAAO;CAErB,MAAM,WAAW,YAAY;CAM7B,MAAM,kBAJY,WAAW,MAIS;CACtC,MAAM,mBAAmB,IAAI,YAAY,OAAO,OAAO,CAAC;AAExD,KAAI,qBAAqB,EAAG,QAAO;CAInC,MAAM,eAAgB,WAAW,qBAAuB;CACxD,IAAI,iBAAiB,aAAa;CAElC,MAAM,YAAY,IAAI,YAAY,OAAO,OAAO;CAChD,IAAI,SAAS;AAGb,QAAO,eAAe,iBAAiB,0BACrC,WAAU,OAAO,aACf,GAAG,UAAU,SAAS,gBAAgB,kBAAkB,0BAA0B,CACnF;AAGH,QAAO,SAAS,OAAO,aAAa,GAAG,UAAU,SAAS,gBAAgB,aAAa,CAAC;;;;;;;;;AC3C1F,SAAgB,aAAa,cA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AQ,KAAK;EACb,QAAQ,KAAK;EACd;CAED,MAAM,iBAAkC,EAAE;AAC1C,KAAI,WAAW,SAAS,EACtB,gBAAe,KAAK,IAAI,iBAAiB,OAAO,CAAC;AAEnD,KAAI,aAAa,SAAS,EACxB,gBAAe,KAAK,IAAI,iBAAiB,SAAS,CAAC;AAGrD,OAAM,QAAQ,IAAI,eAAe;AAEjC,OAAM,IAAI,UAAU,QAAQ,gBAAgB,MAAM,KAAK,CAAC,iCAAiC,KAAK,OAAO,WAAW;;;AAQlH,eAAsB,gBACpB,KACe;AACf,OAAM,IAAI,aAAa,EAAE,EAAE,EAAE,CAAC;;;;;ACvRhC,eAAsB,2BACpB,cACA,aACA,WACyC;AACzC,KAAI,CAAC,aACH;CAIF,MAAM,UAAU,cADH,QAAQ,aAAa,aAAa,CACZ,CAAC;AAEpC,KAAI;EACF,MAAM,QAAQ,YAAY,KAAK;EAC/B,MAAM,qBAAqB,MAAM,OAAO,UAAU;AAClD,QAAM,IAAI,UAAU,gDAAgD,YAAY,KAAK,GAAG,OAAO,QAAQ,EAAE,CAAC,KAAK;AAE/G,MAAI,OAAO,sBAAsB,WAC/B,OAAM,IAAI,MACR,4IACoB,OAAO,kBAAkB,KAAK,OAAO,kBAAkB,GAC5E;MAED,QAAO;UAEF,OAAO;AACd,MAAK,qBACH,OAAM;AAGR,QAAM,IAAI,MACR,gDAAgD,QAAQ,8KAGxD,EAAE,OAAO,OAAO,CACjB"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import c from "tinyrainbow";
|
|
2
|
+
import { versions } from "node:process";
|
|
3
|
+
|
|
4
|
+
//#region src/util/node-check.ts
|
|
5
|
+
const NODE_VERSION = versions.node;
|
|
6
|
+
const NODE_MAJOR_VERSION = parseInt(NODE_VERSION.split(".")[0], 10);
|
|
7
|
+
function isCoverageSupported() {
|
|
8
|
+
return NODE_MAJOR_VERSION >= 22;
|
|
9
|
+
}
|
|
10
|
+
function warnIfASCoverageNotSupported() {
|
|
11
|
+
if (!isCoverageSupported()) console.warn(`\n` + c.yellow(`Warning:`) + c.gray(` Coverage is enabled, but current Node version (${versions.node})\n does not support required WASM multi-memory features.\n Coverage collection will be `) + c.yellow(`disabled`) + c.gray(" for AssemblyScript WASM.\n Please upgrade to Node 22 or above if you need WASM coverage support."));
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
//#endregion
|
|
15
|
+
export { isCoverageSupported, warnIfASCoverageNotSupported };
|
|
16
|
+
//# sourceMappingURL=node-check-CooGQMLH.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"node-check-CooGQMLH.mjs","names":[],"sources":["../src/util/node-check.ts"],"sourcesContent":["import { versions } from 'node:process';\nimport c from 'tinyrainbow';\n\nconst NODE_VERSION = versions.node;\nconst NODE_MAJOR_VERSION = parseInt(NODE_VERSION.split('.')[0]!, 10);\n\nexport function isCoverageSupported(): boolean {\n return NODE_MAJOR_VERSION >= 22;\n}\n\nexport function warnIfASCoverageNotSupported(): void {\n if (!isCoverageSupported()) {\n console.warn(`\\n`\n + c.yellow(`Warning:`)\n + c.gray(` Coverage is enabled, but current Node version (${versions.node})\\n`\n + ` does not support required WASM multi-memory features.\\n`\n + ` Coverage collection will be `) + c.yellow(`disabled`) + c.gray(` for AssemblyScript WASM.\\n`\n + ` Please upgrade to Node 22 or above if you need WASM coverage support.`)\n );\n }\n}\n"],"mappings":";;;;AAGA,MAAM,eAAe,SAAS;AAC9B,MAAM,qBAAqB,SAAS,aAAa,MAAM,IAAI,CAAC,IAAK,GAAG;AAEpE,SAAgB,sBAA+B;AAC7C,QAAO,sBAAsB;;AAG/B,SAAgB,+BAAqC;AACnD,KAAI,CAAC,qBAAqB,CACxB,SAAQ,KAAK,OACT,EAAE,OAAO,WAAW,GACpB,EAAE,KAAK,mDAAmD,SAAS,KAAK,0GAEhC,GAAG,EAAE,OAAO,WAAW,GAAG,EAAE,KAAK,4GACQ,CACpF"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { POOL_ERROR_NAMES } from "./constants-
|
|
2
|
-
import { resolvePoolOptions } from "./resolve-config-
|
|
3
|
-
import { createPoolError, createPoolErrorFromAnyError, debug, isAbortError, setGlobalDebugMode } from "./debug-
|
|
1
|
+
import { POOL_ERROR_NAMES } from "./constants-DuBLuMjt.mjs";
|
|
2
|
+
import { resolvePoolOptions } from "./resolve-config-BFNr7LW7.mjs";
|
|
3
|
+
import { createPoolError, createPoolErrorFromAnyError, debug, isAbortError, setGlobalDebugMode } from "./debug-Cm1VFmaz.mjs";
|
|
4
4
|
import { createInitialFileTask } from "./vitest-file-tasks-BUwzh375.mjs";
|
|
5
|
-
import { failTestWithTimeoutError, flagTestTerminated } from "./vitest-tasks-
|
|
5
|
+
import { failTestWithTimeoutError, flagTestTerminated } from "./vitest-tasks-ByPK8DvF.mjs";
|
|
6
6
|
import { createWorkerRPCChannel } from "./worker-rpc-channel-lbhK7Qz8.mjs";
|
|
7
7
|
import { availableParallelism } from "node:os";
|
|
8
8
|
import { resolve } from "node:path";
|
|
@@ -397,4 +397,4 @@ function createAssemblyScriptPool(userPoolOptions) {
|
|
|
397
397
|
|
|
398
398
|
//#endregion
|
|
399
399
|
export { createAssemblyScriptPool };
|
|
400
|
-
//# sourceMappingURL=pool-runner-init-
|
|
400
|
+
//# sourceMappingURL=pool-runner-init-D1QamWkS.mjs.map
|