vitest-pool-assemblyscript 0.9.1 → 0.10.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/assembly/compare.ts +11 -12
- package/assembly/describe.ts +4 -4
- package/assembly/expect.ts +44 -26
- package/assembly/test.ts +9 -9
- package/assembly/utils.ts +218 -62
- package/dist/{addon-interface-CYFXMbK7.mjs → addon-interface-DJB-K27u.mjs} +12 -12
- package/dist/addon-interface-DJB-K27u.mjs.map +1 -0
- package/dist/{ast-visitor-CWEOd3UH.mjs → ast-visitor-w1HMbuJR.mjs} +2 -2
- package/dist/{ast-visitor-CWEOd3UH.mjs.map → ast-visitor-w1HMbuJR.mjs.map} +1 -1
- package/dist/compile-runner-D4SJWhMh.mjs +82 -0
- package/dist/compile-runner-D4SJWhMh.mjs.map +1 -0
- package/dist/compiler/transforms/deep-equals.d.mts.map +1 -1
- package/dist/compiler/transforms/deep-equals.mjs +61 -22
- package/dist/compiler/transforms/deep-equals.mjs.map +1 -1
- package/dist/compiler/transforms/strip-inline.mjs +2 -2
- package/dist/{compiler-Dqs-qd3I.mjs → compiler-DSKhQ5--.mjs} +55 -27
- package/dist/compiler-DSKhQ5--.mjs.map +1 -0
- package/dist/config/index-v3.d.mts +1 -1
- package/dist/config/index-v3.d.mts.map +1 -1
- package/dist/config/index-v3.mjs.map +1 -1
- package/dist/config/index.d.mts +2 -2
- package/dist/config/index.mjs +5 -7
- package/dist/{constants-DbxJ3hzg.mjs → constants-Bq5KNxXJ.mjs} +4 -2
- package/dist/constants-Bq5KNxXJ.mjs.map +1 -0
- package/dist/{coverage-merge-CBXkpM1O.mjs → coverage-merge-0WqdC-dq.mjs} +1 -1
- package/dist/{coverage-merge-CBXkpM1O.mjs.map → coverage-merge-0WqdC-dq.mjs.map} +1 -1
- package/dist/coverage-provider/index.mjs +36 -36
- package/dist/coverage-provider/index.mjs.map +1 -1
- package/dist/{feature-check-Bje3ntpV.mjs → feature-check-DLfJqIrE.mjs} +4 -4
- package/dist/{feature-check-Bje3ntpV.mjs.map → feature-check-DLfJqIrE.mjs.map} +1 -1
- package/dist/index-internal.d.mts +3 -3
- package/dist/index-internal.d.mts.map +1 -1
- package/dist/index-internal.mjs +5 -4
- package/dist/index-v3.d.mts.map +1 -1
- package/dist/index-v3.mjs +19 -33
- package/dist/index-v3.mjs.map +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.mjs +5 -7
- package/dist/{load-user-imports-Bx5ZlhSm.mjs → load-user-imports-6Pv-9hRg.mjs} +103 -229
- package/dist/load-user-imports-6Pv-9hRg.mjs.map +1 -0
- package/dist/pool-errors-GWfwrsD7.mjs +631 -0
- package/dist/pool-errors-GWfwrsD7.mjs.map +1 -0
- package/dist/{pool-runner-init-CNpRdA5u.d.mts → pool-runner-init-CCvnKt5o.d.mts} +2 -2
- package/dist/pool-runner-init-CCvnKt5o.d.mts.map +1 -0
- package/dist/{pool-runner-init-BqkwQ2tk.mjs → pool-runner-init-Cta6aVJ6.mjs} +15 -30
- package/dist/pool-runner-init-Cta6aVJ6.mjs.map +1 -0
- package/dist/pool-thread/compile-worker-thread.d.mts +1 -1
- package/dist/pool-thread/compile-worker-thread.d.mts.map +1 -1
- package/dist/pool-thread/compile-worker-thread.mjs +29 -19
- package/dist/pool-thread/compile-worker-thread.mjs.map +1 -1
- package/dist/pool-thread/test-worker-thread.d.mts +1 -1
- package/dist/pool-thread/test-worker-thread.d.mts.map +1 -1
- package/dist/pool-thread/test-worker-thread.mjs +25 -18
- package/dist/pool-thread/test-worker-thread.mjs.map +1 -1
- package/dist/pool-thread/v3-tinypool-thread.d.mts +1 -1
- package/dist/pool-thread/v3-tinypool-thread.d.mts.map +1 -1
- package/dist/pool-thread/v3-tinypool-thread.mjs +43 -33
- package/dist/pool-thread/v3-tinypool-thread.mjs.map +1 -1
- package/dist/test-runner-M21HMDdH.mjs +147 -0
- package/dist/test-runner-M21HMDdH.mjs.map +1 -0
- package/dist/{types-DHVk5iAx.d.mts → types-CoroKYxB.d.mts} +39 -16
- package/dist/types-CoroKYxB.d.mts.map +1 -0
- package/dist/vitest-file-tasks-Coc4btUw.mjs +473 -0
- package/dist/vitest-file-tasks-Coc4btUw.mjs.map +1 -0
- package/dist/wasm-memory-C8Nkl2Sz.mjs +134 -0
- package/dist/wasm-memory-C8Nkl2Sz.mjs.map +1 -0
- package/dist/{worker-rpc-channel-CZZIxtv5.mjs → worker-rpc-channel-CvCrc8aa.mjs} +1 -1
- package/dist/{worker-rpc-channel-CZZIxtv5.mjs.map → worker-rpc-channel-CvCrc8aa.mjs.map} +1 -1
- package/package.json +1 -1
- package/prebuilds/darwin-arm64/vitest-pool-assemblyscript.glibc.node +0 -0
- package/prebuilds/darwin-x64/vitest-pool-assemblyscript.glibc.node +0 -0
- package/prebuilds/linux-arm64/vitest-pool-assemblyscript.glibc.node +0 -0
- package/prebuilds/linux-x64/vitest-pool-assemblyscript.glibc.node +0 -0
- package/prebuilds/linux-x64/vitest-pool-assemblyscript.musl.node +0 -0
- package/prebuilds/win32-arm64/vitest-pool-assemblyscript.glibc.node +0 -0
- package/prebuilds/win32-x64/vitest-pool-assemblyscript.glibc.node +0 -0
- package/src/instrumentation/native/addon.cpp +71 -32
- package/dist/addon-interface-CYFXMbK7.mjs.map +0 -1
- package/dist/compile-runner-BNFHRGZO.mjs +0 -85
- package/dist/compile-runner-BNFHRGZO.mjs.map +0 -1
- package/dist/compiler-Dqs-qd3I.mjs.map +0 -1
- package/dist/constants-DbxJ3hzg.mjs.map +0 -1
- package/dist/debug-DtRAL4rM.mjs +0 -232
- package/dist/debug-DtRAL4rM.mjs.map +0 -1
- package/dist/load-user-imports-Bx5ZlhSm.mjs.map +0 -1
- package/dist/path-utils-t9OzjXYF.mjs +0 -24
- package/dist/path-utils-t9OzjXYF.mjs.map +0 -1
- package/dist/pool-runner-init-BqkwQ2tk.mjs.map +0 -1
- package/dist/pool-runner-init-CNpRdA5u.d.mts.map +0 -1
- package/dist/resolve-config-s9gSJSMc.mjs +0 -85
- package/dist/resolve-config-s9gSJSMc.mjs.map +0 -1
- package/dist/test-runner-BGqc9uCK.mjs +0 -138
- package/dist/test-runner-BGqc9uCK.mjs.map +0 -1
- package/dist/types-DHVk5iAx.d.mts.map +0 -1
- package/dist/vitest-file-tasks-D8sOClGX.mjs +0 -149
- package/dist/vitest-file-tasks-D8sOClGX.mjs.map +0 -1
- package/dist/vitest-tasks-BZ24sghI.mjs +0 -321
- package/dist/vitest-tasks-BZ24sghI.mjs.map +0 -1
- package/dist/wasm-names-BFtzQCH4.mjs +0 -124
- package/dist/wasm-names-BFtzQCH4.mjs.map +0 -1
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
import "../constants-
|
|
2
|
-
import "../
|
|
3
|
-
import { debug, setGlobalDebugMode } from "../
|
|
4
|
-
import "../
|
|
5
|
-
import "../
|
|
6
|
-
import {
|
|
7
|
-
import
|
|
8
|
-
import "../
|
|
9
|
-
import {
|
|
10
|
-
import { runSuite } from "../test-runner-BGqc9uCK.mjs";
|
|
1
|
+
import "../constants-Bq5KNxXJ.mjs";
|
|
2
|
+
import { failFile } from "../vitest-file-tasks-Coc4btUw.mjs";
|
|
3
|
+
import { buildEnhancedFileError, debug, setGlobalDebugMode } from "../pool-errors-GWfwrsD7.mjs";
|
|
4
|
+
import "../wasm-memory-C8Nkl2Sz.mjs";
|
|
5
|
+
import { createRpcClient, flushRpcUpdates, loadUserWasmImportsFactory, reportFileError, reportFileQueued } from "../load-user-imports-6Pv-9hRg.mjs";
|
|
6
|
+
import { isNodeVersionSupportedForCoverage } from "../feature-check-DLfJqIrE.mjs";
|
|
7
|
+
import "../compiler-DSKhQ5--.mjs";
|
|
8
|
+
import { runCompileAndDiscover } from "../compile-runner-D4SJWhMh.mjs";
|
|
9
|
+
import { runSuite } from "../test-runner-M21HMDdH.mjs";
|
|
11
10
|
import { basename } from "node:path";
|
|
12
11
|
import { workerId } from "tinypool";
|
|
13
12
|
import { threadId, workerData } from "node:worker_threads";
|
|
@@ -18,35 +17,46 @@ import { threadId, workerData } from "node:worker_threads";
|
|
|
18
17
|
*/
|
|
19
18
|
const logModule = `WorkerThread`;
|
|
20
19
|
const [_unused, initData] = workerData;
|
|
21
|
-
const {
|
|
22
|
-
setGlobalDebugMode(asPoolOptions.debug);
|
|
23
|
-
debug(`[${logModule}] New pool thread created`);
|
|
20
|
+
const { asCoverageOptions } = initData;
|
|
24
21
|
const COVERAGE_SUPPORTED = isNodeVersionSupportedForCoverage();
|
|
25
|
-
const createUserWasmImports = await loadUserWasmImportsFactory(asPoolOptions.wasmImportsFactory, projectRoot, logModule);
|
|
26
22
|
async function runTestFile(taskData) {
|
|
27
|
-
const { dispatchStart, port, file, config, isCollectTestsMode, timedOutTest, timedOutCompilation } = taskData;
|
|
23
|
+
const { dispatchStart, port, file, config, asPoolOptions, isCollectTestsMode, timedOutTest, timedOutCompilation } = taskData;
|
|
24
|
+
const initPerf = performance.now();
|
|
28
25
|
const dispatchToInit = Date.now() - dispatchStart;
|
|
29
|
-
const logModuleWithId =
|
|
26
|
+
const logModuleWithId = `${logModule} ${workerId} (t ${threadId})`;
|
|
27
|
+
const mode = isCollectTestsMode ? "collectTests" : "runTests";
|
|
28
|
+
const diffOptions = typeof config.diff === "object" ? config.diff : void 0;
|
|
29
|
+
setGlobalDebugMode(asPoolOptions.debug);
|
|
30
30
|
const rpc = createRpcClient(port);
|
|
31
31
|
port.unref();
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
32
|
+
let compilation;
|
|
33
|
+
try {
|
|
34
|
+
debug(`[${logModuleWithId}] -------- ${mode} starting -------- | dispatchToInit: ${dispatchToInit.toFixed(2)}ms`);
|
|
35
|
+
debug(`[${logModuleWithId}] projectName: "${config.name}" | file: "${file.filepath}"`);
|
|
36
|
+
const createUserWasmImports = await loadUserWasmImportsFactory(asPoolOptions.wasmImportsFactory, config.root, logModuleWithId);
|
|
37
|
+
compilation = timedOutCompilation ?? await runCompileAndDiscover(file, logModuleWithId, rpc, asPoolOptions, config.root, config.coverage.enabled && COVERAGE_SUPPORTED, asCoverageOptions.globbedAssemblyScriptProjectRelativeExcludeOnly ?? [], { createUserWasmImports }, diffOptions, config.testNamePattern, config.allowOnly);
|
|
38
|
+
if (compilation && !timedOutCompilation) {
|
|
39
|
+
port.postMessage({
|
|
40
|
+
compilation,
|
|
41
|
+
type: "file-compiled",
|
|
42
|
+
["__as_pool__"]: true
|
|
43
|
+
});
|
|
44
|
+
debug(`[${logModuleWithId}] compiled binary and transferred back to main pool for "${compilation.filePath}"`);
|
|
45
|
+
}
|
|
46
|
+
if (compilation && !isCollectTestsMode) {
|
|
47
|
+
debug(`[${logModuleWithId}] Running file suite`);
|
|
48
|
+
await runSuite(rpc, port, basename(file.filepath), config.coverage.enabled && COVERAGE_SUPPORTED, compilation, file, logModuleWithId, asPoolOptions, { createUserWasmImports }, "v3", config.root, config.bail, diffOptions, timedOutTest);
|
|
49
|
+
} else debug(`[${logModuleWithId}] Skipping file suite run`);
|
|
50
|
+
} catch (error) {
|
|
51
|
+
failFile(file, await buildEnhancedFileError(error, file, compilation?.sourceMap, logModuleWithId, config.root, "tinypool thread", diffOptions), initPerf);
|
|
52
|
+
await reportFileQueued(rpc, file, logModule, logModuleWithId);
|
|
53
|
+
await reportFileError(rpc, file, logModule, logModuleWithId);
|
|
54
|
+
debug(`${logModuleWithId} - Reported file error`);
|
|
55
|
+
} finally {
|
|
56
|
+
await flushRpcUpdates(rpc);
|
|
57
|
+
port.close();
|
|
58
|
+
debug(`[${logModuleWithId}] -------- ${mode} completed file run --------`);
|
|
43
59
|
}
|
|
44
|
-
if (compilation && !isCollectTestsMode) {
|
|
45
|
-
debug(`[${logModuleWithId}] Running file suite`);
|
|
46
|
-
await runSuite(rpc, port, basename(file.filepath), config.coverage.enabled && COVERAGE_SUPPORTED, compilation, file, logModuleWithId, asPoolOptions, { createUserWasmImports }, "v3", config.bail, typeof config.diff === "object" ? config.diff : void 0, timedOutTest);
|
|
47
|
-
} else debug(`[${logModuleWithId}] Skipping file suite run`);
|
|
48
|
-
debug(`[${logModuleWithId}] -------- ${mode} completed file run --------`);
|
|
49
|
-
port.close();
|
|
50
60
|
}
|
|
51
61
|
|
|
52
62
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"v3-tinypool-thread.mjs","names":[],"sources":["../../src/pool-thread/v3-tinypool-thread.ts"],"sourcesContent":["/**\n * Worker entry point - Tinypool (vitest v3)\n */\nimport { basename } from 'node:path';\nimport { threadId, workerData } from 'node:worker_threads';\nimport { workerId } from 'tinypool';\n\nimport type {
|
|
1
|
+
{"version":3,"file":"v3-tinypool-thread.mjs","names":[],"sources":["../../src/pool-thread/v3-tinypool-thread.ts"],"sourcesContent":["/**\n * Worker entry point - Tinypool (vitest v3)\n */\nimport { basename } from 'node:path';\nimport { threadId, workerData } from 'node:worker_threads';\nimport { workerId } from 'tinypool';\n\nimport type {\n ProcessPoolRunFileTask,\n TestFileCompiled,\n ThreadImports,\n WASMCompilation,\n WasmImportsFactory,\n WorkerThreadInitData\n} from '../types/types.js';\nimport { AS_POOL_WORKER_MSG_FLAG } from '../types/constants.js';\nimport { debug, setGlobalDebugMode } from '../util/debug.js';\nimport { createRpcClient, flushRpcUpdates, reportFileError, reportFileQueued } from './rpc-reporter.js';\nimport { runCompileAndDiscover } from './runner/compile-runner.js';\nimport { runSuite } from './runner/test-runner.js';\nimport { loadUserWasmImportsFactory } from './load-user-imports.js';\nimport { isNodeVersionSupportedForCoverage } from '../util/feature-check.js';\nimport { failFile } from '../util/vitest-file-tasks.js';\nimport { buildEnhancedFileError } from '../util/pool-errors.js';\n\nconst logModule = `WorkerThread` as const;\nconst [_unused, initData] = workerData;\nconst { asCoverageOptions } = initData as WorkerThreadInitData;\nconst COVERAGE_SUPPORTED = isNodeVersionSupportedForCoverage();\n\nexport async function runTestFile(taskData: ProcessPoolRunFileTask): Promise<void> {\n const {\n dispatchStart, port, file, config, asPoolOptions,\n isCollectTestsMode, timedOutTest, timedOutCompilation\n } = taskData;\n const initPerf = performance.now();\n const dispatchToInit = Date.now() - dispatchStart;\n const logModuleWithId = `${logModule} ${workerId} (t ${threadId})`;\n const mode = isCollectTestsMode ? 'collectTests' : 'runTests';\n const diffOptions = typeof config.diff === 'object' ? config.diff : undefined;\n \n setGlobalDebugMode(asPoolOptions.debug);\n\n const rpc = createRpcClient(port);\n port.unref();\n\n let compilation: WASMCompilation | undefined;\n\n try {\n debug(`[${logModuleWithId}] -------- ${mode} starting -------- | dispatchToInit: ${dispatchToInit.toFixed(2)}ms`);\n debug(`[${logModuleWithId}] projectName: \"${config.name}\" | file: \"${file.filepath}\"`);\n\n const createUserWasmImports: WasmImportsFactory | undefined = await loadUserWasmImportsFactory(\n asPoolOptions.wasmImportsFactory,\n config.root,\n logModuleWithId\n );\n\n compilation = timedOutCompilation ?? await runCompileAndDiscover(\n file,\n logModuleWithId,\n rpc,\n asPoolOptions,\n config.root,\n config.coverage.enabled && COVERAGE_SUPPORTED,\n asCoverageOptions.globbedAssemblyScriptProjectRelativeExcludeOnly ?? [],\n { createUserWasmImports } satisfies ThreadImports, \n diffOptions,\n config.testNamePattern,\n config.allowOnly,\n );\n\n if (compilation && !timedOutCompilation) {\n port.postMessage({\n compilation,\n type: 'file-compiled',\n [AS_POOL_WORKER_MSG_FLAG]: true\n } satisfies TestFileCompiled);\n\n debug(`[${logModuleWithId}] compiled binary and transferred back to main pool for \"${compilation.filePath}\"`);\n }\n \n if (compilation && !isCollectTestsMode) {\n debug(`[${logModuleWithId}] Running file suite`);\n await runSuite(\n rpc,\n port,\n basename(file.filepath),\n config.coverage.enabled && COVERAGE_SUPPORTED,\n compilation,\n file,\n logModuleWithId,\n asPoolOptions,\n { createUserWasmImports } satisfies ThreadImports,\n 'v3',\n config.root,\n config.bail,\n diffOptions,\n timedOutTest,\n );\n } else {\n debug(`[${logModuleWithId}] Skipping file suite run`);\n }\n } catch (error: any) {\n const testError = await buildEnhancedFileError(\n error,\n file,\n compilation?.sourceMap,\n logModuleWithId,\n config.root,\n 'tinypool thread',\n diffOptions\n );\n\n failFile(file, testError, initPerf);\n \n await reportFileQueued(rpc, file, logModule, logModuleWithId);\n await reportFileError(rpc, file, logModule, logModuleWithId);\n \n debug(`${logModuleWithId} - Reported file error`);\n } finally {\n await flushRpcUpdates(rpc);\n port.close();\n \n debug(`[${logModuleWithId}] -------- ${mode} completed file run --------`);\n }\n\n return;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAyBA,MAAM,YAAY;AAClB,MAAM,CAAC,SAAS,YAAY;AAC5B,MAAM,EAAE,sBAAsB;AAC9B,MAAM,qBAAqB,mCAAmC;AAE9D,eAAsB,YAAY,UAAiD;CACjF,MAAM,EACJ,eAAe,MAAM,MAAM,QAAQ,eACnC,oBAAoB,cAAc,wBAChC;CACJ,MAAM,WAAW,YAAY,KAAK;CAClC,MAAM,iBAAiB,KAAK,KAAK,GAAG;CACpC,MAAM,kBAAkB,GAAG,UAAU,GAAG,SAAS,MAAM,SAAS;CAChE,MAAM,OAAO,qBAAqB,iBAAiB;CACnD,MAAM,cAAc,OAAO,OAAO,SAAS,WAAW,OAAO,OAAO;AAEpE,oBAAmB,cAAc,MAAM;CAEvC,MAAM,MAAM,gBAAgB,KAAK;AACjC,MAAK,OAAO;CAEZ,IAAI;AAEJ,KAAI;AACF,QAAM,IAAI,gBAAgB,aAAa,KAAK,uCAAuC,eAAe,QAAQ,EAAE,CAAC,IAAI;AACjH,QAAM,IAAI,gBAAgB,kBAAkB,OAAO,KAAK,aAAa,KAAK,SAAS,GAAG;EAEtF,MAAM,wBAAwD,MAAM,2BAClE,cAAc,oBACd,OAAO,MACP,gBACD;AAED,gBAAc,uBAAuB,MAAM,sBACzC,MACA,iBACA,KACA,eACA,OAAO,MACP,OAAO,SAAS,WAAW,oBAC3B,kBAAkB,mDAAmD,EAAE,EACvE,EAAE,uBAAuB,EACzB,aACA,OAAO,iBACP,OAAO,UACR;AAED,MAAI,eAAe,CAAC,qBAAqB;AACvC,QAAK,YAAY;IACf;IACA,MAAM;qBACqB;IAC5B,CAA4B;AAE7B,SAAM,IAAI,gBAAgB,2DAA2D,YAAY,SAAS,GAAG;;AAG/G,MAAI,eAAe,CAAC,oBAAoB;AACtC,SAAM,IAAI,gBAAgB,sBAAsB;AAChD,SAAM,SACJ,KACA,MACA,SAAS,KAAK,SAAS,EACvB,OAAO,SAAS,WAAW,oBAC3B,aACA,MACA,iBACA,eACA,EAAE,uBAAuB,EACzB,MACA,OAAO,MACP,OAAO,MACP,aACA,aACD;QAED,OAAM,IAAI,gBAAgB,2BAA2B;UAEhD,OAAY;AAWnB,WAAS,MAVS,MAAM,uBACtB,OACA,MACA,aAAa,WACb,iBACA,OAAO,MACP,mBACA,YACD,EAEyB,SAAS;AAEnC,QAAM,iBAAiB,KAAK,MAAM,WAAW,gBAAgB;AAC7D,QAAM,gBAAgB,KAAK,MAAM,WAAW,gBAAgB;AAE5D,QAAM,GAAG,gBAAgB,wBAAwB;WACzC;AACR,QAAM,gBAAgB,IAAI;AAC1B,OAAK,OAAO;AAEZ,QAAM,IAAI,gBAAgB,aAAa,KAAK,8BAA8B"}
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import { checkFailsAndInvertResult, failFile, finalizeSuiteResult, flagTestFinalized, getRunnableTasks, getTaskLogPrefix, isSuiteOwnFile, resetTestForRetry, setSuitePrepareResult, setTestResultForTestPrepare, shouldRetryTask, updateSuiteFinishedResult, updateTestResultAfterRun } from "./vitest-file-tasks-Coc4btUw.mjs";
|
|
2
|
+
import { buildEnhancedFileError, debug } from "./pool-errors-GWfwrsD7.mjs";
|
|
3
|
+
import { executeWASMTest, flushRpcUpdates, reportFileError, reportSuiteFinished, reportSuitePrepare, reportTestFinished, reportTestPrepare, reportTestRetried, reportUserConsoleLogs } from "./load-user-imports-6Pv-9hRg.mjs";
|
|
4
|
+
import { mergeCoverageData } from "./coverage-merge-0WqdC-dq.mjs";
|
|
5
|
+
|
|
6
|
+
//#region src/pool-thread/runner/test-runner.ts
|
|
7
|
+
async function bailIfNeeded(rpc, bailConfig, testWithResult, logPrefix, logModule) {
|
|
8
|
+
if (bailConfig && testWithResult.result?.state !== "pass") {
|
|
9
|
+
const currentFailures = 1 + await rpc.getCountOfFailedTests();
|
|
10
|
+
if (currentFailures >= bailConfig) {
|
|
11
|
+
debug(`${logPrefix} bailing: ${currentFailures} failures >= ${bailConfig} to bail`);
|
|
12
|
+
debug(`[${logModule}] -------- BAIL! ${currentFailures} failures >= ${bailConfig} to bail --------`);
|
|
13
|
+
return rpc.onCancel("test-failure");
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
async function postProcessTestResult(rpc, bailConfig, testWithResult, logPrefix, logModule) {
|
|
18
|
+
checkFailsAndInvertResult(testWithResult, logPrefix);
|
|
19
|
+
return bailIfNeeded(rpc, bailConfig, testWithResult, logPrefix, logModule);
|
|
20
|
+
}
|
|
21
|
+
function notifyTestStart(port, test) {
|
|
22
|
+
port.postMessage({
|
|
23
|
+
executionStart: Date.now(),
|
|
24
|
+
test,
|
|
25
|
+
type: "execution-start",
|
|
26
|
+
["__as_pool__"]: true
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
function notifyTestEnd(port, test) {
|
|
30
|
+
port.postMessage({
|
|
31
|
+
executionEnd: Date.now(),
|
|
32
|
+
testTaskId: test.id,
|
|
33
|
+
type: "execution-end",
|
|
34
|
+
["__as_pool__"]: true
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
async function runTest(rpc, port, base, collectCoverage, compilation, test, logModule, poolOptions, threadImports, projectRoot, bail, diffOptions) {
|
|
38
|
+
const testLogPrefix = getTaskLogPrefix(logModule, base, test);
|
|
39
|
+
const logMessages = [];
|
|
40
|
+
const handleLog = (msg, isError = false) => {
|
|
41
|
+
logMessages.push({
|
|
42
|
+
msg,
|
|
43
|
+
time: Date.now(),
|
|
44
|
+
isError
|
|
45
|
+
});
|
|
46
|
+
};
|
|
47
|
+
const executionStart = Date.now();
|
|
48
|
+
let thisRunIsARetry = false;
|
|
49
|
+
let testPreparePromise = Promise.resolve();
|
|
50
|
+
if (!test.retry || !test.result) {
|
|
51
|
+
debug(`${testLogPrefix} - Beginning test run`);
|
|
52
|
+
setTestResultForTestPrepare(test, executionStart);
|
|
53
|
+
testPreparePromise = reportTestPrepare(rpc, test, logModule, base);
|
|
54
|
+
} else if (test.retry && test.result) {
|
|
55
|
+
debug(`${testLogPrefix} - Beginning test retry run`);
|
|
56
|
+
thisRunIsARetry = true;
|
|
57
|
+
resetTestForRetry(test, executionStart);
|
|
58
|
+
}
|
|
59
|
+
notifyTestStart(port, test);
|
|
60
|
+
const [_reported, { testTimings }] = await Promise.all([testPreparePromise, executeWASMTest(test, compilation, poolOptions, collectCoverage, handleLog, logModule, threadImports, projectRoot, diffOptions)]);
|
|
61
|
+
notifyTestEnd(port, test);
|
|
62
|
+
updateTestResultAfterRun(test, testTimings);
|
|
63
|
+
let willRetry = shouldRetryTask(test);
|
|
64
|
+
await Promise.all([reportUserConsoleLogs(rpc, logMessages, logModule, base, test), willRetry ? reportTestRetried(rpc, test, logModule, base) : Promise.resolve()]);
|
|
65
|
+
if (thisRunIsARetry) {
|
|
66
|
+
debug(`${testLogPrefix} - Completed test retry run`);
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
while (willRetry) {
|
|
70
|
+
test.result.retryCount = (test.result?.retryCount ?? 0) + 1;
|
|
71
|
+
debug(`${testLogPrefix} - Retrying after failure | Retry ${test.result?.retryCount || 0} / ${test.retry} | ${test.result?.errors?.length ?? 0} errors`);
|
|
72
|
+
await runTest(rpc, port, base, collectCoverage, compilation, test, logModule, poolOptions, threadImports, projectRoot, bail, diffOptions);
|
|
73
|
+
willRetry = shouldRetryTask(test);
|
|
74
|
+
if (!willRetry) debug(`${testLogPrefix} - Max retries ${test.result?.retryCount || 0} / ${test.retry} | ${test.result?.errors?.length ?? 0} errors`);
|
|
75
|
+
}
|
|
76
|
+
await Promise.all([postProcessTestResult(rpc, bail, test, testLogPrefix, logModule), reportTestFinished(rpc, test, logModule, base)]);
|
|
77
|
+
flagTestFinalized(test);
|
|
78
|
+
debug(`${testLogPrefix} - Completed test run`);
|
|
79
|
+
}
|
|
80
|
+
async function runSuite(rpc, port, base, collectCoverage, compilation, suite, logModule, poolOptions, threadImports, vitestVersion, projectRoot, bail, diffOptions, timedOutTest) {
|
|
81
|
+
const suiteStartPerf = performance.now();
|
|
82
|
+
const suiteMeta = suite.meta;
|
|
83
|
+
const suiteLogPrefix = getTaskLogPrefix(logModule, base, suite);
|
|
84
|
+
const isTimedOutTestInSuite = timedOutTest?.suite?.id === suite.id;
|
|
85
|
+
if (suiteMeta.resultFinal) {
|
|
86
|
+
debug(`${suiteLogPrefix} - Skipping completed suite | state: "${suite.result?.state}"`);
|
|
87
|
+
return suite;
|
|
88
|
+
} else {
|
|
89
|
+
const threadRestartTime = Date.now() - ((timedOutTest?.meta)?.lastTimeoutTerminationTime ?? 0);
|
|
90
|
+
debug(`${!!timedOutTest && isSuiteOwnFile(suite) ? `(thread resumed in ${threadRestartTime} ms) ` : ""}${suiteLogPrefix} - runSuite ${!!timedOutTest ? `resuming after timeout "${timedOutTest.name}" | isTestInSuite: ${isTimedOutTestInSuite}` : "beginning"}`);
|
|
91
|
+
}
|
|
92
|
+
try {
|
|
93
|
+
if (!suiteMeta.suitePreparedSent) {
|
|
94
|
+
setSuitePrepareResult(suite);
|
|
95
|
+
await reportSuitePrepare(rpc, suite, logModule, base);
|
|
96
|
+
suiteMeta.suitePreparedSent = true;
|
|
97
|
+
}
|
|
98
|
+
suiteMeta.coverageData = { hitCountsByFileAndPosition: {} };
|
|
99
|
+
debug(`${suiteLogPrefix} - Initialized empty suite coverage data`);
|
|
100
|
+
let tasksToRun = getRunnableTasks(suite);
|
|
101
|
+
debug(`${suiteLogPrefix} - Runnable tasks:`, tasksToRun.length);
|
|
102
|
+
for (const task of tasksToRun) if (task.type === "suite") {
|
|
103
|
+
const suiteTaskMeta = task.meta;
|
|
104
|
+
await runSuite(rpc, port, base, collectCoverage, compilation, task, logModule, poolOptions, threadImports, vitestVersion, projectRoot, bail, diffOptions, timedOutTest);
|
|
105
|
+
if (suiteMeta.coverageData && suiteTaskMeta.coverageData) mergeCoverageData(suiteMeta.coverageData, suiteTaskMeta.coverageData);
|
|
106
|
+
} else {
|
|
107
|
+
const testLogPrefix = getTaskLogPrefix(logModule, base, task);
|
|
108
|
+
const testTaskMeta = task.meta;
|
|
109
|
+
const testCompleted = testTaskMeta.resultFinal;
|
|
110
|
+
const testTimedOutPreviously = !!timedOutTest && task.id === timedOutTest.id;
|
|
111
|
+
if (testCompleted) debug(`${testLogPrefix} - Skipping completed test | state: "${task.result?.state}"`);
|
|
112
|
+
else if (testTimedOutPreviously) if (shouldRetryTask(task)) {
|
|
113
|
+
const newRetryCount = (task.result?.retryCount ?? 0) + 1;
|
|
114
|
+
debug(`${testLogPrefix} - Retrying after test timeout | retry attempt ${newRetryCount} / ${task.retry} | ${task.result?.errors?.length ?? 0} errors | state: "${task.result?.state}"`);
|
|
115
|
+
await reportTestRetried(rpc, task, logModule, base);
|
|
116
|
+
task.result.retryCount = newRetryCount;
|
|
117
|
+
await runTest(rpc, port, base, collectCoverage, compilation, task, logModule, poolOptions, threadImports, projectRoot, bail, diffOptions);
|
|
118
|
+
} else {
|
|
119
|
+
debug(`${testLogPrefix} - Timed-out test has no retries left | retries attempted ${task.result?.retryCount || 0} / ${task.retry} | ${task.result?.errors?.length ?? 0} errors | state: "${task.result?.state}"`);
|
|
120
|
+
await Promise.all([postProcessTestResult(rpc, bail, task, testLogPrefix, logModule), reportTestFinished(rpc, task, logModule, base)]);
|
|
121
|
+
flagTestFinalized(task);
|
|
122
|
+
debug(`${testLogPrefix} - Completed timed out test run`);
|
|
123
|
+
}
|
|
124
|
+
else {
|
|
125
|
+
debug(`${testLogPrefix} - Running test task | state: "${task.result?.state}"`);
|
|
126
|
+
await runTest(rpc, port, base, collectCoverage, compilation, task, logModule, poolOptions, threadImports, projectRoot, bail, diffOptions);
|
|
127
|
+
}
|
|
128
|
+
if (suiteMeta.coverageData && testTaskMeta.coverageData) mergeCoverageData(suiteMeta.coverageData, testTaskMeta.coverageData);
|
|
129
|
+
}
|
|
130
|
+
updateSuiteFinishedResult(suite, suiteLogPrefix);
|
|
131
|
+
await reportSuiteFinished(rpc, suite, logModule, base, vitestVersion);
|
|
132
|
+
finalizeSuiteResult(suite);
|
|
133
|
+
} catch (error) {
|
|
134
|
+
const testError = await buildEnhancedFileError(error, suite.file, compilation.sourceMap, suiteLogPrefix, projectRoot, "test runner", diffOptions);
|
|
135
|
+
failFile(suite.file, testError, suiteStartPerf);
|
|
136
|
+
await reportFileError(rpc, suite.file, logModule, suiteLogPrefix);
|
|
137
|
+
debug(`${suiteLogPrefix} - Reported file error`);
|
|
138
|
+
} finally {
|
|
139
|
+
await flushRpcUpdates(rpc);
|
|
140
|
+
debug(`${suiteLogPrefix} - runSuite Completed | TIMING ${(performance.now() - suiteStartPerf).toFixed(2)} ms`);
|
|
141
|
+
}
|
|
142
|
+
return suite;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
//#endregion
|
|
146
|
+
export { runSuite };
|
|
147
|
+
//# sourceMappingURL=test-runner-M21HMDdH.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"test-runner-M21HMDdH.mjs","names":[],"sources":["../src/pool-thread/runner/test-runner.ts"],"sourcesContent":["/**\n * Worker thread test runner logic for AssemblyScript Pool\n */\n\nimport type { MessagePort } from 'node:worker_threads';\nimport type { File, Suite, Task, Test } from '@vitest/runner/types';\nimport type { SerializedDiffOptions } from '@vitest/utils/diff';\n\nimport type {\n AssemblyScriptConsoleLog,\n AssemblyScriptConsoleLogHandler,\n AssemblyScriptSuiteTaskMeta,\n AssemblyScriptTestTaskMeta,\n ResolvedAssemblyScriptPoolOptions,\n TestExecutionEnd,\n TestExecutionStart,\n ThreadImports,\n VitestVersion,\n WASMCompilation,\n WorkerRPC,\n} from '../../types/types.js';\nimport { AS_POOL_WORKER_MSG_FLAG } from '../../types/constants.js';\nimport { executeWASMTest } from '../../wasm-executor/index.js';\nimport { debug } from '../../util/debug.js';\nimport {\n reportTestPrepare,\n reportTestFinished,\n reportTestRetried,\n reportUserConsoleLogs,\n reportSuitePrepare,\n reportSuiteFinished,\n flushRpcUpdates,\n reportFileError,\n} from '../rpc-reporter.js';\nimport {\n checkFailsAndInvertResult,\n finalizeSuiteResult,\n flagTestFinalized,\n getRunnableTasks,\n getTaskLogPrefix,\n resetTestForRetry,\n setSuitePrepareResult,\n setTestResultForTestPrepare,\n shouldRetryTask,\n updateSuiteFinishedResult,\n updateTestResultAfterRun,\n isSuiteOwnFile\n} from '../../util/vitest-tasks.js';\nimport { mergeCoverageData } from '../../coverage-provider/coverage-merge.js';\nimport { failFile } from '../../util/vitest-file-tasks.js';\nimport { buildEnhancedFileError } from '../../util/pool-errors.js';\n\nasync function bailIfNeeded(\n rpc: WorkerRPC,\n bailConfig: number | undefined,\n testWithResult: Test,\n logPrefix: string,\n logModule: string,\n): Promise<void> {\n if (bailConfig && testWithResult.result?.state !== 'pass') {\n const previousFailures = await rpc.getCountOfFailedTests();\n const currentFailures = 1 + previousFailures;\n\n if (currentFailures >= bailConfig) {\n debug(`${logPrefix} bailing: ${currentFailures} failures >= ${bailConfig} to bail`);\n debug(`[${logModule}] -------- BAIL! ${currentFailures} failures >= ${bailConfig} to bail --------`);\n return rpc.onCancel('test-failure');\n }\n }\n}\n\nasync function postProcessTestResult(\n rpc: WorkerRPC,\n bailConfig: number | undefined,\n testWithResult: Test,\n logPrefix: string,\n logModule: string,\n): Promise<void> {\n // invert result if test configured as 'fails'\n checkFailsAndInvertResult(testWithResult, logPrefix);\n\n // bail now if this is a failed test above bail threshold\n return bailIfNeeded(rpc, bailConfig, testWithResult, logPrefix, logModule);\n}\n\nfunction notifyTestStart(port: MessagePort, test: Test): void {\n port.postMessage({\n executionStart: Date.now(),\n test,\n type: 'execution-start',\n [AS_POOL_WORKER_MSG_FLAG]: true\n } satisfies TestExecutionStart);\n}\n\nfunction notifyTestEnd(port: MessagePort, test: Test): void {\n port.postMessage({\n executionEnd: Date.now(),\n testTaskId: test.id,\n type: 'execution-end',\n [AS_POOL_WORKER_MSG_FLAG]: true\n } satisfies TestExecutionEnd);\n}\n\nasync function runTest(\n rpc: WorkerRPC,\n port: MessagePort,\n base: string,\n collectCoverage: boolean,\n compilation: WASMCompilation,\n test: Test,\n logModule: string,\n poolOptions: ResolvedAssemblyScriptPoolOptions,\n threadImports: ThreadImports,\n projectRoot: string,\n bail?: number,\n diffOptions?: SerializedDiffOptions,\n): Promise<void> {\n const testLogPrefix = getTaskLogPrefix(logModule, base, test);\n const logMessages: AssemblyScriptConsoleLog[] = [];\n const handleLog: AssemblyScriptConsoleLogHandler = (msg: string, isError: boolean = false): void => {\n logMessages.push({ msg, time: Date.now(), isError });\n };\n\n const executionStart = Date.now();\n\n let thisRunIsARetry: boolean = false;\n let testPreparePromise: Promise<void> = Promise.resolve();\n \n if (!test.retry || !test.result) {\n debug(`${testLogPrefix} - Beginning test run`);\n\n // first/only attempt: create test result and report test-prepare\n setTestResultForTestPrepare(test, executionStart);\n testPreparePromise = reportTestPrepare(rpc, test, logModule, base);\n } else if (test.retry && test.result ) {\n debug(`${testLogPrefix} - Beginning test retry run`);\n thisRunIsARetry = true;\n\n // this is a retry, reset the result state and meta\n resetTestForRetry(test, executionStart);\n }\n \n // inform pool of test task start so it can enforce timeouts\n notifyTestStart(port, test);\n\n const [_reported, { testTimings }] = await Promise.all([\n testPreparePromise,\n executeWASMTest(\n test,\n compilation,\n poolOptions,\n collectCoverage,\n handleLog,\n logModule,\n threadImports,\n projectRoot,\n diffOptions\n )\n ]);\n\n // inform pool of test task end to stop timeout if under threshold\n notifyTestEnd(port, test);\n\n // update run->pass if appropriate, accumulate duration using executor timings\n updateTestResultAfterRun(test, testTimings);\n\n let willRetry = shouldRetryTask(test);\n\n await Promise.all([\n reportUserConsoleLogs(rpc, logMessages, logModule, base, test),\n\n willRetry ? reportTestRetried(rpc, test, logModule, base) : Promise.resolve(),\n ]);\n\n if (thisRunIsARetry) {\n debug(`${testLogPrefix} - Completed test retry run`);\n return;\n }\n\n // non-timeout retry handling\n while (willRetry) {\n // increment the retry count\n test.result!.retryCount = (test.result?.retryCount ?? 0) + 1;\n\n debug(`${testLogPrefix} - Retrying after failure`\n + ` | Retry ${test.result?.retryCount || 0} / ${test.retry} ` \n + ` | ${test.result?.errors?.length ?? 0} errors`\n );\n\n await runTest(\n rpc, port, base, collectCoverage, compilation,\n test, logModule, poolOptions, threadImports, projectRoot, bail, diffOptions\n );\n\n willRetry = shouldRetryTask(test);\n\n if (!willRetry) {\n debug(`${testLogPrefix} - Max retries ${test.result?.retryCount || 0} / ${test.retry} ` \n + ` | ${test.result?.errors?.length ?? 0} errors`\n );\n }\n }\n\n await Promise.all([\n // as needed: invert if `fails`, bail\n postProcessTestResult(rpc, bail, test, testLogPrefix, logModule),\n\n reportTestFinished(rpc, test, logModule, base),\n ]);\n\n // ensure completed test will not be run again if another test\n // times out later and the file worker thread gets re-launched\n flagTestFinalized(test);\n\n debug(`${testLogPrefix} - Completed test run`);\n}\n\nexport async function runSuite(\n rpc: WorkerRPC,\n port: MessagePort,\n base: string,\n collectCoverage: boolean,\n compilation: WASMCompilation,\n suite: Suite | File,\n logModule: string,\n poolOptions: ResolvedAssemblyScriptPoolOptions,\n threadImports: ThreadImports,\n vitestVersion: VitestVersion,\n projectRoot: string,\n bail?: number,\n diffOptions?: SerializedDiffOptions,\n timedOutTest?: Test,\n): Promise<Suite> {\n const suiteStartPerf = performance.now();\n const suiteMeta = suite.meta as AssemblyScriptSuiteTaskMeta;\n const suiteLogPrefix = getTaskLogPrefix(logModule, base, suite);\n const isTimedOutTestInSuite: boolean = timedOutTest?.suite?.id === suite.id;\n\n if (suiteMeta.resultFinal) {\n debug(`${suiteLogPrefix} - Skipping completed suite | state: \"${suite.result?.state}\"`);\n\n return suite;\n } else {\n const threadRestartTime = Date.now() - ((timedOutTest?.meta as AssemblyScriptTestTaskMeta)?.lastTimeoutTerminationTime ?? 0);\n const showRestart = !!timedOutTest && isSuiteOwnFile(suite)\n debug(`${showRestart ? `(thread resumed in ${threadRestartTime} ms) ` : ''}${suiteLogPrefix} - runSuite ${!!timedOutTest\n ? `resuming after timeout \"${timedOutTest.name}\" | isTestInSuite: ${isTimedOutTestInSuite}`\n : 'beginning'\n }`);\n }\n\n try {\n // ensure suite-prepare will only be sent once if a test\n // times out and the file worker thread gets re-launched\n if (!suiteMeta.suitePreparedSent) {\n setSuitePrepareResult(suite);\n await reportSuitePrepare(rpc, suite, logModule, base);\n suiteMeta.suitePreparedSent = true;\n }\n\n // initialize aggregated coverage data for suite, which gets updated as each subtask completes\n suiteMeta.coverageData = { hitCountsByFileAndPosition: {} };\n debug(`${suiteLogPrefix} - Initialized empty suite coverage data`);\n\n let tasksToRun: Task[] = getRunnableTasks(suite);\n debug(`${suiteLogPrefix} - Runnable tasks:`, tasksToRun.length);\n\n for (const task of tasksToRun) {\n if (task.type === 'suite') {\n const suiteTaskMeta = task.meta as AssemblyScriptSuiteTaskMeta;\n\n await runSuite(\n rpc, port, base, collectCoverage, compilation, task, logModule,\n poolOptions, threadImports, vitestVersion, projectRoot, bail, diffOptions, timedOutTest\n );\n\n // merge suite task coverage into parent suite coverage\n if (suiteMeta.coverageData && suiteTaskMeta.coverageData) {\n mergeCoverageData(suiteMeta.coverageData, suiteTaskMeta.coverageData);\n }\n \n } else {\n const testLogPrefix = getTaskLogPrefix(logModule, base, task);\n const testTaskMeta = task.meta as AssemblyScriptTestTaskMeta;\n\n const testCompleted = testTaskMeta.resultFinal;\n const testTimedOutPreviously = !!timedOutTest && task.id === timedOutTest.id;\n\n if (testCompleted) {\n debug(`${testLogPrefix} - Skipping completed test | state: \"${task.result?.state}\"`);\n } else if (testTimedOutPreviously) {\n if (shouldRetryTask(task)) {\n const previousRetryCount = task.result?.retryCount ?? 0;\n const newRetryCount = previousRetryCount + 1;\n\n debug(`${testLogPrefix} - Retrying after test timeout`\n + ` | retry attempt ${newRetryCount} / ${task.retry} ` \n + ` | ${task.result?.errors?.length ?? 0} errors`\n + ` | state: \"${task.result?.state}\"`\n );\n \n // report retried for the previous timeout failure, which won't\n // have been reported because the thread was killed to timeout\n await reportTestRetried(rpc, task, logModule, base);\n\n // increment the retry count (after reporting retried)\n task.result!.retryCount = newRetryCount;\n \n // retry timed out test\n // - if it passes, process as normal\n // - if it fails again, it will end up in the else block below\n await runTest(\n rpc, port, base, collectCoverage, compilation,\n task, logModule, poolOptions, threadImports, projectRoot, bail, diffOptions\n );\n } else {\n debug(`${testLogPrefix} - Timed-out test has no retries left`\n + ` | retries attempted ${task.result?.retryCount || 0} / ${task.retry} ` \n + ` | ${task.result?.errors?.length ?? 0} errors`\n + ` | state: \"${task.result?.state}\"`\n );\n\n await Promise.all([\n // as needed: invert if `fails`, bail\n postProcessTestResult(rpc, bail, task, testLogPrefix, logModule),\n \n reportTestFinished(rpc, task, logModule, base),\n ]);\n\n // ensure completed test will not be run again if another test\n // times out later and the file worker thread gets re-launched\n flagTestFinalized(task);\n\n debug(`${testLogPrefix} - Completed timed out test run`);\n }\n } else {\n debug(`${testLogPrefix} - Running test task | state: \"${task.result?.state}\"`);\n await runTest(\n rpc, port, base, collectCoverage, compilation,\n task, logModule, poolOptions, threadImports, projectRoot, bail, diffOptions\n );\n }\n\n // merge test coverage into suite coverage\n if (suiteMeta.coverageData && testTaskMeta.coverageData) {\n mergeCoverageData(suiteMeta.coverageData, testTaskMeta.coverageData);\n }\n }\n }\n\n // update suite result based on its tasks, report coverage data, report suite task result\n updateSuiteFinishedResult(suite, suiteLogPrefix);\n await reportSuiteFinished(rpc, suite, logModule, base, vitestVersion);\n\n // ensure completed suite will not be run again if another test\n // times out later and the file worker thread gets re-launched\n finalizeSuiteResult(suite);\n } catch (error: any) {\n const testError = await buildEnhancedFileError(\n error,\n suite.file,\n compilation.sourceMap,\n suiteLogPrefix,\n projectRoot,\n 'test runner',\n diffOptions\n );\n\n failFile(suite.file, testError, suiteStartPerf);\n\n await reportFileError(rpc, suite.file, logModule, suiteLogPrefix);\n\n debug(`${suiteLogPrefix} - Reported file error`);\n } finally {\n await flushRpcUpdates(rpc);\n const suiteTime = performance.now() - suiteStartPerf;\n debug(`${suiteLogPrefix} - runSuite Completed | TIMING ${suiteTime.toFixed(2)} ms`);\n }\n\n return suite;\n}\n"],"mappings":";;;;;;AAoDA,eAAe,aACb,KACA,YACA,gBACA,WACA,WACe;AACf,KAAI,cAAc,eAAe,QAAQ,UAAU,QAAQ;EAEzD,MAAM,kBAAkB,IADC,MAAM,IAAI,uBAAuB;AAG1D,MAAI,mBAAmB,YAAY;AACjC,SAAM,GAAG,UAAU,YAAY,gBAAgB,eAAe,WAAW,UAAU;AACnF,SAAM,IAAI,UAAU,mBAAmB,gBAAgB,eAAe,WAAW,mBAAmB;AACpG,UAAO,IAAI,SAAS,eAAe;;;;AAKzC,eAAe,sBACb,KACA,YACA,gBACA,WACA,WACe;AAEf,2BAA0B,gBAAgB,UAAU;AAGpD,QAAO,aAAa,KAAK,YAAY,gBAAgB,WAAW,UAAU;;AAG5E,SAAS,gBAAgB,MAAmB,MAAkB;AAC5D,MAAK,YAAY;EACf,gBAAgB,KAAK,KAAK;EAC1B;EACA,MAAM;mBACqB;EAC5B,CAA8B;;AAGjC,SAAS,cAAc,MAAmB,MAAkB;AAC1D,MAAK,YAAY;EACf,cAAc,KAAK,KAAK;EACxB,YAAY,KAAK;EACjB,MAAM;mBACqB;EAC5B,CAA4B;;AAG/B,eAAe,QACb,KACA,MACA,MACA,iBACA,aACA,MACA,WACA,aACA,eACA,aACA,MACA,aACe;CACf,MAAM,gBAAgB,iBAAiB,WAAW,MAAM,K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,QACJ,KAAK,MAAM,MAAM,iBAAiB,aAClC,MAAM,WAAW,aAAa,eAAe,aAAa,MAAM,YACjE;;AAIH,OAAI,UAAU,gBAAgB,aAAa,aACzC,mBAAkB,UAAU,cAAc,aAAa,aAAa;;AAM1E,4BAA0B,OAAO,eAAe;AAChD,QAAM,oBAAoB,KAAK,OAAO,WAAW,MAAM,cAAc;AAIrE,sBAAoB,MAAM;UACnB,OAAY;EACnB,MAAM,YAAY,MAAM,uBACtB,OACA,MAAM,MACN,YAAY,WACZ,gBACA,aACA,eACA,YACD;AAED,WAAS,MAAM,MAAM,WAAW,eAAe;AAE/C,QAAM,gBAAgB,KAAK,MAAM,MAAM,WAAW,eAAe;AAEjE,QAAM,GAAG,eAAe,wBAAwB;WACxC;AACR,QAAM,gBAAgB,IAAI;AAE1B,QAAM,GAAG,eAAe,kCADN,YAAY,KAAK,GAAG,gBAC6B,QAAQ,EAAE,CAAC,KAAK;;AAGrF,QAAO"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { RawSourceMap } from "source-map";
|
|
1
2
|
import { MessagePort } from "node:worker_threads";
|
|
2
3
|
import { SerializedConfig } from "vitest";
|
|
3
4
|
import { File, Test } from "@vitest/runner/types";
|
|
@@ -74,9 +75,39 @@ interface WasmImportsFactoryInfo {
|
|
|
74
75
|
};
|
|
75
76
|
}
|
|
76
77
|
type WasmImportsFactory = (moduleInfo: WasmImportsFactoryInfo) => WebAssembly.Imports;
|
|
78
|
+
declare const AS_POOL_FIELDS_WITH_DEFAULTS: readonly ["debug", "debugNative", "debugCoverageExtract", "_instrumentPoolInternals", "stripInline", "maxThreadsV3", "extraCompilerFlags"];
|
|
79
|
+
declare const AS_POOL_OPTIONAL_FIELDS: readonly ["testMemoryPagesInitial", "testMemoryPagesMax", "coverageMemoryPagesInitial", "coverageMemoryPagesMax", "wasmImportsFactory"];
|
|
80
|
+
/** Fields that have default values. Internally these will always be defined. */
|
|
81
|
+
type ASPoolOptionsFieldsWithDefaultValues = typeof AS_POOL_FIELDS_WITH_DEFAULTS[number];
|
|
82
|
+
/** Fields with optional values and NO defaults */
|
|
83
|
+
type ASPoolOptionsOptionalFields = typeof AS_POOL_OPTIONAL_FIELDS[number];
|
|
77
84
|
type SerializedConfigCompat = SerializedConfig & {
|
|
78
85
|
retry: number;
|
|
79
86
|
};
|
|
87
|
+
/**
|
|
88
|
+
* Pool options resolved so that all fields are filled with user values preferentially,
|
|
89
|
+
* with required fields being guaranteed to be populated with defaults otherwise.
|
|
90
|
+
*/
|
|
91
|
+
type ResolvedAssemblyScriptPoolOptions = Required<Pick<AssemblyScriptPoolOptions, ASPoolOptionsFieldsWithDefaultValues>> & Partial<Pick<AssemblyScriptPoolOptions, ASPoolOptionsOptionalFields>> & {
|
|
92
|
+
readonly isResolved: true;
|
|
93
|
+
};
|
|
94
|
+
interface WASMCompilation {
|
|
95
|
+
filePath: string;
|
|
96
|
+
sourceMap: RawSourceMap;
|
|
97
|
+
debugInfo?: BinaryDebugInfo;
|
|
98
|
+
compiledModule: WebAssembly.Module;
|
|
99
|
+
requiredMemory: WASMModuleMemoryRequirements;
|
|
100
|
+
isInstrumented: boolean;
|
|
101
|
+
compileTiming: number;
|
|
102
|
+
}
|
|
103
|
+
interface WASMImportMemoryRequirements {
|
|
104
|
+
initialPages: number;
|
|
105
|
+
maximumPages?: number;
|
|
106
|
+
}
|
|
107
|
+
interface WASMModuleMemoryRequirements {
|
|
108
|
+
testMemory: WASMImportMemoryRequirements;
|
|
109
|
+
coverageMemory: WASMImportMemoryRequirements;
|
|
110
|
+
}
|
|
80
111
|
interface AssemblyScriptCompilerOptions {
|
|
81
112
|
shouldInstrument: boolean;
|
|
82
113
|
projectRoot: string;
|
|
@@ -84,13 +115,6 @@ interface AssemblyScriptCompilerOptions {
|
|
|
84
115
|
stripInline?: boolean;
|
|
85
116
|
extraFlags?: string[];
|
|
86
117
|
}
|
|
87
|
-
interface AssemblyScriptCompilerResult {
|
|
88
|
-
binary: Uint8Array;
|
|
89
|
-
sourceMap: string;
|
|
90
|
-
debugInfo?: BinaryDebugInfo;
|
|
91
|
-
isInstrumented: boolean;
|
|
92
|
-
compileTiming: number;
|
|
93
|
-
}
|
|
94
118
|
interface InstrumentationOptions {
|
|
95
119
|
/** Project root for resolving source map paths to absolute paths */
|
|
96
120
|
projectRoot: string;
|
|
@@ -100,8 +124,10 @@ interface InstrumentationOptions {
|
|
|
100
124
|
excludedLibraryFileOverridePrefix?: string;
|
|
101
125
|
excludedInternalFunctionSubstring: string;
|
|
102
126
|
coverageMemoryPagesMin: number;
|
|
103
|
-
coverageMemoryPagesMax
|
|
127
|
+
coverageMemoryPagesMax?: number;
|
|
104
128
|
debug?: boolean;
|
|
129
|
+
coverageMemoryModule: string;
|
|
130
|
+
coverageMemoryName: string;
|
|
105
131
|
}
|
|
106
132
|
/**
|
|
107
133
|
* Source location in original AssemblyScript code (a point, not a range)
|
|
@@ -201,12 +227,6 @@ interface BinaryDebugInfo {
|
|
|
201
227
|
functionsByFileAndPosition: Record<string, Record<string, FunctionDebugInfo[]>>;
|
|
202
228
|
instrumentedFunctionCount: number;
|
|
203
229
|
}
|
|
204
|
-
interface WASMCompilation {
|
|
205
|
-
filePath: string;
|
|
206
|
-
binary: Uint8Array;
|
|
207
|
-
sourceMap: string;
|
|
208
|
-
debugInfo?: BinaryDebugInfo;
|
|
209
|
-
}
|
|
210
230
|
interface ThreadSpec {
|
|
211
231
|
file: File;
|
|
212
232
|
compilation?: WASMCompilation;
|
|
@@ -217,6 +237,7 @@ interface RunCompileAndDiscoverTask {
|
|
|
217
237
|
port: MessagePort;
|
|
218
238
|
file: File;
|
|
219
239
|
config: SerializedConfigCompat;
|
|
240
|
+
asPoolOptions: ResolvedAssemblyScriptPoolOptions;
|
|
220
241
|
isCollectTestsMode: boolean;
|
|
221
242
|
}
|
|
222
243
|
interface RunTestsTask {
|
|
@@ -226,6 +247,7 @@ interface RunTestsTask {
|
|
|
226
247
|
file: File;
|
|
227
248
|
compilation: WASMCompilation;
|
|
228
249
|
config: SerializedConfigCompat;
|
|
250
|
+
asPoolOptions: ResolvedAssemblyScriptPoolOptions;
|
|
229
251
|
isCollectTestsMode: boolean;
|
|
230
252
|
timedOutTest?: Test;
|
|
231
253
|
}
|
|
@@ -234,10 +256,11 @@ interface ProcessPoolRunFileTask {
|
|
|
234
256
|
port: MessagePort;
|
|
235
257
|
file: File;
|
|
236
258
|
config: SerializedConfigCompat;
|
|
259
|
+
asPoolOptions: ResolvedAssemblyScriptPoolOptions;
|
|
237
260
|
isCollectTestsMode: boolean;
|
|
238
261
|
timedOutTest?: Test;
|
|
239
262
|
timedOutCompilation?: WASMCompilation;
|
|
240
263
|
}
|
|
241
264
|
//#endregion
|
|
242
|
-
export { AssemblyScriptCompilerOptions,
|
|
243
|
-
//# sourceMappingURL=types-
|
|
265
|
+
export { AssemblyScriptCompilerOptions, AssemblyScriptPoolOptions, HybridProviderOptions, ProcessPoolRunFileTask, RunCompileAndDiscoverTask, RunTestsTask, ThreadSpec, WASMCompilation, WasmImportsFactory, WasmImportsFactoryInfo };
|
|
266
|
+
//# sourceMappingURL=types-CoroKYxB.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types-CoroKYxB.d.mts","names":[],"sources":["../src/types/types.ts"],"mappings":";;;;;;;;;UAsEiB,yBAAA;;EAEf,KAAA;EACA,WAAA;EACA,oBAAA;;EAGA,wBAAA;EAwEF;;;;;;;;;EA7DE,WAAA;EAgEF;;;;;AAUA;;EAjEE,YAAA;EAEA,0BAAA;EACA,sBAAA;EAEA,sBAAA;EACA,kBAAA;EAEA,kBAAA;EAEA,kBAAA;AAAA;AAmEF;;;;;AAGA;;;;;AAHA,UAtDiB,qBAAA;EACf,aAAA;;;;;;;;;EAUA,qBAAA;;;;;;EAOA,qBAAA;AAAA;AAAA,UAGe,sBAAA;EACf,MAAA,EAAQ,WAAA,CAAY,MAAA;EACpB,MAAA,EAAQ,WAAA,CAAY,MAAA;EACpB,K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