vitest-pool-assemblyscript 0.10.0 → 0.11.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 +3 -3
- package/dist/{addon-interface-DJB-K27u.mjs → addon-interface-BaUmn7uC.mjs} +2 -2
- package/dist/{addon-interface-DJB-K27u.mjs.map → addon-interface-BaUmn7uC.mjs.map} +1 -1
- package/dist/{compile-runner-D4SJWhMh.mjs → compile-runner-BGYyiUEf.mjs} +5 -5
- package/dist/{compile-runner-D4SJWhMh.mjs.map → compile-runner-BGYyiUEf.mjs.map} +1 -1
- package/dist/{compiler-DSKhQ5--.mjs → compiler-CXR5UJId.mjs} +4 -4
- package/dist/{compiler-DSKhQ5--.mjs.map → compiler-CXR5UJId.mjs.map} +1 -1
- package/dist/config/index-v3.d.mts +1 -1
- package/dist/config/index.d.mts +2 -2
- package/dist/config/index.mjs +3 -3
- package/dist/coverage-provider/index.mjs +2 -2
- package/dist/coverage-provider/index.mjs.map +1 -1
- package/dist/{feature-check-DLfJqIrE.mjs → feature-check-BJpc4LoO.mjs} +3 -3
- package/dist/{feature-check-DLfJqIrE.mjs.map → feature-check-BJpc4LoO.mjs.map} +1 -1
- package/dist/index-internal.d.mts +1 -1
- package/dist/index-internal.mjs +3 -3
- package/dist/index-v3.mjs +2 -2
- package/dist/index.d.mts +1 -1
- package/dist/index.mjs +3 -3
- package/dist/{load-user-imports-6Pv-9hRg.mjs → load-user-imports-iAQUMKAi.mjs} +22 -9
- package/dist/load-user-imports-iAQUMKAi.mjs.map +1 -0
- package/dist/{pool-errors-GWfwrsD7.mjs → pool-errors-Bn6YaguR.mjs} +4 -5
- package/dist/pool-errors-Bn6YaguR.mjs.map +1 -0
- package/dist/{pool-runner-init-CCvnKt5o.d.mts → pool-runner-init-CPQL6pVL.d.mts} +2 -2
- package/dist/pool-runner-init-CPQL6pVL.d.mts.map +1 -0
- package/dist/{pool-runner-init-Cta6aVJ6.mjs → pool-runner-init-CSJt3dHv.mjs} +3 -3
- package/dist/{pool-runner-init-Cta6aVJ6.mjs.map → pool-runner-init-CSJt3dHv.mjs.map} +1 -1
- package/dist/pool-thread/compile-worker-thread.d.mts +1 -1
- package/dist/pool-thread/compile-worker-thread.mjs +6 -6
- package/dist/pool-thread/test-worker-thread.d.mts +1 -1
- package/dist/pool-thread/test-worker-thread.mjs +5 -5
- package/dist/pool-thread/v3-tinypool-thread.d.mts +1 -1
- package/dist/pool-thread/v3-tinypool-thread.mjs +7 -7
- package/dist/{test-runner-M21HMDdH.mjs → test-runner-BDcm8vg0.mjs} +4 -4
- package/dist/{test-runner-M21HMDdH.mjs.map → test-runner-BDcm8vg0.mjs.map} +1 -1
- package/dist/{types-CoroKYxB.d.mts → types-CRbjiCC7.d.mts} +2 -2
- package/dist/{types-CoroKYxB.d.mts.map → types-CRbjiCC7.d.mts.map} +1 -1
- package/dist/{vitest-file-tasks-Coc4btUw.mjs → vitest-file-tasks-BBsZ_wS6.mjs} +5 -3
- package/dist/vitest-file-tasks-BBsZ_wS6.mjs.map +1 -0
- package/package.json +17 -10
- package/prebuilds/darwin-arm64/vitest-pool-assemblyscript.glibc.node +0 -0
- package/prebuilds/darwin-x64/vitest-pool-assemblyscript.glibc.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/dist/load-user-imports-6Pv-9hRg.mjs.map +0 -1
- package/dist/pool-errors-GWfwrsD7.mjs.map +0 -1
- package/dist/pool-runner-init-CCvnKt5o.d.mts.map +0 -1
- package/dist/vitest-file-tasks-Coc4btUw.mjs.map +0 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { dirname, resolve } from "node:path";
|
|
2
2
|
import { access, readFile, unlink } from "node:fs/promises";
|
|
3
|
-
import { fileURLToPath } from "node:url";
|
|
4
3
|
import c from "tinyrainbow";
|
|
4
|
+
import { fileURLToPath } from "node:url";
|
|
5
5
|
import { versions } from "node:process";
|
|
6
6
|
|
|
7
7
|
//#region src/util/feature-check.ts
|
|
@@ -66,7 +66,7 @@ async function warnIfNativeBuildFailed() {
|
|
|
66
66
|
const buildError = await readNativeBuildError();
|
|
67
67
|
if (!buildError) return;
|
|
68
68
|
try {
|
|
69
|
-
await import("./addon-interface-
|
|
69
|
+
await import("./addon-interface-BaUmn7uC.mjs");
|
|
70
70
|
await clearNativeBuildError();
|
|
71
71
|
return;
|
|
72
72
|
} catch {}
|
|
@@ -79,4 +79,4 @@ async function warnIfNativeBuildFailed() {
|
|
|
79
79
|
|
|
80
80
|
//#endregion
|
|
81
81
|
export { clearNativeBuildError, hasNativeBuildError, isNodeVersionSupportedForCoverage, warnASInstrumentationNotLoaded, warnIfASCoverageNotSupportedByNode, warnIfNativeBuildFailed };
|
|
82
|
-
//# sourceMappingURL=feature-check-
|
|
82
|
+
//# sourceMappingURL=feature-check-BJpc4LoO.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"feature-check-
|
|
1
|
+
{"version":3,"file":"feature-check-BJpc4LoO.mjs","names":[],"sources":["../src/util/feature-check.ts"],"sourcesContent":["import { versions } from 'node:process';\nimport { access, readFile, unlink } from 'node:fs/promises';\nimport { resolve, dirname } from 'node:path';\nimport { fileURLToPath } from 'node:url';\nimport c from 'tinyrainbow';\n\nimport type { NativeBuildError } from '../types/types.js';\n\n// Marker file written by install script when native build fails\nconst __filename = fileURLToPath(import.meta.url);\nconst __dirname = dirname(__filename);\nconst packageRoot = resolve(__dirname, '..');\nconst NATIVE_BUILD_ERROR_FILE = resolve(packageRoot, '.native-build-error');\n\n/**\n * Read the native build error marker file if it exists.\n * Returns undefined if file doesn't exist or can't be parsed.\n */\nasync function readNativeBuildError(): Promise<NativeBuildError | undefined> {\n try {\n const content = await readFile(NATIVE_BUILD_ERROR_FILE, 'utf8');\n return JSON.parse(content) as NativeBuildError;\n } catch {\n return undefined;\n }\n}\n\n/**\n * Check if a native build error marker file exists.\n * Used by compiler threads to distinguish known build failures (marker present,\n * user already warned by coverage provider) from unexpected addon load failures.\n */\nexport async function hasNativeBuildError(): Promise<boolean> {\n try {\n await access(NATIVE_BUILD_ERROR_FILE);\n return true;\n } catch {\n return false;\n }\n}\n\n/**\n * Remove the native build error marker file.\n * Called when the addon loads successfully at runtime, clearing any stale marker\n * left from a previous failed install (e.g. after a manual rebuild).\n */\nexport async function clearNativeBuildError(): Promise<void> {\n try {\n await unlink(NATIVE_BUILD_ERROR_FILE);\n } catch {\n // File doesn't exist or can't be removed — non-critical\n }\n}\n\nconst NODE_VERSION = versions.node;\nconst NODE_MAJOR_VERSION = parseInt(NODE_VERSION.split('.')[0]!, 10);\n\nexport function isNodeVersionSupportedForCoverage(): boolean {\n return NODE_MAJOR_VERSION >= 22;\n}\n\nexport function warnIfASCoverageNotSupportedByNode(): void {\n if (!isNodeVersionSupportedForCoverage()) {\n console.warn(`\\n`\n + c.yellow(`Warning:`)\n + c.gray(` Coverage config 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\n/**\n * Warn that the native instrumentation addon could not be loaded.\n * Used by compiler threads for unexpected failures (no marker file present).\n */\nexport function warnASInstrumentationNotLoaded(errorMessage: string): void {\n console.warn(`\\n`\n + c.yellow(`Warning:`)\n + c.gray(` Coverage config is enabled, but instrumentation native addon module\\n`\n + ` was not loaded. Tests will run with ` + c.yellow(`coverage disabled`) + `. Error:\\n\\n`\n + `${errorMessage}`)\n );\n}\n\nconst ERROR_PREVIEW_MAX_LINES = 10;\n\n/**\n * Check for a native build error marker file and warn if present.\n * Called once from the coverage provider (main process), so the warning\n * is not duplicated across compiler threads.\n */\nexport async function warnIfNativeBuildFailed(): Promise<void> {\n const buildError = await readNativeBuildError();\n if (!buildError) return;\n\n // Before warning, check if the addon actually loads (e.g. after a manual rebuild).\n // If it loads, the marker file is stale — clear it and skip the warning.\n try {\n await import('../instrumentation/addon-interface.js');\n await clearNativeBuildError();\n return;\n } catch {\n // Addon still can't load — proceed with warning\n }\n\n const stageName = buildError.stage === 'binaryen-download'\n ? 'Binaryen dependency download'\n : 'native addon compilation';\n\n // Truncate error for display, point to file for full details\n const errorLines = buildError.error.split('\\n');\n const truncated = errorLines.length > ERROR_PREVIEW_MAX_LINES;\n const preview = errorLines.slice(-ERROR_PREVIEW_MAX_LINES).join('\\n');\n\n console.warn(`\\n`\n + c.yellow(`Warning:`) + c.gray(` Build failed during \"${stageName}\" while installing.\\n`)\n + c.gray(` vitest-pool-assemblyscript. AssemblyScript tests will run,\\n`)\n + c.gray(` but `) + c.yellow(`coverage will be disabled`) + c.gray(`. Platform: `)\n + c.yellowBright(`${buildError.platform}\\n`)\n + c.gray(` Build Error Message:\\n`)\n + `\\n`\n + (truncated ? c.gray(`... (truncated)\\n`) : ``)+ c.redBright(`${preview}`) + `\\n`\n + `\\n`\n + c.gray(` Full error details: `) + c.cyan(`${NATIVE_BUILD_ERROR_FILE}`) + `\\n`\n + `\\n`\n + c.gray(` To resolve, inspect the error above, ensure a C++ compiler toolchain\\n`)\n + c.gray(` is installed (`) + c.cyan(`https://github.com/nodejs/node-gyp#installation`) + c.gray(`)\\n`)\n + c.gray(` and then reinstall: `) + c.cyan(`npm install vitest-pool-assemblyscript`)\n + `\\n`\n );\n}\n"],"mappings":";;;;;;;AAYA,MAAM,0BAA0B,QADZ,QADF,QADC,cAAc,OAAO,KAAK,IAAI,CACZ,EACE,KAAK,EACS,sBAAsB;;;;;AAM3E,eAAe,uBAA8D;AAC3E,KAAI;EACF,MAAM,UAAU,MAAM,SAAS,yBAAyB,OAAO;AAC/D,SAAO,KAAK,MAAM,QAAQ;SACpB;AACN;;;;;;;;AASJ,eAAsB,sBAAwC;AAC5D,KAAI;AACF,QAAM,OAAO,wBAAwB;AACrC,SAAO;SAC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,GAAG,UAAU,GAAG,SAE5E,EAAE,KAAK,8BAA8B,GAAG,EAAE,KAAK,GAAG,0BAA0B,GAAG,SAE/E,EAAE,KAAK,gFAAgF,GACvF,EAAE,KAAK,wBAAwB,GAAG,EAAE,KAAK,kDAAkD,GAAG,EAAE,KAAK,MAAM,GAC3G,EAAE,KAAK,8BAA8B,GAAG,EAAE,KAAK,yCAAyC,GACxF,KACH"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AssemblyScriptCompilerOptions, AssemblyScriptPoolOptions, WASMCompilation } from "./types-
|
|
1
|
+
import { AssemblyScriptCompilerOptions, AssemblyScriptPoolOptions, WASMCompilation } from "./types-CRbjiCC7.mjs";
|
|
2
2
|
|
|
3
3
|
//#region src/compiler/index.d.ts
|
|
4
4
|
/**
|
package/dist/index-internal.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import "./constants-Bq5KNxXJ.mjs";
|
|
2
|
-
import "./pool-errors-
|
|
2
|
+
import "./pool-errors-Bn6YaguR.mjs";
|
|
3
3
|
import "./wasm-memory-C8Nkl2Sz.mjs";
|
|
4
|
-
import "./feature-check-
|
|
5
|
-
import { compileAssemblyScript } from "./compiler-
|
|
4
|
+
import "./feature-check-BJpc4LoO.mjs";
|
|
5
|
+
import { compileAssemblyScript } from "./compiler-CXR5UJId.mjs";
|
|
6
6
|
|
|
7
7
|
export { compileAssemblyScript };
|
package/dist/index-v3.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { POOL_ERROR_NAMES } from "./constants-Bq5KNxXJ.mjs";
|
|
2
|
-
import { createInitialFileTask, failTestWithTimeoutError, flagTestTerminated, getCompatConfig, getConfigs } from "./vitest-file-tasks-
|
|
3
|
-
import { debug, isAbortError, setGlobalDebugMode } from "./pool-errors-
|
|
2
|
+
import { createInitialFileTask, failTestWithTimeoutError, flagTestTerminated, getCompatConfig, getConfigs } from "./vitest-file-tasks-BBsZ_wS6.mjs";
|
|
3
|
+
import { debug, isAbortError, setGlobalDebugMode } from "./pool-errors-Bn6YaguR.mjs";
|
|
4
4
|
import { createWorkerRPCChannel } from "./worker-rpc-channel-CvCrc8aa.mjs";
|
|
5
5
|
import { basename, resolve } from "node:path";
|
|
6
6
|
import { access } from "node:fs/promises";
|
package/dist/index.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { createAssemblyScriptPool } from "./pool-runner-init-
|
|
1
|
+
import { createAssemblyScriptPool } from "./pool-runner-init-CPQL6pVL.mjs";
|
|
2
2
|
export { createAssemblyScriptPool };
|
package/dist/index.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import "./constants-Bq5KNxXJ.mjs";
|
|
2
|
-
import "./vitest-file-tasks-
|
|
3
|
-
import "./pool-errors-
|
|
2
|
+
import "./vitest-file-tasks-BBsZ_wS6.mjs";
|
|
3
|
+
import "./pool-errors-Bn6YaguR.mjs";
|
|
4
4
|
import "./worker-rpc-channel-CvCrc8aa.mjs";
|
|
5
|
-
import { createAssemblyScriptPool } from "./pool-runner-init-
|
|
5
|
+
import { createAssemblyScriptPool } from "./pool-runner-init-CSJt3dHv.mjs";
|
|
6
6
|
|
|
7
7
|
export { createAssemblyScriptPool };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { COVERAGE_PAYLOAD_FORMATS, POOL_ERROR_NAMES, TEST_ERROR_NAMES } from "./constants-Bq5KNxXJ.mjs";
|
|
2
|
-
import { createAfterSuiteRunMeta, createSuiteTask, createTestTask, failTestAssertionError, failTestRuntimeError, getTaskLogLabel, isSuiteOwnFile } from "./vitest-file-tasks-
|
|
3
|
-
import { abortWASMExecution, abortWASMExecutionOnSuccess, createPoolError, debug, debugOverride, enhanceTestError, extractCallStack, getExpectedMessageOrAny, wrapPoolError } from "./pool-errors-
|
|
2
|
+
import { createAfterSuiteRunMeta, createSuiteTask, createTestTask, failTestAssertionError, failTestRuntimeError, getTaskLogLabel, isSuiteOwnFile } from "./vitest-file-tasks-BBsZ_wS6.mjs";
|
|
3
|
+
import { abortWASMExecution, abortWASMExecutionOnSuccess, createPoolError, debug, debugOverride, enhanceTestError, extractCallStack, getExpectedMessageOrAny, wrapPoolError } from "./pool-errors-Bn6YaguR.mjs";
|
|
4
4
|
import { createMemory, decodeAbortInfo, liftString } from "./wasm-memory-C8Nkl2Sz.mjs";
|
|
5
5
|
import { basename, resolve } from "node:path";
|
|
6
6
|
import { pathToFileURL } from "node:url";
|
|
@@ -97,10 +97,8 @@ function createUserWasmImports(createWasmImports, memory, module, logPrefix) {
|
|
|
97
97
|
});
|
|
98
98
|
debug(`${logPrefix} Created user WASM imports for test execution in ${(performance.now() - start).toFixed(2)} ms`);
|
|
99
99
|
userEnvImports = userImports?.env;
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
delete userCustomEnvImports.env;
|
|
103
|
-
}
|
|
100
|
+
userCustomEnvImports = { ...userImports };
|
|
101
|
+
if (userEnvImports) delete userCustomEnvImports.env;
|
|
104
102
|
} catch (error) {
|
|
105
103
|
throw createPoolError(POOL_ERROR_NAMES.WASMUserImportsError, "Could not create user WasmImportsFactory. Ensure that your module has a default export matching () => WebAssembly.Imports", error, true);
|
|
106
104
|
}
|
|
@@ -291,9 +289,24 @@ async function executeWASMDiscovery(compilation, poolOptions, isBinaryInstrument
|
|
|
291
289
|
if (typeof exports._start === "function") exports._start();
|
|
292
290
|
else throw createPoolError(POOL_ERROR_NAMES.WASMExecutionHarnessError, "no _start() export found on compiled WASM binary");
|
|
293
291
|
} catch (error) {
|
|
294
|
-
if (error instanceof WebAssembly.RuntimeError && error?.message.includes("null function or function signature mismatch")) throw createPoolError(POOL_ERROR_NAMES.PoolSyntaxError, SIG_MISMATCH_ERROR_MSG, error);
|
|
295
292
|
if (error && error["__as_pool_error__"]) throw error;
|
|
296
|
-
|
|
293
|
+
if (error instanceof WebAssembly.RuntimeError && error.message.includes("null function or function signature mismatch")) throw createPoolError(POOL_ERROR_NAMES.PoolSyntaxError, SIG_MISMATCH_ERROR_MSG, error);
|
|
294
|
+
if (error instanceof Error) {
|
|
295
|
+
let match = null;
|
|
296
|
+
let moduleName;
|
|
297
|
+
let functionName;
|
|
298
|
+
let errorMessage;
|
|
299
|
+
if (match = /"(.+)": module is not an object or function/.exec(error.message)) {
|
|
300
|
+
moduleName = match[1];
|
|
301
|
+
errorMessage = `Expected module "${moduleName}" to be defined as an object or function within user WASM imports (returned by WasmImportsFactory).`;
|
|
302
|
+
} else if (match = /"(.+)" (function=)?"(.+)": function import requires a callable/.exec(error.message)) {
|
|
303
|
+
moduleName = match[1];
|
|
304
|
+
functionName = match[3];
|
|
305
|
+
errorMessage = `Expected function "${functionName}" to be defined in module "${moduleName}" within user WASM imports (returned by WasmImportsFactory).`;
|
|
306
|
+
}
|
|
307
|
+
if (errorMessage) throw createPoolError(POOL_ERROR_NAMES.WASMUserImportsError, errorMessage, error);
|
|
308
|
+
}
|
|
309
|
+
throw wrapPoolError(POOL_ERROR_NAMES.WASMExecutionHarnessError, error, true);
|
|
297
310
|
}
|
|
298
311
|
debug(`${logPrefix} - Discovered ${file.tasks.length} top-level tasks`);
|
|
299
312
|
}
|
|
@@ -553,4 +566,4 @@ async function loadUserWasmImportsFactory(relativePath, projectRoot, logModule)
|
|
|
553
566
|
|
|
554
567
|
//#endregion
|
|
555
568
|
export { createRpcClient, executeWASMDiscovery, executeWASMTest, flushRpcUpdates, loadUserWasmImportsFactory, reportFileCollected, reportFileError, reportFileQueued, reportSuiteFinished, reportSuitePrepare, reportTestFinished, reportTestPrepare, reportTestRetried, reportUserConsoleLogs };
|
|
556
|
-
//# sourceMappingURL=load-user-imports-
|
|
569
|
+
//# sourceMappingURL=load-user-imports-iAQUMKAi.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"load-user-imports-iAQUMKAi.mjs","names":[],"sources":["../src/wasm-executor/wasm-console.ts","../src/wasm-executor/collect-options.ts","../src/wasm-executor/wasm-imports.ts","../src/wasm-executor/index.ts","../src/pool-thread/rpc-reporter.ts","../src/pool-thread/load-user-imports.ts"],"sourcesContent":["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 {\n AS_POOL_WASM_COVERAGE_MEM_IMPORT_NAME,\n AS_POOL_WASM_IMPORTS_MODULE_NAME,\n POOL_ERROR_NAMES,\n TEST_ERROR_NAMES\n} from '../types/constants.js';\nimport { debug } from '../util/debug.js';\nimport { abortWASMExecution, abortWASMExecutionOnSuccess, createPoolError, getExpectedMessageOrAny } from '../util/pool-errors.js';\nimport { liftString } from '../util/assemblyscript/binding-helpers.js';\nimport { decodeAbortInfo } from './wasm-memory.js';\nimport { createWasmConsole } from './wasm-console.js';\nimport { mergeAssemblyScriptTestOptions } from './collect-options.js';\nimport { createSuiteTask, createTestTask, failTestAssertionError, failTestRuntimeError } 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 userCustomEnvImports = { ...userImports };\n \n if (userEnvImports) {\n delete userCustomEnvImports.env;\n }\n } catch (error) {\n const msg = `Could not create user WasmImportsFactory.`\n + ` Ensure that your module has a default export matching () => WebAssembly.Imports`;\n throw createPoolError(\n POOL_ERROR_NAMES.WASMUserImportsError,\n msg,\n error,\n true\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 const testError: AssemblyScriptTestError = {\n message,\n name: TEST_ERROR_NAMES.WASMRuntimeError,\n };\n\n throw abortWASMExecution(testError, new Error());\n },\n },\n\n [AS_POOL_WASM_IMPORTS_MODULE_NAME]: {\n\n ...(coverageMemory ? { [AS_POOL_WASM_COVERAGE_MEM_IMPORT_NAME]: 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 lastFailedAssertion: FailedAssertion | undefined;\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 // handle expected aborts for thrown errors\n if (isExpectingError) {\n // TODO: decide if .includes is correct here or not\n if (!expectedErrorMsgStr || message.includes(expectedErrorMsgStr)) {\n // either no specifically expected error (any error), or error message matches\n (test.meta as AssemblyScriptTestTaskMeta).assertionsPassedCount++;\n \n debug(`${logPrefix} - Thrown error matches expected - assertion passes`);\n\n // abort without failing the test\n throw abortWASMExecutionOnSuccess();\n } else {\n const expected = getExpectedMessageOrAny(expectedErrorMsgStr);\n\n // error message mismatch\n failureMessage = `expected function to throw error ${expected}, but received error \"${message}\"`;\n\n lastFailedAssertion = {\n message: failureMessage,\n actualTypeName: 'string',\n expectedTypeName: 'string',\n valuesProvided: true,\n actual: message,\n expected: expectedErrorMsgStr\n };\n\n const errStr = `Thrown error does not match expected | Expected: ${expected} | Actual: \"${message}\"`;\n debug(`${logPrefix} - Assertion failed: ${errStr}`);\n }\n }\n\n const testError = lastFailedAssertion\n ? failTestAssertionError(test, lastFailedAssertion)\n : failTestRuntimeError(test, '', failureMessage);\n\n throw abortWASMExecution(testError, new Error());\n },\n },\n\n [AS_POOL_WASM_IMPORTS_MODULE_NAME]: {\n \n ...(coverageMemory ? { [AS_POOL_WASM_COVERAGE_MEM_IMPORT_NAME]: 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, actualTypeNamePtr: number, expectedTypeNamePtr: number, valuesProvided: boolean, actualPtr?: number, expectedPtr?: number) {\n const errorMsg = liftString(memory, msgPtr) ?? '';\n const actualTypeName = liftString(memory, actualTypeNamePtr) ?? '';\n const expectedTypeName = liftString(memory, expectedTypeNamePtr) ?? '';\n let valuesMsg = ' | No Values Provided';\n \n lastFailedAssertion = {\n actualTypeName,\n expectedTypeName,\n message: errorMsg,\n valuesProvided: Boolean(valuesProvided)\n };\n\n (test.meta as AssemblyScriptTestTaskMeta).assertionsFailed.push(lastFailedAssertion);\n \n if (valuesProvided && actualPtr && expectedPtr) {\n lastFailedAssertion.actual = liftString(memory, actualPtr);\n lastFailedAssertion.expected = liftString(memory, expectedPtr);\n valuesMsg = ` | Actual Type: ${actualTypeName} | Expected Type: ${expectedTypeName}`\n + ` | Actual Value: \\`${lastFailedAssertion.actual}\\` | Expected Value: \\`${lastFailedAssertion.expected}\\``;\n }\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: ${getExpectedMessageOrAny(expectedErrorMsgStr)}`);\n\n if (wasmFunctionTable && typeof wasmFunctionTable.get === 'function') {\n const fn = wasmFunctionTable.get(fnIndex);\n if (!fn) {\n throw createPoolError(\n POOL_ERROR_NAMES.WASMExecutionHarnessError,\n `Could not access function (fnPtr ${fnIndex}) which is expected to throw in test \"${test.name}\"`,\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 POOL_ERROR_NAMES.WASMExecutionHarnessError,\n `Could not access WASM function table to call function expected to throw`,\n );\n }\n },\n\n __end_expect_throw() {\n if (isExpectingError) {\n const errStr = `Expected thrown error but got none | Expected: \"${expectedErrorMsgStr}\"`;\n debug(`${logPrefix} - Assertion failed: ${errStr}`);\n \n const failureMessage = `function did not throw, but was expected to throw error: ${getExpectedMessageOrAny(expectedErrorMsgStr)}`;\n const testError = failTestAssertionError(test, {\n message: failureMessage,\n actualTypeName: 'undefined',\n expectedTypeName: 'string',\n valuesProvided: true,\n actual: undefined,\n expected: expectedErrorMsgStr\n });\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 throw abortWASMExecution(testError);\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","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 { AS_POOL_ERROR_FLAG, POOL_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, wrapPoolError } from '../util/pool-errors.js';\nimport { failTestRuntimeError, getTaskLogLabel } from '../util/vitest-tasks.js';\nimport { extractCallStack } from './source-maps.js';\n\nconst SIG_MISMATCH_ERROR_MSG = `WASM function signature type mismatch during test collection.`\n + ` This is most likely caused by passing a type-inferred, non-void callback to expect().`\n + ` To fix, either explicitly define the non-void return type on the callback`\n + ` e.g. \\`expect((): i32 => failingFunction()).toThrowError()\\``\n + ` or use braces to make it void e.g. \\`expect(() => { failingFunction(); }).toThrowError()\\`.`\n + ` Look for the failing expect() within the describe() block indicated in the stack trace.`;\n\nfunction verifyMemoryRequirements(\n compilation: WASMCompilation,\n poolOptions: ResolvedAssemblyScriptPoolOptions,\n) {\n if (poolOptions.testMemoryPagesInitial && poolOptions.testMemoryPagesInitial < compilation.requiredMemory.testMemory.initialPages) {\n throw createPoolError(\n POOL_ERROR_NAMES.PoolConfigError,\n `WASM binary requires initial test memory pages (${compilation.requiredMemory.testMemory.initialPages}) exceeding configured \"testMemoryPagesInitial\"`\n + ` (${poolOptions.testMemoryPagesInitial}). Increase value, or remove for auto sizing.`,\n );\n }\n \n if (poolOptions.testMemoryPagesMax && compilation.requiredMemory.testMemory.maximumPages\n && poolOptions.testMemoryPagesMax < compilation.requiredMemory.testMemory.maximumPages\n ) {\n throw createPoolError(\n POOL_ERROR_NAMES.PoolConfigError,\n `WASM binary requires maximum test memory pages (${compilation.requiredMemory.testMemory.maximumPages}) exceeding configured \"testMemoryPagesMax\"`\n + ` (${poolOptions.testMemoryPagesMax}). Increase value, or remove for auto sizing.`,\n );\n }\n \n if (poolOptions.coverageMemoryPagesInitial && poolOptions.coverageMemoryPagesInitial < compilation.requiredMemory.coverageMemory.initialPages) {\n throw createPoolError(\n POOL_ERROR_NAMES.PoolConfigError,\n `WASM binary requires initial coverage memory pages (${compilation.requiredMemory.coverageMemory.initialPages}) exceeding configured \"coverageMemoryPagesInitial\"`\n + ` (${poolOptions.coverageMemoryPagesInitial}). Increase value, or remove for auto sizing.`,\n );\n }\n\n if (poolOptions.coverageMemoryPagesMax && compilation.requiredMemory.coverageMemory.maximumPages\n && poolOptions.coverageMemoryPagesMax < compilation.requiredMemory.coverageMemory.maximumPages\n ) {\n throw createPoolError(\n POOL_ERROR_NAMES.PoolConfigError,\n `WASM binary requires maximum coverage memory pages (${compilation.requiredMemory.coverageMemory.maximumPages}) exceeding configured \"coverageMemoryPagesMax\"`\n + ` (${poolOptions.coverageMemoryPagesMax}). Increase value, or remove for auto sizing.`,\n );\n }\n}\n\nfunction createExecutorMemories(\n compilation: WASMCompilation,\n poolOptions: ResolvedAssemblyScriptPoolOptions,\n includeCoverageMemory: boolean,\n): { testMemory: WebAssembly.Memory; coverageMemory?: WebAssembly.Memory } {\n verifyMemoryRequirements(compilation, poolOptions);\n\n const testMemory = createMemory(\n poolOptions.testMemoryPagesInitial ?? compilation.requiredMemory.testMemory.initialPages,\n poolOptions.testMemoryPagesMax ?? compilation.requiredMemory.testMemory.maximumPages\n );\n const coverageMemory = includeCoverageMemory ?\n createMemory(\n poolOptions.coverageMemoryPagesInitial ?? compilation.requiredMemory.coverageMemory.initialPages,\n poolOptions.coverageMemoryPagesMax ?? compilation.requiredMemory.coverageMemory.maximumPages\n )\n : undefined;\n\n return { testMemory, coverageMemory };\n}\n\n/**\n * Discover tests via test() and suites via describe() registration calls\n */\nexport async function executeWASMDiscovery(\n compilation: WASMCompilation,\n poolOptions: ResolvedAssemblyScriptPoolOptions,\n isBinaryInstrumented: boolean,\n handleLog: AssemblyScriptConsoleLogHandler,\n file: File,\n moduleLabel: string,\n threadImports: ThreadImports,\n): Promise<void> {\n const base = basename(file.filepath);\n const logPrefix = `[${moduleLabel} Exec] ${getTaskLogLabel(base, file)}`;\n \n try {\n const { testMemory, coverageMemory } = createExecutorMemories(compilation, poolOptions, isBinaryInstrumented);\n\n const importObject = createDiscoveryImports(\n testMemory,\n compilation.compiledModule,\n file,\n handleLog,\n logPrefix,\n coverageMemory,\n threadImports.createUserWasmImports\n );\n\n // Instantiate WASM module\n const instance = new WebAssembly.Instance(compilation.compiledModule, 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 exports._start();\n } else {\n throw createPoolError(\n POOL_ERROR_NAMES.WASMExecutionHarnessError,\n 'no _start() export found on compiled WASM binary'\n );\n }\n } catch (error: any) {\n if (error && error[AS_POOL_ERROR_FLAG]) {\n throw error;\n }\n\n // void type inference issue\n if (error instanceof WebAssembly.RuntimeError && error.message.includes('null function or function signature mismatch')) {\n throw createPoolError(POOL_ERROR_NAMES.PoolSyntaxError, SIG_MISMATCH_ERROR_MSG, error);\n }\n\n if (error instanceof Error) {\n let match: RegExpExecArray | null = null;\n let moduleName: string | undefined;\n let functionName: string | undefined;\n let errorMessage: string | undefined;\n \n if (match = /\"(.+)\": module is not an object or function/.exec(error.message)) {\n // module import error\n moduleName = match[1];\n errorMessage = `Expected module \"${moduleName}\" to be defined as an object`\n + ` or function within user WASM imports (returned by WasmImportsFactory).`;\n } else if (match = /\"(.+)\" (function=)?\"(.+)\": function import requires a callable/.exec(error.message)) {\n // function import error\n moduleName = match[1];\n functionName = match[3];\n errorMessage = `Expected function \"${functionName}\" to be defined in module \"${moduleName}\"`\n + ` within user WASM imports (returned by WasmImportsFactory).`;\n }\n\n if (errorMessage) {\n throw createPoolError(POOL_ERROR_NAMES.WASMUserImportsError, errorMessage, error);\n }\n }\n \n // any other error\n throw wrapPoolError(POOL_ERROR_NAMES.WASMExecutionHarnessError, error, true);\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 poolOptions: ResolvedAssemblyScriptPoolOptions,\n collectCoverage: boolean,\n handleLog: AssemblyScriptConsoleLogHandler,\n moduleLabel: string,\n threadImports: ThreadImports,\n projectRoot: string,\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 const { testMemory, coverageMemory } = createExecutorMemories(compilation, poolOptions, collectCoverage);\n\n // Create import object with pool-side functions for capturing test execution results\n const { imports, provideFunctionTable } = createTestExecutionImports(\n testMemory,\n compilation.compiledModule,\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(compilation.compiledModule, 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 createPoolError(\n POOL_ERROR_NAMES.WASMExecutionHarnessError,\n 'no _start() export found on compiled WASM binary'\n );\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 createPoolError(\n POOL_ERROR_NAMES.WASMExecutionHarnessError,\n `Test function at index ${idx} not found in function table`\n );\n }\n } else {\n throw createPoolError(\n POOL_ERROR_NAMES.WASMExecutionHarnessError,\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: any) {\n testTimings.execEnd = performance.now();\n\n let testError: AssemblyScriptTestError;\n let stack: NodeJS.CallSite[];\n let allowStackJS: boolean;\n let applyStackToTestErrorCause: boolean;\n\n if (error && error[AS_POOL_ERROR_FLAG]) {\n const wrapper = error as AssemblyScriptPoolError;\n testError = wrapper.testError;\n stack = wrapper.originalErrorRawStack;\n allowStackJS = wrapper.originalErrorMayContainJS;\n applyStackToTestErrorCause = wrapper.applyStackToTestErrorCause;\n } else if (error instanceof Error) {\n testError = failTestRuntimeError(test, error.name, error.message);\n stack = extractCallStack(error);\n allowStackJS = true;\n applyStackToTestErrorCause = false;\n } else {\n testError = failTestRuntimeError(test, '', `Unexpected WASM test execution error: ${String(error)}`);\n stack = extractCallStack(new Error());\n allowStackJS = true;\n applyStackToTestErrorCause = false;\n }\n\n await enhanceTestError(\n testError,\n test,\n compilation.sourceMap,\n logPrefix,\n allowStackJS,\n projectRoot,\n applyStackToTestErrorCause,\n stack,\n diffOptions\n );\n }\n\n const meta = test.meta as AssemblyScriptTestTaskMeta;\n\n // Extract coverage hits from coverage memory\n if (collectCoverage && compilation.debugInfo) {\n if (!coverageMemory) {\n throw createPoolError(\n POOL_ERROR_NAMES.WASMExecutionHarnessError,\n 'Coverage memory not created despite 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 { POOL_ERROR_NAMES } from '../types/constants.js';\nimport { createPoolError } from '../util/pool-errors.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}] Imported user WasmImportsFactory \"${safeUrl}\" | TIMING ${(performance.now() - start).toFixed(2)} ms`);\n\n if (typeof createWasmImports !== 'function') {\n const msg = `Could not load user WasmImportsFactory from \"${safeUrl}\".`\n + ` Ensure that your module has a default export matching () => WebAssembly.Imports`\n + ` \\nDefault export type is currently \"${typeof createWasmImports}\"`;\n \n throw createPoolError(POOL_ERROR_NAMES.WASMUserImportsError, msg);\n } else {\n return createWasmImports;\n }\n } catch (error) {\n const msg = `Could not load user WasmImportsFactory from \"${safeUrl}\".`\n + ` Ensure that your module path is relative to the project root`\n + ` (location of shallowest vitest config), and that it has a`\n + ` default export matching () => WebAssembly.Imports`;\n throw createPoolError(\n POOL_ERROR_NAMES.WASMUserImportsError,\n msg,\n error,\n true\n );\n }\n};\n"],"mappings":";;;;;;;;;AAGA,SAAgB,kBACd,QACA,WACA;CACA,MAAM,cAAc,QAAgB,QAA4B,SAAiB,OAAe;AAC9F,SAAO,GAAG,SAAS,SAAS,WAAW,QAAQ,OAAO,GAAG;;CAG3D,MAAM,gBAA6C,EAAE;AAIrD,QAAO;EACL,mBAAsB,WAAc,WAAyB;AAC3D,OAAI,CAAC,WAAW;IACd,MAAM,MAAM,WAAW,QAAQ,OAAO;AACtC,cAAU,mBAAmB,MAAM,KAAK,QAAQ,KAAK;;;EAGzD,gBAAgB,WAAyB;AACvC,aAAU,WAAW,QAAQ,OAAO,CAAC;;EAEvC,kBAAkB,WAAyB;AACzC,aAAU,WAAW,QAAQ,QAAQ,UAAU,CAAC;;EAElD,iBAAiB,WAAyB;AACxC,aAAU,WAAW,QAAQ,QAAQ,SAAS,CAAC;;EAEjD,iBAAiB,WAAyB;AACxC,aAAU,WAAW,QAAQ,QAAQ,YAAY,EAAE,KAAK;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O,KAAK,KAAK;EAC5D,QAAQ,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;;;;;ACtRhC,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,sCAAsC,QAAQ,cAAc,YAAY,KAAK,GAAG,OAAO,QAAQ,EAAE,CAAC,KAAK;AAE3H,MAAI,OAAO,sBAAsB,YAAY;GAC3C,MAAM,MAAM,gDAAgD,QAAQ,yHAExB,OAAO,kBAAkB;AAErE,SAAM,gBAAgB,iBAAiB,sBAAsB,IAAI;QAEjE,QAAO;UAEF,OAAO;EACd,MAAM,MAAM,gDAAgD,QAAQ;AAIpE,QAAM,gBACJ,iBAAiB,sBACjB,KACA,OACA,KACD"}
|
|
@@ -2,9 +2,9 @@ import { POOL_ERROR_NAMES, POOL_INTERNAL_PATHS, TEST_ERROR_NAMES } from "./const
|
|
|
2
2
|
import { relative } from "node:path";
|
|
3
3
|
import { readFile } from "node:fs/promises";
|
|
4
4
|
import { stripVTControlCharacters } from "node:util";
|
|
5
|
-
import { fileURLToPath } from "node:url";
|
|
6
5
|
import c from "tinyrainbow";
|
|
7
6
|
import { highlight } from "tinyhighlight";
|
|
7
|
+
import { fileURLToPath } from "node:url";
|
|
8
8
|
import { diff } from "@vitest/utils/diff";
|
|
9
9
|
import { SourceMapConsumer } from "source-map";
|
|
10
10
|
|
|
@@ -113,9 +113,8 @@ function toVitestLikeStackFrameString(frame) {
|
|
|
113
113
|
}
|
|
114
114
|
async function getSourceCodeFrameString(sourceMap, frame) {
|
|
115
115
|
let source;
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
if (fileIndex < 0 || !sourceMap.sourcesContent) source = await readFile(fileURLToPath(frame.file), "utf-8");
|
|
116
|
+
const fileIndex = sourceMap?.sources.indexOf(frame.file) ?? -1;
|
|
117
|
+
if (fileIndex < 0 || !sourceMap?.sourcesContent) source = await readFile(frame.file, "utf-8");
|
|
119
118
|
else source = sourceMap.sourcesContent[fileIndex];
|
|
120
119
|
if (!source) return;
|
|
121
120
|
return generateCodeFrame(source.length < MAX_CODE_HIGHLIGHT_LENGTH ? highlightCode(source) : source, CODE_FRAME_INDENT_SPACES, frame);
|
|
@@ -628,4 +627,4 @@ async function buildEnhancedFileError(error, task, sourceMap, logPrefix, project
|
|
|
628
627
|
|
|
629
628
|
//#endregion
|
|
630
629
|
export { abortWASMExecution, abortWASMExecutionOnSuccess, buildEnhancedFileError, createPoolError, createTestExpectedToFailError, createTestTimeoutError, debug, debugOverride, enhanceTestError, extractCallStack, getExpectedMessageOrAny, getShortFunctionName, isAbortError, parseSourceMap, setGlobalDebugMode, toForwardSlash, wrapPoolError };
|
|
631
|
-
//# sourceMappingURL=pool-errors-
|
|
630
|
+
//# sourceMappingURL=pool-errors-Bn6YaguR.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pool-errors-Bn6YaguR.mjs","names":[],"sources":["../src/util/path-utils.ts","../src/util/debug.ts","../src/util/highlight-code.ts","../src/util/test-error-formatting.ts","../src/wasm-executor/source-maps.ts","../src/wasm-executor/wasm-names.ts","../src/wasm-executor/wasm-errors.ts","../src/util/pool-errors.ts"],"sourcesContent":["/**\n * Path Utilities\n *\n * Cross-platform path normalization for consistent path comparisons.\n * All internal paths use forward slashes.\n */\n\n/**\n * Convert path to forward slashes for consistent cross-platform comparison.\n *\n * Source maps always use forward slashes regardless of OS. By normalizing\n * all paths to forward slashes, we ensure consistent matching between:\n * - Source map paths (already forward slashes)\n * - Glob results (OS-native, need conversion on Windows)\n * - Relative paths from Node's path.relative() (OS-native)\n * - Resolved paths from Node's path.resolve() (OS-native)\n */\nexport function toForwardSlash(path: string): string {\n return path.replace(/\\\\/g, '/');\n}\n","/**\n * Debug logging utility\n */\n\ndeclare global {\n var AS_POOL_DEBUG: boolean | undefined;\n}\n\nglobalThis.AS_POOL_DEBUG = false;\n\nconst DEBUG_ENV_ENABLED_VALUE = 'vitest_as_pool' as const;\n\nfunction isEnabled(): boolean {\n return globalThis.AS_POOL_DEBUG === true || process.env.DEBUG === DEBUG_ENV_ENABLED_VALUE;\n}\n\n/**\n * Initialize debug mode for current async context (called by worker at task start)\n * @param {boolean} debugEnabled - Enable verbose debug logging\n */\nexport function setGlobalDebugMode(debugEnabled: boolean): void {\n globalThis.AS_POOL_DEBUG = debugEnabled;\n}\n\nfunction debugLog(...args: any): void {\n // if first arg is a function, execute it and then print the result\n if (args?.length > 0 && typeof args[0] === 'function') {\n const result = args[0]();\n const rest = args.length > 1 ? args.slice(1) : [];\n console.log(Date.now(), String(result), ...rest);\n } else {\n console.log(Date.now(), ...args);\n }\n}\n\n/**\n * Log debug message (only when debug enabled in current global context)\n * or when environment has a given DEBUG variable set.\n */\nexport function debug(...args: any): void {\n if (isEnabled()) {\n debugLog(...args);\n }\n}\n\n/**\n * Log debug message (caller expected to determine if enabled)\n */\nexport function debugOverride(...args: any): void {\n debugLog(...args);\n}\n\n/**\n * Determine if debug mode is enabled for the current global context\n */\nexport function isDebugModeEnabled(): boolean {\n return isEnabled();\n}\n\nexport async function delay(ms: number = 5000): Promise<void> {\n return new Promise<void>((resolve, _reject) => {\n setTimeout(resolve, ms);\n });\n}\n","import { highlight, type TokenColors } from 'tinyhighlight';\nimport c from 'tinyrainbow';\n\n/**\n * Adapted from vitest. The internal function was changed between vitest 3.2.x and 4.0.x,\n * and then removed from public exposure in 4.1.x, so now instead we recreate the same\n * highlighting color rules.\n * \n * @see https://github.com/vitest-dev/vitest/blob/v4.1.0/packages/vitest/src/utils/colors.ts#L18\n * \n * Vitest is released under the MIT license, included in this project's root.\n * Copyright (c) 2021-Present Vitest Team\n */\n\nconst colors: TokenColors = {\n Keyword: c.magenta,\n IdentifierCapitalized: c.yellow,\n Punctuator: c.yellow,\n StringLiteral: c.green,\n NoSubstitutionTemplate: c.green,\n MultiLineComment: c.gray,\n SingleLineComment: c.gray,\n RegularExpressionLiteral: c.cyan,\n NumericLiteral: c.blue,\n TemplateHead: text =>\n c.green(text.slice(0, text.length - 2)) + c.cyan(text.slice(-2)),\n TemplateTail: text => c.cyan(text.slice(0, 1)) + c.green(text.slice(1)),\n TemplateMiddle: text =>\n c.cyan(text.slice(0, 1))\n + c.green(text.slice(1, text.length - 2))\n + c.cyan(text.slice(-2)),\n IdentifierCallable: c.blue,\n PrivateIdentifierCallable: text => `#${c.blue(text.slice(1))}`,\n Invalid: (text: string) => c.white(c.bgRed(c.bold(text)))\n};\n\nexport function highlightCode(source: string): string {\n return highlight(source, { colors });\n}\n","import { stripVTControlCharacters } from 'node:util';\nimport { readFile } from 'node:fs/promises';\nimport type { RawSourceMap } from 'source-map';\nimport type { ParsedStack } from '@vitest/utils';\nimport c from 'tinyrainbow';\n\nimport { highlightCode } from './highlight-code.js';\n\nconst FRAME_POINTER = '❯' as const;\nconst CODE_FRAME_INDENT_SPACES = 4 as const;\n\n// same performance guard used in vitest `printError`\nconst MAX_CODE_HIGHLIGHT_LENGTH = 100_000 as const;\n\nexport function getYellowString(str: string): string {\n return c.yellow(str);\n}\n\nexport function toPlaintextStackFrameString(frame: ParsedStack): string {\n return ` at ${frame.method} ${frame.file}:${frame.line}:${frame.column}`;\n}\n\nexport function toVitestLikeStackFrameString(frame: ParsedStack): string {\n return c.cyan(\n ` ${c.dim(FRAME_POINTER)} ${frame.method} ${frame.file}:${c.dim(`${frame.line}:${frame.column}`)}`\n );\n}\n\nexport async function getSourceCodeFrameString(\n sourceMap: RawSourceMap | undefined,\n frame: ParsedStack,\n): Promise<string | undefined> {\n let source: string | undefined;\n\n const fileIndex = sourceMap?.sources.indexOf(frame.file) ?? -1;\n if (fileIndex < 0 || !sourceMap?.sourcesContent) {\n source = await readFile(frame.file, 'utf-8');\n } else {\n source = sourceMap.sourcesContent[fileIndex];\n }\n\n if (!source) {\n return undefined;\n }\n\n const highlightedSource = source.length < MAX_CODE_HIGHLIGHT_LENGTH\n ? highlightCode(source)\n : source;\n\n return generateCodeFrame(highlightedSource, CODE_FRAME_INDENT_SPACES, frame);\n}\n\n\n// ============================================================================\n// Source code formatting functions borrowed from Vitest\n// ============================================================================\n\n/**\n * Vitest doesn't expose generateCodeFrame as a util, so we have\n * recreated it here with minimal changes.\n * \n * @see https://github.com/vitest-dev/vitest/blob/v3.2.4/packages/vitest/src/node/printError.ts#L424\n * \n * Vitest is released under the MIT license, included in this project's root.\n * Copyright (c) 2021-Present Vitest Team\n */\n\nconst lineSplitRE: RegExp = /\\r?\\n/;\n\nfunction generateCodeFrame(\n source: string,\n indent = 0,\n loc: { line: number; column: number } | number,\n range = 2,\n): string {\n const start\n = typeof loc === 'object'\n ? positionToOffset(source, loc.line, loc.column)\n : loc\n const end = start\n const lines = source.split(lineSplitRE)\n const nl = /\\r\\n/.test(source) ? 2 : 1\n let count = 0\n let res: string[] = []\n\n const columns = process.stdout?.columns || 80\n\n for (let i = 0; i < lines.length; i++) {\n count += lines[i]!.length + nl\n if (count >= start) {\n for (let j = i - range; j <= i + range || end > count; j++) {\n if (j < 0 || j >= lines.length) {\n continue\n }\n\n const lineLength = lines[j]!.length\n\n // too long, maybe it's a minified file, skip for codeframe\n if (stripVTControlCharacters(lines[j]!).length > 200) {\n return ''\n }\n\n res.push(\n lineNo(j + 1)\n + truncateString(lines[j]!.replace(/\\t/g, ' '), columns - 5 - indent),\n )\n\n if (j === i) {\n // push underline\n const pad = start - (count - lineLength) + (nl - 1)\n const length = Math.max(\n 1,\n end > count ? lineLength - pad : end - start,\n )\n res.push(lineNo() + ' '.repeat(pad) + c.red('^'.repeat(length)))\n }\n else if (j > i) {\n if (end > count) {\n const length = Math.max(1, Math.min(end - count, lineLength))\n res.push(lineNo() + c.red('^'.repeat(length)))\n }\n count += lineLength + 1\n }\n }\n break\n }\n }\n\n if (indent) {\n res = res.map(line => ' '.repeat(indent) + line)\n }\n\n return res.join('\\n')\n}\n\n\nfunction positionToOffset(\n source: string,\n lineNumber: number,\n columnNumber: number,\n): number {\n const lines = source.split(lineSplitRE)\n const nl = /\\r\\n/.test(source) ? 2 : 1\n let start = 0\n\n if (lineNumber > lines.length) {\n return source.length\n }\n\n for (let i = 0; i < lineNumber - 1; i++) {\n start += lines[i]!.length + nl\n }\n\n return start + columnNumber\n}\n\nfunction lineNo(no: number | string = '') {\n return c.gray(`${String(no).padStart(3, ' ')}| `)\n}\n\nfunction truncateString(text: string, maxLength: number): string {\n const plainText = stripVTControlCharacters(text)\n\n if (plainText.length <= maxLength) {\n return text\n }\n\n return `${plainText.slice(0, maxLength - 1)}…`\n}\n","/**\n * Source Map Utilities\n *\n * Maps WASM errors to AssemblyScript source locations using V8 stack traces + source maps.\n *\n * Approach: V8's Error.prepareStackTrace provides WAT (WebAssembly Text) line:column positions,\n * which can be mapped to AS source using the source maps generated by AS compiler.\n */\n\nimport { type RawSourceMap, SourceMapConsumer } from 'source-map';\n\nimport { debug } from '../util/debug.js';\nimport type { WebAssemblyCallSite } from '../types/types.js';\n\nexport function parseSourceMap(sourceMap: string): RawSourceMap {\n // Remove sourceRoot if present to prevent source-map library from prepending it to paths\n // AS compiler sets sourceRoot: \"./output\" which would make paths like \"output/tests/...\"\n // instead of \"tests/...\" - these paths don't exist and won't be found by Vitest\n const sourceMapObj: RawSourceMap = JSON.parse(sourceMap);\n delete sourceMapObj.sourceRoot;\n return sourceMapObj;\n}\n\n/**\n * Extract structured call stack from V8 using Error.prepareStackTrace\n *\n * V8 provides a special API to access structured stack traces with line:column info.\n * This gives us WAT text positions which can be mapped to AS source via source maps.\n *\n * @param capturedError - Error object to extract stack from\n * @returns Array of V8 CallSite objects\n */\nexport function extractCallStack(capturedError: Error): NodeJS.CallSite[] {\n let stackTrace: NodeJS.CallSite[] = [];\n\n const originalPrepareStackTrace = Error.prepareStackTrace;\n Error.prepareStackTrace = (_err: Error, structuredStackTrace: NodeJS.CallSite[]) => {\n stackTrace = structuredStackTrace;\n return ''; // Return empty string to avoid modifying error.stack\n };\n\n // Access error.stack to trigger prepareStackTrace (result unused, just triggers callback)\n capturedError.stack;\n\n // Restore original\n Error.prepareStackTrace = originalPrepareStackTrace;\n\n return stackTrace;\n}\n\n/**\n * Create WebAssembly call site with source mapping\n *\n * Takes a V8 CallSite and maps it to AS source location if possible.\n *\n * @param callSite - V8 CallSite object from Error.prepareStackTrace\n * @param sourceMapJson - Source map consumer initialized with WASM source map\n * @returns Mapped call site or null if not a WASM call site\n */\nexport function createWebAssemblyCallSite(\n callSite: NodeJS.CallSite,\n sourceMapConsumer: SourceMapConsumer,\n loggingPrefix: string,\n allowJS: boolean,\n): WebAssemblyCallSite | null {\n const fileName = callSite.getFileName();\n const watLine = callSite.getLineNumber();\n const watColumn = callSite.getColumnNumber();\n const functionName = callSite.getFunctionName() ?? 'function[unknown]';\n const debugString = `function: \"${functionName}\" | file: ${fileName}:${watLine}:${watColumn}`;\n\n // Only process WASM call sites\n if (!fileName) {\n debug(`${loggingPrefix} - Skipping source-mapping of invalid frame (no file): ${debugString}`);\n return null;\n }\n \n if (!fileName.startsWith('wasm://')) {\n if (allowJS) {\n if (!watLine || !watColumn) {\n debug(`${loggingPrefix} - Failed to pass through invalid JS stack location: ${debugString}`);\n return null;\n }\n\n debug(`${loggingPrefix} - Passing through JS stack location: ${debugString}`);\n return {\n functionName,\n location: {\n filePath: fileName,\n line: watLine,\n column: watColumn\n }\n }; \n } else {\n debug(`${loggingPrefix} - Skipping source-mapping of non-WASM stack location: ${debugString}`);\n return null;\n }\n }\n\n // Try to map WAT location to source location using source map\n if (watLine && watColumn) {\n const original = sourceMapConsumer.originalPositionFor({\n line: watLine,\n column: watColumn\n });\n \n if (!original.source || original.line === null || original.column === null) {\n debug(`${loggingPrefix} - Failed to source-map stack location: ${debugString}`);\n return null;\n }\n\n debug(`${loggingPrefix} - Source-mapped stack location: ${debugString} → ${original.source}:${original.line}:${original.column}`);\n return {\n functionName,\n location: {\n filePath: original.source,\n line: original.line,\n column: original.column\n }\n };\n }\n\n debug(`${loggingPrefix} - Cannot source-map stack-location: ${debugString}`);\n return null;\n}\n","/**\n * Extracts the short name from a WASM function table name identifier.\n */\nexport function getShortFunctionName(fullName: string): string {\n if (!fullName) {\n return '';\n }\n\n // URL decode first (handle potential decoding errors)\n let decoded: string;\n try {\n decoded = decodeURIComponent(fullName);\n \n // handle AS encoding quirk in generics\n // e.g. \"closeTo<bool\\2cbool>\" -> \"closeTo<bool,bool>\"\n decoded = decoded.replace('\\\\2c', ',');\n } catch {\n decoded = fullName;\n }\n\n // Find the last '/' that's not inside angle brackets or parens\n let angleBracketDepth = 0;\n let parenDepth = 0;\n let lastSlashOutsideBrackets = -1;\n\n for (let i = 0; i < decoded.length; i++) {\n const char = decoded[i];\n if (char === '<') {\n angleBracketDepth++;\n } else if (char === '>' && decoded[i - 1] !== '=') {\n angleBracketDepth--;\n } else if (char === '(') {\n parenDepth++;\n } else if (char === ')') {\n parenDepth--;\n } else if (char === '/' && angleBracketDepth === 0 && parenDepth === 0) {\n lastSlashOutsideBrackets = i;\n }\n }\n\n const functionPart = lastSlashOutsideBrackets >= 0\n ? decoded.substring(lastSlashOutsideBrackets + 1)\n : decoded;\n\n // Handle anonymous function case: \"file.as.test~anonymous|1\" → \"anonymous|1\"\n const anonymousMatch = functionPart.match(/^.+~(anonymous\\|\\d+)$/);\n if (anonymousMatch) {\n return anonymousMatch[1]!;\n }\n\n // Process any generics/paths in the function signature\n return shortenTypePart(functionPart);\n}\n\n/**\n * Finds the index of the closing '>' that matches the opening '<' at openIndex.\n */\nfunction findMatchingCloseBracket(str: string, openIndex: number): number {\n let angleBracketDepth = 1;\n\n for (let i = openIndex + 1; i < str.length; i++) {\n const char = str[i];\n if (char === '<') {\n angleBracketDepth++;\n } else if (char === '>' && str[i - 1] !== '=') {\n angleBracketDepth--;\n if (angleBracketDepth === 0) return i;\n }\n }\n return str.length - 1;\n}\n\n/**\n * Finds the index of the closing ')' that matches the opening '(' at openIndex.\n */\nfunction findMatchingCloseParen(str: string, openIndex: number): number {\n let parenDepth = 1;\n let angleBracketDepth = 0;\n\n for (let i = openIndex + 1; i < str.length; i++) {\n const char = str[i];\n if (char === '(') {\n parenDepth++;\n } else if (char === ')') {\n parenDepth--;\n if (parenDepth === 0) return i;\n } else if (char === '<') {\n angleBracketDepth++;\n } else if (char === '>' && str[i - 1] !== '=') {\n angleBracketDepth--;\n }\n }\n return str.length - 1;\n}\n\n/**\n * Splits a string by commas at the top level (not inside <> or ()).\n */\nfunction splitByTopLevelComma(str: string): string[] {\n const parts: string[] = [];\n let current = '';\n let angleBracketDepth = 0;\n let parenDepth = 0;\n\n for (let i = 0; i < str.length; i++) {\n const char = str[i];\n if (char === '<') {\n angleBracketDepth++;\n } else if (char === '>' && str[i - 1] !== '=') {\n angleBracketDepth--;\n } else if (char === '(') {\n parenDepth++;\n } else if (char === ')') {\n parenDepth--;\n } else if (char === ',' && angleBracketDepth === 0 && parenDepth === 0) {\n parts.push(current);\n current = '';\n continue;\n }\n current += char;\n }\n parts.push(current);\n return parts;\n}\n\n/**\n * Processes the content inside generic brackets or function args.\n */\nfunction shortenGenericContent(content: string): string {\n const parts = splitByTopLevelComma(content);\n return parts.map(part => shortenTypePart(part.trim())).join(',');\n}\n\n/**\n * Shortens a function type like (args)=>returnType.\n */\nfunction shortenFunctionType(part: string): string {\n const closeParenIndex = findMatchingCloseParen(part, 0);\n const argsContent = part.substring(1, closeParenIndex);\n const afterParen = part.substring(closeParenIndex + 1);\n\n const shortenedArgs = argsContent ? shortenGenericContent(argsContent) : '';\n\n let returnPart = afterParen;\n if (afterParen.startsWith('=>') && afterParen.length > 2) {\n const returnType = afterParen.substring(2);\n returnPart = '=>' + shortenTypePart(returnType);\n }\n\n return '(' + shortenedArgs + ')' + returnPart;\n}\n\n/**\n * Shortens a type/function part, processing paths and generics recursively.\n */\nfunction shortenTypePart(part: string): string {\n // Function types\n if (part.startsWith('(')) {\n return shortenFunctionType(part);\n }\n\n const openBracket = part.indexOf('<');\n\n if (openBracket === -1) {\n // No generics - extract last path segment if present\n if (!part.includes('/')) {\n return part;\n }\n return part.substring(part.lastIndexOf('/') + 1);\n }\n\n // Has generics - extract name and process content\n const namePart = part.substring(0, openBracket);\n const closeBracket = findMatchingCloseBracket(part, openBracket);\n const genericContent = part.substring(openBracket + 1, closeBracket);\n\n const name = namePart.includes('/')\n ? namePart.substring(namePart.lastIndexOf('/') + 1)\n : namePart;\n\n const shortenedContent = shortenGenericContent(genericContent);\n\n return name + '<' + shortenedContent + '>';\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 { relative } from 'node:path';\nimport { fileURLToPath } from 'node:url';\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, WebAssemblyCallSite } from '../types/types.js';\nimport { POOL_INTERNAL_PATHS, TEST_ERROR_NAMES } from '../types/constants.js';\nimport { debug } from '../util/debug.js';\nimport { createWebAssemblyCallSite } from './source-maps.js';\nimport { getShortFunctionName } from './wasm-names.js';\nimport {\n getSourceCodeFrameString,\n toPlaintextStackFrameString,\n toVitestLikeStackFrameString,\n} from '../util/test-error-formatting.js';\nimport { toForwardSlash } from '../util/path-utils.js';\n\nconst POOL_INTERNAL_PATHS_SET = new Set(POOL_INTERNAL_PATHS);\n\nfunction passthroughCallSite(callSite: NodeJS.CallSite): ParsedStack {\n const fileName = callSite.getFileName();\n const watLine = callSite.getLineNumber();\n const watColumn = callSite.getColumnNumber();\n const functionName = callSite.getFunctionName() || 'wasm-function[unknown]';\n\n return {\n method: functionName,\n file: fileName ?? 'unknown-file',\n line: watLine || -1,\n column: watColumn || -1\n };\n}\n\nasync function sourceMapRawCallStack(\n rawCallStack: NodeJS.CallSite[],\n sourceMap: RawSourceMap | undefined,\n loggingPrefix: string,\n allowJS: boolean,\n): Promise<WebAssemblyCallSite[]> {\n const mappedStack: WebAssemblyCallSite[] = [];\n\n if (!rawCallStack || rawCallStack.length === 0) {\n return mappedStack;\n }\n\n if (sourceMap) {\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, allowJS);\n if (mappedCallSite) {\n mappedStack.push(mappedCallSite);\n }\n });\n \n sourceMapConsumer.destroy();\n }\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.filePath.startsWith('file')\n ? frame.location.column // unmapped file needs no change \n : frame.location.column + 1, // Convert from raw source-map's 0-indexed to 1-indexed for display\n }));\n}\n\nexport async function processWASMErrorStack(\n rawCallStack: NodeJS.CallSite[],\n sourceMap: RawSourceMap | undefined,\n loggingPrefix: string,\n allowJS: bool,\n): Promise<ParsedStack[]> {\n // map stack call sites from WASM locations to source code locations \n const sourceMappedStack = await sourceMapRawCallStack(rawCallStack, sourceMap, loggingPrefix, allowJS);\n debug(`${loggingPrefix} - Mapped ${rawCallStack.length} call sites to ${sourceMappedStack.length} source locations`);\n\n const parsedStack = parseMappedStack(sourceMappedStack);\n\n if (parsedStack.length === 0) {\n rawCallStack.forEach(callSite => {\n parsedStack.push(passthroughCallSite(callSite));\n });\n }\n\n return parsedStack;\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 testError: AssemblyScriptTestError,\n task: Test | Suite,\n sourceMap: RawSourceMap | undefined,\n logPrefix: string,\n allowJS: boolean,\n projectRoot: string,\n applyStackToTestErrorCause: boolean,\n rawCallStack?: NodeJS.CallSite[],\n diffOptions?: SerializedDiffOptions\n): Promise<void> {\n let expectedVsActualDiffString: string | undefined;\n const isAssertionFailure = testError.name === TEST_ERROR_NAMES.AssertionError;\n const valuesProvided = testError.expected !== undefined && testError.actual !== undefined;\n\n if (isAssertionFailure && valuesProvided) {\n // remain undefined if there were no expected/actual values provided with the assertion failure\n expectedVsActualDiffString = diff(testError.expected, testError.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 testError.diff = expectedVsActualDiffString;\n\n // stack is used by vitest for error deduplication, so make sure it is set\n testError.stack = `${task.name} - ${testError.message}`;\n\n return;\n }\n\n const testErrorToUpdate: AssemblyScriptTestError = applyStackToTestErrorCause && testError.cause\n ? testError.cause as AssemblyScriptTestError : testError;\n\n // map stack call sites from WASM locations to source locations\n const parsedStack = await processWASMErrorStack(rawCallStack, sourceMap, logPrefix, allowJS);\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 // normalize all paths\n parsedStack.forEach((frame) => {\n\t\t\tif (frame.file.startsWith(\"file://\")) {\n\t\t\t\tframe.file = toForwardSlash(relative(projectRoot, fileURLToPath(frame.file)));\n testErrorToUpdate.stack += toPlaintextStackFrameString(frame) + '\\n';\n\t\t\t}\n\t\t});\n\n const primaryStackFrame = parsedStack[0]!;\n \n // Test error is set to rest of the stack without the first frame.\n // Vitest will report the ParsedStack[] on TestError.stacks below the diff we set.\n testErrorToUpdate.stacks = parsedStack.slice(1);\n\n // stack is used by vitest for error deduplication, so make sure it is set also\n testErrorToUpdate.stack = parsedStack.map(toPlaintextStackFrameString).join('\\n');\n\n try {\n highlightedSourceCodeFrameString = await getSourceCodeFrameString(sourceMap, primaryStackFrame);\n } catch (err) {\n debug(`${logPrefix} - Error reading source for primary stack frame file \"${primaryStackFrame.file}\":`, err);\n }\n\n primaryStackFrameString = toVitestLikeStackFrameString(primaryStackFrame);\n\n debug(`${logPrefix} - Enhanced ${testError.name} error with parsed source stack`);\n } else {\n testErrorToUpdate.stack = `${task.name} - ${testError.message}`;\n }\n\n // Use the diff field as our way to show all output (other than result.error.stacks)\n testErrorToUpdate.diff = [\n expectedVsActualDiffString,\n expectedVsActualDiffString ? '\\n\\n' : '',\n primaryStackFrameString ?? '',\n highlightedSourceCodeFrameString ? '\\n' : '',\n highlightedSourceCodeFrameString ?? ''\n ].join('');\n\n debug(`[${logPrefix} - Enhanced error with diffs`);\n\n return;\n}\n","import type { Suite, Test } from '@vitest/runner/types';\nimport type { SerializedDiffOptions } from '@vitest/utils/diff';\nimport type { RawSourceMap } from 'source-map';\n\nimport type {\n AssemblyScriptPoolError,\n AssemblyScriptTestError,\n PoolErrorName,\n} from '../types/types.js';\nimport {\n AS_POOL_ERROR_FLAG,\n POOL_ERROR_NAMES,\n TEST_ERROR_NAMES\n} from '../types/constants.js';\nimport { getYellowString } from './test-error-formatting.js';\nimport { extractCallStack } from '../wasm-executor/source-maps.js';\nimport { enhanceTestError } from '../wasm-executor/wasm-errors.js';\n\nexport function abortWASMExecutionOnSuccess(): AssemblyScriptPoolError {\n return {\n [AS_POOL_ERROR_FLAG]: true,\n name: POOL_ERROR_NAMES.WASMExecutionAbortSuccess,\n testError: {} as AssemblyScriptTestError,\n originalErrorMayContainJS: false,\n originalErrorRawStack: [],\n applyStackToTestErrorCause: false\n };\n}\n\nexport function abortWASMExecution(\n testError: AssemblyScriptTestError,\n errorForStack?: Error,\n): AssemblyScriptPoolError {\n return {\n [AS_POOL_ERROR_FLAG]: true,\n name: POOL_ERROR_NAMES.WASMExecutionAbortError,\n testError,\n originalErrorMayContainJS: false,\n originalErrorRawStack: errorForStack ? extractCallStack(errorForStack) : [],\n applyStackToTestErrorCause: false\n };\n}\n\nexport function wrapPoolError(\n name: PoolErrorName,\n originalError: any,\n originalErrorMayContainJS: boolean = false,\n): AssemblyScriptPoolError {\n let originalErrorName: string | undefined;\n let originalErrorMessage: string;\n let originalErrorRawStack: NodeJS.CallSite[];\n\n if (originalError && originalError instanceof Error) {\n originalErrorName = originalError.name;\n originalErrorMessage = originalError.message;\n originalErrorRawStack = extractCallStack(originalError);\n } else if (originalError) {\n originalErrorMessage = String(originalError);\n originalErrorRawStack = [];\n } else {\n originalErrorMessage = 'Unknown Error';\n originalErrorRawStack = [];\n }\n\n const namePrefix = originalErrorName ? `${originalErrorName}: ` : '';\n const testError: AssemblyScriptTestError = {\n name,\n message: `${namePrefix}${originalErrorMessage}`\n };\n\n return {\n [AS_POOL_ERROR_FLAG]: true,\n name,\n message: 'Wrapped error',\n originalErrorRawStack,\n originalErrorMayContainJS,\n testError,\n applyStackToTestErrorCause: false\n };\n}\n\nexport function createPoolError(\n name: PoolErrorName,\n message: string,\n originalError?: any,\n originalErrorMayContainJS: boolean = true,\n): AssemblyScriptPoolError {\n if (originalError && originalError[AS_POOL_ERROR_FLAG]) {\n return originalError;\n }\n\n let originalErrorRawStack: NodeJS.CallSite[] = [];\n let applyStackToTestErrorCause: boolean = false;\n const testError: AssemblyScriptTestError = {\n name,\n message\n };\n\n if (originalError && originalError instanceof Error) {\n testError.cause = {\n name: originalError.name,\n message: `${originalError.message}`\n };\n originalErrorRawStack = extractCallStack(originalError);\n applyStackToTestErrorCause = true;\n } else if (originalError) {\n testError.cause = {\n name: POOL_ERROR_NAMES.PoolError,\n message: String(originalError)\n }\n }\n\n return {\n [AS_POOL_ERROR_FLAG]: true,\n name,\n message,\n originalErrorRawStack,\n originalErrorMayContainJS,\n testError,\n applyStackToTestErrorCause\n };\n}\n\nexport function createTestTimeoutError(\n test: Test\n): AssemblyScriptTestError {\n const message = `Test timed out after ${test.timeout}ms`;\n const err: AssemblyScriptTestError = {\n name: POOL_ERROR_NAMES.WASMExecutionTimeoutError,\n message,\n stack: `${test.id}_${message}`,\n diff: getYellowString(` Test Timeout Exceeded (${test.timeout}ms)`)\n };\n return err;\n}\n\nexport function createTestExpectedToFailError(test: Test): AssemblyScriptTestError {\n const message = `Test is expected to fail, but all assertion(s) passed`;\n const err: AssemblyScriptTestError = {\n name: TEST_ERROR_NAMES.AssertionError,\n message,\n stack: `${test.id}_${message}`,\n diff: getYellowString(` Expected to fail, but all assertion(s) passed`)\n };\n return err;\n}\n\nfunction isAbortErrorString(item: any): boolean {\n return item === POOL_ERROR_NAMES.PoolRunAbortedError || item === 'AbortError';\n}\n\nexport function isAbortError(error: any): boolean {\n return isAbortErrorString(error) \n || isAbortErrorString(error?.name)\n || error?.message === 'Terminating worker thread';\n}\n\nexport function getExpectedMessageOrAny(expectedMsgStr?: string): string {\n return expectedMsgStr ? `\"${expectedMsgStr}\"` : '<any>';\n}\n\nexport async function buildEnhancedFileError(\n error: any,\n task: Test | Suite,\n sourceMap: RawSourceMap | undefined,\n logPrefix: string,\n projectRoot: string,\n unexpectedContext: string,\n diffOptions?: SerializedDiffOptions,\n): Promise<AssemblyScriptTestError> {\n let testError: AssemblyScriptTestError;\n let stack: NodeJS.CallSite[];\n let applyStackToTestErrorCause: boolean;\n let allowStackJS: boolean;\n\n if (error && error[AS_POOL_ERROR_FLAG]) {\n const wrapper = error as AssemblyScriptPoolError;\n testError = wrapper.testError;\n stack = wrapper.originalErrorRawStack;\n applyStackToTestErrorCause = wrapper.applyStackToTestErrorCause;\n allowStackJS = wrapper.originalErrorMayContainJS;\n } else if (error instanceof Error) {\n testError = {\n name: POOL_ERROR_NAMES.PoolError,\n message: `${error.name}: ${error.message}`\n };\n stack = extractCallStack(error);\n allowStackJS = true;\n applyStackToTestErrorCause = false;\n } else {\n testError = {\n name: POOL_ERROR_NAMES.PoolError,\n message: `Unexpected error (${unexpectedContext}): ${String(error)}`\n };\n stack = extractCallStack(new Error());\n allowStackJS = true;\n applyStackToTestErrorCause = false;\n }\n\n await enhanceTestError(\n testError,\n task,\n sourceMap,\n logPrefix,\n allowStackJS,\n projectRoot,\n applyStackToTestErrorCause,\n stack,\n diffOptions\n );\n\n return testError;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAiBA,SAAgB,eAAe,MAAsB;AACnD,QAAO,KAAK,QAAQ,OAAO,IAAI;;;;;ACVjC,WAAW,gBAAgB;AAE3B,MAAM,0BAA0B;AAEhC,SAAS,YAAqB;AAC5B,QAAO,WAAW,kBAAkB,QAAQ,QAAQ,IAAI,UAAU;;;;;;AAOpE,SAAgB,mBAAmB,cAA6B;AAC9D,YAAW,gBAAgB;;AAG7B,SAAS,SAAS,GAAG,MAAiB;AAEpC,KAAI,MAAM,SAAS,KAAK,OAAO,KAAK,OAAO,YAAY;EACrD,MAAM,SAAS,KAAK,IAAI;EACxB,MAAM,OAAO,KAAK,SAAS,IAAI,KAAK,MAAM,EAAE,GAAG,EAAE;AACjD,UAAQ,IAAI,KAAK,KAAK,EAAE,OAAO,OAAO,EAAE,GAAG,KAAK;OAEhD,SAAQ,IAAI,KAAK,KAAK,EAAE,GAAG,KAAK;;;;;;AAQpC,SAAgB,MAAM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,IAAI,MAAM;GAClC;AACD,UAAQ,iBAAiB,MAAM;AAC/B,iBAAe;AACf,+BAA6B;QACxB;AACL,cAAY;GACV,MAAM,iBAAiB;GACvB,SAAS,qBAAqB,kBAAkB,KAAK,OAAO,MAAM;GACnE;AACD,UAAQ,iCAAiB,IAAI,OAAO,CAAC;AACrC,iBAAe;AACf,+BAA6B;;AAG/B,OAAM,iBACJ,WACA,MACA,WACA,WACA,cACA,aACA,4BACA,OACA,YACD;AAED,QAAO"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { AssemblyScriptPoolOptions } from "./types-
|
|
1
|
+
import { AssemblyScriptPoolOptions } from "./types-CRbjiCC7.mjs";
|
|
2
2
|
import { PoolRunnerInitializer } from "vitest/node";
|
|
3
3
|
|
|
4
4
|
//#region src/pool/pool-runner-init.d.ts
|
|
5
5
|
declare function createAssemblyScriptPool(userPoolOptions?: AssemblyScriptPoolOptions): PoolRunnerInitializer;
|
|
6
6
|
//#endregion
|
|
7
7
|
export { createAssemblyScriptPool };
|
|
8
|
-
//# sourceMappingURL=pool-runner-init-
|
|
8
|
+
//# sourceMappingURL=pool-runner-init-CPQL6pVL.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pool-runner-init-CPQL6pVL.d.mts","names":[],"sources":["../src/pool/pool-runner-init.ts"],"mappings":";;;;iBAUgB,wBAAA,CAAyB,eAAA,GAAkB,yBAAA,GAA4B,qBAAA"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { POOL_ERROR_NAMES } from "./constants-Bq5KNxXJ.mjs";
|
|
2
|
-
import { createInitialFileTask, failTestWithTimeoutError, flagTestTerminated, getCompatConfig, resolvePoolOptions } from "./vitest-file-tasks-
|
|
3
|
-
import { createPoolError, debug, isAbortError, setGlobalDebugMode, toForwardSlash } from "./pool-errors-
|
|
2
|
+
import { createInitialFileTask, failTestWithTimeoutError, flagTestTerminated, getCompatConfig, resolvePoolOptions } from "./vitest-file-tasks-BBsZ_wS6.mjs";
|
|
3
|
+
import { createPoolError, debug, isAbortError, setGlobalDebugMode, toForwardSlash } from "./pool-errors-Bn6YaguR.mjs";
|
|
4
4
|
import { createWorkerRPCChannel } from "./worker-rpc-channel-CvCrc8aa.mjs";
|
|
5
5
|
import { availableParallelism } from "node:os";
|
|
6
6
|
import { resolve } from "node:path";
|
|
@@ -383,4 +383,4 @@ function createAssemblyScriptPool(userPoolOptions) {
|
|
|
383
383
|
|
|
384
384
|
//#endregion
|
|
385
385
|
export { createAssemblyScriptPool };
|
|
386
|
-
//# sourceMappingURL=pool-runner-init-
|
|
386
|
+
//# sourceMappingURL=pool-runner-init-CSJt3dHv.mjs.map
|