vitest-pool-assemblyscript 0.9.1 → 0.10.1
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-BaUmn7uC.mjs} +12 -12
- package/dist/addon-interface-BaUmn7uC.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-BGHM_85g.mjs +82 -0
- package/dist/compile-runner-BGHM_85g.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-CXR5UJId.mjs} +55 -27
- package/dist/compiler-CXR5UJId.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-BJpc4LoO.mjs} +4 -4
- package/dist/{feature-check-Bje3ntpV.mjs.map → feature-check-BJpc4LoO.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-Bcx9NOt9.mjs} +119 -232
- package/dist/load-user-imports-Bcx9NOt9.mjs.map +1 -0
- package/dist/pool-errors-Bn6YaguR.mjs +630 -0
- package/dist/pool-errors-Bn6YaguR.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-DjRCbiX-.mjs} +15 -30
- package/dist/pool-runner-init-DjRCbiX-.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-BeP8ClnE.mjs +147 -0
- package/dist/test-runner-BeP8ClnE.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-vvZzigcF.mjs +473 -0
- package/dist/vitest-file-tasks-vvZzigcF.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,85 +0,0 @@
|
|
|
1
|
-
import { POOL_ERROR_NAMES } from "./constants-DbxJ3hzg.mjs";
|
|
2
|
-
import { createPoolError } from "./debug-DtRAL4rM.mjs";
|
|
3
|
-
import { availableParallelism } from "node:os";
|
|
4
|
-
|
|
5
|
-
//#region src/types/types.ts
|
|
6
|
-
const AS_POOL_FIELDS_WITH_DEFAULTS = [
|
|
7
|
-
"debug",
|
|
8
|
-
"debugNative",
|
|
9
|
-
"debugCoverageExtract",
|
|
10
|
-
"_instrumentPoolInternals",
|
|
11
|
-
"stripInline",
|
|
12
|
-
"maxThreadsV3",
|
|
13
|
-
"coverageMemoryPagesInitial",
|
|
14
|
-
"coverageMemoryPagesMax",
|
|
15
|
-
"testMemoryPagesInitial",
|
|
16
|
-
"extraCompilerFlags"
|
|
17
|
-
];
|
|
18
|
-
|
|
19
|
-
//#endregion
|
|
20
|
-
//#region src/util/resolve-config.ts
|
|
21
|
-
const DEFAULT_ASSEMBLYSCRIPT_POOL_OTIONS = {
|
|
22
|
-
debug: false,
|
|
23
|
-
debugNative: false,
|
|
24
|
-
debugCoverageExtract: false,
|
|
25
|
-
_instrumentPoolInternals: false,
|
|
26
|
-
stripInline: true,
|
|
27
|
-
maxThreadsV3: availableParallelism() - 1,
|
|
28
|
-
coverageMemoryPagesInitial: 1,
|
|
29
|
-
coverageMemoryPagesMax: 4,
|
|
30
|
-
testMemoryPagesInitial: 1,
|
|
31
|
-
extraCompilerFlags: []
|
|
32
|
-
};
|
|
33
|
-
function resolvePoolOptions(userPoolOptions) {
|
|
34
|
-
const poolOptions = userPoolOptions ?? DEFAULT_ASSEMBLYSCRIPT_POOL_OTIONS;
|
|
35
|
-
for (const configKey of AS_POOL_FIELDS_WITH_DEFAULTS) if (poolOptions[configKey] === void 0) poolOptions[configKey] = DEFAULT_ASSEMBLYSCRIPT_POOL_OTIONS[configKey];
|
|
36
|
-
const resolved = {
|
|
37
|
-
...poolOptions,
|
|
38
|
-
isResolved: true
|
|
39
|
-
};
|
|
40
|
-
if (resolved.coverageMemoryPagesInitial < 1 || resolved.coverageMemoryPagesMax < 1) throw createPoolError(`Coverage memory page size options must be positive - coverageMemoryPagesMin: ${resolved.coverageMemoryPagesInitial} | coverageMemoryPagesMax: ${resolved.coverageMemoryPagesMax}`, POOL_ERROR_NAMES.PoolConfigError);
|
|
41
|
-
if (resolved.testMemoryPagesInitial < 1 || resolved.testMemoryPagesMax !== void 0 && resolved.testMemoryPagesMax < 1) throw createPoolError(`Test memory page size options must be positive - testMemoryPagesMin: ${resolved.testMemoryPagesInitial} | testMemoryPagesMax: ${resolved.testMemoryPagesMax}`, POOL_ERROR_NAMES.PoolConfigError);
|
|
42
|
-
return resolved;
|
|
43
|
-
}
|
|
44
|
-
function retryCompat(retry) {
|
|
45
|
-
return typeof retry === "number" ? retry : retry?.count ?? 0;
|
|
46
|
-
}
|
|
47
|
-
function getCompatConfig(config) {
|
|
48
|
-
return {
|
|
49
|
-
...config,
|
|
50
|
-
retry: retryCompat(config.retry)
|
|
51
|
-
};
|
|
52
|
-
}
|
|
53
|
-
function getProjectSerializedOrGlobalConfig(ctx) {
|
|
54
|
-
let testProject;
|
|
55
|
-
let foundProjectSerializedConfig = false;
|
|
56
|
-
let v3PoolOptions;
|
|
57
|
-
if (ctx.projects && ctx.projects.length > 0) {
|
|
58
|
-
const project = ctx.projects.find((p) => p.config.pool.includes("assemblyscript"));
|
|
59
|
-
if (project) {
|
|
60
|
-
testProject = project;
|
|
61
|
-
foundProjectSerializedConfig = true;
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
const config = !!testProject ? {
|
|
65
|
-
...getCompatConfig(testProject.serializedConfig),
|
|
66
|
-
coverage: {
|
|
67
|
-
...testProject.serializedConfig.coverage,
|
|
68
|
-
...ctx.config.coverage
|
|
69
|
-
}
|
|
70
|
-
} : {
|
|
71
|
-
...ctx.config,
|
|
72
|
-
coverage: ctx.config.coverage
|
|
73
|
-
};
|
|
74
|
-
const maybeOptions = !!testProject ? testProject.config?.poolOptions?.assemblyScript : config?.poolOptions?.assemblyScript;
|
|
75
|
-
if (maybeOptions) v3PoolOptions = resolvePoolOptions(maybeOptions);
|
|
76
|
-
return {
|
|
77
|
-
config,
|
|
78
|
-
foundProjectSerializedConfig,
|
|
79
|
-
v3PoolOptions
|
|
80
|
-
};
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
//#endregion
|
|
84
|
-
export { getCompatConfig, getProjectSerializedOrGlobalConfig, resolvePoolOptions, retryCompat };
|
|
85
|
-
//# sourceMappingURL=resolve-config-s9gSJSMc.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"resolve-config-s9gSJSMc.mjs","names":[],"sources":["../src/types/types.ts","../src/util/resolve-config.ts"],"sourcesContent":["/*\n * Shared TypeScript types and interfaces\n */\n\nimport type { MessagePort } from 'node:worker_threads';\nimport type { BirpcReturn } from 'birpc';\nimport type { RunnerRPC, RuntimeRPC, SerializedConfig, SerializedCoverageConfig } from 'vitest';\nimport type { TestError } from '@vitest/utils';\nimport type { ResolvedConfig, ResolvedCoverageOptions } from 'vitest/node';\nimport type { File, Test, TaskMeta, TestOptions } from '@vitest/runner/types';\n\nimport {\n AS_POOL_WORKER_MSG_FLAG,\n AS_POOL_ERROR_TYPE_FLAG,\n COVERAGE_PAYLOAD_FORMATS,\n POOL_ERROR_NAMES,\n TEST_ERROR_NAMES,\n} from './constants.js';\n\n// ============================================================================\n// Errors\n// ============================================================================\n\n/** Error name type derived from TEST_ERROR_NAMES values */\nexport type TestErrorName = typeof TEST_ERROR_NAMES[keyof typeof TEST_ERROR_NAMES];\n\n/** Error name type derived from POOL_ERROR_NAMES values */\nexport type PoolErrorName = typeof POOL_ERROR_NAMES[keyof typeof POOL_ERROR_NAMES];\n\n/**\n * Conforms to Error interface but with required, strictly-typed name field.\n * Thrown internally for all pool errors.\n * \n * Must be thrown as a POJO (not using the Error() constructor!) to be properly\n * serialized across worker-pool boundery.\n */\nexport interface AssemblyScriptPoolError extends Error {\n readonly [AS_POOL_ERROR_TYPE_FLAG]: true;\n name: PoolErrorName;\n rawCallStack?: NodeJS.CallSite[];\n causeIsEnhancedError?: boolean;\n}\n\n/**\n * Extended vitest TestError with required, strictly-typed name field.\n * This is an explicitly serializable error format constructred to report\n * Test/Suite failures to vitest.\n */\nexport type AssemblyScriptTestError = TestError & { name: TestErrorName | PoolErrorName };\n\n/**\n * Native build error marker file content.\n * Written by install script when native addon compilation fails.\n * Read at runtime to display detailed error information to users.\n */\nexport interface NativeBuildError {\n stage: 'binaryen-download' | 'native-compile';\n error: string;\n platform: string;\n timestamp: string;\n}\n\n// ============================================================================\n// User Configuration\n// ============================================================================\n\n/**\n * AssemblyScript pool configuration options\n */\nexport interface AssemblyScriptPoolOptions {\n /** Enable verbose debug logging */\n debug?: boolean;\n debugNative?: boolean;\n debugCoverageExtract?: boolean;\n\n /** enable to collect coverage instrumentation on the pool's assembly/* files */\n _instrumentPoolInternals?: boolean;\n\n /**\n * Strip `@inline` decorators during compilation to improve error message and coverage accuracy\n *\n * - When true (default): `@inline` decorators removed, functions become visible in coverage\n * and source mapped errors point to the correct lines\n * - When false: `@inline` functions are inlined by compiler, missing from coverage, and \n * error line numbers don't match the non-inlined source\n * @default true\n */\n stripInline?: boolean;\n\n /**\n * Maximum number of worker threads to spawn with vitest 3.x.\n * Defaults to os.availableParallelism() - 1\n * \n * Use project config `test.maxWorkers` with vitest 4.x to control\n * the number of cuncurrently executing tests. \n */\n maxThreadsV3?: number;\n\n coverageMemoryPagesInitial?: number;\n coverageMemoryPagesMax?: number;\n\n testMemoryPagesInitial?: number;\n testMemoryPagesMax?: number;\n\n extraCompilerFlags?: string[];\n\n wasmImportsFactory?: string;\n}\n\n/**\n * AssemblyScript-specific coverage fields contributed by the hybrid coverage\n * provider on top of vitest's standard coverage options.\n *\n * Single source of truth for these field declarations: extended by the\n * vitest module augmentation files in `src/config/` so users get autocomplete\n * on these fields in their `vitest.config.ts` coverage block, and consumed\n * internally via `Required<HybridProviderOptions>` in\n * `ResolvedHybridProviderOptions`.\n */\nexport interface HybridProviderOptions {\n debugIstanbul?: boolean;\n\n /**\n * Glob patterns for AssemblyScript source files to include in coverage.\n * Used to build the complete AS coverage map.\n *\n * The standard `include` patterns are used by the v8 provider for JS/TS files.\n *\n * @example ['assembly/**\\/*.as.ts']\n */\n assemblyScriptInclude?: string[];\n\n /**\n * Glob patterns for AssemblyScript files to exclude from coverage.\n *\n * @example ['**\\/*.as.test.ts']\n */\n assemblyScriptExclude?: string[];\n}\n\nexport interface WasmImportsFactoryInfo {\n module: WebAssembly.Module;\n memory: WebAssembly.Memory;\n utils: {\n liftString: (stringPtr: number) => string | undefined;\n }\n}\n\nexport type WasmImportsFactory = (moduleInfo: WasmImportsFactoryInfo) => WebAssembly.Imports;\n\n// define these constants here so they make sense in context\nexport const AS_POOL_FIELDS_WITH_DEFAULTS = [\n 'debug',\n 'debugNative',\n 'debugCoverageExtract',\n '_instrumentPoolInternals',\n 'stripInline',\n 'maxThreadsV3',\n 'coverageMemoryPagesInitial',\n 'coverageMemoryPagesMax',\n 'testMemoryPagesInitial',\n 'extraCompilerFlags'\n] as const;\nexport const AS_POOL_OPTIONAL_FIELDS = ['testMemoryPagesMax', 'wasmImportsFactory'] as const;\n\n/** Fields that have default values. Internally these will always be defined. */\nexport type ASPoolOptionsFieldsWithDefaultValues = typeof AS_POOL_FIELDS_WITH_DEFAULTS[number];\n\n/** Fields with optional values and NO defaults */\nexport type ASPoolOptionsOptionalFields = typeof AS_POOL_OPTIONAL_FIELDS[number];\n\n// compatibility type for internal consumption - configs from all versions\n// of Vitest are converted to this format for internal consumption\nexport type SerializedConfigCompat = SerializedConfig & {\n retry: number;\n};\n\nexport type AssemblyScriptProjectConfig = (SerializedConfigCompat & {\n coverage: SerializedCoverageConfig & ResolvedHybridProviderOptions;\n}) | ResolvedConfig & {\n coverage: ResolvedHybridProviderOptions;\n};\n\n /**\n * Pool options resolved so that all fields are filled with user values preferentially, \n * with required fields being guaranteed to be populated with defaults otherwise.\n */\nexport type ResolvedAssemblyScriptPoolOptions =\n Required<Pick<AssemblyScriptPoolOptions, ASPoolOptionsFieldsWithDefaultValues>>\n & Partial<Pick<AssemblyScriptPoolOptions, ASPoolOptionsOptionalFields>>\n & { readonly isResolved: true };\n\nexport type ResolvedHybridProviderOptions =\n Required<HybridProviderOptions>\n & Omit<ResolvedCoverageOptions, 'provider'>\n & {\n provider: 'custom';\n customProviderModule: string;\n globbedAssemblyScriptInclude: GlobResult[];\n globbedAssemblyScriptProjectRelativeExcludeOnly: string[];\n };\n\n// vitest TestOptions fields that are supported by AssemblyScript tests in this pool\nexport type AssemblyScriptTestOptions = Required<Pick<TestOptions, 'timeout' | 'retry' | 'skip' | 'only' | 'fails'>>;\n\n// ============================================================================\n// Utility Types\n// ============================================================================\n\nexport type VitestVersion = 'v3' | 'v4';\n\nexport interface ThreadImports {\n createUserWasmImports?: WasmImportsFactory;\n}\n\nexport interface GlobResult {\n absolute: string;\n projectRootRelative: string;\n}\n\n// ============================================================================\n// Compilation & Results\n// ============================================================================\n\nexport interface AssemblyScriptCompilerOptions {\n shouldInstrument: boolean;\n projectRoot: string;\n instrumentationOptions?: InstrumentationOptions;\n stripInline?: boolean;\n extraFlags?: string[];\n}\n\nexport interface AssemblyScriptCompilerResult {\n binary: Uint8Array;\n sourceMap: string;\n debugInfo?: BinaryDebugInfo;\n isInstrumented: boolean;\n compileTiming: number;\n}\n\nexport interface InstrumentationOptions {\n /** Project root for resolving source map paths to absolute paths */\n projectRoot: string;\n /** List of relative file paths to exclude from instrumentation */\n relativeExcludedFiles: string[];\n excludedLibraryFilePrefix: string;\n excludedLibraryFileOverridePrefix?: string;\n excludedInternalFunctionSubstring: string;\n coverageMemoryPagesMin: number;\n coverageMemoryPagesMax: number;\n debug?: boolean;\n}\n\n/**\n * Result of instrumenting a WASM binary for coverage\n */\nexport interface InstrumentationResult {\n /** Instrumented WASM binary with coverage counter increments */\n instrumentedWasm: Buffer;\n /** Regenerated source map (offsets adjusted for instrumentation) */\n sourceMap: string;\n /** Debug info with coverageMemoryIndex assigned to each function */\n debugInfo: BinaryDebugInfo;\n}\n\n// ============================================================================\n// Error Source Mapping\n// ============================================================================\n\n/**\n * Source location in original AssemblyScript code (a point, not a range)\n *\n * All values are 1-based for internal consistency.\n * Conversion to 0-based columns happens at Istanbul output boundary.\n */\nexport interface SourceLocation {\n /** Absolute file path (normalized from source map during debug info extraction) */\n filePath: string;\n line: number;\n column: number;\n}\n\n/**\n * WebAssembly call site with mapped source location\n */\nexport interface WebAssemblyCallSite {\n functionName: string;\n location: SourceLocation;\n}\n\n// ============================================================================\n// Coverage Data (Runtime Hit Counts)\n// ============================================================================\n\n/**\n * Coverage data collected during test execution\n *\n * Simple hit count storage using position-based keys for stable merging.\n * Note: Function source metadata (names, ranges) comes from ParsedSourceInfo.\n *\n * Outer Record: keyed by absolute file path\n * Inner Record: keyed by position (\"line:column\") → hit count\n */\nexport interface CoverageData {\n hitCountsByFileAndPosition: Record<string, Record<string, number>>;\n}\n\n/**\n * Coverage payload sent via RPC from worker to hybrid coverage provider\n *\n * The __format marker distinguishes AS coverage from JS coverage in onAfterSuiteRun.\n */\nexport interface AssemblyScriptCoveragePayload {\n readonly __format: typeof COVERAGE_PAYLOAD_FORMATS.AssemblyScript;\n coverageData: CoverageData;\n suiteLogLabel: string;\n}\n\n\n// ============================================================================\n// Binary Debug Info (returned from native instrumentation addon)\n// ============================================================================\n//\n// These types represent debug information extracted from compiled WASM binaries\n// via the native addon. Binary debug info only has POINTS (from source map),\n// not ranges. Ranges come from source parsing (ParsedSource* types below).\n//\n// Naming convention: *DebugInfo suffix indicates binary-extracted data.\n\n/**\n * Source range in original AssemblyScript code (start and end points)\n *\n * All values are 1-based for internal consistency.\n * Conversion to 0-based columns happens at Istanbul output boundary.\n */\nexport interface SourceRange {\n /** Relative file path */\n filePath: string;\n startLine: number;\n startColumn: number;\n endLine: number;\n endColumn: number;\n}\n\n/**\n * Branch edge in control flow graph\n */\nexport interface BranchEdgeDebugInfo {\n /** Target basic block index */\n targetBlockIndex: number;\n /** Index of the expression that creates this branch (e.g., if condition) */\n sourceExpressionIndex?: number;\n}\n\n/**\n * Expression debug info extracted from WASM binary\n *\n * Expressions are the smallest unit of execution in WASM.\n * In v2, each expression can be mapped to a source statement for line-level coverage.\n */\nexport interface ExpressionDebugInfo {\n /** WASM expression type (e.g., \"call\", \"if\", \"block\") */\n type: string;\n /** Source location (POINT, not range) from source map */\n location?: SourceLocation;\n /** Whether this expression is a branch point (if, switch, select) */\n isBranch: boolean;\n /** Number of branch paths (for branch coverage) */\n branchPaths?: number;\n /**\n * Index into coverage memory counters\n * v2 only: Propagated from containing BasicBlockDebugInfo by TS wrapper\n */\n coverageMemoryIndex?: number;\n}\n\n/**\n * Basic block debug info from CFG analysis\n *\n * Basic blocks are sequences of expressions with single entry/exit points.\n * In v2, counters are placed at basic block boundaries for efficient coverage.\n */\nexport interface BasicBlockDebugInfo {\n /** Block index within the function */\n index: number;\n /** Indices of expressions contained in this block */\n expressionIndices: number[];\n /** Outgoing branch edges */\n branches: BranchEdgeDebugInfo[];\n /**\n * Index into coverage memory counters\n * v2 only: Source of truth for block-level coverage\n */\n coverageMemoryIndex?: number;\n}\n\n/**\n * Function debug info extracted from WASM binary via native addon\n */\nexport interface FunctionDebugInfo {\n /** WASM function index */\n wasmIndex: number;\n /** Function name from WASM (informational) */\n name: string;\n /**\n * Representative source location (a point within the function).\n * Used for containment matching to find the parsedsource function.\n */\n representativeLocation: SourceLocation;\n /** Index into coverage memory counters */\n coverageMemoryIndex: number;\n /** All expressions in this function */\n expressions: ExpressionDebugInfo[];\n /** Basic blocks from CFG analysis */\n basicBlocks: BasicBlockDebugInfo[];\n}\n\n/**\n * Binary debug info extracted from WASM + source map via native addon\n *\n * This is the processed output after TS wrapper transforms NativeDebugInfoOutput.\n * Functions are grouped by file and keyed by position for stable identity.\n */\nexport interface BinaryDebugInfo {\n /** All source files represented in extracted debug info (directly or inlined) */\n debugSourceFiles: string[];\n /**\n * Functions grouped by file path, then keyed by position (\"line:column\").\n * Position key enables stable identity across compilations.\n * Array value accommodates generic monomorphizations that share a source position.\n */\n functionsByFileAndPosition: Record<string, Record<string, FunctionDebugInfo[]>>;\n\n instrumentedFunctionCount: number;\n}\n\n/**\n * Raw output from native addon's instrumentForCoverage() C++ function\n */\nexport interface NativeInstrumentationResult {\n instrumentedWasm: Buffer;\n sourceMap: string;\n debugInfo: NativeDebugInfoOutput;\n errors?: string[];\n}\n\nexport interface NativeDebugInfoOutput {\n /** All source files represented in extracted debug info (directly or inlined) */\n debugSourceFiles: string[];\n /** Flat list of all functions with their debug info */\n functions: NativeFunctionDebugInfo[];\n}\n\nexport interface NativeFunctionDebugInfo extends Omit<FunctionDebugInfo, 'expressions' | 'representativeLocation'> {\n representativeLocation: NativeSourceLocation;\n expressions: NativeExpressionDebugInfo[];\n}\n\nexport interface NativeExpressionDebugInfo extends Omit<ExpressionDebugInfo, 'location'> {\n location?: NativeSourceLocation;\n}\n\nexport interface NativeSourceLocation extends Omit<SourceLocation, 'filePath'> {\n /** Index into NativeDebugInfoOutput.debugSourceFiles */\n fileIndex: number;\n}\n\nexport interface NativeInstrumentationOptions extends Omit<InstrumentationOptions, 'relativeExcludedFiles' | 'projectRoot'> {\n excludedFiles?: string[];\n logPrefix?: string;\n}\n\nexport type InstrumentForCoverageFunc = (\n wasmBuffer: Buffer,\n sourceMapBuffer: Buffer,\n instrumentationOptions: InstrumentationOptions,\n logModule: string,\n logLabel: string,\n) => InstrumentationResult;\n\nexport interface NativeAddonInterface {\n instrumentForCoverage: InstrumentForCoverageFunc;\n}\n\n/**\n * Typed interface for the native addon's exported methods.\n * The addon is loaded via node-gyp-build at runtime (CJS .node binary).\n */\nexport interface NativeAddon {\n instrumentForCoverage(\n wasmBuffer: Buffer,\n sourceMapBuffer: Buffer,\n options: NativeInstrumentationOptions,\n ): NativeInstrumentationResult;\n}\n\n// ============================================================================\n// Parsed Source Info (from AST Parser)\n// ============================================================================\n//\n// These types represent information parsed from source files via AST.\n// Parsed source info has *ranges* (start and end positions) for containment matching.\n\n/**\n * Function info parsed from AssemblyScript source via AST\n */\nexport interface ParsedSourceFunctionInfo {\n /** Fully \"qualified\" (WASM debug) name */\n qualifiedName: string;\n /** Short name for display */\n shortName: string;\n /** Source range for containment matching */\n range: SourceRange;\n}\n\n/**\n * Statement info parsed from AssemblyScript source via AST\n *\n * v2 only: Used for line-level statement coverage.\n * Binary expression points are matched to source statement ranges.\n */\nexport interface ParsedSourceStatementInfo {\n /** Source range for containment matching */\n range: SourceRange;\n /** Statement type (e.g., \"variable\", \"expression\", \"return\") */\n statementType?: string;\n}\n\n/**\n * Branch info parsed from AssemblyScript source via AST\n *\n * v2 only: Used for branch coverage.\n * Binary branch expressions are matched to source branch ranges.\n */\nexport interface ParsedSourceBranchInfo {\n /** Source range for containment matching */\n range: SourceRange;\n /** Type of branch construct */\n branchType: 'if' | 'ternary' | 'switch' | 'logical';\n}\n\n/**\n * Complete parsed source info from AST parser\n *\n * Generated by coverage provider when processing coverage (not during compilation).\n * Provides the \"what SHOULD be covered\" view from source code.\n */\nexport interface ParsedSourceInfo {\n /**\n * Functions grouped by file path, then by start line for containment matching.\n * Multiple functions can start on the same line, but limiting matching to checking\n * only the functions grouped on the input position's line is very performant.\n */\n functionsByFileAndStartLine: Record<string, Record<number, ParsedSourceFunctionInfo[]>>;\n /**\n * Statements grouped by file path, then keyed by position (\"line:column\")\n * v2 only: For line-level statement coverage\n */\n statementsByFileAndPosition: Record<string, Record<string, ParsedSourceStatementInfo>>;\n /**\n * Branches grouped by file path, then keyed by position (\"line:column\")\n * v2 only: For branch coverage\n */\n branchesByFileAndPosition: Record<string, Record<string, ParsedSourceBranchInfo>>;\n}\n\n// ============================================================================\n// Worker Communication & RPC\n// ============================================================================\n\nexport interface AssemblyScriptConsoleLog {\n msg: string;\n time: number;\n isError: boolean;\n}\n\nexport type AssemblyScriptConsoleLogHandler = (msg: string, isError?: boolean) => void;\n\nexport interface FailedAssertion {\n expected?: string;\n actual?: string;\n valuesProvided?: boolean;\n typeName?: string;\n message?: string;\n}\n\nexport interface AssemblyScriptSuiteTaskMeta extends TaskMeta {\n idxInParentTasks: number;\n defaultTestOptions: AssemblyScriptTestOptions;\n suitePreparedSent: boolean;\n resultFinal: boolean;\n coverageData?: CoverageData;\n}\n\nexport interface AssemblyScriptTestTaskMeta extends TaskMeta {\n idxInParentTasks: number;\n fnIndex: number;\n assertionsPassedCount: number;\n assertionsFailed: FailedAssertion[];\n resultFinal: boolean;\n coverageData?: CoverageData;\n lastError?: AssemblyScriptTestError;\n lastErrorValuesProvided?: boolean;\n lastErrorRawCallStack?: NodeJS.CallSite[];\n lastTimeoutTerminationTime?: number;\n};\n\nexport interface WASMExecutorPerfTimings {\n /** function start */\n fnInit: number;\n /** test start: execStart - fnInit = env init time */\n execStart: number;\n /** test end: execEnd - execStart = test duration */\n execEnd: number;\n /** function end: fnFinal - execEnd = error prep and/or coverage extraction time */\n fnfinal: number;\n}\n\nexport type WorkerRPC = BirpcReturn<RuntimeRPC, RunnerRPC>;\n\n/**\n * Worker channel with RPC for suite-level communication\n */\nexport interface WorkerChannel {\n /** Port to send to worker for RPC communication */\n workerPort: MessagePort;\n /** Pool-side port for cleanup */\n poolPort: MessagePort;\n /** RPC client for calling Vitest methods (only remote functions matter for our usage) */\n rpc: WorkerRPC;\n}\n\nexport interface WorkerThreadInitData {\n projectRoot: string,\n asPoolOptions: ResolvedAssemblyScriptPoolOptions;\n asCoverageOptions: ResolvedHybridProviderOptions;\n}\n\nexport interface AssemblyScriptPoolWorkerMessageBase {\n readonly [AS_POOL_WORKER_MSG_FLAG]: true;\n readonly type: string;\n}\n\nexport interface TestFileCompiled extends AssemblyScriptPoolWorkerMessageBase {\n readonly type: 'file-compiled';\n compilation: WASMCompilation;\n}\n\n\nexport interface TestExecutionStart extends AssemblyScriptPoolWorkerMessageBase {\n readonly type: 'execution-start';\n executionStart: number;\n test: Test;\n}\n\nexport interface TestExecutionEnd extends AssemblyScriptPoolWorkerMessageBase {\n readonly type: 'execution-end';\n executionEnd: number;\n testTaskId: string;\n}\n\nexport type AssemblyScriptPoolWorkerMessage = TestExecutionStart | TestExecutionEnd | TestFileCompiled;\n\nexport interface WASMCompilation {\n filePath: string;\n binary: Uint8Array;\n sourceMap: string;\n debugInfo?: BinaryDebugInfo;\n}\n\nexport interface TestRunRecord {\n test: Test;\n executionStart: number;\n timeoutId: NodeJS.Timeout;\n}\n\nexport interface ThreadSpec {\n file: File;\n compilation?: WASMCompilation;\n}\n\nexport interface RunCompileAndDiscoverTask {\n dispatchStart: number;\n workerId: number;\n port: MessagePort;\n file: File;\n config: SerializedConfigCompat;\n isCollectTestsMode: boolean;\n}\n\nexport interface RunTestsTask {\n dispatchStart: number;\n workerId: number;\n port: MessagePort;\n file: File;\n compilation: WASMCompilation;\n config: SerializedConfigCompat;\n isCollectTestsMode: boolean;\n timedOutTest?: Test;\n}\n\nexport interface ProcessPoolRunFileTask {\n dispatchStart: number;\n port: MessagePort;\n file: File;\n config: SerializedConfigCompat;\n isCollectTestsMode: boolean;\n timedOutTest?: Test;\n timedOutCompilation?: WASMCompilation;\n}\n","import { availableParallelism } from 'node:os';\nimport type { SerializedConfig } from 'vitest';\nimport type { Retry, SerializableRetry } from '@vitest/runner';\nimport type { TestProject, Vitest } from 'vitest/node';\n\nimport type {\n AssemblyScriptPoolOptions,\n ASPoolOptionsFieldsWithDefaultValues,\n ResolvedAssemblyScriptPoolOptions,\n ResolvedHybridProviderOptions,\n AssemblyScriptProjectConfig,\n SerializedConfigCompat,\n} from '../types/types.js';\nimport { AS_POOL_FIELDS_WITH_DEFAULTS } from '../types/types.js';\nimport { ASSEMBLYSCRIPT_POOL_NAME, POOL_ERROR_NAMES } from '../types/constants.js';\nimport { createPoolError } from '../util/pool-errors.js';\n\nconst DEFAULT_ASSEMBLYSCRIPT_POOL_OTIONS: Required<Pick<AssemblyScriptPoolOptions, ASPoolOptionsFieldsWithDefaultValues>> = {\n debug: false,\n debugNative: false,\n debugCoverageExtract: false,\n _instrumentPoolInternals: false,\n stripInline: true,\n maxThreadsV3: availableParallelism() - 1,\n coverageMemoryPagesInitial: 1,\n coverageMemoryPagesMax: 4,\n testMemoryPagesInitial: 1,\n extraCompilerFlags: [],\n} as const;\n\n// v4: used in runner init to parse user-provided param directly\nexport function resolvePoolOptions(userPoolOptions?: any): ResolvedAssemblyScriptPoolOptions {\n const poolOptions: AssemblyScriptPoolOptions = userPoolOptions ?? DEFAULT_ASSEMBLYSCRIPT_POOL_OTIONS;\n\n // resolve fields with defaults if user hasn't provided them\n for (const configKey of AS_POOL_FIELDS_WITH_DEFAULTS) {\n if (poolOptions[configKey] === undefined) {\n poolOptions[configKey] = DEFAULT_ASSEMBLYSCRIPT_POOL_OTIONS[configKey] as any;\n }\n }\n\n const resolved = { ...poolOptions, isResolved: true } as ResolvedAssemblyScriptPoolOptions;\n\n if (resolved.coverageMemoryPagesInitial < 1 || resolved.coverageMemoryPagesMax < 1) {\n throw createPoolError(\n `Coverage memory page size options must be positive - coverageMemoryPagesMin: ${resolved.coverageMemoryPagesInitial}`\n + ` | coverageMemoryPagesMax: ${resolved.coverageMemoryPagesMax}`,\n POOL_ERROR_NAMES.PoolConfigError\n );\n }\n \n if (resolved.testMemoryPagesInitial < 1 || (resolved.testMemoryPagesMax !== undefined && resolved.testMemoryPagesMax < 1)) {\n throw createPoolError(\n `Test memory page size options must be positive - testMemoryPagesMin: ${resolved.testMemoryPagesInitial}`\n + ` | testMemoryPagesMax: ${resolved.testMemoryPagesMax}`,\n POOL_ERROR_NAMES.PoolConfigError\n );\n }\n\n return resolved;\n}\n\nexport function retryCompat(retry?: SerializableRetry | Retry): number {\n return typeof retry === 'number' ? retry : retry?.count ?? 0;\n}\n\nexport function getCompatConfig(config: SerializedConfig): SerializedConfigCompat {\n return {\n ...config,\n retry: retryCompat(config.retry)\n };\n}\n\n// v3 & hybrid coverage provider: used to get project config & poolOptions, with global coverage on project config\n// poolOptions will be undefined for v4 in coverage provider, but it doesn't need them\nexport function getProjectSerializedOrGlobalConfig(ctx: Vitest): {\n config: AssemblyScriptProjectConfig;\n foundProjectSerializedConfig: boolean;\n v3PoolOptions?: ResolvedAssemblyScriptPoolOptions;\n} {\n let testProject: TestProject | undefined;\n let foundProjectSerializedConfig: boolean = false;\n let v3PoolOptions: ResolvedAssemblyScriptPoolOptions | undefined;\n\n // In multi-project mode, ctx.config is the global config, not the project-specific config\n // We need to find our project in ctx.projects to get project-specific config at the \"pool level\" in v3,\n // and in the hybrid coverage provider regardless of version (specifically the project root)\n if (ctx.projects && ctx.projects.length > 0) {\n // Multi-project mode: find the first project using this pool\n // Use string.includes because project.config.pool resolves to the *path* of the dist file\n const project = ctx.projects.find(p => p.config.pool.includes(ASSEMBLYSCRIPT_POOL_NAME));\n\n if (project) {\n testProject = project;\n foundProjectSerializedConfig = true;\n }\n }\n\n const config = !!testProject ? {\n ...getCompatConfig(testProject.serializedConfig),\n coverage: {\n ...testProject.serializedConfig.coverage,\n ...(ctx.config.coverage as unknown as ResolvedHybridProviderOptions)\n }\n } : {\n ...ctx.config,\n coverage: ctx.config.coverage as unknown as ResolvedHybridProviderOptions\n };\n\n // @ts-ignore - we build with v4, but this is correct for v3 (has config.poolOptions)\n const maybeOptions: any = !!testProject ? testProject.config?.poolOptions?.assemblyScript : config?.poolOptions?.assemblyScript;\n if (maybeOptions) {\n v3PoolOptions = resolvePoolOptions(maybeOptions);\n }\n\n return {\n config,\n foundProjectSerializedConfig,\n v3PoolOptions\n };\n}"],"mappings":";;;;;AAuJA,MAAa,+BAA+B;CAC1C;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACD;;;;ACjJD,MAAM,qCAAsH;CAC1H,OAAO;CACP,aAAa;CACb,sBAAsB;CACtB,0BAA0B;CAC1B,aAAa;CACb,cAAc,sBAAsB,GAAG;CACvC,4BAA4B;CAC5B,wBAAwB;CACxB,wBAAwB;CACxB,oBAAoB,EAAE;CACvB;AAGD,SAAgB,mBAAmB,iBAA0D;CAC3F,MAAM,cAAyC,mBAAmB;AAGlE,MAAK,MAAM,aAAa,6BACtB,KAAI,YAAY,eAAe,OAC7B,aAAY,aAAa,mCAAmC;CAIhE,MAAM,WAAW;EAAE,GAAG;EAAa,YAAY;EAAM;AAErD,KAAI,SAAS,6BAA6B,KAAK,SAAS,yBAAyB,EAC/E,OAAM,gBACJ,gFAAgF,SAAS,wDACzD,SAAS,0BACzC,iBAAiB,gBAClB;AAGH,KAAI,SAAS,yBAAyB,KAAM,SAAS,uBAAuB,UAAa,SAAS,qBAAqB,EACrH,OAAM,gBACJ,wEAAwE,SAAS,gDACrD,SAAS,sBACrC,iBAAiB,gBAClB;AAGH,QAAO;;AAGT,SAAgB,YAAY,OAA2C;AACrE,QAAO,OAAO,UAAU,WAAW,QAAQ,OAAO,SAAS;;AAG7D,SAAgB,gBAAgB,QAAkD;AAChF,QAAO;EACL,GAAG;EACH,OAAO,YAAY,OAAO,MAAM;EACjC;;AAKH,SAAgB,mCAAmC,KAIjD;CACA,IAAI;CACJ,IAAI,+BAAwC;CAC5C,IAAI;AAKJ,KAAI,IAAI,YAAY,IAAI,SAAS,SAAS,GAAG;EAG3C,MAAM,UAAU,IAAI,SAAS,MAAK,MAAK,EAAE,OAAO,KAAK,0BAAkC,CAAC;AAExF,MAAI,SAAS;AACX,iBAAc;AACd,kCAA+B;;;CAInC,MAAM,SAAS,CAAC,CAAC,cAAc;EAC7B,GAAG,gBAAgB,YAAY,iBAAiB;EAChD,UAAU;GACR,GAAG,YAAY,iBAAiB;GAChC,GAAI,IAAI,OAAO;GAChB;EACF,GAAG;EACF,GAAG,IAAI;EACP,UAAU,IAAI,OAAO;EACtB;CAGD,MAAM,eAAoB,CAAC,CAAC,cAAc,YAAY,QAAQ,aAAa,iBAAiB,QAAQ,aAAa;AACjH,KAAI,aACF,iBAAgB,mBAAmB,aAAa;AAGlD,QAAO;EACL;EACA;EACA;EACD"}
|
|
@@ -1,138 +0,0 @@
|
|
|
1
|
-
import { debug } from "./debug-DtRAL4rM.mjs";
|
|
2
|
-
import { checkFailsAndInvertResult, finalizeSuiteResult, flagTestFinalized, getRunnableTasks, getTaskLogPrefix, isSuiteOwnFile, resetTestForRetry, setSuitePrepareResult, setTestResultForTestPrepare, shouldRetryTask, updateSuiteFinishedResult, updateTestResultAfterRun } from "./vitest-tasks-BZ24sghI.mjs";
|
|
3
|
-
import { executeWASMTest, reportSuiteFinished, reportSuitePrepare, reportTestFinished, reportTestPrepare, reportTestRetried, reportUserConsoleLogs } from "./load-user-imports-Bx5ZlhSm.mjs";
|
|
4
|
-
import { mergeCoverageData } from "./coverage-merge-CBXkpM1O.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, 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, base, poolOptions, collectCoverage, handleLog, logModule, threadImports, 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, 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, bail, diffOptions, timedOutTest) {
|
|
81
|
-
const suiteStart = 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
|
-
if (!suiteMeta.suitePreparedSent) {
|
|
93
|
-
setSuitePrepareResult(suite);
|
|
94
|
-
await reportSuitePrepare(rpc, suite, logModule, base);
|
|
95
|
-
suiteMeta.suitePreparedSent = true;
|
|
96
|
-
}
|
|
97
|
-
suiteMeta.coverageData = { hitCountsByFileAndPosition: {} };
|
|
98
|
-
debug(`${suiteLogPrefix} - Initialized empty suite coverage data`);
|
|
99
|
-
let tasksToRun = getRunnableTasks(suite);
|
|
100
|
-
debug(`${suiteLogPrefix} - Runnable tasks:`, tasksToRun.length);
|
|
101
|
-
for (const task of tasksToRun) if (task.type === "suite") {
|
|
102
|
-
const suiteTaskMeta = task.meta;
|
|
103
|
-
await runSuite(rpc, port, base, collectCoverage, compilation, task, logModule, poolOptions, threadImports, vitestVersion, bail, diffOptions, timedOutTest);
|
|
104
|
-
if (suiteMeta.coverageData && suiteTaskMeta.coverageData) mergeCoverageData(suiteMeta.coverageData, suiteTaskMeta.coverageData);
|
|
105
|
-
} else {
|
|
106
|
-
const testLogPrefix = getTaskLogPrefix(logModule, base, task);
|
|
107
|
-
const testTaskMeta = task.meta;
|
|
108
|
-
const testCompleted = testTaskMeta.resultFinal;
|
|
109
|
-
const testTimedOutPreviously = !!timedOutTest && task.id === timedOutTest.id;
|
|
110
|
-
if (testCompleted) debug(`${testLogPrefix} - Skipping completed test | state: "${task.result?.state}"`);
|
|
111
|
-
else if (testTimedOutPreviously) if (shouldRetryTask(task)) {
|
|
112
|
-
const newRetryCount = (task.result?.retryCount ?? 0) + 1;
|
|
113
|
-
debug(`${testLogPrefix} - Retrying after test timeout | retry attempt ${newRetryCount} / ${task.retry} | ${task.result?.errors?.length ?? 0} errors | state: "${task.result?.state}"`);
|
|
114
|
-
await reportTestRetried(rpc, task, logModule, base);
|
|
115
|
-
task.result.retryCount = newRetryCount;
|
|
116
|
-
await runTest(rpc, port, base, collectCoverage, compilation, task, logModule, poolOptions, threadImports, bail, diffOptions);
|
|
117
|
-
} else {
|
|
118
|
-
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}"`);
|
|
119
|
-
await Promise.all([postProcessTestResult(rpc, bail, task, testLogPrefix, logModule), reportTestFinished(rpc, task, logModule, base)]);
|
|
120
|
-
flagTestFinalized(task);
|
|
121
|
-
debug(`${testLogPrefix} - Completed timed out test run`);
|
|
122
|
-
}
|
|
123
|
-
else {
|
|
124
|
-
debug(`${testLogPrefix} - Running test task | state: "${task.result?.state}"`);
|
|
125
|
-
await runTest(rpc, port, base, collectCoverage, compilation, task, logModule, poolOptions, threadImports, bail, diffOptions);
|
|
126
|
-
}
|
|
127
|
-
if (suiteMeta.coverageData && testTaskMeta.coverageData) mergeCoverageData(suiteMeta.coverageData, testTaskMeta.coverageData);
|
|
128
|
-
}
|
|
129
|
-
updateSuiteFinishedResult(suite, suiteLogPrefix);
|
|
130
|
-
await reportSuiteFinished(rpc, suite, logModule, base, vitestVersion);
|
|
131
|
-
finalizeSuiteResult(suite);
|
|
132
|
-
debug(`${suiteLogPrefix} - Suite Run Complete | TIMING ${(performance.now() - suiteStart).toFixed(2)} ms`);
|
|
133
|
-
return suite;
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
//#endregion
|
|
137
|
-
export { runSuite };
|
|
138
|
-
//# sourceMappingURL=test-runner-BGqc9uCK.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"test-runner-BGqc9uCK.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} 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';\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 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 base,\n poolOptions,\n collectCoverage,\n handleLog,\n logModule,\n threadImports,\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, 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 bail?: number,\n diffOptions?: SerializedDiffOptions,\n timedOutTest?: Test,\n): Promise<Suite> {\n const suiteStart = 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 if (!suiteMeta.suitePreparedSent) {\n setSuitePrepareResult(suite);\n await reportSuitePrepare(rpc, suite, logModule, base);\n\n // ensure suite-prepare will only be sent once if a test\n // times out and the file worker thread gets re-launched\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, 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, 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, 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 test will not be run again if another test\n // times out later and the file worker thread gets re-launched\n finalizeSuiteResult(suite);\n\n const suiteTime = performance.now() - suiteStart;\n debug(`${suiteLogPrefix} - Suite Run Complete | TIMING ${suiteTime.toFixed(2)} ms`);\n\n return suite;\n}\n"],"mappings":";;;;;;AAgDA,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,MACA,aACe;CACf,MAAM,gBAAgB,iBAAiB,WA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EAAM,IAAA;EACN,MAAA,EAAQ,sBAAA;EACR,kBAAA;EACA,YAAA,GAAe,IAAA;EACf,mBAAA,GAAsB,eAAA;AAAA"}
|
|
@@ -1,149 +0,0 @@
|
|
|
1
|
-
import { calculateSuiteHash, createFileTask, someTasksAreOnly } from "@vitest/runner/utils";
|
|
2
|
-
import { processError } from "@vitest/utils/error";
|
|
3
|
-
|
|
4
|
-
//#region src/types/typed-constants.ts
|
|
5
|
-
const DEFAULT_ASSEMBLYSCRIPT_TEST_OPTIONS = {
|
|
6
|
-
fails: false,
|
|
7
|
-
skip: false,
|
|
8
|
-
only: false
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
//#endregion
|
|
12
|
-
//#region src/util/vitest-file-tasks.ts
|
|
13
|
-
function createInitialFileTask(testFile, projectName, projectRoot, configTestTimeout, configRetry) {
|
|
14
|
-
const file = createFileTask(testFile, projectRoot, projectName, "assemblyscript");
|
|
15
|
-
file.mode = "queued";
|
|
16
|
-
file.environmentLoad = 0;
|
|
17
|
-
file.setupDuration = 0;
|
|
18
|
-
file.meta = {
|
|
19
|
-
idxInParentTasks: -1,
|
|
20
|
-
defaultTestOptions: {
|
|
21
|
-
...DEFAULT_ASSEMBLYSCRIPT_TEST_OPTIONS,
|
|
22
|
-
timeout: configTestTimeout,
|
|
23
|
-
retry: configRetry
|
|
24
|
-
},
|
|
25
|
-
suitePreparedSent: false,
|
|
26
|
-
resultFinal: false
|
|
27
|
-
};
|
|
28
|
-
return file;
|
|
29
|
-
}
|
|
30
|
-
function prepareFileTaskForCollection(file, testNamePattern, allowOnly) {
|
|
31
|
-
calculateSuiteHash(file);
|
|
32
|
-
interpretTaskModes(file, testNamePattern, void 0, void 0, void 0, someTasksAreOnly(file), false, allowOnly);
|
|
33
|
-
if (file.mode === "queued") file.mode = "run";
|
|
34
|
-
}
|
|
35
|
-
function failFile(file, error, runStartPerf) {
|
|
36
|
-
file.mode = "run";
|
|
37
|
-
if (file.result) {
|
|
38
|
-
file.result.state = "fail";
|
|
39
|
-
file.result.errors = file.result.errors ? file.result.errors.concat(error) : [error];
|
|
40
|
-
} else file.result = {
|
|
41
|
-
state: "fail",
|
|
42
|
-
errors: [error]
|
|
43
|
-
};
|
|
44
|
-
file.environmentLoad = file.environmentLoad ?? 0;
|
|
45
|
-
file.setupDuration = performance.now() - runStartPerf;
|
|
46
|
-
file.collectDuration = file.collectDuration ?? 0;
|
|
47
|
-
return file;
|
|
48
|
-
}
|
|
49
|
-
function getFullTaskHierarchy(file) {
|
|
50
|
-
function spacesForLevel(level) {
|
|
51
|
-
return new Array(level + 1).fill(" ").join("");
|
|
52
|
-
}
|
|
53
|
-
function taskStr(task, level) {
|
|
54
|
-
if (task.type === "test") return `${spacesForLevel(level)}ID: ${task.id} Mode: "${task.mode}" Test: "${task.name}"`;
|
|
55
|
-
else return `${spacesForLevel(level)}ID: ${task.id} Mode: "${task.mode}" Suite: "${task.name}"\n` + task.tasks.map((t) => taskStr(t, level + 1)).join("\n");
|
|
56
|
-
}
|
|
57
|
-
return taskStr(file, 0);
|
|
58
|
-
}
|
|
59
|
-
/**
|
|
60
|
-
* Function interface changes from vitest 4.0.x -> 4.1.x, so now were' just handling this
|
|
61
|
-
* functionality ourselves to prevent version compat conflicts.
|
|
62
|
-
*
|
|
63
|
-
* @see https://github.com/vitest-dev/vitest/blob/v4.1.0/packages/runner/src/utils/collect.ts#L10
|
|
64
|
-
*
|
|
65
|
-
* Vitest is released under the MIT license, included in this project's root.
|
|
66
|
-
* Copyright (c) 2021-Present Vitest Team
|
|
67
|
-
*/
|
|
68
|
-
function interpretTaskModes(file, namePattern, testLocations, testIds, testTagsFilter, onlyMode, parentIsOnly, allowOnly) {
|
|
69
|
-
const matchedLocations = [];
|
|
70
|
-
const traverseSuite = (suite, parentIsOnly, parentMatchedWithLocation) => {
|
|
71
|
-
const suiteIsOnly = parentIsOnly || suite.mode === "only";
|
|
72
|
-
const hasSomeTasksOnly = onlyMode && suite.tasks.some((t) => t.mode === "only" || t.type === "suite" && someTasksAreOnly(t));
|
|
73
|
-
suite.tasks.forEach((t) => {
|
|
74
|
-
const includeTask = hasSomeTasksOnly ? t.mode === "only" || t.type === "suite" && someTasksAreOnly(t) : suiteIsOnly || t.mode === "only";
|
|
75
|
-
if (onlyMode) {
|
|
76
|
-
if (t.type === "suite" && (includeTask || someTasksAreOnly(t))) {
|
|
77
|
-
if (t.mode === "only") {
|
|
78
|
-
checkAllowOnly(t, allowOnly);
|
|
79
|
-
t.mode = "run";
|
|
80
|
-
}
|
|
81
|
-
} else if (t.mode === "run" && !includeTask) t.mode = "skip";
|
|
82
|
-
else if (t.mode === "only") {
|
|
83
|
-
checkAllowOnly(t, allowOnly);
|
|
84
|
-
t.mode = "run";
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
let hasLocationMatch = parentMatchedWithLocation;
|
|
88
|
-
if (testLocations !== void 0 && testLocations.length !== 0) {
|
|
89
|
-
if (t.location && testLocations?.includes(t.location.line)) {
|
|
90
|
-
t.mode = "run";
|
|
91
|
-
matchedLocations.push(t.location.line);
|
|
92
|
-
hasLocationMatch = true;
|
|
93
|
-
} else if (parentMatchedWithLocation) t.mode = "run";
|
|
94
|
-
else if (t.type === "test") t.mode = "skip";
|
|
95
|
-
}
|
|
96
|
-
if (t.type === "test") {
|
|
97
|
-
if (namePattern && !getTaskFullName(t).match(namePattern)) t.mode = "skip";
|
|
98
|
-
if (testIds && !testIds.includes(t.id)) t.mode = "skip";
|
|
99
|
-
if (testTagsFilter && !testTagsFilter(t.tags || [])) t.mode = "skip";
|
|
100
|
-
} else if (t.type === "suite") if (t.mode === "skip") skipAllTasks(t);
|
|
101
|
-
else if (t.mode === "todo") todoAllTasks(t);
|
|
102
|
-
else traverseSuite(t, includeTask, hasLocationMatch);
|
|
103
|
-
});
|
|
104
|
-
if (suite.mode === "run" || suite.mode === "queued") {
|
|
105
|
-
if (suite.tasks.length && suite.tasks.every((i) => i.mode !== "run" && i.mode !== "queued")) suite.mode = "skip";
|
|
106
|
-
}
|
|
107
|
-
};
|
|
108
|
-
traverseSuite(file, parentIsOnly, false);
|
|
109
|
-
const nonMatching = testLocations?.filter((loc) => !matchedLocations.includes(loc));
|
|
110
|
-
if (nonMatching && nonMatching.length !== 0) {
|
|
111
|
-
const message = nonMatching.length === 1 ? `line ${nonMatching[0]}` : `lines ${nonMatching.join(", ")}`;
|
|
112
|
-
if (file.result === void 0) file.result = {
|
|
113
|
-
state: "fail",
|
|
114
|
-
errors: []
|
|
115
|
-
};
|
|
116
|
-
if (file.result.errors === void 0) file.result.errors = [];
|
|
117
|
-
file.result.errors.push(processError(/* @__PURE__ */ new Error(`No test found in ${file.name} in ${message}`)));
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
function getTaskFullName(task) {
|
|
121
|
-
return `${task.suite ? `${getTaskFullName(task.suite)} ` : ""}${task.name}`;
|
|
122
|
-
}
|
|
123
|
-
function skipAllTasks(suite) {
|
|
124
|
-
suite.tasks.forEach((t) => {
|
|
125
|
-
if (t.mode === "run" || t.mode === "queued") {
|
|
126
|
-
t.mode = "skip";
|
|
127
|
-
if (t.type === "suite") skipAllTasks(t);
|
|
128
|
-
}
|
|
129
|
-
});
|
|
130
|
-
}
|
|
131
|
-
function todoAllTasks(suite) {
|
|
132
|
-
suite.tasks.forEach((t) => {
|
|
133
|
-
if (t.mode === "run" || t.mode === "queued") {
|
|
134
|
-
t.mode = "todo";
|
|
135
|
-
if (t.type === "suite") todoAllTasks(t);
|
|
136
|
-
}
|
|
137
|
-
});
|
|
138
|
-
}
|
|
139
|
-
function checkAllowOnly(task, allowOnly) {
|
|
140
|
-
if (allowOnly) return;
|
|
141
|
-
task.result = {
|
|
142
|
-
state: "fail",
|
|
143
|
-
errors: [processError(/* @__PURE__ */ new Error("[Vitest] Unexpected .only modifier. Remove it or pass --allowOnly argument to bypass this error"))]
|
|
144
|
-
};
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
//#endregion
|
|
148
|
-
export { createInitialFileTask, failFile, getFullTaskHierarchy, prepareFileTaskForCollection };
|
|
149
|
-
//# sourceMappingURL=vitest-file-tasks-D8sOClGX.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"vitest-file-tasks-D8sOClGX.mjs","names":[],"sources":["../src/types/typed-constants.ts","../src/util/vitest-file-tasks.ts"],"sourcesContent":["/**\n * Typed Constants\n * \n * Constants which require importing ./types\n */\n\nimport { AssemblyScriptTestOptions } from './types.js';\n\n// hard-coded defaults only - timeout and retry defaults always come from vitest config\nexport const DEFAULT_ASSEMBLYSCRIPT_TEST_OPTIONS: Pick<AssemblyScriptTestOptions, 'fails' | 'skip' | 'only'> = {\n fails: false,\n skip: false,\n only: false\n};\n","import type { SerializedConfig } from 'vitest';\nimport type { File, Suite, Task, TaskBase } from '@vitest/runner/types';\nimport {\n calculateSuiteHash,\n createFileTask,\n someTasksAreOnly\n} from '@vitest/runner/utils';\nimport { processError } from '@vitest/utils/error';\n\nimport { ASSEMBLYSCRIPT_POOL_NAME } from '../types/constants.js';\nimport { DEFAULT_ASSEMBLYSCRIPT_TEST_OPTIONS } from '../types/typed-constants.js';\nimport type {\n AssemblyScriptSuiteTaskMeta,\n AssemblyScriptTestError,\n AssemblyScriptTestOptions,\n} from '../types/types.js';\n\nexport function createInitialFileTask(\n testFile: string,\n projectName: string,\n projectRoot: string,\n configTestTimeout: number,\n configRetry: number,\n): File {\n const file: File = createFileTask(\n testFile,\n projectRoot,\n projectName,\n ASSEMBLYSCRIPT_POOL_NAME\n );\n\n file.mode = 'queued';\n file.environmentLoad = 0; // AS pool has no environment setup\n file.setupDuration = 0; // AS pool has no setup files\n\n const defaultTestOptions: AssemblyScriptTestOptions = {\n ...DEFAULT_ASSEMBLYSCRIPT_TEST_OPTIONS,\n timeout: configTestTimeout,\n retry: configRetry,\n };\n\n const meta: AssemblyScriptSuiteTaskMeta = {\n idxInParentTasks: -1, // file task has no parent, should never be used anyway\n defaultTestOptions,\n suitePreparedSent: false,\n resultFinal: false,\n }\n file.meta = meta;\n\n return file;\n}\n\nexport function createFailedFileTask(\n testFile: string,\n projectName: string,\n config: SerializedConfig,\n error: AssemblyScriptTestError,\n): File {\n const file: File = createFileTask(\n testFile,\n config.root,\n projectName,\n ASSEMBLYSCRIPT_POOL_NAME\n );\n file.mode = 'run';\n file.result = {\n state: 'fail',\n errors: [error]\n };\n file.environmentLoad = 0;\n file.setupDuration = 0;\n file.collectDuration = 0;\n\n return file;\n}\n\nexport function prepareFileTaskForCollection(\n file: File,\n testNamePattern?: RegExp,\n allowOnly?: boolean,\n): void {\n calculateSuiteHash(file);\n\n // Interpret task modes does the following:\n // 1. If only mode enabled on any test, flip all non-only test.mode to skip\n // 2. Apply test name pattern filtering (from -t flag) to skip if needed\n // 3. If all test modes are skip, set file task mode to skip\n const hasOnly = someTasksAreOnly(file);\n interpretTaskModes(\n file,\n testNamePattern, // user regexp\n undefined, // testLocations\n undefined,\n undefined,\n hasOnly, // onlyMode - true if only is used anywhere\n false, // parentIsOnly - always false for the file task\n allowOnly\n );\n\n // update from queued (onQueued report) to run (onCollected report)\n if (file.mode === 'queued') {\n file.mode = 'run';\n }\n}\n\nexport function failFile(\n file: File,\n error: AssemblyScriptTestError,\n runStartPerf: number,\n): File {\n file.mode = 'run';\n\n if (file.result) {\n file.result.state = 'fail';\n file.result.errors = file.result.errors ? file.result.errors.concat(error) : [error];\n } else {\n file.result = {\n state: 'fail',\n errors: [error]\n };\n }\n file.environmentLoad = file.environmentLoad ?? 0;\n file.setupDuration = performance.now() - runStartPerf;\n file.collectDuration = file.collectDuration ?? 0;\n\n return file;\n}\n\n\n\nexport function getFullTaskHierarchy(file: File): string {\n function spacesForLevel(level: number): string {\n return new Array(level + 1).fill(' ').join('');\n }\n\n function taskStr(task: Task, level: number): string {\n if (task.type === 'test') {\n return `${spacesForLevel(level)}ID: ${task.id} Mode: \"${task.mode}\" Test: \"${task.name}\"`;\n } else {\n const suiteStr = `${spacesForLevel(level)}ID: ${task.id} Mode: \"${task.mode}\" Suite: \"${task.name}\"\\n`;\n return suiteStr + task.tasks.map(t => taskStr(t, level + 1)).join('\\n');\n }\n };\n\n return taskStr(file, 0);\n}\n\n\n// ============================================================================\n// interpretTaskModes function borrowed from Vitest\n// ============================================================================\n\n/**\n * Function interface changes from vitest 4.0.x -> 4.1.x, so now were' just handling this\n * functionality ourselves to prevent version compat conflicts.\n * \n * @see https://github.com/vitest-dev/vitest/blob/v4.1.0/packages/runner/src/utils/collect.ts#L10\n * \n * Vitest is released under the MIT license, included in this project's root.\n * Copyright (c) 2021-Present Vitest Team\n */\n\nfunction interpretTaskModes(\n file: Suite,\n namePattern?: string | RegExp,\n testLocations?: number[] | undefined,\n testIds?: string[] | undefined,\n testTagsFilter?: ((testTags: string[]) => boolean) | undefined,\n onlyMode?: boolean,\n parentIsOnly?: boolean,\n allowOnly?: boolean,\n): void {\n const matchedLocations: number[] = [];\n\n const traverseSuite = (suite: Suite, parentIsOnly?: boolean, parentMatchedWithLocation?: boolean) => {\n const suiteIsOnly = parentIsOnly || suite.mode === 'only';\n\n // Check if any tasks in this suite have `.only` - if so, only those should run\n const hasSomeTasksOnly = onlyMode && suite.tasks.some(\n t => t.mode === 'only' || (t.type === 'suite' && someTasksAreOnly(t)),\n );\n\n suite.tasks.forEach((t) => {\n // Check if either the parent suite or the task itself are marked as included\n // If there are tasks with `.only` in this suite, only include those (not all tasks from describe.only)\n const includeTask = hasSomeTasksOnly\n ? (t.mode === 'only' || (t.type === 'suite' && someTasksAreOnly(t)))\n : (suiteIsOnly || t.mode === 'only');\n if (onlyMode) {\n if (t.type === 'suite' && (includeTask || someTasksAreOnly(t))) {\n // Don't skip this suite\n if (t.mode === 'only') {\n checkAllowOnly(t, allowOnly);\n t.mode = 'run';\n }\n }\n else if (t.mode === 'run' && !includeTask) {\n t.mode = 'skip';\n }\n else if (t.mode === 'only') {\n checkAllowOnly(t, allowOnly);\n t.mode = 'run';\n }\n }\n\n let hasLocationMatch = parentMatchedWithLocation\n // Match test location against provided locations, only run if present\n // in `testLocations`. Note: if `includeTaskLocation` is not enabled,\n // all test will be skipped.\n if (testLocations !== undefined && testLocations.length !== 0) {\n if (t.location && testLocations?.includes(t.location.line)) {\n t.mode = 'run';\n matchedLocations.push(t.location.line);\n hasLocationMatch = true;\n }\n else if (parentMatchedWithLocation) {\n t.mode = 'run';\n }\n else if (t.type === 'test') {\n t.mode = 'skip';\n }\n }\n\n if (t.type === 'test') {\n if (namePattern && !getTaskFullName(t).match(namePattern)) {\n t.mode = 'skip';\n }\n if (testIds && !testIds.includes(t.id)) {\n t.mode = 'skip';\n }\n if (testTagsFilter && !testTagsFilter(t.tags || [])) {\n t.mode = 'skip';\n }\n }\n else if (t.type === 'suite') {\n if (t.mode === 'skip') {\n skipAllTasks(t);\n }\n else if (t.mode === 'todo') {\n todoAllTasks(t);\n }\n else {\n traverseSuite(t, includeTask, hasLocationMatch);\n }\n }\n })\n\n // if all subtasks are skipped, mark as skip\n if (suite.mode === 'run' || suite.mode === 'queued') {\n if (suite.tasks.length && suite.tasks.every(i => i.mode !== 'run' && i.mode !== 'queued')) {\n suite.mode = 'skip';\n }\n }\n }\n\n traverseSuite(file, parentIsOnly, false);\n\n const nonMatching = testLocations?.filter(loc => !matchedLocations.includes(loc))\n if (nonMatching && nonMatching.length !== 0) {\n const message = nonMatching.length === 1\n ? `line ${nonMatching[0]}`\n : `lines ${nonMatching.join(', ')}`;\n\n if (file.result === undefined) {\n file.result = {\n state: 'fail',\n errors: [],\n };\n }\n if (file.result.errors === undefined) {\n file.result.errors = [];\n }\n\n file.result.errors.push(\n processError(new Error(`No test found in ${file.name} in ${message}`)),\n );\n }\n}\n\nfunction getTaskFullName(task: TaskBase): string {\n return `${task.suite ? `${getTaskFullName(task.suite)} ` : ''}${task.name}`;\n}\n\nfunction skipAllTasks(suite: Suite) {\n suite.tasks.forEach((t) => {\n if (t.mode === 'run' || t.mode === 'queued') {\n t.mode = 'skip';\n if (t.type === 'suite') {\n skipAllTasks(t);\n }\n }\n });\n}\n\nfunction todoAllTasks(suite: Suite) {\n suite.tasks.forEach((t) => {\n if (t.mode === 'run' || t.mode === 'queued') {\n t.mode = 'todo';\n if (t.type === 'suite') {\n todoAllTasks(t);\n }\n }\n });\n}\n\nfunction checkAllowOnly(task: TaskBase, allowOnly?: boolean) {\n if (allowOnly) {\n return;\n }\n const error = processError(\n new Error(\n '[Vitest] Unexpected .only modifier. Remove it or pass --allowOnly argument to bypass this error',\n ),\n );\n task.result = {\n state: 'fail',\n errors: [error],\n };\n}\n"],"mappings":";;;;AASA,MAAa,sCAAkG;CAC7G,OAAO;CACP,MAAM;CACN,MAAM;CACP;;;;ACID,SAAgB,sBACd,UACA,aACA,aACA,mBACA,aACM;CACN,MAAM,OAAa,eACjB,UACA,aACA,8BAED;AAED,MAAK,OAAO;AACZ,MAAK,kBAAkB;AACvB,MAAK,gBAAgB;AAcrB,MAAK,OANqC;EACxC,kBAAkB;EAClB,oBARoD;GACpD,GAAG;GACH,SAAS;GACT,OAAO;GACR;EAKC,mBAAmB;EACnB,aAAa;EACd;AAGD,QAAO;;AA2BT,SAAgB,6BACd,MACA,iBACA,WACM;AACN,oBAAmB,KAAK;AAOxB,oBACE,MACA,iBACA,QACA,QACA,QANc,iBAAiB,KAAK,EAQpC,OACA,UACD;AAGD,KAAI,KAAK,SAAS,SAChB,MAAK,OAAO;;AAIhB,SAAgB,SACd,MACA,OACA,cACM;AACN,MAAK,OAAO;AAEZ,KAAI,KAAK,QAAQ;AACf,OAAK,OAAO,QAAQ;AACpB,OAAK,OAAO,SAAS,KAAK,OAAO,SAAS,KAAK,OAAO,OAAO,OAAO,MAAM,GAAG,CAAC,MAAM;OAEpF,MAAK,SAAS;EACZ,OAAO;EACP,QAAQ,CAAC,MAAM;EAChB;AAEH,MAAK,kBAAkB,KAAK,mBAAmB;AAC/C,MAAK,gBAAgB,YAAY,KAAK,GAAG;AACzC,MAAK,kBAAkB,KAAK,mBAAmB;AAE/C,QAAO;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