mootant 0.2.0 → 0.3.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/bin/mootant.js +3 -2
- package/dist/adapters/jest/collect-jest-dependencies.d.ts +8 -6
- package/dist/adapters/jest/collect-jest-dependencies.js +20 -14
- package/dist/adapters/jest/get-jest-cache-inputs.d.ts +14 -13
- package/dist/adapters/jest/index.d.ts +3 -1
- package/dist/adapters/jest/run-dry.js +20 -20
- package/dist/adapters/jest/start-jest-session.d.ts +6 -2
- package/dist/adapters/jest/start-jest-session.js +9 -2
- package/dist/adapters/jest/types/jest-handle.d.ts +2 -1
- package/dist/adapters/jest/types/jest-record.d.ts +4 -3
- package/dist/adapters/jest/types/worker-channel.d.ts +7 -0
- package/dist/adapters/jest/worker/boot-worker.d.ts +5 -4
- package/dist/adapters/jest/worker/create-test-runner.d.ts +4 -1
- package/dist/adapters/jest/worker/keep-reset-loads.d.ts +13 -0
- package/dist/adapters/jest/worker/list-runtime-files.d.ts +13 -0
- package/dist/adapters/jest/worker/run-unit.d.ts +25 -20
- package/dist/adapters/jest/worker/vm-setup.js +1 -1
- package/dist/adapters/jest/worker/worker.js +1 -1
- package/dist/adapters/node-test/check-typescript.js +2 -2
- package/dist/adapters/node-test/collect-node-dependencies.d.ts +7 -5
- package/dist/adapters/node-test/collect-node-dependencies.js +26 -20
- package/dist/adapters/node-test/create-spare-processes.d.ts +26 -0
- package/dist/adapters/node-test/create-spare-processes.js +53 -0
- package/dist/adapters/node-test/filter-exec-argv.d.ts +2 -1
- package/dist/adapters/node-test/filter-exec-argv.js +13 -12
- package/dist/adapters/node-test/get-node-cache-inputs.js +1 -1
- package/dist/adapters/node-test/get-unit-deadline.d.ts +6 -5
- package/dist/adapters/node-test/index.d.ts +2 -2
- package/dist/adapters/node-test/index.js +1 -0
- package/dist/adapters/node-test/is-group-alive.d.ts +8 -0
- package/dist/adapters/node-test/is-group-alive.js +8 -0
- package/dist/adapters/node-test/list-setup-files.js +2 -2
- package/dist/adapters/node-test/place-preload.d.ts +2 -1
- package/dist/adapters/node-test/place-preload.js +24 -18
- package/dist/adapters/node-test/preload/create-commonjs-route.js +1 -1
- package/dist/adapters/node-test/preload/preload.js +54 -52
- package/dist/adapters/node-test/preload/read-line-sync.d.ts +11 -0
- package/dist/adapters/node-test/preload/read-line-sync.js +25 -0
- package/dist/adapters/node-test/preload/read-unit.d.ts +11 -5
- package/dist/adapters/node-test/preload/read-unit.js +5 -4
- package/dist/adapters/node-test/run-isolated.d.ts +19 -10
- package/dist/adapters/node-test/run-isolated.js +68 -52
- package/dist/adapters/node-test/run-test-file.d.ts +12 -4
- package/dist/adapters/node-test/run-test-file.js +18 -14
- package/dist/adapters/node-test/run-test-process.d.ts +30 -13
- package/dist/adapters/node-test/run-test-process.js +38 -40
- package/dist/adapters/node-test/start-node-test-session.d.ts +10 -2
- package/dist/adapters/node-test/start-node-test-session.js +90 -84
- package/dist/adapters/node-test/start-test-process.d.ts +30 -0
- package/dist/adapters/node-test/start-test-process.js +27 -0
- package/dist/adapters/node-test/types/node-test-handle.d.ts +14 -1
- package/dist/adapters/node-test/types/process-watch.d.ts +4 -3
- package/dist/adapters/node-test/types/spare-processes.d.ts +20 -0
- package/dist/adapters/node-test/types/test-process-outcome.d.ts +8 -1
- package/dist/adapters/shared/allows-spares.d.ts +11 -0
- package/dist/adapters/shared/allows-spares.js +23 -0
- package/dist/adapters/shared/create-environment-proxy.d.ts +4 -3
- package/dist/adapters/shared/create-input-filter.d.ts +17 -14
- package/dist/adapters/shared/create-input-filter.js +2 -2
- package/dist/adapters/shared/enable-compile-cache.d.ts +32 -0
- package/dist/adapters/shared/enable-compile-cache.js +7 -0
- package/dist/adapters/shared/find-tsconfig-property.d.ts +13 -0
- package/dist/adapters/shared/find-tsconfig-property.js +6 -0
- package/dist/adapters/shared/get-spare-limit.d.ts +10 -0
- package/dist/adapters/shared/get-spare-limit.js +5 -0
- package/dist/adapters/shared/index-environment-hashes.d.ts +2 -2
- package/dist/adapters/shared/index-environment-hashes.js +5 -13
- package/dist/adapters/{node-test → shared}/list-flag-values.d.ts +2 -1
- package/dist/adapters/shared/list-flag-values.js +10 -0
- package/dist/adapters/shared/list-tsconfig-files.d.ts +14 -5
- package/dist/adapters/shared/list-tsconfig-files.js +15 -13
- package/dist/adapters/shared/parse-tsconfig.d.ts +10 -0
- package/dist/adapters/shared/parse-tsconfig.js +19 -0
- package/dist/adapters/shared/read-flag-name.d.ts +9 -0
- package/dist/adapters/shared/read-flag-name.js +5 -0
- package/dist/adapters/shared/read-node-options.d.ts +11 -0
- package/dist/adapters/shared/read-node-options.js +6 -0
- package/dist/adapters/shared/read-prefork-switch.d.ts +10 -0
- package/dist/adapters/shared/read-prefork-switch.js +5 -0
- package/dist/adapters/shared/read-tsconfig-extends.d.ts +2 -5
- package/dist/adapters/shared/read-tsconfig-extends.js +16 -31
- package/dist/adapters/shared/read-tsconfig-references.d.ts +12 -0
- package/dist/adapters/shared/read-tsconfig-references.js +13 -0
- package/dist/adapters/shared/track-file-reads.d.ts +13 -12
- package/dist/adapters/shared/track-file-reads.js +71 -71
- package/dist/adapters/shared/track-process-group.d.ts +2 -1
- package/dist/adapters/shared/track-process-group.js +7 -2
- package/dist/adapters/vitest/build-isolated-facts.d.ts +4 -3
- package/dist/adapters/vitest/collect-dependencies.d.ts +11 -5
- package/dist/adapters/vitest/collect-dependencies.js +36 -27
- package/dist/adapters/vitest/configure-project.d.ts +3 -2
- package/dist/adapters/vitest/configure-project.js +1 -1
- package/dist/adapters/vitest/create-forks-pool.d.ts +34 -7
- package/dist/adapters/vitest/create-forks-pool.js +102 -24
- package/dist/adapters/vitest/create-interleaved-sequencer.d.ts +3 -2
- package/dist/adapters/vitest/drop-signal-listeners.d.ts +14 -0
- package/dist/adapters/vitest/drop-signal-listeners.js +15 -0
- package/dist/adapters/vitest/get-cache-inputs.d.ts +3 -1
- package/dist/adapters/vitest/get-cache-inputs.js +43 -28
- package/dist/adapters/vitest/get-module-file.d.ts +3 -5
- package/dist/adapters/vitest/get-module-file.js +1 -1
- package/dist/adapters/vitest/get-spare-key.d.ts +15 -0
- package/dist/adapters/vitest/get-spare-key.js +15 -0
- package/dist/adapters/vitest/index.d.ts +2 -1
- package/dist/adapters/vitest/index.js +1 -0
- package/dist/adapters/vitest/is-virtual-module.d.ts +1 -2
- package/dist/adapters/vitest/is-virtual-module.js +1 -1
- package/dist/adapters/vitest/list-script-defines.d.ts +13 -0
- package/dist/adapters/vitest/list-script-defines.js +22 -0
- package/dist/adapters/vitest/read-unit-inputs.d.ts +2 -1
- package/dist/adapters/vitest/run-dry.js +1 -1
- package/dist/adapters/vitest/run-plan.d.ts +10 -8
- package/dist/adapters/vitest/run-plan.js +1 -1
- package/dist/adapters/vitest/run-specifications.d.ts +9 -2
- package/dist/adapters/vitest/run-specifications.js +22 -12
- package/dist/adapters/vitest/runner.d.ts +60 -29
- package/dist/adapters/vitest/runner.js +109 -86
- package/dist/adapters/vitest/start-vitest-session.d.ts +5 -1
- package/dist/adapters/vitest/start-vitest-session.js +64 -59
- package/dist/adapters/vitest/stop-hung-worker.d.ts +11 -4
- package/dist/adapters/vitest/stop-hung-worker.js +20 -7
- package/dist/adapters/vitest/types/mootant-forks-pool.d.ts +47 -0
- package/dist/adapters/vitest/types/vitest-session-state.d.ts +9 -8
- package/dist/adapters/vitest/types/vitest-worker.d.ts +48 -33
- package/dist/adapters/vitest/wait-for-workers.d.ts +5 -2
- package/dist/adapters/vitest/wait-for-workers.js +15 -15
- package/dist/adapters/vitest/worker/track-meta-defines.d.ts +39 -0
- package/dist/adapters/vitest/worker/track-meta-defines.js +23 -0
- package/dist/adapters/vitest/worker/track-values.d.ts +38 -0
- package/dist/adapters/vitest/worker/track-values.js +45 -0
- package/dist/adapters/vitest/worker/value-prefixes.d.ts +12 -0
- package/dist/adapters/vitest/worker/value-prefixes.js +6 -0
- package/dist/adapters/vitest/worker/wait-for-turn.d.ts +8 -6
- package/dist/adapters/vitest/worker/watch-property.d.ts +17 -0
- package/dist/adapters/vitest/worker/watch-property.js +27 -0
- package/dist/cli/create-run-progress.d.ts +8 -1
- package/dist/cli/create-run-progress.js +4 -1
- package/dist/cli/ensure-exit.d.ts +11 -0
- package/dist/cli/ensure-exit.js +15 -0
- package/dist/cli/html/build-html-report.js +1 -0
- package/dist/cli/html/client/main.js +1 -1
- package/dist/cli/html/client/render-overview.d.ts +3 -3
- package/dist/cli/index.d.ts +1 -0
- package/dist/cli/index.js +3 -2
- package/dist/cli/parse-arguments.d.ts +4 -0
- package/dist/cli/parse-arguments.js +4 -1
- package/dist/cli/report/build-run-report.js +1 -0
- package/dist/cli/report/format-command.d.ts +5 -0
- package/dist/cli/report/format-command.js +1 -1
- package/dist/cli/report/format-run-text-report.d.ts +5 -4
- package/dist/cli/report/format-run-text-report.js +10 -10
- package/dist/cli/report/slim-run-report.d.ts +10 -10
- package/dist/cli/report/slim-run-report.js +1 -0
- package/dist/cli/run-mutation.d.ts +5 -1
- package/dist/cli/run-mutation.js +32 -24
- package/dist/cli/terminal/create-spinner.d.ts +1 -2
- package/dist/cli/terminal/create-spinner.js +23 -32
- package/dist/cli/watch-interrupts.d.ts +41 -0
- package/dist/cli/watch-interrupts.js +32 -0
- package/dist/core/cache/apply-cached-units.d.ts +8 -7
- package/dist/core/cache/build-hash.d.ts +9 -0
- package/dist/core/cache/build-hash.js +2 -0
- package/dist/core/cache/cache-version.d.ts +4 -4
- package/dist/core/cache/check-dry-snapshot.d.ts +25 -0
- package/dist/core/cache/check-dry-snapshot.js +13 -0
- package/dist/core/cache/create-dry-reuse-miss.d.ts +12 -0
- package/dist/core/cache/create-dry-reuse-miss.js +7 -0
- package/dist/core/cache/create-dry-snapshot.d.ts +71 -0
- package/dist/core/cache/create-dry-snapshot.js +27 -0
- package/dist/core/cache/create-run-cache.d.ts +20 -2
- package/dist/core/cache/create-run-cache.js +31 -22
- package/dist/core/cache/create-snapshot-session.d.ts +12 -0
- package/dist/core/cache/create-snapshot-session.js +19 -0
- package/dist/core/cache/get-build-id.d.ts +11 -0
- package/dist/core/cache/get-build-id.js +7 -0
- package/dist/core/cache/get-cache-path.d.ts +1 -1
- package/dist/core/cache/get-cache-path.js +1 -1
- package/dist/core/cache/get-dry-snapshot-key.d.ts +47 -0
- package/dist/core/cache/get-dry-snapshot-key.js +43 -0
- package/dist/core/cache/get-dry-snapshot-path.d.ts +9 -0
- package/dist/core/cache/get-dry-snapshot-path.js +5 -0
- package/dist/core/cache/get-environment-key.d.ts +9 -4
- package/dist/core/cache/get-environment-key.js +3 -2
- package/dist/core/cache/get-test-file-keys.d.ts +2 -1
- package/dist/core/cache/get-test-file-keys.js +11 -10
- package/dist/core/cache/hash-files.d.ts +8 -7
- package/dist/core/cache/hash-files.js +17 -11
- package/dist/core/cache/hash-project-tree.d.ts +22 -0
- package/dist/core/cache/hash-project-tree.js +69 -0
- package/dist/core/cache/is-dry-reuse-miss.d.ts +8 -0
- package/dist/core/cache/is-dry-reuse-miss.js +4 -0
- package/dist/core/cache/list-file-hashes.d.ts +4 -0
- package/dist/core/cache/list-file-hashes.js +5 -2
- package/dist/core/cache/list-install-states.d.ts +12 -0
- package/dist/core/cache/list-install-states.js +19 -0
- package/dist/core/cache/list-variable-hashes.d.ts +15 -0
- package/dist/core/cache/list-variable-hashes.js +14 -0
- package/dist/core/cache/prepare-run-cache.d.ts +48 -22
- package/dist/core/cache/prepare-run-cache.js +86 -73
- package/dist/core/cache/read-dry-snapshot.d.ts +10 -0
- package/dist/core/cache/read-dry-snapshot.js +15 -0
- package/dist/core/cache/read-run-cache.js +6 -2
- package/dist/core/cache/save-dry-snapshot.d.ts +34 -0
- package/dist/core/cache/save-dry-snapshot.js +32 -0
- package/dist/core/cache/volatile-variables.d.ts +7 -0
- package/dist/core/cache/volatile-variables.js +11 -0
- package/dist/core/cache/write-run-cache.js +1 -1
- package/dist/core/config/load-typescript-config.d.ts +6 -1
- package/dist/core/config/load-typescript-config.js +26 -10
- package/dist/core/config/prepare-run.d.ts +7 -3
- package/dist/core/config/prepare-run.js +1 -0
- package/dist/core/config/resolve-run-settings.d.ts +3 -2
- package/dist/core/config/resolve-run-settings.js +1 -0
- package/dist/core/config/validate-config.js +3 -2
- package/dist/core/files/get-package-manifest.d.ts +12 -0
- package/dist/core/files/get-package-manifest.js +7 -0
- package/dist/core/generate/collect-candidates.d.ts +5 -1
- package/dist/core/generate/collect-candidates.js +125 -97
- package/dist/core/generate/generate-file-mutants.js +6 -5
- package/dist/core/index.d.ts +18 -0
- package/dist/core/mutators/shared/get-branch-copy-skip.d.ts +2 -2
- package/dist/core/mutators/shared/get-comparison-plan.d.ts +2 -2
- package/dist/core/mutators/shared/get-default-option-skip.d.ts +2 -2
- package/dist/core/mutators/shared/get-group-constant.d.ts +2 -2
- package/dist/core/mutators/shared/get-literal-skip.d.ts +3 -3
- package/dist/core/mutators/shared/get-loop-running-skip.d.ts +2 -2
- package/dist/core/mutators/shared/get-nullish-swap-skip.d.ts +2 -2
- package/dist/core/mutators/shared/get-or-default-skip.d.ts +2 -2
- package/dist/core/mutators/shared/get-owned-constants.d.ts +2 -2
- package/dist/core/mutators/shared/leave-now-skip.d.ts +2 -2
- package/dist/core/mutators/shared/no-op-callback-skip.d.ts +2 -2
- package/dist/core/plugins/create-mutator-registry.d.ts +4 -2
- package/dist/core/plugins/create-mutator-registry.js +15 -5
- package/dist/core/plugins/validate-plugin.d.ts +3 -3
- package/dist/core/plugins/validate-plugin.js +32 -10
- package/dist/core/regex/collect-pattern-changes.d.ts +2 -2
- package/dist/core/regex/create-regex-replacement.d.ts +2 -2
- package/dist/core/run/apply-isolated-result.d.ts +22 -14
- package/dist/core/run/apply-isolated-result.js +45 -26
- package/dist/core/run/count-run.d.ts +2 -1
- package/dist/core/run/create-run-state.d.ts +5 -0
- package/dist/core/run/create-run-state.js +1 -0
- package/dist/core/run/create-work-directory.d.ts +4 -1
- package/dist/core/run/create-work-directory.js +15 -12
- package/dist/core/run/decide-evidence.d.ts +4 -3
- package/dist/core/run/get-unit-evidence.d.ts +13 -7
- package/dist/core/run/get-unit-evidence.js +1 -1
- package/dist/core/run/guard-session.d.ts +18 -0
- package/dist/core/run/guard-session.js +30 -0
- package/dist/core/run/live-work-directories.d.ts +5 -0
- package/dist/core/run/live-work-directories.js +2 -0
- package/dist/core/run/read-isolated-unit.d.ts +6 -3
- package/dist/core/run/read-isolated-unit.js +77 -38
- package/dist/core/run/remove-live-work-directories.d.ts +7 -0
- package/dist/core/run/remove-live-work-directories.js +12 -0
- package/dist/core/run/run-isolated-rounds.d.ts +16 -12
- package/dist/core/run/run-isolated-rounds.js +3 -2
- package/dist/core/run/validate-adapter.d.ts +1 -1
- package/dist/core/run/validate-adapter.js +1 -1
- package/dist/core/run-mutants.d.ts +34 -2
- package/dist/core/run-mutants.js +356 -216
- package/dist/core/skips/skip-rules.d.ts +3 -1
- package/dist/package.js +1 -1
- package/dist/types/adapter/adapter-context.d.ts +20 -0
- package/dist/types/adapter/adapter-session.d.ts +2 -1
- package/dist/types/adapter/cache-inputs.d.ts +3 -2
- package/dist/types/adapter/dry-file.d.ts +4 -2
- package/dist/types/adapter/isolated-plan.d.ts +2 -1
- package/dist/types/adapter/isolated-result.d.ts +3 -1
- package/dist/types/adapter/run-inputs.d.ts +5 -4
- package/dist/types/adapter/test-adapter.d.ts +7 -0
- package/dist/types/cache/cache-entry.d.ts +9 -7
- package/dist/types/cache/cached-inputs.d.ts +2 -2
- package/dist/types/cache/dry-snapshot.d.ts +76 -0
- package/dist/types/cache/project-tree.d.ts +16 -0
- package/dist/types/cache/run-cache-file.d.ts +1 -1
- package/dist/types/cache/run-cache.d.ts +6 -5
- package/dist/types/config/plugin.d.ts +11 -2
- package/dist/types/config/run-config.d.ts +10 -0
- package/dist/types/config/run-settings.d.ts +6 -0
- package/dist/types/mutant/core-note.d.ts +12 -0
- package/dist/types/mutant/diagnostic.d.ts +1 -0
- package/dist/types/mutant/registered-skip-rule.d.ts +11 -0
- package/dist/types/mutant/skip-note.d.ts +7 -6
- package/dist/types/mutant/skip-rule-id.d.ts +3 -2
- package/dist/types/mutant/skip-rule.d.ts +2 -1
- package/dist/types/mutant/skipped-candidate.d.ts +14 -7
- package/dist/types/mutant/skipped-mutant.d.ts +6 -6
- package/dist/types/mutator/mutator.d.ts +3 -2
- package/dist/types/mutator/registered-mutator.d.ts +8 -0
- package/dist/types/regex/regex-change.d.ts +2 -2
- package/dist/types/report/html-report.d.ts +3 -2
- package/dist/types/report/list-report-skipped.d.ts +3 -2
- package/dist/types/report/run-report.d.ts +11 -2
- package/dist/types/report/slim-run-report.d.ts +1 -1
- package/dist/types/run/isolated-evidence.d.ts +3 -2
- package/dist/types/run/isolated-reason.d.ts +2 -1
- package/dist/types/run/run-durations.d.ts +8 -3
- package/dist/types/run/run-event.d.ts +10 -7
- package/dist/types/run/run-result.d.ts +11 -2
- package/dist/types/run/run-state.d.ts +21 -0
- package/dist/types/run/try-cause.d.ts +2 -1
- package/package.json +1 -1
- package/readme.md +85 -68
- package/skills/mootant/SKILL.md +36 -19
- package/skills/mootant/references/mutators.md +29 -23
- package/dist/adapters/node-test/list-flag-values.js +0 -9
- /package/dist/adapters/{node-test → shared}/loader-flags.d.ts +0 -0
- /package/dist/adapters/{node-test → shared}/loader-flags.js +0 -0
- /package/dist/{adapters/shared → core/files}/list-package-files.d.ts +0 -0
- /package/dist/{adapters/shared → core/files}/list-package-files.js +0 -0
- /package/dist/{adapters/shared → core/files}/read-package-type.d.ts +0 -0
- /package/dist/{adapters/shared → core/files}/read-package-type.js +0 -0
|
@@ -1,49 +1,127 @@
|
|
|
1
|
-
|
|
1
|
+
import { getSpareLimit as e } from "../shared/get-spare-limit.js";
|
|
2
|
+
import { getSpareKey as t } from "./get-spare-key.js";
|
|
3
|
+
const n = "mootant-forks", r = {
|
|
2
4
|
__vitest_worker_response__: !0,
|
|
3
5
|
type: "stopped"
|
|
4
6
|
};
|
|
5
|
-
function
|
|
7
|
+
function i(i, s, c) {
|
|
8
|
+
let l = /* @__PURE__ */ new Map(), u = [], d = null, f = !1, p = /* @__PURE__ */ new Set();
|
|
9
|
+
function m(e) {
|
|
10
|
+
p.has(e) || (p.add(e), e.once("exit", () => {
|
|
11
|
+
p.delete(e);
|
|
12
|
+
}));
|
|
13
|
+
}
|
|
14
|
+
async function h(e) {
|
|
15
|
+
if (o(e.child)) try {
|
|
16
|
+
await e.worker.stop();
|
|
17
|
+
} catch {}
|
|
18
|
+
}
|
|
19
|
+
function g(e, t) {
|
|
20
|
+
let n = new i(e), r = null;
|
|
21
|
+
function s() {
|
|
22
|
+
r !== null && u.includes(r) && (u = u.filter((e) => e !== r), h(r));
|
|
23
|
+
}
|
|
24
|
+
async function c() {
|
|
25
|
+
try {
|
|
26
|
+
await n.start();
|
|
27
|
+
} catch {
|
|
28
|
+
s();
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
n.on("error", s), c();
|
|
32
|
+
let l = a(n);
|
|
33
|
+
return l === null || !o(l) ? !1 : (l.on("exit", s), m(l), r = {
|
|
34
|
+
release: () => {
|
|
35
|
+
n.off("error", s), l.off("exit", s);
|
|
36
|
+
},
|
|
37
|
+
worker: n,
|
|
38
|
+
child: l,
|
|
39
|
+
key: t
|
|
40
|
+
}, u.push(r), !0);
|
|
41
|
+
}
|
|
42
|
+
function _(t, n) {
|
|
43
|
+
if (f) return;
|
|
44
|
+
let { project: r } = t;
|
|
45
|
+
try {
|
|
46
|
+
let i = e(r.config.maxWorkers), a = l.get(r) ?? 0;
|
|
47
|
+
for (let e = u.filter((e) => e.key === n).length; e < a && u.length < i; e += 1) if (!g(t, n)) {
|
|
48
|
+
l.delete(r);
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
} catch {
|
|
52
|
+
l.delete(r);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
function v(e) {
|
|
56
|
+
let t = u.find((t) => t.key === e && o(t.child));
|
|
57
|
+
return t === void 0 ? null : (u = u.filter((e) => e !== t), t.release(), t.worker);
|
|
58
|
+
}
|
|
6
59
|
return {
|
|
7
|
-
createPoolWorker: (
|
|
8
|
-
let
|
|
9
|
-
function
|
|
10
|
-
for (let
|
|
60
|
+
createPoolWorker: (e) => {
|
|
61
|
+
let n = new i(e), o = c ? t(e) : null, u = /* @__PURE__ */ new Set(), p = !1, h = !1, g = !1;
|
|
62
|
+
function y() {
|
|
63
|
+
for (let e of u) e(r);
|
|
11
64
|
}
|
|
12
65
|
return {
|
|
13
66
|
start: async () => {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
67
|
+
if (f) throw h = !0, Error("The run was interrupted, so mootant starts no Vitest worker.");
|
|
68
|
+
let t = Date.now(), { project: r } = e, i = l.get(r);
|
|
69
|
+
i !== void 0 && l.set(r, Math.max(0, i - 1));
|
|
70
|
+
let c = o === null ? null : v(o);
|
|
71
|
+
c === null ? await n.start() : n = c;
|
|
72
|
+
let u = a(n);
|
|
73
|
+
d ??= u !== null, u !== null && (s.set(u.pid, t), g = u.exitCode !== null || u.signalCode !== null, m(u)), n.on("exit", () => {
|
|
74
|
+
g = !0, p && y();
|
|
75
|
+
}), o !== null && d && setImmediate(() => {
|
|
76
|
+
_(e, o);
|
|
19
77
|
});
|
|
20
78
|
},
|
|
21
79
|
on: (e, t) => {
|
|
22
|
-
e === "message" &&
|
|
23
|
-
},
|
|
24
|
-
stop: async () => {
|
|
25
|
-
s = !1, c || await a.stop();
|
|
80
|
+
e === "message" && u.add(t), n.on(e, t);
|
|
26
81
|
},
|
|
27
82
|
off: (e, t) => {
|
|
28
|
-
|
|
83
|
+
u.delete(t), h || n.off(e, t);
|
|
84
|
+
},
|
|
85
|
+
stop: async () => {
|
|
86
|
+
p = !1, !g && !h && await n.stop();
|
|
29
87
|
},
|
|
30
88
|
send: (e) => {
|
|
31
|
-
|
|
89
|
+
p ||= e.type === "stop", n.send(e);
|
|
32
90
|
},
|
|
33
|
-
deserialize: (e) =>
|
|
34
|
-
cacheFs:
|
|
35
|
-
name:
|
|
91
|
+
deserialize: (e) => n.deserialize(e),
|
|
92
|
+
cacheFs: n.cacheFs,
|
|
93
|
+
name: n.name
|
|
36
94
|
};
|
|
37
95
|
},
|
|
38
|
-
|
|
96
|
+
prepare: (e) => {
|
|
97
|
+
l = /* @__PURE__ */ new Map();
|
|
98
|
+
for (let { project: t, pool: r } of e) r === n && l.set(t, (l.get(t) ?? 0) + 1);
|
|
99
|
+
},
|
|
100
|
+
stopWorker: (e) => {
|
|
101
|
+
let t = [...p].find((t) => t.pid === e);
|
|
102
|
+
return t === void 0 ? d !== !0 && null : t.kill("SIGKILL");
|
|
103
|
+
},
|
|
104
|
+
drain: async () => {
|
|
105
|
+
l = /* @__PURE__ */ new Map();
|
|
106
|
+
let e = u;
|
|
107
|
+
u = [], await Promise.all(e.map((e) => h(e)));
|
|
108
|
+
},
|
|
109
|
+
interrupt: () => {
|
|
110
|
+
f = !0;
|
|
111
|
+
for (let e of p) e.kill("SIGKILL");
|
|
112
|
+
},
|
|
113
|
+
name: n
|
|
39
114
|
};
|
|
40
115
|
}
|
|
41
|
-
function
|
|
116
|
+
function a(e) {
|
|
42
117
|
try {
|
|
43
118
|
let t = Reflect.get(e, "fork");
|
|
44
|
-
return typeof t?.pid == "number" ? t
|
|
119
|
+
return typeof t?.pid == "number" ? t : null;
|
|
45
120
|
} catch {
|
|
46
121
|
return null;
|
|
47
122
|
}
|
|
48
123
|
}
|
|
49
|
-
|
|
124
|
+
function o(e) {
|
|
125
|
+
return e.pid !== void 0 && e.exitCode === null && e.signalCode === null;
|
|
126
|
+
}
|
|
127
|
+
export { i as createForksPool };
|
|
@@ -4,8 +4,9 @@ import { TestSequencerConstructor } from 'vitest/node';
|
|
|
4
4
|
* test file, the units of one file in a mootant run, are spread out: after the
|
|
5
5
|
* given sequencer sorted them, they are taken in turns, one per test file and
|
|
6
6
|
* project, in the order each file first appears. A unit waits for the unit
|
|
7
|
-
* before it of the same file,
|
|
8
|
-
*
|
|
7
|
+
* before it of the same file, unless an isolated run has parallel units, so
|
|
8
|
+
* spreading them lets other test files use the workers meanwhile. A run with
|
|
9
|
+
* one specification per file keeps its order.
|
|
9
10
|
*
|
|
10
11
|
* @param Base - Sequencer class the instance was configured with.
|
|
11
12
|
* @returns Sequencer class to put in its place.
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Runs a start and drops every listener of SIGINT or SIGTERM added meanwhile,
|
|
3
|
+
* right after it is added. Vitest adds its own as it is created, and Vite one
|
|
4
|
+
* for a server out of middleware mode; they end the process soon after the
|
|
5
|
+
* signal, before mootant could stop the workers and close Vitest, which removes
|
|
6
|
+
* its temporary files, so the command line handles these signals itself. A
|
|
7
|
+
* listener is dropped in a microtask, which always runs before the process can
|
|
8
|
+
* handle a signal. Those the project's configuration and plugins add meanwhile
|
|
9
|
+
* are dropped too, as nothing tells them apart; listeners added later stay.
|
|
10
|
+
*
|
|
11
|
+
* @param start - Start to run.
|
|
12
|
+
* @returns What the start gives.
|
|
13
|
+
*/
|
|
14
|
+
export declare function dropSignalListeners<Result>(start: () => Promise<Result>): Promise<Result>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
const e = /* @__PURE__ */ new Set(["SIGTERM", "SIGINT"]);
|
|
2
|
+
async function t(t) {
|
|
3
|
+
function n(t, n) {
|
|
4
|
+
e.has(t) && queueMicrotask(() => {
|
|
5
|
+
process.off(t, n);
|
|
6
|
+
});
|
|
7
|
+
}
|
|
8
|
+
process.on("newListener", n);
|
|
9
|
+
try {
|
|
10
|
+
return await t();
|
|
11
|
+
} finally {
|
|
12
|
+
process.off("newListener", n);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
export { t as dropSignalListeners };
|
|
@@ -6,7 +6,9 @@ import { CacheInputs } from '../../types/adapter/cache-inputs.js';
|
|
|
6
6
|
* and the files of every project (`addProjectFiles`); the resolved settings of
|
|
7
7
|
* every project that change verdicts (`describeProjectSettings`); and the
|
|
8
8
|
* hashes of the environment variables the workers of each project saw, with `*`
|
|
9
|
-
* for all of them but those that change from shell to shell
|
|
9
|
+
* for all of them but those that change from shell to shell, and of the values
|
|
10
|
+
* of `provide` and `define` of each project (`hashValues`), which count only
|
|
11
|
+
* for the test files that read them.
|
|
10
12
|
*
|
|
11
13
|
* @param vitest - Vitest instance of the session.
|
|
12
14
|
* @param variables - Hashes of the environment variables of each project's
|
|
@@ -1,20 +1,27 @@
|
|
|
1
1
|
import { VERDICT_VARIABLE_PATTERN as e } from "../shared/verdict-variable-pattern.js";
|
|
2
2
|
import { indexEnvironmentHashes as t } from "../shared/index-environment-hashes.js";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import i from "
|
|
6
|
-
import {
|
|
7
|
-
|
|
3
|
+
import { createDigest as n } from "../../core/cache/create-digest.js";
|
|
4
|
+
import { VITEST_VARIABLES as r } from "./worker/vitest-variables.js";
|
|
5
|
+
import { VALUE_PREFIXES as i } from "./worker/value-prefixes.js";
|
|
6
|
+
import { getModuleFile as a } from "./get-module-file.js";
|
|
7
|
+
import o from "node:path";
|
|
8
|
+
import { inspect as s } from "node:util";
|
|
9
|
+
const c = /^\.{0,2}[/\\]|^[a-z]:/iu, l = {
|
|
8
10
|
maxStringLength: Infinity,
|
|
9
11
|
maxArrayLength: Infinity,
|
|
10
12
|
breakLength: Infinity,
|
|
11
|
-
|
|
13
|
+
customInspect: !1,
|
|
14
|
+
depth: Infinity,
|
|
15
|
+
getters: !0
|
|
12
16
|
};
|
|
13
|
-
function
|
|
17
|
+
function u(e, n) {
|
|
14
18
|
let i = new Set(e.vite.config.configFileDependencies), a = {}, o = [];
|
|
15
19
|
for (let s of e.projects) {
|
|
16
|
-
let e = t(Object.entries(
|
|
17
|
-
a[s.name] =
|
|
20
|
+
let e = t(Object.entries(n[s.name] ?? {}), r);
|
|
21
|
+
a[s.name] = {
|
|
22
|
+
...e,
|
|
23
|
+
...f(s)
|
|
24
|
+
}, p(s, i), o.push(d(s, e));
|
|
18
25
|
}
|
|
19
26
|
return {
|
|
20
27
|
files: [...i],
|
|
@@ -22,15 +29,9 @@ function c(e, r) {
|
|
|
22
29
|
settings: o
|
|
23
30
|
};
|
|
24
31
|
}
|
|
25
|
-
function
|
|
32
|
+
function d(t, n) {
|
|
26
33
|
let { config: r } = t, i = t.vitest.state.onUnhandledError;
|
|
27
34
|
return {
|
|
28
|
-
values: a([
|
|
29
|
-
t.vite.config.define ?? null,
|
|
30
|
-
r.defines,
|
|
31
|
-
Reflect.get(r, "_scriptDefines") ?? null,
|
|
32
|
-
Object.entries(t.getProvidedContext()).filter(([e]) => e !== "mootant")
|
|
33
|
-
], s),
|
|
34
35
|
sequence: {
|
|
35
36
|
seed: r.sequence.shuffle ? r.sequence.seed : null,
|
|
36
37
|
concurrent: r.sequence.concurrent,
|
|
@@ -53,25 +54,39 @@ function l(t, n) {
|
|
|
53
54
|
env: r.env
|
|
54
55
|
};
|
|
55
56
|
}
|
|
56
|
-
function
|
|
57
|
+
function f(e) {
|
|
58
|
+
let { config: t } = e, n = Object.entries(e.getProvidedContext()).filter(([e]) => e !== "mootant"), r = Reflect.get(t, "_scriptDefines") ?? {}, a = t.defines, o = /* @__PURE__ */ new Set([...Object.keys(a), ...Object.keys(r)]), s = {};
|
|
59
|
+
for (let [e, t] of n) s[`${i.provide}${e}`] = m(t);
|
|
60
|
+
s[`${i.provide}*`] = m(n);
|
|
61
|
+
for (let e of o) s[`${i.define}${e}`] = m([a, r].map((t) => Object.hasOwn(t, e) ? [t[e]] : []));
|
|
62
|
+
return s[i.defines] = m([
|
|
63
|
+
Object.keys(a),
|
|
64
|
+
Object.keys(r),
|
|
65
|
+
e.vite.config.define ?? null
|
|
66
|
+
]), s;
|
|
67
|
+
}
|
|
68
|
+
function p(e, t) {
|
|
57
69
|
let { config: n } = e;
|
|
58
70
|
for (let n of e.vite.config.configFileDependencies) t.add(n);
|
|
59
|
-
let { envDir:
|
|
60
|
-
if (
|
|
71
|
+
let { envDir: r, mode: i } = e.vite.config;
|
|
72
|
+
if (r !== !1) for (let e of [
|
|
61
73
|
".env",
|
|
62
74
|
".env.local",
|
|
63
|
-
`.env.${
|
|
64
|
-
`.env.${
|
|
65
|
-
]) t.add(
|
|
75
|
+
`.env.${i}`,
|
|
76
|
+
`.env.${i}.local`
|
|
77
|
+
]) t.add(o.join(r, e));
|
|
66
78
|
for (let e of n.globalSetup) t.add(e);
|
|
67
|
-
let
|
|
68
|
-
if (
|
|
69
|
-
let e = [...
|
|
79
|
+
let s = Reflect.get(e, "runner");
|
|
80
|
+
if (s.evaluatedModules !== void 0) {
|
|
81
|
+
let e = [...s.evaluatedModules.idToModuleMap.keys()];
|
|
70
82
|
for (let n of e) {
|
|
71
|
-
let e =
|
|
83
|
+
let e = a(n);
|
|
72
84
|
e !== null && t.add(e);
|
|
73
85
|
}
|
|
74
86
|
}
|
|
75
|
-
|
|
87
|
+
c.test(n.environment) && t.add(o.resolve(n.root, n.environment));
|
|
88
|
+
}
|
|
89
|
+
function m(e) {
|
|
90
|
+
return n(s(e, l));
|
|
76
91
|
}
|
|
77
|
-
export {
|
|
92
|
+
export { u as getCacheInputs };
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Tells which
|
|
3
|
-
*
|
|
4
|
-
* the lockfile stands for.
|
|
2
|
+
* Tells which file a Vite module id stands for: the id without its query or
|
|
3
|
+
* hash, when that is an absolute path, under `node_modules` too.
|
|
5
4
|
*
|
|
6
5
|
* @param id - Module id or path.
|
|
7
|
-
* @returns Absolute path of the file, or null for a virtual or built-in module
|
|
8
|
-
* and for a file under `node_modules`.
|
|
6
|
+
* @returns Absolute path of the file, or null for a virtual or built-in module.
|
|
9
7
|
*/
|
|
10
8
|
export declare function getModuleFile(id: string): string | null;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { PoolWorkerOptions } from './types/mootant-forks-pool.js';
|
|
2
|
+
/**
|
|
3
|
+
* Gives the key of the workers a spare forks worker can serve. The process of a
|
|
4
|
+
* forks worker depends only on its environment variables, its flags and
|
|
5
|
+
* Vitest's worker entry, and starts in mootant's working directory; the
|
|
6
|
+
* project, the test environment and the test files come later, in messages. A
|
|
7
|
+
* worker whose flags or `NODE_OPTIONS` load a module other than Vitest's own
|
|
8
|
+
* `suppress-warnings.cjs`, take flags or code from a file, or watch the process
|
|
9
|
+
* (`allowsSpares`) gets no spare, so no code of the project runs before the
|
|
10
|
+
* task takes the worker.
|
|
11
|
+
*
|
|
12
|
+
* @param options - Options of the worker.
|
|
13
|
+
* @returns The key, or null when the worker gets no spare.
|
|
14
|
+
*/
|
|
15
|
+
export declare function getSpareKey(options: Pick<PoolWorkerOptions, 'distPath' | 'execArgv' | 'env'>): string | null;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { readNodeOptions as e } from "../shared/read-node-options.js";
|
|
2
|
+
import { listFlagValues as t } from "../shared/list-flag-values.js";
|
|
3
|
+
import { allowsSpares as n } from "../shared/allows-spares.js";
|
|
4
|
+
import { LOADER_FLAGS as r } from "../shared/loader-flags.js";
|
|
5
|
+
import i from "node:path";
|
|
6
|
+
function a(a) {
|
|
7
|
+
let { distPath: o, execArgv: s, env: c } = a, l = i.resolve(o, "../suppress-warnings.cjs"), u = [...e(c.NODE_OPTIONS ?? ""), ...s];
|
|
8
|
+
return !n(u) || t(u, r).some((e) => e !== l) ? null : JSON.stringify([
|
|
9
|
+
c,
|
|
10
|
+
s,
|
|
11
|
+
o,
|
|
12
|
+
process.cwd()
|
|
13
|
+
]);
|
|
14
|
+
}
|
|
15
|
+
export { a as getSpareKey };
|
|
@@ -6,6 +6,7 @@ export type { VitestAdapterOptions } from './types/vitest-adapter-options.js';
|
|
|
6
6
|
* `vitestAdapter({ config: 'vitest.unit.config.ts' })` in `run.runner`.
|
|
7
7
|
*
|
|
8
8
|
* @param options - Vitest configuration file, when not the one Vitest finds.
|
|
9
|
-
* @returns Adapter named `vitest` with batch mode and mootant's
|
|
9
|
+
* @returns Adapter named `vitest` with batch mode, parallel units and mootant's
|
|
10
|
+
* version.
|
|
10
11
|
*/
|
|
11
12
|
export declare function vitestAdapter(options?: VitestAdapterOptions): TestAdapter;
|
|
@@ -2,8 +2,7 @@
|
|
|
2
2
|
* Tells whether a Vite module id names a virtual module, which a plugin makes
|
|
3
3
|
* up instead of loading a file, such as `\0virtual:limits` or `virtual:limits`:
|
|
4
4
|
* an id that, without its query or hash, is neither empty, nor an absolute
|
|
5
|
-
* path, nor a Node built-in
|
|
6
|
-
* stands for.
|
|
5
|
+
* path, nor a Node built-in.
|
|
7
6
|
*
|
|
8
7
|
* @param id - Module id, as a worker reports it or Vite's module graph has it.
|
|
9
8
|
* @returns Whether the id names a virtual module.
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Vitest } from 'vitest/node';
|
|
2
|
+
/**
|
|
3
|
+
* Lists, by project name, the defines Vitest runs as a script in the workers
|
|
4
|
+
* (`_scriptDefines`): those whose value is not JSON, which the script evaluates
|
|
5
|
+
* as code, and those whose key holds a dot, by key, with whether the value is
|
|
6
|
+
* code, as Vitest tells them. A key that becomes an environment variable of the
|
|
7
|
+
* worker is left out unless its value is code, which may change anything as it
|
|
8
|
+
* runs.
|
|
9
|
+
*
|
|
10
|
+
* @param vitest - Vitest instance of the session.
|
|
11
|
+
* @returns Whether the value of each define is code, by key, by project name.
|
|
12
|
+
*/
|
|
13
|
+
export declare function listScriptDefines(vitest: Vitest): Record<string, Record<string, boolean>>;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
const e = /^(?:import\.meta\.env|process\.env)\./u;
|
|
2
|
+
function t(t) {
|
|
3
|
+
let r = {};
|
|
4
|
+
for (let i of t.projects) {
|
|
5
|
+
let t = Reflect.get(i.config, "_scriptDefines") ?? {}, a = {};
|
|
6
|
+
for (let [r, i] of Object.entries(t)) {
|
|
7
|
+
let t = n(i);
|
|
8
|
+
(t || !e.test(r)) && (a[r] = t);
|
|
9
|
+
}
|
|
10
|
+
r[i.name] = a;
|
|
11
|
+
}
|
|
12
|
+
return r;
|
|
13
|
+
}
|
|
14
|
+
function n(e) {
|
|
15
|
+
if (typeof e != "string") return !1;
|
|
16
|
+
try {
|
|
17
|
+
return JSON.parse(e), !1;
|
|
18
|
+
} catch {
|
|
19
|
+
return !0;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
export { t as listScriptDefines };
|
|
@@ -17,7 +17,8 @@ import { RunInputs } from '../../types/adapter/run-inputs.js';
|
|
|
17
17
|
* record.
|
|
18
18
|
* @param reported.dependencies - Module ids and paths of `listDependencies`, or
|
|
19
19
|
* null when the worker could not tell.
|
|
20
|
-
* @param reported.environment - Names of the environment variables
|
|
20
|
+
* @param reported.environment - Names of the environment variables and values
|
|
21
|
+
* read (`VitestOutRecord.environment`).
|
|
21
22
|
* @param reported.filtered - Whether `onUnhandledError` decided an unhandled
|
|
22
23
|
* error of the unit.
|
|
23
24
|
* @returns Inputs of the unit, or null without a report or dependencies.
|
|
@@ -18,7 +18,7 @@ async function f(e, n) {
|
|
|
18
18
|
let i = await m(e, n);
|
|
19
19
|
a(r.workDirectory);
|
|
20
20
|
let s = [], f = c(r.workDirectory, async (e) => {
|
|
21
|
-
await l(e.pid) && s.push(e);
|
|
21
|
+
await l(e.pid, d.pool) && s.push(e);
|
|
22
22
|
}), { onUnitEnd: h } = r, g = u(r.workDirectory, h === void 0 ? void 0 : (() => {
|
|
23
23
|
h();
|
|
24
24
|
})), _;
|
|
@@ -9,14 +9,16 @@ import { UnitOutcome } from './types/unit-outcome.js';
|
|
|
9
9
|
* hung workers and counts finished units while the run goes on. Several workers
|
|
10
10
|
* may get the same test file; each claims the next unit of the file and waits
|
|
11
11
|
* until the unit before it finished (`waitForTurn`), so a test file never runs
|
|
12
|
-
* twice at once
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
* the
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
12
|
+
* twice at once, unless an isolated run has parallel units, whose units of one
|
|
13
|
+
* test file start at once. A concurrency lowers every project's `maxWorkers`
|
|
14
|
+
* for this run. A unit counts as finished when its worker marks it done or,
|
|
15
|
+
* once the run is over, when a worker claimed it and died or was stopped before
|
|
16
|
+
* it could, so the progress reaches the number of units that ran. The context's
|
|
17
|
+
* `onUnitEnd` gets the index of each finished unit and, for a unit its worker
|
|
18
|
+
* marked done, its facts with `describe`, else how long it ran, from its
|
|
19
|
+
* records. The read as a unit ends and the read after the run share their
|
|
20
|
+
* decisions of the unhandled errors, so each error is decided once
|
|
21
|
+
* (`StrayDecisions`).
|
|
20
22
|
*
|
|
21
23
|
* @param handle - Live Vitest instance of the session.
|
|
22
24
|
* @param plan - Kind of the run, units in plan order and the most units at
|
|
@@ -14,7 +14,7 @@ async function d(d, f) {
|
|
|
14
14
|
let _ = await a(g, p), v = p.map((e) => h.getProjectByName(e.project).createSpecification(e.file)), y = h.projects.map((e) => e.config), b = y.map((e) => e.maxWorkers);
|
|
15
15
|
if (f.concurrency !== void 0) for (let e of y) e.maxWorkers = Math.min(e.maxWorkers, f.concurrency);
|
|
16
16
|
let x = /* @__PURE__ */ new Map(), S = n(g, async (e) => {
|
|
17
|
-
await i(e.pid) && x.set(e.unit, e);
|
|
17
|
+
await i(e.pid, d.state.pool) && x.set(e.unit, e);
|
|
18
18
|
}), { onUnitEnd: C } = d.context, w = /* @__PURE__ */ new Map(), T = new Map(_.map((e, t) => [e, t])), E = o(g, C === void 0 ? void 0 : ((e) => {
|
|
19
19
|
let t = T.get(e), n = r(h, u.join(g, "out", `${e}.jsonl`), w);
|
|
20
20
|
if (f.describe === void 0) {
|
|
@@ -9,7 +9,14 @@ import { VitestHandle } from './types/vitest-session-state.js';
|
|
|
9
9
|
* must run until this resolves: the wait relies on it to stop workers that hang
|
|
10
10
|
* in their teardown. Failing tests and unhandled errors, such as a worker that
|
|
11
11
|
* died, are expected in mootant's runs, so the exit code Vitest sets for them
|
|
12
|
-
* is restored.
|
|
12
|
+
* is restored. When the context allows parallel units, the workers are told so,
|
|
13
|
+
* and a unit of an isolated run does not wait for the unit before it of the
|
|
14
|
+
* same test file; the pool then keeps spare workers for the units of the run
|
|
15
|
+
* (`MootantForksPool.prepare`). Otherwise the worker of a unit starts while the
|
|
16
|
+
* unit before it runs and waits for it, so spares would only add load. The
|
|
17
|
+
* spares left stop once Vitest ends the run, as no unit claims them, so the
|
|
18
|
+
* wait for workers never sees them. The options name the defines each project
|
|
19
|
+
* runs as a script (`listScriptDefines`).
|
|
13
20
|
*
|
|
14
21
|
* @param handle - Live Vitest instance of the session.
|
|
15
22
|
* @param worker - Kind of the run the workers perform and, for a dry run, the
|
|
@@ -21,4 +28,4 @@ import { VitestHandle } from './types/vitest-session-state.js';
|
|
|
21
28
|
* @returns First unhandled error of the run, such as a worker that died, or
|
|
22
29
|
* null.
|
|
23
30
|
*/
|
|
24
|
-
export declare function runSpecifications(handle: VitestHandle, worker: Omit<VitestWorkerOptions, 'directory' | 'root'>, specifications: TestSpecification[]): Promise<string | null>;
|
|
31
|
+
export declare function runSpecifications(handle: VitestHandle, worker: Omit<VitestWorkerOptions, 'directory' | 'parallel' | 'defines' | 'root'>, specifications: TestSpecification[]): Promise<string | null>;
|
|
@@ -1,19 +1,29 @@
|
|
|
1
1
|
import { getErrorMessage as e } from "../shared/get-error-message.js";
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
o
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
2
|
+
import { listScriptDefines as t } from "./list-script-defines.js";
|
|
3
|
+
import { waitForWorkers as n } from "./wait-for-workers.js";
|
|
4
|
+
async function r(r, i, a) {
|
|
5
|
+
let { context: o, vitest: s, state: c } = r, { exitCode: l } = process;
|
|
6
|
+
s.provide("mootant", {
|
|
7
|
+
...i,
|
|
8
|
+
...o.parallelUnits === !0 && { parallel: !0 },
|
|
9
|
+
defines: t(s),
|
|
10
|
+
directory: o.workDirectory,
|
|
11
|
+
root: o.root
|
|
9
12
|
});
|
|
13
|
+
let u = o.parallelUnits === !0 && i.mode === "isolated";
|
|
14
|
+
c.pool.prepare(u ? a : []);
|
|
10
15
|
try {
|
|
11
|
-
let
|
|
12
|
-
|
|
13
|
-
|
|
16
|
+
let t;
|
|
17
|
+
try {
|
|
18
|
+
t = await s.runTestSpecifications(a);
|
|
19
|
+
} finally {
|
|
20
|
+
await c.pool.drain();
|
|
21
|
+
}
|
|
22
|
+
await n(o.workDirectory, c.pool);
|
|
23
|
+
let [r] = t.unhandledErrors;
|
|
14
24
|
return r === void 0 ? null : e(r);
|
|
15
25
|
} finally {
|
|
16
|
-
process.exitCode =
|
|
26
|
+
process.exitCode = l;
|
|
17
27
|
}
|
|
18
28
|
}
|
|
19
|
-
export {
|
|
29
|
+
export { r as runSpecifications };
|