mootant 0.1.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/build-dry-file.d.ts +12 -12
- package/dist/adapters/jest/collect-jest-dependencies.d.ts +15 -12
- 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/runner.d.ts +1 -1
- package/dist/adapters/jest/runner.js +1 -1
- 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 +5 -4
- package/dist/adapters/jest/types/unit-worker.d.ts +16 -8
- package/dist/adapters/jest/types/worker-channel.d.ts +7 -0
- package/dist/adapters/jest/types/worker-session.d.ts +6 -7
- package/dist/adapters/jest/worker/boot-worker.d.ts +5 -3
- 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 +24 -17
- package/dist/adapters/jest/worker/vm-setup.js +1 -1
- package/dist/adapters/jest/worker/worker.js +1 -1
- package/dist/adapters/jest/write-worker-session.d.ts +1 -2
- package/dist/adapters/jest/write-worker-session.js +2 -2
- 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 -49
- 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 +19 -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/node-test-record.d.ts +3 -3
- package/dist/adapters/node-test/types/node-test-unit.d.ts +6 -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 +29 -0
- package/dist/adapters/shared/create-input-filter.js +32 -0
- 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-inputs.d.ts +7 -3
- package/dist/adapters/shared/track-file-inputs.js +16 -7
- package/dist/adapters/shared/track-file-reads.d.ts +13 -8
- package/dist/adapters/shared/track-file-reads.js +122 -69
- package/dist/adapters/shared/track-inputs.d.ts +13 -6
- package/dist/adapters/shared/track-inputs.js +7 -7
- package/dist/adapters/shared/track-process-group.d.ts +2 -1
- package/dist/adapters/shared/track-process-group.js +7 -2
- package/dist/adapters/shared/types/file-input-tracking.d.ts +6 -0
- package/dist/adapters/shared/types/input-tracking.d.ts +3 -3
- package/dist/adapters/vitest/build-isolated-facts.d.ts +4 -3
- package/dist/adapters/vitest/collect-dependencies.d.ts +10 -3
- package/dist/adapters/vitest/collect-dependencies.js +36 -26
- 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 +46 -29
- 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 +10 -0
- package/dist/adapters/vitest/is-virtual-module.js +8 -0
- 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-out-files.d.ts +7 -2
- package/dist/adapters/vitest/read-out-files.js +5 -5
- package/dist/adapters/vitest/read-out-records.d.ts +17 -0
- package/dist/adapters/vitest/read-out-records.js +27 -0
- package/dist/adapters/vitest/read-strays.d.ts +20 -0
- package/dist/adapters/vitest/read-strays.js +53 -0
- package/dist/adapters/vitest/read-unit-inputs.d.ts +9 -2
- package/dist/adapters/vitest/read-unit-inputs.js +1 -1
- package/dist/adapters/vitest/run-dry.js +17 -17
- package/dist/adapters/vitest/run-plan.d.ts +10 -6
- package/dist/adapters/vitest/run-plan.js +16 -16
- package/dist/adapters/vitest/run-specifications.d.ts +11 -3
- package/dist/adapters/vitest/run-specifications.js +22 -12
- package/dist/adapters/vitest/runner.d.ts +92 -46
- package/dist/adapters/vitest/runner.js +126 -104
- 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/stray-decisions.d.ts +8 -0
- package/dist/adapters/vitest/types/unit-outcome.d.ts +2 -1
- package/dist/adapters/vitest/types/vitest-session-state.d.ts +9 -8
- package/dist/adapters/vitest/types/vitest-worker.d.ts +118 -32
- 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/encode-stray.d.ts +16 -0
- package/dist/adapters/vitest/worker/encode-stray.js +16 -0
- package/dist/adapters/vitest/worker/intercept-strays.d.ts +26 -0
- package/dist/adapters/vitest/worker/intercept-strays.js +13 -0
- package/dist/adapters/vitest/worker/read-try-facts.d.ts +5 -4
- 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/adapters/vitest/worker/write-out-record.d.ts +2 -2
- 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 +2 -1
- package/dist/cli/html/client/main.js +1 -1
- package/dist/cli/html/client/render-change.d.ts +3 -2
- package/dist/cli/html/client/render-code.d.ts +1 -1
- package/dist/cli/html/client/render-overview.d.ts +3 -3
- package/dist/cli/html/pack-replacement.d.ts +1 -1
- 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-list-report.js +1 -1
- package/dist/cli/report/build-run-report.js +2 -1
- package/dist/cli/report/format-command.d.ts +5 -0
- package/dist/cli/report/format-command.js +1 -1
- package/dist/cli/report/format-file-groups.d.ts +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 +55 -47
- package/dist/cli/terminal/create-spinner.d.ts +2 -3
- package/dist/cli/terminal/create-spinner.js +23 -32
- package/dist/cli/terminal/get-text-style.js +4 -4
- 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 +5 -4
- 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 +11 -6
- package/dist/core/cache/hash-files.js +22 -17
- 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 +64 -16
- package/dist/core/cache/prepare-run-cache.js +109 -62
- 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/save-run-cache.d.ts +8 -7
- package/dist/core/cache/save-run-cache.js +2 -1
- package/dist/core/cache/unknown-hash.d.ts +7 -0
- package/dist/core/cache/unknown-hash.js +2 -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/files/select-changed-mutants.d.ts +11 -6
- package/dist/core/files/select-changed-mutants.js +38 -13
- package/dist/core/generate/apply-solitary-rule.d.ts +8 -5
- package/dist/core/generate/apply-solitary-rule.js +36 -29
- package/dist/core/generate/collect-candidates.d.ts +23 -5
- package/dist/core/generate/collect-candidates.js +202 -92
- package/dist/core/generate/compare-targets.d.ts +14 -0
- package/dist/core/generate/compare-targets.js +6 -0
- package/dist/core/generate/deduplicate-candidates.d.ts +6 -4
- package/dist/core/generate/deduplicate-candidates.js +11 -9
- package/dist/core/generate/find-list-removal.d.ts +20 -0
- package/dist/core/generate/find-list-removal.js +26 -0
- package/dist/core/generate/generate-file-mutants.js +49 -47
- package/dist/core/generate/get-mutant-site.d.ts +18 -0
- package/dist/core/generate/get-mutant-site.js +4 -0
- package/dist/core/generate/get-target.d.ts +14 -0
- package/dist/core/generate/get-target.js +4 -0
- package/dist/core/generate/pick-host.d.ts +10 -0
- package/dist/core/generate/pick-host.js +16 -0
- package/dist/core/generate/validate-replacement.d.ts +15 -4
- package/dist/core/generate/validate-replacement.js +28 -13
- package/dist/core/ignore/find-ignore-rule.d.ts +8 -7
- package/dist/core/index.d.ts +18 -0
- package/dist/core/instrument/find-attribute-values.d.ts +12 -0
- package/dist/core/instrument/find-attribute-values.js +13 -0
- package/dist/core/instrument/get-site-syntax.d.ts +14 -0
- package/dist/core/instrument/get-site-syntax.js +12 -0
- package/dist/core/instrument/group-mutant-ranges.d.ts +7 -3
- package/dist/core/instrument/group-mutant-ranges.js +25 -19
- package/dist/core/instrument/instrument-file.d.ts +5 -3
- package/dist/core/instrument/instrument-file.js +10 -9
- package/dist/core/instrument/instrumenter-version.d.ts +1 -1
- package/dist/core/instrument/render-branch.d.ts +17 -0
- package/dist/core/instrument/render-branch.js +81 -0
- package/dist/core/instrument/render-mutant-range.d.ts +17 -6
- package/dist/core/instrument/render-mutant-range.js +39 -13
- package/dist/core/list-mutants.d.ts +7 -5
- package/dist/core/list-mutants.js +2 -2
- package/dist/core/mutators/array-element.d.ts +7 -6
- package/dist/core/mutators/array-element.js +13 -13
- package/dist/core/mutators/assignment-operator.js +34 -33
- package/dist/core/mutators/boolean-literal.d.ts +3 -2
- package/dist/core/mutators/number-literal.d.ts +1 -1
- package/dist/core/mutators/object-property.d.ts +4 -3
- package/dist/core/mutators/object-property.js +7 -8
- package/dist/core/mutators/return-value.js +65 -33
- package/dist/core/mutators/shared/get-branch-copy-skip.d.ts +14 -9
- package/dist/core/mutators/shared/get-branch-copy-skip.js +34 -35
- package/dist/core/mutators/shared/get-canonical-falsy-default.d.ts +32 -0
- package/dist/core/mutators/shared/get-canonical-falsy-default.js +11 -0
- package/dist/core/mutators/shared/get-comparison-plan.d.ts +2 -2
- package/dist/core/mutators/shared/get-comparison-plan.js +86 -85
- package/dist/core/mutators/shared/get-condition-constants.d.ts +8 -8
- package/dist/core/mutators/shared/get-condition-constants.js +3 -3
- package/dist/core/mutators/shared/get-default-option-skip.d.ts +2 -2
- package/dist/core/mutators/shared/get-endless-value.d.ts +20 -0
- package/dist/core/mutators/shared/get-endless-value.js +25 -0
- package/dist/core/mutators/shared/get-forced-test-justifier.d.ts +44 -0
- package/dist/core/mutators/shared/get-forced-test-justifier.js +25 -0
- package/dist/core/mutators/shared/get-group-constant.d.ts +6 -6
- package/dist/core/mutators/shared/get-group-constant.js +2 -2
- package/dist/core/mutators/shared/get-literal-skip.d.ts +9 -9
- package/dist/core/mutators/shared/get-literal-skip.js +2 -2
- package/dist/core/mutators/shared/get-logical-drops.d.ts +8 -8
- package/dist/core/mutators/shared/get-logical-drops.js +80 -82
- 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/get-owner-constant.d.ts +3 -1
- package/dist/core/mutators/shared/get-running-value.d.ts +5 -4
- package/dist/core/mutators/shared/get-toward-mutant.d.ts +10 -2
- package/dist/core/mutators/shared/get-toward-mutant.js +45 -40
- package/dist/core/mutators/shared/has-other-exit.js +16 -36
- package/dist/core/mutators/shared/is-loop-exit.d.ts +20 -0
- package/dist/core/mutators/shared/is-loop-exit.js +32 -0
- package/dist/core/mutators/shared/is-read-only.d.ts +26 -0
- package/dist/core/mutators/shared/is-read-only.js +53 -0
- 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/mutators/statement-removal.d.ts +4 -3
- package/dist/core/mutators/statement-removal.js +69 -73
- package/dist/core/mutators/string-literal.d.ts +15 -5
- package/dist/core/mutators/string-literal.js +79 -50
- 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/presets/recommended.d.ts +2 -2
- package/dist/core/presets/strict.d.ts +4 -2
- 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-batch-result.d.ts +23 -22
- package/dist/core/run/apply-batch-result.js +5 -5
- package/dist/core/run/apply-isolated-result.d.ts +21 -12
- package/dist/core/run/apply-isolated-result.js +45 -25
- package/dist/core/run/classify-try.d.ts +9 -8
- 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-test-file-limits.d.ts +13 -0
- package/dist/core/run/get-test-file-limits.js +13 -0
- package/dist/core/run/get-unit-evidence.d.ts +12 -3
- 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/plan-batch.d.ts +6 -3
- package/dist/core/run/plan-batch.js +36 -31
- package/dist/core/run/plan-isolated.d.ts +3 -1
- package/dist/core/run/plan-isolated.js +8 -14
- package/dist/core/run/read-isolated-unit.d.ts +9 -6
- 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-batch-phases.d.ts +4 -3
- package/dist/core/run/run-dry-phase.d.ts +35 -19
- package/dist/core/run/run-dry-phase.js +127 -77
- package/dist/core/run/run-isolated-rounds.d.ts +15 -10
- package/dist/core/run/run-isolated-rounds.js +4 -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 +59 -22
- package/dist/core/run-mutants.js +356 -208
- package/dist/core/runtime/create-hit-limit-error.d.ts +5 -3
- package/dist/core/runtime/create-hit-limit-error.js +1 -1
- package/dist/core/runtime/install-mutant-runtime.js +23 -6
- package/dist/core/runtime/runtime-version.d.ts +4 -4
- package/dist/core/skips/skip-rules.d.ts +7 -1
- package/dist/core/skips/skip-rules.js +4 -0
- package/dist/core/syntax/is-brace-sensitive-attribute.d.ts +18 -0
- package/dist/core/syntax/is-brace-sensitive-attribute.js +28 -0
- package/dist/core/syntax/is-spread-safe-member.d.ts +18 -0
- package/dist/core/syntax/is-spread-safe-member.js +18 -0
- package/dist/core/syntax/is-value-position.d.ts +3 -1
- package/dist/core/text/get-list-removal-range.d.ts +22 -0
- package/dist/core/text/get-list-removal-range.js +46 -0
- package/dist/core/text/is-plain-attribute-string.d.ts +10 -0
- package/dist/core/text/is-plain-attribute-string.js +5 -0
- package/dist/core/text/parse-expression.d.ts +8 -4
- package/dist/core/text/parse-expression.js +1 -0
- package/dist/core/text/remove-list-element.d.ts +2 -4
- package/dist/core/text/remove-list-element.js +4 -45
- package/dist/docs/styles/colors.js +1 -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 +6 -3
- package/dist/types/adapter/dry-run-request.d.ts +5 -4
- package/dist/types/adapter/isolated-plan.d.ts +2 -1
- package/dist/types/adapter/isolated-result.d.ts +3 -1
- package/dist/types/adapter/mutant-runtime.d.ts +30 -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/cli/text-style.d.ts +1 -1
- package/dist/types/config/plugin.d.ts +11 -2
- package/dist/types/config/preset-settings.d.ts +2 -2
- package/dist/types/config/run-config.d.ts +22 -4
- package/dist/types/config/run-settings.d.ts +6 -0
- package/dist/types/html/indexed-mutant.d.ts +4 -2
- package/dist/types/html/shown-change.d.ts +4 -3
- package/dist/types/mutant/core-note.d.ts +12 -0
- package/dist/types/mutant/diagnostic.d.ts +1 -0
- package/dist/types/mutant/list-removal.d.ts +37 -0
- package/dist/types/mutant/mutant-candidate.d.ts +11 -17
- package/dist/types/mutant/mutant-host.d.ts +49 -0
- package/dist/types/mutant/mutant-kind.d.ts +18 -0
- package/dist/types/mutant/mutant-range.d.ts +15 -8
- package/dist/types/mutant/mutant.d.ts +9 -15
- package/dist/types/mutant/registered-skip-rule.d.ts +11 -0
- package/dist/types/mutant/site-syntax.d.ts +14 -0
- package/dist/types/mutant/skip-justifier.d.ts +3 -1
- 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 +27 -17
- package/dist/types/mutant/skipped-mutant.d.ts +15 -12
- package/dist/types/mutator/mutator.d.ts +3 -2
- package/dist/types/mutator/registered-mutator.d.ts +8 -0
- package/dist/types/mutator/replacement.d.ts +14 -3
- package/dist/types/regex/regex-change.d.ts +2 -2
- package/dist/types/report/html-report.d.ts +13 -9
- package/dist/types/report/list-report-focus.d.ts +3 -2
- package/dist/types/report/list-report-justifier.d.ts +4 -2
- package/dist/types/report/list-report-mutant.d.ts +15 -9
- package/dist/types/report/list-report-skipped.d.ts +6 -4
- package/dist/types/report/list-report.d.ts +1 -1
- package/dist/types/report/run-report.d.ts +13 -4
- package/dist/types/report/slim-list-report.d.ts +6 -3
- package/dist/types/report/slim-run-report.d.ts +2 -2
- package/dist/types/run/isolated-evidence.d.ts +3 -2
- package/dist/types/run/isolated-reason.d.ts +6 -4
- package/dist/types/run/mutant-state.d.ts +1 -1
- package/dist/types/run/run-durations.d.ts +8 -3
- package/dist/types/run/run-event.d.ts +11 -8
- package/dist/types/run/run-kind.d.ts +3 -2
- package/dist/types/run/run-result.d.ts +17 -5
- package/dist/types/run/run-state.d.ts +30 -1
- package/dist/types/run/run-status.d.ts +2 -2
- package/dist/types/run/try-cause.d.ts +10 -7
- package/dist/types/syntax/syntax-helpers.d.ts +5 -3
- package/package.json +5 -5
- package/readme.md +85 -68
- package/skills/mootant/SKILL.md +50 -31
- package/skills/mootant/references/mutators.md +31 -23
- package/dist/adapters/node-test/list-flag-values.js +0 -9
- package/dist/core/instrument/get-site-check.d.ts +0 -9
- package/dist/core/instrument/get-site-check.js +0 -5
- package/dist/core/instrument/get-template-site-check.d.ts +0 -12
- package/dist/core/instrument/get-template-site-check.js +0 -5
- /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/cli/{built-in-adapters.d.ts → get-built-in-adapters.d.ts} +0 -0
- /package/dist/cli/{built-in-adapters.js → get-built-in-adapters.js} +0 -0
- /package/dist/cli/terminal/{colors.d.ts → create-colors.d.ts} +0 -0
- /package/dist/cli/terminal/{colors.js → create-colors.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,11 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { readFileSync as e } from "node:fs";
|
|
2
|
+
import { execFile as t } from "node:child_process";
|
|
3
|
+
async function n(e, t) {
|
|
4
|
+
let n = t.stopWorker(e);
|
|
5
|
+
if (n !== null) return n;
|
|
3
6
|
try {
|
|
4
7
|
process.kill(e, 0);
|
|
5
8
|
} catch {
|
|
6
9
|
return !1;
|
|
7
10
|
}
|
|
8
|
-
if (process.platform !== "win32" && await
|
|
11
|
+
if (process.platform !== "win32" && (r(e) ?? await i(e)) !== process.pid) return !1;
|
|
9
12
|
try {
|
|
10
13
|
process.kill(e, "SIGKILL");
|
|
11
14
|
} catch (e) {
|
|
@@ -14,16 +17,26 @@ async function t(e) {
|
|
|
14
17
|
}
|
|
15
18
|
return !0;
|
|
16
19
|
}
|
|
17
|
-
function
|
|
20
|
+
function r(t) {
|
|
21
|
+
let n;
|
|
22
|
+
try {
|
|
23
|
+
n = e(`/proc/${t}/stat`, "utf8");
|
|
24
|
+
} catch {
|
|
25
|
+
return null;
|
|
26
|
+
}
|
|
27
|
+
let [, r] = n.slice(n.lastIndexOf(")") + 2).split(" ", 2);
|
|
28
|
+
return Number(r);
|
|
29
|
+
}
|
|
30
|
+
function i(e) {
|
|
18
31
|
return new Promise((n) => {
|
|
19
|
-
|
|
32
|
+
t("ps", [
|
|
20
33
|
"-o",
|
|
21
34
|
"ppid=",
|
|
22
35
|
"-p",
|
|
23
|
-
String(
|
|
36
|
+
String(e)
|
|
24
37
|
], (e, t) => {
|
|
25
38
|
n(e === null ? Number(t.trim()) : null);
|
|
26
39
|
});
|
|
27
40
|
});
|
|
28
41
|
}
|
|
29
|
-
export {
|
|
42
|
+
export { n as stopHungWorker };
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { PoolRunnerInitializer, TestSpecification } from 'vitest/node';
|
|
2
|
+
/**
|
|
3
|
+
* Mootant's pool of Vitest forks workers (`createForksPool`), which keeps spare
|
|
4
|
+
* workers for the tasks of a run.
|
|
5
|
+
*/
|
|
6
|
+
export interface MootantForksPool extends PoolRunnerInitializer {
|
|
7
|
+
/**
|
|
8
|
+
* Tells the pool the test files of the run to come, whose tasks spare workers
|
|
9
|
+
* may serve.
|
|
10
|
+
*
|
|
11
|
+
* @param specifications - Test files of the run.
|
|
12
|
+
*/
|
|
13
|
+
prepare(specifications: readonly TestSpecification[]): void
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Stops the process of a worker or spare the pool started that still runs,
|
|
17
|
+
* with `SIGKILL` through the process itself, which cannot stand for another
|
|
18
|
+
* process before it ended.
|
|
19
|
+
*
|
|
20
|
+
* @param pid - Process id of the worker.
|
|
21
|
+
* @returns Whether the process was stopped: false when no process of the pool
|
|
22
|
+
* with this id runs, null when Vitest does not expose the processes of its
|
|
23
|
+
* workers, so the pool cannot tell.
|
|
24
|
+
*/
|
|
25
|
+
stopWorker(pid: number): boolean | null
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Stops the spare workers no task took, and the run's spares to come.
|
|
29
|
+
*
|
|
30
|
+
* @returns Resolves when every spare is gone.
|
|
31
|
+
*/
|
|
32
|
+
drain(): Promise<void>
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Stops the process of every worker and spare the pool started that still
|
|
36
|
+
* runs, as the run is interrupted, and starts none from then on: the start of
|
|
37
|
+
* a task fails at once.
|
|
38
|
+
*/
|
|
39
|
+
interrupt(): void
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Options of a worker of a pool, as Vitest gives them for each task.
|
|
44
|
+
*/
|
|
45
|
+
export type PoolWorkerOptions = Parameters<
|
|
46
|
+
PoolRunnerInitializer['createPoolWorker']
|
|
47
|
+
>[0]
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What the main process decided for the unhandled errors workers recorded in a
|
|
3
|
+
* run (`readStrays`): the first line of an error that counts, or null for one
|
|
4
|
+
* that does not, by the number of the error (`VitestStray.id`), by the path of
|
|
5
|
+
* its out file. Each error is decided once, however often its out file is read
|
|
6
|
+
* and however many tries recorded it.
|
|
7
|
+
*/
|
|
8
|
+
export type StrayDecisions = Map<string, Map<number, string | null>>
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Vitest } from 'vitest/node';
|
|
2
2
|
import { AdapterContext } from '../../../types/adapter/adapter-context.js';
|
|
3
3
|
import { SwitchedFile } from '../../../types/adapter/switched-file.js';
|
|
4
4
|
import { Diagnostic } from '../../../types/mutant/diagnostic.js';
|
|
5
|
+
import { MootantForksPool } from './mootant-forks-pool.js';
|
|
5
6
|
/**
|
|
6
7
|
* State shared by the Vitest session, its Vite plugin and the project
|
|
7
8
|
* configuration hook.
|
|
@@ -20,16 +21,11 @@ export interface VitestSessionState {
|
|
|
20
21
|
files: Map<string, SwitchedFile> | null
|
|
21
22
|
|
|
22
23
|
/**
|
|
23
|
-
* Epoch milliseconds at which
|
|
24
|
-
*
|
|
24
|
+
* Epoch milliseconds at which each task of the current run got its worker
|
|
25
|
+
* process, by process id (`createForksPool`).
|
|
25
26
|
*/
|
|
26
27
|
spawns: Map<number, number>
|
|
27
28
|
|
|
28
|
-
/**
|
|
29
|
-
* Pool the projects run with (`createForksPool`).
|
|
30
|
-
*/
|
|
31
|
-
pool: PoolRunnerInitializer
|
|
32
|
-
|
|
33
29
|
/**
|
|
34
30
|
* Real paths of the module ids the plugin has seen, by id.
|
|
35
31
|
*/
|
|
@@ -45,6 +41,11 @@ export interface VitestSessionState {
|
|
|
45
41
|
*/
|
|
46
42
|
mismatched: Set<string>
|
|
47
43
|
|
|
44
|
+
/**
|
|
45
|
+
* Pool the projects run with (`createForksPool`).
|
|
46
|
+
*/
|
|
47
|
+
pool: MootantForksPool
|
|
48
|
+
|
|
48
49
|
/**
|
|
49
50
|
* Whether the plugin serves switched texts; false while a dry run checks the
|
|
50
51
|
* tests without them.
|
|
@@ -2,17 +2,19 @@ import { IsolatedUnit } from '../../../types/adapter/isolated-plan.js';
|
|
|
2
2
|
import { BatchUnit } from '../../../types/adapter/batch-plan.js';
|
|
3
3
|
import { TryFacts } from '../../../types/adapter/try-facts.js';
|
|
4
4
|
/**
|
|
5
|
-
* One line of `out/<hash>-<n>.jsonl
|
|
6
|
-
*
|
|
5
|
+
* One line of `out/<hash>-<n>.jsonl` as the main process reads it
|
|
6
|
+
* (`readOutRecords`): the tries of one test, an unhandled error after a try, or
|
|
7
|
+
* the end of a unit, with the first lines of only those unhandled errors that
|
|
8
|
+
* count (`readStrays`).
|
|
7
9
|
*/
|
|
8
10
|
export type VitestOutRecord =
|
|
9
11
|
| {
|
|
10
12
|
/**
|
|
11
13
|
* Ids of the modules the worker evaluated, the files Node's `require`
|
|
12
|
-
* loaded, the
|
|
13
|
-
* snapshot files of the test file
|
|
14
|
-
* worker cannot tell, as with a
|
|
15
|
-
* own.
|
|
14
|
+
* loaded, the files the test code read through `node:fs` that count as
|
|
15
|
+
* inputs (`createInputFilter`) and the snapshot files of the test file
|
|
16
|
+
* (`listDependencies`), or null when the worker cannot tell, as with a
|
|
17
|
+
* test environment other than Vitest's own.
|
|
16
18
|
*/
|
|
17
19
|
dependencies: string[] | null
|
|
18
20
|
|
|
@@ -30,7 +32,8 @@ export type VitestOutRecord =
|
|
|
30
32
|
|
|
31
33
|
/**
|
|
32
34
|
* Names of the environment variables the test code read, or `*` when it
|
|
33
|
-
* listed them all,
|
|
35
|
+
* listed them all, and of the values of `provide` and `define` it read
|
|
36
|
+
* (`trackValues`), sorted.
|
|
34
37
|
*/
|
|
35
38
|
environment: string[]
|
|
36
39
|
|
|
@@ -45,9 +48,9 @@ export type VitestOutRecord =
|
|
|
45
48
|
concurrent: boolean
|
|
46
49
|
|
|
47
50
|
/**
|
|
48
|
-
*
|
|
49
|
-
* changed itself, by writing, creating, removing or moving
|
|
50
|
-
* entries of a directory, sorted.
|
|
51
|
+
* Files and directories the test code read through `node:fs` that count
|
|
52
|
+
* as inputs and changed itself, by writing, creating, removing or moving
|
|
53
|
+
* them or the entries of a directory, sorted.
|
|
51
54
|
*/
|
|
52
55
|
modified: string[]
|
|
53
56
|
|
|
@@ -56,6 +59,13 @@ export type VitestOutRecord =
|
|
|
56
59
|
*/
|
|
57
60
|
abandoned: boolean
|
|
58
61
|
|
|
62
|
+
/**
|
|
63
|
+
* Whether `onUnhandledError` of the root configuration decided an
|
|
64
|
+
* unhandled error of the unit; what that callback depends on is out of
|
|
65
|
+
* sight, so the unit's inputs cannot be told (`readUnitInputs`).
|
|
66
|
+
*/
|
|
67
|
+
filtered: boolean
|
|
68
|
+
|
|
59
69
|
/**
|
|
60
70
|
* Milliseconds from the start of loading to the end of the file.
|
|
61
71
|
*/
|
|
@@ -72,7 +82,7 @@ export type VitestOutRecord =
|
|
|
72
82
|
reached: boolean
|
|
73
83
|
|
|
74
84
|
/**
|
|
75
|
-
*
|
|
85
|
+
* First lines of the unhandled errors outside tries that count.
|
|
76
86
|
*/
|
|
77
87
|
strays: string[]
|
|
78
88
|
|
|
@@ -104,7 +114,7 @@ export type VitestOutRecord =
|
|
|
104
114
|
mutant: string | null
|
|
105
115
|
|
|
106
116
|
/**
|
|
107
|
-
* First line of the error.
|
|
117
|
+
* First line of the error, which counts.
|
|
108
118
|
*/
|
|
109
119
|
message: string
|
|
110
120
|
|
|
@@ -140,6 +150,52 @@ export type VitestOutRecord =
|
|
|
140
150
|
kind: 'test'
|
|
141
151
|
}
|
|
142
152
|
|
|
153
|
+
/**
|
|
154
|
+
* Options the main process provides to workers under the key `mootant`.
|
|
155
|
+
*/
|
|
156
|
+
export interface VitestWorkerOptions {
|
|
157
|
+
/**
|
|
158
|
+
* Defines Vitest runs as a script in the workers of each project, by key,
|
|
159
|
+
* with whether each value is code (`listScriptDefines`), by project name;
|
|
160
|
+
* none when omitted.
|
|
161
|
+
*/
|
|
162
|
+
defines?: Record<string, Record<string, boolean>>
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* Watchdog budgets of a dry run (`DryRunRequest.timeouts`), or null in batch
|
|
166
|
+
* and isolated runs, whose plans carry their own.
|
|
167
|
+
*/
|
|
168
|
+
timeouts: { test: number; file: number } | null
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* Kind of the run.
|
|
172
|
+
*/
|
|
173
|
+
mode: 'isolated' | 'batch' | 'dry'
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* Whether a unit of an isolated run starts without waiting for the unit
|
|
177
|
+
* before it of the same test file (`AdapterContext.parallelUnits`); false or
|
|
178
|
+
* omitted waits.
|
|
179
|
+
*/
|
|
180
|
+
parallel?: boolean
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* Work directory of this run.
|
|
184
|
+
*/
|
|
185
|
+
directory: string
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* Whether a dry run tries every test twice in a row (`DryRunRequest.repeat`);
|
|
189
|
+
* false in batch and isolated runs.
|
|
190
|
+
*/
|
|
191
|
+
repeat: boolean
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* Project root; reads outside it count too (`createInputFilter`).
|
|
195
|
+
*/
|
|
196
|
+
root: string
|
|
197
|
+
}
|
|
198
|
+
|
|
143
199
|
/**
|
|
144
200
|
* Content of `beat/<pid>.json`; the main process timestamps it when it first
|
|
145
201
|
* sees `sequence`.
|
|
@@ -187,37 +243,56 @@ export interface VitestHeartbeat {
|
|
|
187
243
|
}
|
|
188
244
|
|
|
189
245
|
/**
|
|
190
|
-
*
|
|
246
|
+
* Unhandled error as a worker recorded it: what Vitest's listener passed to the
|
|
247
|
+
* worker's RPC (`interceptStrays`), encoded (`encodeStray`), before the main
|
|
248
|
+
* process decides whether it counts (`readStrays`).
|
|
191
249
|
*/
|
|
192
|
-
export interface
|
|
250
|
+
export interface VitestStray {
|
|
193
251
|
/**
|
|
194
|
-
*
|
|
195
|
-
* and
|
|
252
|
+
* Base64 of the `node:v8` serialization of the error as Vitest serialized it,
|
|
253
|
+
* with the name of the running test and the path of the test file, or of a
|
|
254
|
+
* reason that is not an object.
|
|
196
255
|
*/
|
|
197
|
-
|
|
256
|
+
error: string
|
|
198
257
|
|
|
199
258
|
/**
|
|
200
|
-
*
|
|
201
|
-
|
|
202
|
-
mode: 'isolated' | 'batch' | 'dry'
|
|
203
|
-
|
|
204
|
-
/**
|
|
205
|
-
* Work directory of this run.
|
|
206
|
-
*/
|
|
207
|
-
directory: string
|
|
208
|
-
|
|
209
|
-
/**
|
|
210
|
-
* Whether a dry run tries every test twice in a row (`DryRunRequest.repeat`);
|
|
211
|
-
* false in batch and isolated runs.
|
|
259
|
+
* Event of the error, as Vitest names it: `Uncaught Exception` or `Unhandled
|
|
260
|
+
* Rejection`.
|
|
212
261
|
*/
|
|
213
|
-
|
|
262
|
+
type: string
|
|
214
263
|
|
|
215
264
|
/**
|
|
216
|
-
*
|
|
265
|
+
* Number of the error among those the worker recorded, from 0; its copies in
|
|
266
|
+
* tries that ran at once share it, so the main process decides it once.
|
|
217
267
|
*/
|
|
218
|
-
|
|
268
|
+
id: number
|
|
219
269
|
}
|
|
220
270
|
|
|
271
|
+
/**
|
|
272
|
+
* One line of `out/<hash>-<n>.jsonl` as the worker writes it, with the
|
|
273
|
+
* unhandled errors as it recorded them; the main process reads it into a
|
|
274
|
+
* `VitestOutRecord` (`readOutRecords`).
|
|
275
|
+
*/
|
|
276
|
+
export type VitestOutLine =
|
|
277
|
+
| ({
|
|
278
|
+
/**
|
|
279
|
+
* Unhandled errors outside tries.
|
|
280
|
+
*/
|
|
281
|
+
strays: VitestStray[]
|
|
282
|
+
} & Omit<Extract<VitestOutRecord, { kind: 'end' }>, 'filtered' | 'strays'>)
|
|
283
|
+
| ({
|
|
284
|
+
/**
|
|
285
|
+
* Tries of the test in the order they ran.
|
|
286
|
+
*/
|
|
287
|
+
tries: VitestTryFacts[]
|
|
288
|
+
} & Omit<Extract<VitestOutRecord, { kind: 'test' }>, 'tries'>)
|
|
289
|
+
| ({
|
|
290
|
+
/**
|
|
291
|
+
* Unhandled error after the try.
|
|
292
|
+
*/
|
|
293
|
+
stray: VitestStray
|
|
294
|
+
} & Omit<Extract<VitestOutRecord, { kind: 'late' }>, 'message'>)
|
|
295
|
+
|
|
221
296
|
/**
|
|
222
297
|
* Plan file of one test file: `plan/<hash of the path>.json`.
|
|
223
298
|
*/
|
|
@@ -233,6 +308,17 @@ export interface VitestPlanFile {
|
|
|
233
308
|
indexes: number[]
|
|
234
309
|
}
|
|
235
310
|
|
|
311
|
+
/**
|
|
312
|
+
* Facts of a try as the worker writes them, with its unhandled errors as it
|
|
313
|
+
* recorded them.
|
|
314
|
+
*/
|
|
315
|
+
export interface VitestTryFacts extends Omit<TryFacts, 'strays'> {
|
|
316
|
+
/**
|
|
317
|
+
* Unhandled errors while the try ran.
|
|
318
|
+
*/
|
|
319
|
+
strays: VitestStray[]
|
|
320
|
+
}
|
|
321
|
+
|
|
236
322
|
declare module 'vitest' {
|
|
237
323
|
/**
|
|
238
324
|
* Values the main process provides to test workers.
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { MootantForksPool } from './types/mootant-forks-pool.js';
|
|
1
2
|
/**
|
|
2
3
|
* Waits until every worker of the run is gone. Vitest ends a run as soon as its
|
|
3
4
|
* workers reported their files, and stops them afterwards: worker-scoped
|
|
@@ -12,9 +13,11 @@
|
|
|
12
13
|
* that is, and the watchdog must run until the wait is over. A beat file that
|
|
13
14
|
* cannot be read, such as one being written, is read again on the next look and
|
|
14
15
|
* counts as a beat without budget until then. Workers still alive past the
|
|
15
|
-
* limit and without such a beat are stopped, so no worker
|
|
16
|
+
* limit and without such a beat are stopped (`stopHungWorker`), so no worker
|
|
17
|
+
* outlives the run.
|
|
16
18
|
*
|
|
17
19
|
* @param directory - Work directory of the session.
|
|
20
|
+
* @param pool - Pool of the session.
|
|
18
21
|
* @param limits - Milliseconds to wait at most without a pending heartbeat and
|
|
19
22
|
* past the budget of one.
|
|
20
23
|
* @param limits.wait - Milliseconds to wait at most without a pending beat.
|
|
@@ -24,7 +27,7 @@
|
|
|
24
27
|
* @throws {Error} When the folders of the run cannot be read or a worker cannot
|
|
25
28
|
* be stopped.
|
|
26
29
|
*/
|
|
27
|
-
export declare function waitForWorkers(directory: string, limits?: {
|
|
30
|
+
export declare function waitForWorkers(directory: string, pool: Pick<MootantForksPool, 'stopWorker'>, limits?: {
|
|
28
31
|
grace: number;
|
|
29
32
|
wait: number;
|
|
30
33
|
}): Promise<void>;
|
|
@@ -3,37 +3,37 @@ import { stopHungWorker as t } from "./stop-hung-worker.js";
|
|
|
3
3
|
import { readFileSync as n, readdirSync as r } from "node:fs";
|
|
4
4
|
import i from "node:path";
|
|
5
5
|
import { setInterval as a } from "node:timers/promises";
|
|
6
|
-
async function o(o, s = {
|
|
6
|
+
async function o(o, s, c = {
|
|
7
7
|
grace: 5e3,
|
|
8
8
|
wait: 7e4
|
|
9
9
|
}) {
|
|
10
|
-
let
|
|
11
|
-
function
|
|
12
|
-
let t = performance.now(), a = r(
|
|
10
|
+
let l = i.join(o, "worker"), u = i.join(o, "beat"), d = performance.now() + c.wait, f = /* @__PURE__ */ new Map();
|
|
11
|
+
function p() {
|
|
12
|
+
let t = performance.now(), a = r(l).filter((t) => e(t));
|
|
13
13
|
if (a.length === 0) return a;
|
|
14
14
|
let o = !1;
|
|
15
|
-
for (let e of r(
|
|
15
|
+
for (let e of r(u)) {
|
|
16
16
|
let r;
|
|
17
17
|
try {
|
|
18
|
-
r = JSON.parse(n(i.join(
|
|
18
|
+
r = JSON.parse(n(i.join(u, e), "utf8"));
|
|
19
19
|
} catch {
|
|
20
20
|
r = {
|
|
21
21
|
sequence: -1,
|
|
22
22
|
budget: 0
|
|
23
23
|
};
|
|
24
24
|
}
|
|
25
|
-
let
|
|
26
|
-
|
|
27
|
-
deadline: t + r.budget +
|
|
25
|
+
let s = f.get(e);
|
|
26
|
+
s?.sequence !== r.sequence && (s = {
|
|
27
|
+
deadline: t + r.budget + c.grace,
|
|
28
28
|
sequence: r.sequence
|
|
29
|
-
},
|
|
29
|
+
}, f.set(e, s)), a.includes(i.basename(e, ".json")) && t < s.deadline && (o = !0);
|
|
30
30
|
}
|
|
31
|
-
return o || t <
|
|
31
|
+
return o || t < d ? null : a;
|
|
32
32
|
}
|
|
33
|
-
let
|
|
34
|
-
if (
|
|
35
|
-
for await (let e of a(10)) if (
|
|
33
|
+
let m = p();
|
|
34
|
+
if (m === null) {
|
|
35
|
+
for await (let e of a(10)) if (m = p(), m !== null) break;
|
|
36
36
|
}
|
|
37
|
-
await Promise.all(
|
|
37
|
+
await Promise.all(m.map((e) => t(Number(e), s)));
|
|
38
38
|
}
|
|
39
39
|
export { o as waitForWorkers };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { VitestStray } from '../types/vitest-worker.js';
|
|
2
|
+
/**
|
|
3
|
+
* Encodes an unhandled error for an out file the way Vitest's forks pool sends
|
|
4
|
+
* it to the main process: serialized by `node:v8`, which keeps the big
|
|
5
|
+
* integers, cycles and undefined values that JSON drops or cannot write, as
|
|
6
|
+
* base64. A value `node:v8` cannot serialize keeps only its first line
|
|
7
|
+
* (`getErrorMessage`), so recording an error never throws in Vitest's
|
|
8
|
+
* listener.
|
|
9
|
+
*
|
|
10
|
+
* @param error - Error as Vitest serialized it, or a reason that is not an
|
|
11
|
+
* object.
|
|
12
|
+
* @param type - Event of the error, as Vitest names it.
|
|
13
|
+
* @param id - Number of the error among those the worker recorded.
|
|
14
|
+
* @returns Unhandled error as the out file keeps it.
|
|
15
|
+
*/
|
|
16
|
+
export declare function encodeStray(error: unknown, type: string, id: number): VitestStray;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { getErrorMessage as e } from "../../shared/get-error-message.js";
|
|
2
|
+
import { serialize as t } from "node:v8";
|
|
3
|
+
function n(n, r, i) {
|
|
4
|
+
let a;
|
|
5
|
+
try {
|
|
6
|
+
a = t(n);
|
|
7
|
+
} catch {
|
|
8
|
+
a = t(e(n));
|
|
9
|
+
}
|
|
10
|
+
return {
|
|
11
|
+
error: a.toString("base64"),
|
|
12
|
+
type: r,
|
|
13
|
+
id: i
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
export { n as encodeStray };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Records an unhandled error as Vitest's listener reports it.
|
|
3
|
+
*
|
|
4
|
+
* @param error - Error as Vitest serialized it, or a reason that is not an
|
|
5
|
+
* object.
|
|
6
|
+
* @param type - Event of the error, as Vitest names it.
|
|
7
|
+
*/
|
|
8
|
+
type StrayReceiver = (error: unknown, type: string) => void;
|
|
9
|
+
/**
|
|
10
|
+
* Takes over Vitest's report of a worker's unhandled errors. Vitest's own
|
|
11
|
+
* listener of the process leaves an error to the code when another listener of
|
|
12
|
+
* its event exists, as in a plain run; otherwise it serializes the error and
|
|
13
|
+
* passes it to `onUnhandledError` of the RPC it reads from the worker state at
|
|
14
|
+
* that moment. That RPC is wrapped once per worker state: the call goes to the
|
|
15
|
+
* receiver instead of the main process, synchronously, so the error lands in
|
|
16
|
+
* the try that runs at that moment, and every other call passes through. A
|
|
17
|
+
* later receiver on the same state takes the wrapper over. No listener of the
|
|
18
|
+
* process is added, which would make Vitest's step aside.
|
|
19
|
+
*
|
|
20
|
+
* @param state - Vitest's worker state.
|
|
21
|
+
* @param receive - Records an unhandled error.
|
|
22
|
+
*/
|
|
23
|
+
export declare function interceptStrays(state: {
|
|
24
|
+
rpc: object;
|
|
25
|
+
}, receive: StrayReceiver): void;
|
|
26
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
const e = Symbol.for("mootant.vitest.strays");
|
|
2
|
+
function t(t, n) {
|
|
3
|
+
let r = Reflect.get(t, e);
|
|
4
|
+
if (r === void 0) {
|
|
5
|
+
let i = { receive: n };
|
|
6
|
+
function a(e, t) {
|
|
7
|
+
i.receive(e, t);
|
|
8
|
+
}
|
|
9
|
+
t.rpc = new Proxy(t.rpc, { get: (e, t) => t === "onUnhandledError" ? a : Reflect.get(e, t) }), Reflect.set(t, e, i), r = i;
|
|
10
|
+
}
|
|
11
|
+
r.receive = n;
|
|
12
|
+
}
|
|
13
|
+
export { t as interceptStrays };
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { RunnerTestCase } from 'vitest';
|
|
2
2
|
import { MutantRuntime } from '../../../types/adapter/mutant-runtime.js';
|
|
3
|
-
import {
|
|
3
|
+
import { VitestTryFacts } from '../types/vitest-worker.js';
|
|
4
4
|
/**
|
|
5
5
|
* What the worker runner observed of a try besides the runtime's counters.
|
|
6
6
|
*/
|
|
7
|
-
interface TryObservation extends Pick<
|
|
7
|
+
interface TryObservation extends Pick<VitestTryFacts, 'timedOut' | 'duration' | 'strays' | 'covers' | 'hits'> {
|
|
8
8
|
/**
|
|
9
9
|
* Errors the try added to the test's result: those of its body, its hooks,
|
|
10
10
|
* its `aroundEach` teardown and fixture cleanup, after Vitest's "expected to
|
|
@@ -30,7 +30,8 @@ interface TryObservation extends Pick<TryFacts, 'timedOut' | 'duration' | 'stray
|
|
|
30
30
|
* @param runtime - Switch and counters the switched code updated.
|
|
31
31
|
* @param observed - Errors and state of the try, its duration, hits, coverage,
|
|
32
32
|
* stray errors and mootant's timeout.
|
|
33
|
-
* @returns Raw facts
|
|
33
|
+
* @returns Raw facts, with the unhandled errors as the worker recorded them,
|
|
34
|
+
* which the main process reads for `classifyTry` (`readOutRecords`).
|
|
34
35
|
*/
|
|
35
|
-
export declare function readTryFacts(test: RunnerTestCase, runtime: MutantRuntime, observed: TryObservation):
|
|
36
|
+
export declare function readTryFacts(test: RunnerTestCase, runtime: MutantRuntime, observed: TryObservation): VitestTryFacts;
|
|
36
37
|
export {};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Module evaluator of Vite's module runner, as far as it is used here.
|
|
3
|
+
*/
|
|
4
|
+
interface Evaluator {
|
|
5
|
+
/**
|
|
6
|
+
* Runs the code of a module that Vite transformed, with the context it gets,
|
|
7
|
+
* its `import.meta` among it.
|
|
8
|
+
*/
|
|
9
|
+
runInlinedModule(context: Record<string, unknown>, code: string, module: unknown): Promise<unknown>;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Makes the defines of `import.meta` report their first read in the modules
|
|
13
|
+
* Vitest evaluates from now on. Vitest's script keeps them in `metaDefines` of
|
|
14
|
+
* the worker state, which its module evaluator copies into the `import.meta` of
|
|
15
|
+
* each module before the module runs: they are taken out of it, and the wrapped
|
|
16
|
+
* evaluator puts them on the `import.meta` of each module itself, as Vitest
|
|
17
|
+
* would, watched until the first read of the unit reports one
|
|
18
|
+
* (`watchProperty`), and plain once it did. Nothing changes when the module
|
|
19
|
+
* runner has no evaluator to wrap or a define is not in `metaDefines`. The
|
|
20
|
+
* tracking is installed once per worker state; a later receiver on the same
|
|
21
|
+
* state takes it over.
|
|
22
|
+
*
|
|
23
|
+
* @param state - Vitest's worker state.
|
|
24
|
+
* @param runner - Module runner Vitest gave the test runner (`moduleRunner`).
|
|
25
|
+
* @param input - Defines to track and the receiver of the names read.
|
|
26
|
+
* @param input.keys - Keys of the defines, such as `import.meta.version`.
|
|
27
|
+
* @param input.record - Receives the names read, such as
|
|
28
|
+
* `define=import.meta.version`.
|
|
29
|
+
* @returns Whether the defines are tracked.
|
|
30
|
+
*/
|
|
31
|
+
export declare function trackMetaDefines(state: {
|
|
32
|
+
metaDefines?: Record<string, unknown>;
|
|
33
|
+
}, runner: {
|
|
34
|
+
evaluator?: Partial<Evaluator>;
|
|
35
|
+
} | undefined, input: {
|
|
36
|
+
record(name: string): void;
|
|
37
|
+
keys: readonly string[];
|
|
38
|
+
}): boolean;
|
|
39
|
+
export {};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { VALUE_PREFIXES as e } from "./value-prefixes.js";
|
|
2
|
+
import { watchProperty as t } from "./watch-property.js";
|
|
3
|
+
const n = Symbol.for("mootant.vitest.meta");
|
|
4
|
+
function r(r, i, a) {
|
|
5
|
+
let o = Reflect.get(r, n);
|
|
6
|
+
if (o !== void 0) return o.record = a.record, !0;
|
|
7
|
+
let s = i?.evaluator, c = r.metaDefines ?? {}, l = a.keys.map((e) => e.slice(12));
|
|
8
|
+
if (typeof s?.runInlinedModule != "function" || l.some((e) => !Object.hasOwn(c, e))) return !1;
|
|
9
|
+
let u = s.runInlinedModule, d = { record: a.record }, f = l.map((e) => [e, c[e]]), p = new Set(l);
|
|
10
|
+
for (let e of l) Reflect.deleteProperty(c, e);
|
|
11
|
+
return s.runInlinedModule = (n, r, i) => {
|
|
12
|
+
let a = n.__vite_ssr_import_meta__;
|
|
13
|
+
for (let [n, r] of f) {
|
|
14
|
+
let i = n.split("."), o = i.pop(), s = a;
|
|
15
|
+
for (let e of i) s[e] ||= {}, s = s[e];
|
|
16
|
+
s[o] = r, p.has(n) && t(s, o, () => {
|
|
17
|
+
p.delete(n), d.record(`${e.define}import.meta.${n}`);
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
return u.call(s, n, r, i);
|
|
21
|
+
}, Reflect.set(r, n, d), !0;
|
|
22
|
+
}
|
|
23
|
+
export { r as trackMetaDefines };
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Makes the values of `provide` and `define` report what code reads, under the
|
|
3
|
+
* names of `VALUE_PREFIXES`. The provided context of the worker state, which
|
|
4
|
+
* `inject` reads on every call, and its alias in the state's context are
|
|
5
|
+
* replaced with a proxy that reports a key read, tested or asked for its
|
|
6
|
+
* descriptor, a missing one too, and `provide=*` when code lists them, but
|
|
7
|
+
* never mootant's own options. Each define Vitest set as a plain property, on
|
|
8
|
+
* `globalThis` or, for a key with dots, on the object that holds its last part,
|
|
9
|
+
* is a getter that reports its first read (`wrapDefine`); `in`, `Object.keys`
|
|
10
|
+
* and descriptors call none, as the names count under `defines=`. Defines of
|
|
11
|
+
* `import.meta` are left to `trackMetaDefines`. Vitest evaluates a define given
|
|
12
|
+
* as code before the runner exists, and that code may read and change anything,
|
|
13
|
+
* or hold `process.env` itself, so such a define is reported at once with
|
|
14
|
+
* `provide=*` and `*`. So is a define that is not such a property, without
|
|
15
|
+
* them, and every value when the project has a custom snapshot environment,
|
|
16
|
+
* which Vitest may load before the runner. The tracking is installed once per
|
|
17
|
+
* worker state; a later receiver on the same state takes it over and gets those
|
|
18
|
+
* names too.
|
|
19
|
+
*
|
|
20
|
+
* @param state - Vitest's worker state.
|
|
21
|
+
* @param project - Defines and snapshot environment of the project.
|
|
22
|
+
* @param project.defines - Defines Vitest set as globals (`defines` of the
|
|
23
|
+
* serialized configuration).
|
|
24
|
+
* @param project.scripted - Defines Vitest ran as a script
|
|
25
|
+
* (`listScriptDefines`), by key, with whether each value is code.
|
|
26
|
+
* @param project.snapshotEnvironment - Custom snapshot environment, if any.
|
|
27
|
+
* @param record - Receives the names read.
|
|
28
|
+
*/
|
|
29
|
+
export declare function trackValues(state: {
|
|
30
|
+
ctx: {
|
|
31
|
+
providedContext: object;
|
|
32
|
+
};
|
|
33
|
+
providedContext: object;
|
|
34
|
+
}, project: {
|
|
35
|
+
scripted: Readonly<Record<string, boolean>>;
|
|
36
|
+
defines: Record<string, unknown>;
|
|
37
|
+
snapshotEnvironment?: string;
|
|
38
|
+
}, record: (name: string) => void): void;
|