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
package/bin/mootant.js
CHANGED
|
@@ -26,18 +26,18 @@ interface DryFileReport {
|
|
|
26
26
|
* ids of tests hold the project, or the core keys the tests of two projects as
|
|
27
27
|
* one. Per-test coverage is wrong in a file with concurrent tests, as their
|
|
28
28
|
* bodies interleave, so the file holds what ran while it loaded and every try
|
|
29
|
-
* what ran after that. Covers stay on a file that failed to load, as
|
|
30
|
-
*
|
|
31
|
-
* file, as the `try` it lost
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
* (`collectJestDependencies`), and so do the
|
|
39
|
-
* files it read and changed itself, whose
|
|
40
|
-
* their times say nothing of edits.
|
|
29
|
+
* what ran after that. Covers stay on a file that failed to load, as they are
|
|
30
|
+
* what the core can blame when it cannot tell what the file depends on, instead
|
|
31
|
+
* of every switched file. A tracker error fails the file, as the `try` it lost
|
|
32
|
+
* would leave a test out with no word. A failed `beforeAll` fails the tests
|
|
33
|
+
* under it, as in plain Jest, which forgives it when they pass on retry or are
|
|
34
|
+
* all `test.todo`, so the file says nothing of it. A snapshot no test checked,
|
|
35
|
+
* such as one of a deleted test, or one that failed in a test that still
|
|
36
|
+
* passed, fails a plain run of Jest with every test passing, so then it fails
|
|
37
|
+
* the file; next to a failed test, that test tells it. What the file depended
|
|
38
|
+
* on comes from the `finish` record (`collectJestDependencies`), and so do the
|
|
39
|
+
* variables the code read and the files it read and changed itself, whose
|
|
40
|
+
* contents the cache then compares, as their times say nothing of edits.
|
|
41
41
|
*
|
|
42
42
|
* @param outcome - What the unit left behind.
|
|
43
43
|
* @param input - Test file, project and root.
|
|
@@ -4,18 +4,21 @@ import { JestTimedRecord } from './types/jest-timed-record.js';
|
|
|
4
4
|
* the unit read, the CommonJS modules its worker loaded in its own realm, such
|
|
5
5
|
* as a transformer and what it imports, which a warm worker no longer reads,
|
|
6
6
|
* the `package.json` files that decide the format and the `#` imports of the
|
|
7
|
-
* files in the directory of each of them (`listPackageFiles`),
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
* which
|
|
7
|
+
* files in the directory of each of them (`listPackageFiles`), for a file of an
|
|
8
|
+
* installed package the `package.json` that decides what an import of the
|
|
9
|
+
* package resolves to (`getPackageManifest`), and the snapshot file Jest
|
|
10
|
+
* resolves for the test file by default, `__snapshots__/<name>.snap` beside it,
|
|
11
|
+
* whether it exists or not. The file a custom snapshot resolver gives is among
|
|
12
|
+
* the reads, as Jest looks for it when the unit starts. The worker leaves out
|
|
13
|
+
* of the reads what lies under `node_modules` but the modules Jest's runtime
|
|
14
|
+
* loaded for the vm, mootant's own files and, outside the directories of the
|
|
15
|
+
* session, the root itself and what `createInputFilter` leaves out, what Jest's
|
|
16
|
+
* resolver read, as a real load is read anyway, and what only the transformers,
|
|
17
|
+
* the test environment and the test runner in their own calls, or a project's
|
|
18
|
+
* own resolver read, which every verdict depends on: through
|
|
19
|
+
* `getJestCacheInputs` when a dry run read it, a missing file there only when
|
|
20
|
+
* named as a configuration file (`isTransformInput`), else through
|
|
21
|
+
* `state.lateTransforms`, which `runIsolated` adds.
|
|
19
22
|
*
|
|
20
23
|
* @param records - Records of the unit.
|
|
21
24
|
* @param file - Absolute path of the test file.
|
|
@@ -1,15 +1,21 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { listPackageFiles as t } from "
|
|
3
|
-
import n from "
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
...
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
1
|
+
import { getPackageManifest as e } from "../../core/files/get-package-manifest.js";
|
|
2
|
+
import { listPackageFiles as t } from "../../core/files/list-package-files.js";
|
|
3
|
+
import { compareCodeUnits as n } from "../../core/compare-code-units.js";
|
|
4
|
+
import r from "node:path";
|
|
5
|
+
function i(i, a) {
|
|
6
|
+
let o = i.find((e) => e.kind === "finish");
|
|
7
|
+
if (!o?.tracked) return null;
|
|
8
|
+
let s = [
|
|
9
|
+
a,
|
|
10
|
+
...o.reads,
|
|
11
|
+
...o.loaded
|
|
12
|
+
], c = /* @__PURE__ */ new Set([...s, r.join(r.dirname(a), "__snapshots__", `${r.basename(a)}.snap`)]);
|
|
13
|
+
for (let t of s) {
|
|
14
|
+
let n = e(t);
|
|
15
|
+
n !== null && c.add(n);
|
|
16
|
+
}
|
|
17
|
+
let l = new Set(s.map((e) => r.dirname(e))), u = /* @__PURE__ */ new Map();
|
|
18
|
+
for (let e of l) for (let n of t(e, u)) c.add(n);
|
|
19
|
+
return [...c].toSorted(n);
|
|
14
20
|
}
|
|
15
|
-
export {
|
|
21
|
+
export { i as collectJestDependencies };
|
|
@@ -16,19 +16,20 @@ import { JestReady } from './types/jest-ready.js';
|
|
|
16
16
|
* worker reads only once, so that a test file whose unit ran after it would
|
|
17
17
|
* miss it, with the missing files among it only when they are named as
|
|
18
18
|
* configuration files (`isTransformInput`); and the modules the host loaded, as
|
|
19
|
-
* the configuration file imports them and global setup ran, but
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
* `NODE_ENV`, `LANG`, `LC_*`)
|
|
29
|
-
*
|
|
30
|
-
* the
|
|
31
|
-
*
|
|
19
|
+
* the configuration file imports them and global setup ran, but mootant's own
|
|
20
|
+
* files and those under `node_modules`, such as Jest's own, which an install
|
|
21
|
+
* that changes them shows in the files that tell what was installed. Settings,
|
|
22
|
+
* with the root in their strings replaced so that a moved project keeps them:
|
|
23
|
+
* per project its configuration without what changes no verdict, and the
|
|
24
|
+
* console its tests print to; what of the global configuration picks the tests
|
|
25
|
+
* of a file and how they run; the versions of Jest, of the `@jest/transform`
|
|
26
|
+
* that strips types and of Node, whose own stripping and targets change the
|
|
27
|
+
* code; whether every unit gets a new worker; and the variables that change
|
|
28
|
+
* verdicts whether tests read them or not (`TZ`, `NODE_ENV`, `LANG`, `LC_*`)
|
|
29
|
+
* with `BABEL_ENV`, which transformers read outside the tests, `NODE_OPTIONS`,
|
|
30
|
+
* the Node flags and the variables the command and the options set.
|
|
31
|
+
* Environment: the hashes of the variables of the host after global setup,
|
|
32
|
+
* which every worker of every project starts from.
|
|
32
33
|
*
|
|
33
34
|
* @param input - What the session started with and what its dry runs read.
|
|
34
35
|
* @param input.transforms - Files the transformers, the test environments, the
|
|
@@ -4,7 +4,9 @@ export type { JestAdapterOptions } from './types/jest-adapter-options.js';
|
|
|
4
4
|
/**
|
|
5
5
|
* Creates the adapter that runs mutants with the project's Jest 29.7 or later,
|
|
6
6
|
* such as `jestAdapter({ command: 'jest --config jest.unit.js' })` in
|
|
7
|
-
* `run.runner`.
|
|
7
|
+
* `run.runner`. It has no parallel units: the units of a test file run as one
|
|
8
|
+
* chain on a warm worker, and the check at the end of the chain takes back the
|
|
9
|
+
* facts of its warm units when the file fails only on warm state.
|
|
8
10
|
*
|
|
9
11
|
* @param options - Test command, when not the one of the test scripts, extra
|
|
10
12
|
* environment variables, and whether every unit gets a new worker.
|
|
@@ -16,10 +16,10 @@ async function d(e, r) {
|
|
|
16
16
|
let d = y(e, r.instrumented);
|
|
17
17
|
l(u.join(a, "out"), { recursive: !0 });
|
|
18
18
|
let p = new Set(r.related);
|
|
19
|
-
function
|
|
19
|
+
function h(e) {
|
|
20
20
|
return e.some((e) => p.has(e));
|
|
21
21
|
}
|
|
22
|
-
let v =
|
|
22
|
+
let v = g(e, r, h), b = await f(e, {
|
|
23
23
|
timeouts: r.timeouts,
|
|
24
24
|
targets: v,
|
|
25
25
|
plan: d
|
|
@@ -41,7 +41,7 @@ async function d(e, r) {
|
|
|
41
41
|
});
|
|
42
42
|
for (let [e, t] of b.entries()) {
|
|
43
43
|
let { project: i, file: a } = v[e], l = t.records.find((e) => e.kind === "finish");
|
|
44
|
-
if (_(t.records, S, o.outside), l?.outcome === "result" && l.execError === null && t.records.every((e) => e.kind !== "load") && C.push(n(a, c)), w || r.files !== null || !t.done ||
|
|
44
|
+
if (_(t.records, S, o.outside), l?.outcome === "result" && l.execError === null && t.records.every((e) => e.kind !== "load") && C.push(n(a, c)), w || r.files !== null || !t.done || h(l.reads)) {
|
|
45
45
|
let e = s(t, {
|
|
46
46
|
project: i.name,
|
|
47
47
|
root: c,
|
|
@@ -92,9 +92,9 @@ async function f(e, t) {
|
|
|
92
92
|
async function p(e, t) {
|
|
93
93
|
let { directory: n, state: r, heap: i, pool: o } = e, { timeouts: s, target: l, clean: d, plan: f, last: p } = t;
|
|
94
94
|
r.units += 1;
|
|
95
|
-
let m = o.take(),
|
|
95
|
+
let m = o.take(), g;
|
|
96
96
|
try {
|
|
97
|
-
|
|
97
|
+
g = await c(o, m, {
|
|
98
98
|
unit: {
|
|
99
99
|
out: u.join(n, "out", `${r.units}.jsonl`),
|
|
100
100
|
project: l.project.config.id,
|
|
@@ -110,7 +110,7 @@ async function p(e, t) {
|
|
|
110
110
|
} finally {
|
|
111
111
|
o.release(m);
|
|
112
112
|
}
|
|
113
|
-
return
|
|
113
|
+
return g.outOfMemory !== null && i.raise(g.outOfMemory), (p || !v(g, d)) && h(e, l, g), g;
|
|
114
114
|
}
|
|
115
115
|
function m(e, r, i) {
|
|
116
116
|
if (e.size > 0) throw Error([...e].map(([e, t]) => [n(e, i), t]).toSorted(([e], [n]) => t(e, n)).map(([e, t]) => `The test runner's transformer rejects the text with mutants of ${e}: ${t}; exclude the file.`).join("\n"));
|
|
@@ -118,6 +118,20 @@ function m(e, r, i) {
|
|
|
118
118
|
if (a !== void 0) throw Error(`Jest ran ${a} with no test framework mootant can follow; jest-circus is required.`);
|
|
119
119
|
}
|
|
120
120
|
function h(t, n, r) {
|
|
121
|
+
let { context: i, state: a } = t, { project: o, file: s } = n;
|
|
122
|
+
i.onUnitEnd?.();
|
|
123
|
+
let c = r.records.find((e) => e.kind === "finish"), l = e({
|
|
124
|
+
project: o.name,
|
|
125
|
+
file: s
|
|
126
|
+
});
|
|
127
|
+
if (c === void 0) a.reads.delete(l);
|
|
128
|
+
else {
|
|
129
|
+
a.reads.set(l, c.reads.filter((e) => !/[/\\]node_modules[/\\]/u.test(e)));
|
|
130
|
+
for (let e of c.transforms) a.transforms.add(e);
|
|
131
|
+
for (let e of [c.consoleOutput, c.failureMessage]) e !== null && i.onOutput?.(e, s);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
function g(t, n, r) {
|
|
121
135
|
let { projects: i, tests: a, state: o } = t;
|
|
122
136
|
return n.files === null ? a.map((e) => ({
|
|
123
137
|
project: i.find(({ config: t }) => t.id === e.project),
|
|
@@ -133,20 +147,6 @@ function h(t, n, r) {
|
|
|
133
147
|
file: t
|
|
134
148
|
}));
|
|
135
149
|
}
|
|
136
|
-
function g(t, n, r) {
|
|
137
|
-
let { context: i, state: a } = t, { project: o, file: s } = n;
|
|
138
|
-
i.onUnitEnd?.();
|
|
139
|
-
let c = r.records.find((e) => e.kind === "finish"), l = e({
|
|
140
|
-
project: o.name,
|
|
141
|
-
file: s
|
|
142
|
-
});
|
|
143
|
-
if (c === void 0) a.reads.delete(l);
|
|
144
|
-
else {
|
|
145
|
-
a.reads.set(l, c.reads);
|
|
146
|
-
for (let e of c.transforms) a.transforms.add(e);
|
|
147
|
-
for (let e of [c.consoleOutput, c.failureMessage]) e !== null && i.onOutput?.(e, s);
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
150
|
function _(e, t, n) {
|
|
151
151
|
for (let r of e) if (r.kind === "served") t.served.add(r.file);
|
|
152
152
|
else if (r.kind === "mismatched") t.mismatched.add(r.file);
|
|
@@ -4,7 +4,7 @@ import { HostTest } from './types/host-test.js';
|
|
|
4
4
|
* The host's `--runner`. Jest loads it once it has read its configuration,
|
|
5
5
|
* built the haste map and run global setup.
|
|
6
6
|
*/
|
|
7
|
-
export default class
|
|
7
|
+
export default class Runner {
|
|
8
8
|
/**
|
|
9
9
|
* Parks Jest until mootant asks to close or goes away.
|
|
10
10
|
*/
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var e = "// adapters/jest/runner.ts\n/**\n* The host's `--runner`. Jest loads it once it has read its configuration,\n* built the haste map and run global setup.\n*/\nvar
|
|
1
|
+
var e = "// adapters/jest/runner.ts\n/**\n* The host's `--runner`. Jest loads it once it has read its configuration,\n* built the haste map and run global setup.\n*/\nvar Runner = class {\n /**\n * Parks Jest until mootant asks to close or goes away.\n */\n runTests;\n /**\n * Tells Jest this runner has no workers of its own; Jest only passes this on\n * as `serial`, which this runner ignores.\n */\n isSerial = true;\n /**\n * Keeps the global configuration for `ready`.\n *\n * @param globalConfig - Global configuration Jest resolved.\n */\n constructor(globalConfig) {\n this.runTests = (tests) => parkHost(tests, globalConfig);\n }\n};\n/**\n* Sends what workers need to know and waits; once this returns, Jest runs\n* global teardown. Listeners are installed here only, because a listener keeps\n* the channel, and with it a host that never gets here, alive. A channel that\n* closed before Jest got here ends the wait at once, so teardown runs then\n* too.\n*\n* @param tests - Every test file Jest would run, of every project.\n* @param globalConfig - Global configuration Jest resolved.\n* @returns A promise that resolves on `close` or when the channel closes.\n*/\nfunction parkHost(tests, globalConfig) {\n return new Promise((resolve) => {\n if (!process.connected) {\n resolve();\n return;\n }\n process.on(\"disconnect\", resolve);\n process.on(\"message\", (message) => {\n if (message.type === \"close\") resolve();\n });\n let ready = {\n moduleMaps: Object.fromEntries(tests.map((test) => [test.context.config.id, test.context.moduleMap.toJSON()])),\n configs: Object.fromEntries(tests.map((test) => [test.context.config.id, test.context.config])),\n tests: tests.map((test) => ({\n project: test.context.config.id,\n path: test.path\n })),\n env: process.env,\n loaded: Object.keys(require.cache),\n umask: process.umask(),\n cwd: process.cwd(),\n type: \"ready\",\n globalConfig\n };\n process.send(ready);\n });\n}\nmodule.exports = Runner;\n";
|
|
2
2
|
export { e as default };
|
|
@@ -28,13 +28,17 @@ import { JestAdapterOptions } from './types/jest-adapter-options.js';
|
|
|
28
28
|
* joined with what they read in earlier sessions (`keepTransformReads`,
|
|
29
29
|
* `getJestCacheInputs`). Once the host is ready the session works with the
|
|
30
30
|
* configuration it ran global setup with (`readHostConfig`), the workers and
|
|
31
|
-
* the cache key alike.
|
|
31
|
+
* the cache key alike. Once the run is interrupted (`AdapterContext.signal`),
|
|
32
|
+
* no Jest process starts and the workers stop; the host stops on the signal
|
|
33
|
+
* that interrupted the run, as its group is tracked, or when the session
|
|
34
|
+
* closes.
|
|
32
35
|
*
|
|
33
36
|
* @param context - Work directory, concurrency, root and output.
|
|
34
37
|
* @param options - Options of the adapter.
|
|
35
38
|
* @returns Session that knows the version, workers, test files and cache
|
|
36
39
|
* inputs, and runs dry runs and isolated units.
|
|
37
40
|
* @throws {Error} When Jest is missing, older than 29.7 or fails to start, or
|
|
38
|
-
* when its settings or the command are not supported
|
|
41
|
+
* when its settings or the command are not supported; once the context's
|
|
42
|
+
* signal aborted before the host started, its reason.
|
|
39
43
|
*/
|
|
40
44
|
export declare function startJestSession(context: AdapterContext, options: JestAdapterOptions): Promise<AdapterSession>;
|
|
@@ -29,6 +29,7 @@ async function w(w, T) {
|
|
|
29
29
|
...T.env
|
|
30
30
|
}).filter(([e]) => !e.startsWith("MOOTANT_")));
|
|
31
31
|
async function M(e) {
|
|
32
|
+
w.signal?.throwIfAborted();
|
|
32
33
|
let r = n(k.args, e), i = {
|
|
33
34
|
onOutput(e) {
|
|
34
35
|
w.onOutput?.(e, null);
|
|
@@ -56,7 +57,9 @@ async function w(w, T) {
|
|
|
56
57
|
let L = await C(D), R = d({
|
|
57
58
|
root: L,
|
|
58
59
|
config: F
|
|
59
|
-
}), z = await u(w.workDirectory)
|
|
60
|
+
}), z = await u(w.workDirectory);
|
|
61
|
+
w.signal?.throwIfAborted();
|
|
62
|
+
let B = await g({
|
|
60
63
|
...I,
|
|
61
64
|
projects: R.projects,
|
|
62
65
|
files: z
|
|
@@ -99,7 +102,11 @@ async function w(w, T) {
|
|
|
99
102
|
slot: e
|
|
100
103
|
}),
|
|
101
104
|
size: V.maxWorkers
|
|
102
|
-
})
|
|
105
|
+
});
|
|
106
|
+
w.signal?.addEventListener("abort", () => {
|
|
107
|
+
J.close();
|
|
108
|
+
}, { once: !0 });
|
|
109
|
+
let Y = {
|
|
103
110
|
state: {
|
|
104
111
|
lateTransforms: /* @__PURE__ */ new Set(),
|
|
105
112
|
transforms: /* @__PURE__ */ new Set(),
|
|
@@ -19,7 +19,8 @@ export interface JestHandle {
|
|
|
19
19
|
timeouts: DryRunRequest['timeouts'] | null
|
|
20
20
|
|
|
21
21
|
/**
|
|
22
|
-
* Files each test file read in its last dry run, by `getTestFileKey
|
|
22
|
+
* Files each test file read in its last dry run, by `getTestFileKey`, but
|
|
23
|
+
* those under `node_modules`, which no file mutants come from is among; a
|
|
23
24
|
* test file with no `finish` has no entry, so it runs again.
|
|
24
25
|
*/
|
|
25
26
|
reads: Map<string, readonly string[]>
|
|
@@ -105,10 +105,11 @@ export type JestRecord =
|
|
|
105
105
|
|
|
106
106
|
/**
|
|
107
107
|
* Files and directories the code read that count, sorted: under the
|
|
108
|
-
* project root or a project's directories,
|
|
109
|
-
*
|
|
110
|
-
*
|
|
111
|
-
*
|
|
108
|
+
* project root or a project's directories, and elsewhere as
|
|
109
|
+
* `createInputFilter` tells, never in mootant's files, nor as the root
|
|
110
|
+
* itself outside those directories, and under `node_modules` only the
|
|
111
|
+
* modules Jest's runtime loaded for the vm. Neither what the resolver
|
|
112
|
+
* read nor what only a transformer read is among them.
|
|
112
113
|
*/
|
|
113
114
|
reads: string[]
|
|
114
115
|
|
|
@@ -14,21 +14,29 @@ export interface UnitWorker {
|
|
|
14
14
|
*/
|
|
15
15
|
reads: {
|
|
16
16
|
/**
|
|
17
|
-
*
|
|
18
|
-
* but in a temporary directory.
|
|
17
|
+
* Absolute directories whose files count, even those that hold the root.
|
|
19
18
|
*/
|
|
20
|
-
|
|
19
|
+
directories: readonly string[]
|
|
21
20
|
|
|
22
21
|
/**
|
|
23
|
-
*
|
|
22
|
+
* Tells whether a path outside the directories counts
|
|
23
|
+
* (`createInputFilter`).
|
|
24
24
|
*/
|
|
25
|
-
|
|
25
|
+
inputs(file: string): boolean
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Modules of the own realm of the worker that a unit wrote itself, such as
|
|
29
|
+
* a helper a test environment wrote in a directory of `mkdtemp`: they stay
|
|
30
|
+
* out of the loaded modules of every later unit too, as the module cache of
|
|
31
|
+
* the worker keeps them.
|
|
32
|
+
*/
|
|
33
|
+
own: Set<string>
|
|
26
34
|
|
|
27
35
|
/**
|
|
28
|
-
*
|
|
29
|
-
*
|
|
36
|
+
* Real path of the project root, which itself counts only under one of the
|
|
37
|
+
* directories.
|
|
30
38
|
*/
|
|
31
|
-
|
|
39
|
+
root: string
|
|
32
40
|
}
|
|
33
41
|
|
|
34
42
|
/**
|
|
@@ -34,6 +34,13 @@ export interface WorkerChannel {
|
|
|
34
34
|
*/
|
|
35
35
|
unit: JestUnit | null
|
|
36
36
|
|
|
37
|
+
/**
|
|
38
|
+
* Files Jest's runtime of the current unit read as the sources of the modules
|
|
39
|
+
* of the vm (`listRuntimeFiles`): what its file cache held before each reset
|
|
40
|
+
* of its modules (`keepResetLoads`) and once the test framework returned.
|
|
41
|
+
*/
|
|
42
|
+
loads: Set<string>
|
|
43
|
+
|
|
37
44
|
/**
|
|
38
45
|
* What the vm's setup registered for the current unit, or null while it has
|
|
39
46
|
* not run.
|
|
@@ -12,18 +12,17 @@ export interface WorkerSession {
|
|
|
12
12
|
*/
|
|
13
13
|
reads: {
|
|
14
14
|
/**
|
|
15
|
-
* Absolute directories whose files count
|
|
16
|
-
* root, and the `rootDir` and `roots` of every
|
|
15
|
+
* Absolute directories whose files count, even those that hold the root:
|
|
16
|
+
* the real path of the project root, and the `rootDir` and `roots` of every
|
|
17
|
+
* project.
|
|
17
18
|
*/
|
|
18
19
|
directories: string[]
|
|
19
20
|
|
|
20
21
|
/**
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
* project, and `snap`, since a custom snapshot resolver may put a snapshot
|
|
24
|
-
* file anywhere.
|
|
22
|
+
* Real path of the project root, which itself counts only under one of the
|
|
23
|
+
* directories.
|
|
25
24
|
*/
|
|
26
|
-
|
|
25
|
+
root: string
|
|
27
26
|
}
|
|
28
27
|
|
|
29
28
|
/**
|
|
@@ -14,9 +14,11 @@ import { WorkerProcess } from '../types/worker-process.js';
|
|
|
14
14
|
* what it gets in plain Jest. Types are stripped only where the project's Jest
|
|
15
15
|
* strips them, which needs Node's function. One count of the calls into the
|
|
16
16
|
* resolvers and transformers of the projects serves every unit, which tells
|
|
17
|
-
* what they read apart from what tests read.
|
|
18
|
-
*
|
|
19
|
-
*
|
|
17
|
+
* what they read apart from what tests read. Every reset of the modules of a
|
|
18
|
+
* runtime first gives the unit what the runtime loaded (`keepResetLoads`).
|
|
19
|
+
* Which reads count outside the directories of the session is decided by the
|
|
20
|
+
* work directory, the one that holds the directory of `session.json`, and the
|
|
21
|
+
* project root (`createInputFilter`), taken here, before any unit runs.
|
|
20
22
|
*
|
|
21
23
|
* @param input - What the worker runs with.
|
|
22
24
|
* @param input.process - The worker's process, with `MOOTANT_SESSION`, the
|
|
@@ -65,7 +65,10 @@ type TestRunnerParameters = [
|
|
|
65
65
|
* runs out of the store of the test environment's calls
|
|
66
66
|
* (`WorkerCalls.environment`), which the last setup file may have entered for
|
|
67
67
|
* `environment.setup()` and the load of the real test framework, and what
|
|
68
|
-
* follows it, `environment.teardown()` among it, is back in it.
|
|
68
|
+
* follows it, `environment.teardown()` among it, is back in it. Once the
|
|
69
|
+
* framework returned, before Jest tears its runtime down, the channel takes the
|
|
70
|
+
* files that runtime loaded for the vm since its last reset of the modules
|
|
71
|
+
* (`listRuntimeFiles`), as it took those before each reset (`keepResetLoads`).
|
|
69
72
|
*
|
|
70
73
|
* @param input - What the wrapper works with.
|
|
71
74
|
* @returns The function Jest calls as `(globalConfig, config, environment,
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { WorkerChannel } from '../types/worker-channel.js';
|
|
2
|
+
/**
|
|
3
|
+
* Wraps the `resetModules` of Jest's runtime class so that the files a runtime
|
|
4
|
+
* holds in its file cache (`listRuntimeFiles`) join those of the current unit
|
|
5
|
+
* (`WorkerChannel.loads`) before each reset empties the cache: whoever resets,
|
|
6
|
+
* a setup file, a test through `jest.resetModules()` or the test framework
|
|
7
|
+
* under the `resetModules` setting, calls that method of the runtime, which a
|
|
8
|
+
* project's own runtime gets from the class too.
|
|
9
|
+
*
|
|
10
|
+
* @param Runtime - Jest's runtime class, as `jest-runtime` exports it.
|
|
11
|
+
* @param channel - Channel of the worker.
|
|
12
|
+
*/
|
|
13
|
+
export declare function keepResetLoads(Runtime: unknown, channel: WorkerChannel): void;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Lists the files Jest's runtime of a unit read as the sources of the modules
|
|
3
|
+
* of its vm, the setup files and the parts of the test framework that run in
|
|
4
|
+
* the vm among them: the keys of the file cache the runtime fills for one test
|
|
5
|
+
* file and empties at its teardown, `fileCache` on Jest 30, `_cacheFS` and
|
|
6
|
+
* `_cacheFSBuffer` on Jest 29.7. A runtime that keeps none of them, such as a
|
|
7
|
+
* project's own, gives none.
|
|
8
|
+
*
|
|
9
|
+
* @param runtime - Jest's runtime of the unit, as Jest hands it to the test
|
|
10
|
+
* framework.
|
|
11
|
+
* @returns Absolute paths.
|
|
12
|
+
*/
|
|
13
|
+
export declare function listRuntimeFiles(runtime: unknown): Set<string>;
|
|
@@ -23,25 +23,32 @@ import { JestUnit } from '../types/jest-unit.js';
|
|
|
23
23
|
* messages, as tests may read them. What the console kept is emptied once
|
|
24
24
|
* `finish` is written, since with `--experimental-vm-modules` the vm of every
|
|
25
25
|
* unit, its console with it, stays in the worker. A read counts under the
|
|
26
|
-
* directories of the session,
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
* the
|
|
37
|
-
*
|
|
26
|
+
* directories of the session, and elsewhere as `createInputFilter` tells, but
|
|
27
|
+
* never in mootant's files, as a `node:` name that a stack frame gave and the
|
|
28
|
+
* tracker made a path of, or as the project root itself outside the directories
|
|
29
|
+
* of the session, which Babel and Browserslist look through in every worker,
|
|
30
|
+
* while its names change with whatever appears beside the project's own files.
|
|
31
|
+
* Under `node_modules` only the modules Jest's runtime of the unit loaded for
|
|
32
|
+
* the vm count (`WorkerChannel.loads`), its setup files and test framework
|
|
33
|
+
* among them: what else is read there is the test runner's own, as Jest, a test
|
|
34
|
+
* environment or a transformer and what they import load once in a warm worker
|
|
35
|
+
* and are read again for stack traces, while an install that changes them shows
|
|
36
|
+
* in the files that tell what was installed. What Jest's resolver reads does
|
|
37
|
+
* not count, as it keeps what it found across units and a real load is read
|
|
38
|
+
* anyway, but what a project's own resolver reads, a file it only looks for
|
|
39
|
+
* too, decides what it gives, Jest's default one aside when it hands that a
|
|
40
|
+
* request (`WorkerCalls.defaultResolver`); that and what a transformer reads go
|
|
41
|
+
* apart, as the session's, since a warm worker reads them only once, and stay
|
|
42
|
+
* among the reads too when code outside the transformers read them, as a test
|
|
43
|
+
* file loads a source the language service of ts-jest read first. The CommonJS
|
|
38
44
|
* modules the own realm of the worker loaded so far count as reads do, since a
|
|
39
45
|
* warm worker does not read a transformer, a test environment or a resolver
|
|
40
|
-
* again, nor what they import
|
|
41
|
-
*
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
*
|
|
46
|
+
* again, nor what they import, but not one that this or an earlier unit of the
|
|
47
|
+
* worker wrote itself (`UnitWorker.reads.own`); ES modules are not in
|
|
48
|
+
* `require.cache`, so one of those counts only in the unit that loaded it. A
|
|
49
|
+
* transform still running when the run ended, of an import the unit never
|
|
50
|
+
* awaited, ends the worker: what it reads from then on reaches no unit, and a
|
|
51
|
+
* later unit would get the module from the worker's memory.
|
|
45
52
|
*
|
|
46
53
|
* @param unit - Test file, project, mutant, switch plan and out file.
|
|
47
54
|
* @param worker - What the boot of the worker made.
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var e = "// core/runtime/create-hit-limit-error.ts\n/**\n* Error that stops a try whose code evaluated more mutant sites than allowed.\n*/\nvar MootantHitLimitError = class extends Error {\n /**\n * Name that tells the error apart, even across realms.\n */\n name = \"MootantHitLimitError\";\n};\n/**\n* Creates the error that stops a try whose code evaluated more mutant sites\n* than its hit limit allows, such as a loop that a mutant made endless.\n*\n* @param id - Id of the mutant whose site went over the limit.\n* @param limit - Site evaluations the try was allowed.\n* @returns Error named `MootantHitLimitError`.\n*/\nfunction createHitLimitError(id, limit) {\n return new MootantHitLimitError(`mootant stopped the test after ${limit} evaluations of mutant sites, at mutant ${id}; the code is likely stuck in a loop.`);\n}\n// core/runtime/runtime-symbol-key.ts\n/**\n* Key of the registered symbol under which `Math` holds the mutant runtime:\n* `Math[Symbol.for('mootant')]`. Vue templates reach the runtime there, since\n* the Vue compiler reads every other global name, `globalThis` included, as a\n* property of the component, but leaves `Math` and `Symbol` alone.\n*/\nvar RUNTIME_SYMBOL_KEY = \"mootant\";\n// core/runtime/runtime-global.ts\n/**\n* Name of the global through which switched code reaches the mutant runtime:\n* `globalThis.__mootant`.\n*/\nvar RUNTIME_GLOBAL = \"__mootant\";\n// core/runtime/install-mutant-runtime.ts\n/**\n* Installs the mutant runtime as `globalThis.__mootant`, where switched code\n* calls `hit` at every mutant site, and as `Math[Symbol.for('mootant')]`, where\n* switched Vue templates call it. The property of `Math` is not enumerable, and\n* `Object.getOwnPropertyNames(Math)` does not list a symbol key, so code that\n* walks `Math` does not see it. A runtime already installed in the process is\n* returned as is, since switched code may already hold it. A new runtime starts\n* with the original code active, no coverage and no hit limit.\n*\n* @returns The runtime of the process.\n*/\nfunction installMutantRuntime() {\n let runtime = Reflect.get(globalThis, \"__mootant\") ?? createRuntime();\n Reflect.set(globalThis, RUNTIME_GLOBAL, runtime);\n Object.defineProperty(Math, Symbol.for(RUNTIME_SYMBOL_KEY), {\n configurable: true,\n enumerable: false,\n value: runtime,\n writable: true\n });\n return runtime;\n}\n/**\n* Creates a runtime with the original code active, no coverage and no hit\n* limit.\n*\n* @returns The new runtime.\n*/\nfunction createRuntime() {\n let runtime = {\n hit(id) {\n runtime.hits += 1;\n if (runtime.hits > runtime.hitLimit) throw createHitLimitError(id, runtime.hitLimit);\n if (runtime.coverage !== null) runtime.coverage.add(id);\n if (runtime.active === id) {\n runtime.reached = true;\n return true;\n }\n return false;\n },\n hitLimit: Infinity,\n coverage: null,\n reached: false,\n active: null,\n hits: 0\n };\n return runtime;\n}\n// adapters/shared/environment-slot.ts\n/**\n* Global slot of the tracking state of the process; a tracking proxy answers\n* that it has this key, which tells it from a plain object.\n*/\nvar ENVIRONMENT_SLOT = Symbol.for(\"mootant.environment\");\n// adapters/shared/create-environment-proxy.ts\n/**\n* Wraps an object of environment variables in a proxy that reports to the\n* receiver of the state the names read and `*` when they are listed. The fields\n* of the state are read at every trap, since their owner replaces them later.\n*\n* @param target - Object to wrap.\n* @param state - Tracking state; `listing` is written here too.\n* @returns The proxy; it answers that it has `ENVIRONMENT_SLOT`, so a caller\n* can tell it from a plain object.\n*/\nfunction createEnvironmentProxy(target, state) {\n let schedule = queueMicrotask;\n /**\n * Reports a variable read by its name.\n *\n * @param name - Property key read.\n */\n function report(name) {\n if (typeof name === \"string\" && !state.listing && !state.ignored.has(name)) state.record?.(name);\n }\n return new Proxy(target, {\n ownKeys: (object) => {\n state.record?.(\"*\");\n if (!state.listing) {\n state.listing = true;\n schedule(() => {\n state.listing = false;\n });\n }\n return Reflect.ownKeys(object);\n },\n getOwnPropertyDescriptor: (object, name) => {\n report(name);\n return Reflect.getOwnPropertyDescriptor(object, name);\n },\n has: (object, name) => {\n report(name);\n return name === ENVIRONMENT_SLOT || Reflect.has(object, name);\n },\n get: (object, name) => {\n report(name);\n return Reflect.get(object, name);\n },\n set: (object, name, value) => Reflect.set(object, name, value)\n });\n}\n// adapters/jest/worker/install-vm-side.ts\n/**\n* Timer functions of a vm, each with the function that clears its handles.\n*/\nvar TIMERS = [\n [\"setTimeout\", \"clearTimeout\"],\n [\"setInterval\", \"clearInterval\"],\n [\"setImmediate\", \"clearImmediate\"]\n];\n/**\n* Sets up a test's vm before any project code, and registers on the channel\n* what the worker reads and stops once the unit ended; it registers last, so a\n* worker that sees no side knows the setup never ran. The file does not change\n* how a timer behaves, and fake timers pass around the wrappers. Nothing is\n* ignored in the environment: Node's loader reads the real `process.env`, not\n* this one.\n*\n* @param input - What the setup works with.\n*/\nfunction installVmSide(input) {\n let { channel, install, target } = input;\n let { token } = channel;\n let unit = channel.unit;\n Reflect.deleteProperty(target, RUNTIME_GLOBAL);\n let runtime = install();\n Object.defineProperty(target, RUNTIME_GLOBAL, {\n configurable: true,\n enumerable: false,\n value: runtime,\n writable: true\n });\n Reflect.set(runtime, Symbol.for(\"$$jest-protect-from-deletion\"), true);\n let { hit } = runtime;\n let reached = false;\n let closed = false;\n runtime.hit = (id) => {\n if (closed) return false;\n let active = hit(id);\n if (active && !reached) {\n reached = true;\n channel.write(token, {\n hits: runtime.hits,\n kind: \"reached\"\n });\n }\n return active;\n };\n let stops = [];\n for (let names of TIMERS) wrapTimer(target, names, stops);\n let seen = /* @__PURE__ */ new Set();\n target.process.env = createEnvironmentProxy(target.process.env, {\n record: (name) => {\n seen.add(name);\n },\n ignored: /* @__PURE__ */ new Set(),\n listing: false\n });\n runtime.active = unit.mutant;\n runtime.hitLimit = unit.hitLimit ?? Infinity;\n runtime.coverage = unit.mutant === null ? /* @__PURE__ */ new Set() : null;\n channel.vm = {\n stopTimers() {\n for (let stop of stops.splice(0)) stop();\n },\n addVariable(name) {\n seen.add(name);\n },\n close() {\n closed = true;\n },\n listVariables: () => [...seen],\n realmError: target.Error,\n isReached: () => reached,\n runtime\n };\n}\n/**\n* Replaces a timer function of the vm, if it has it (jsdom has no\n* `setImmediate`) and the function that clears its handles, with one that\n* remembers how to clear each handle and keeps the original's own properties,\n* above all `util.promisify.custom`.\n*\n* @param target - The vm's `globalThis`.\n* @param names - Names of the function and of the one that clears its handles.\n* @param stops - Receives a function that clears each handle.\n*/\nfunction wrapTimer(target, names, stops) {\n let [startName, clearName] = names;\n let start = Reflect.get(target, startName);\n let clear = Reflect.get(target, clearName);\n if (start === void 0 || clear === void 0) return;\n /**\n * Starts the timer and remembers its handle.\n *\n * @param parameters - Arguments of the call.\n * @returns The handle.\n */\n function wrapper(...parameters) {\n let handle = start.apply(this, parameters);\n stops.push(() => {\n clear.call(target, handle);\n });\n return handle;\n }\n let { prototype, length, name, ...own } = Object.getOwnPropertyDescriptors(start);\n Object.defineProperties(wrapper, own);\n Reflect.set(target, startName, wrapper);\n}\n// adapters/jest/worker/channel-slot.ts\n/**\n* Key of the worker's channel on `process`: a test's vm gets a copy of it that\n* holds what a symbol key holds as it is, so the vm reaches the same object,\n* and the bundle of the vm's setup has no module in common with the worker's.\n*/\nvar CHANNEL_SLOT = Symbol.for(\"mootant.channel\");\n// adapters/jest/worker/vm-setup.ts\n/**\n* First of a project's `setupFiles`. It runs inside the test's vm, where\n* `require` goes through `moduleNameMapper` and automock, so neither this file\n* nor what it imports has a `node:` import. The channel comes on the vm's\n* `process`, since Jest 30.5 sends `process.getBuiltinModule` through\n* `moduleNameMapper` as well.\n*/\ninstallVmSide({\n channel: Reflect.get(process, CHANNEL_SLOT),\n install: installMutantRuntime,\n target: globalThis\n});\n";
|
|
1
|
+
var e = "// core/runtime/create-hit-limit-error.ts\n/**\n* Error that stops a try whose code evaluated more mutant sites than allowed.\n*/\nvar MootantHitLimitError = class extends Error {\n /**\n * Name that tells the error apart, even across realms.\n */\n name = \"MootantHitLimitError\";\n};\n/**\n* Creates the error that stops a batch try, or a test file run with a mutant,\n* whose code evaluated more mutant sites than allowed: a loop that a mutant\n* made endless, or code that a mutant made far hotter, such as a cache turned\n* off.\n*\n* @param id - Id of the mutant whose site went over the limit.\n* @param limit - Site evaluations allowed.\n* @returns Error named `MootantHitLimitError`.\n*/\nfunction createHitLimitError(id, limit) {\n return new MootantHitLimitError(`mootant stopped the test after ${limit} evaluations of mutant sites, at mutant ${id}; the code may loop endlessly or do far more work than without mutants (see run.hitLimit).`);\n}\n// core/runtime/runtime-symbol-key.ts\n/**\n* Key of the registered symbol under which `Math` holds the mutant runtime:\n* `Math[Symbol.for('mootant')]`. Vue templates reach the runtime there, since\n* the Vue compiler reads every other global name, `globalThis` included, as a\n* property of the component, but leaves `Math` and `Symbol` alone.\n*/\nvar RUNTIME_SYMBOL_KEY = \"mootant\";\n// core/runtime/runtime-global.ts\n/**\n* Name of the global through which switched code reaches the mutant runtime:\n* `globalThis.__mootant`.\n*/\nvar RUNTIME_GLOBAL = \"__mootant\";\n// core/runtime/install-mutant-runtime.ts\n/**\n* Installs the mutant runtime as `globalThis.__mootant`, where switched code\n* calls `hit` at every mutant site, and as `Math[Symbol.for('mootant')]`, where\n* switched Vue templates call it. The property of `Math` is not enumerable, and\n* `Object.getOwnPropertyNames(Math)` does not list a symbol key, so code that\n* walks `Math` does not see it. A runtime already installed in the process is\n* returned as is, since switched code may already hold it. A new runtime starts\n* with the original code active, no coverage and no hit limit.\n*\n* @returns The runtime of the process.\n*/\nfunction installMutantRuntime() {\n let runtime = Reflect.get(globalThis, \"__mootant\") ?? createRuntime();\n Reflect.set(globalThis, RUNTIME_GLOBAL, runtime);\n Object.defineProperty(Math, Symbol.for(RUNTIME_SYMBOL_KEY), {\n configurable: true,\n enumerable: false,\n value: runtime,\n writable: true\n });\n return runtime;\n}\n/**\n* Creates a runtime with the original code active, no coverage and no hit\n* limit. Its helpers for the removal of array elements use index loops over\n* arrays the switched code builds, never an array iterator or a method of the\n* array prototype, which tests may replace.\n*\n* @returns The new runtime.\n*/\nfunction createRuntime() {\n let gap = Symbol(\"mootant gap\");\n let runtime = {\n hit(id) {\n runtime.hits += 1;\n if (runtime.hits > runtime.hitLimit) throw createHitLimitError(id, runtime.hitLimit);\n if (runtime.coverage !== null) runtime.coverage.add(id);\n if (runtime.active === id) {\n runtime.reached = true;\n return true;\n }\n return false;\n },\n hitAny(ids) {\n for (let index = 0; index < ids.length; index++) if (runtime.hit(ids[index])) return true;\n return false;\n },\n cut(array) {\n let kept = 0;\n for (let index = 0; index < array.length; index++) {\n let value = array[index];\n if (value !== gap) {\n array[kept] = value;\n kept += 1;\n }\n }\n array.length = kept;\n return array;\n },\n none: { [Symbol.iterator]: () => ({ next: () => ({\n value: void 0,\n done: true\n }) }) },\n hitLimit: Infinity,\n coverage: null,\n reached: false,\n active: null,\n hits: 0,\n gap\n };\n return runtime;\n}\n// adapters/shared/environment-slot.ts\n/**\n* Global slot of the tracking state of the process; a tracking proxy answers\n* that it has this key, which tells it from a plain object.\n*/\nvar ENVIRONMENT_SLOT = Symbol.for(\"mootant.environment\");\n// adapters/shared/create-environment-proxy.ts\n/**\n* Wraps an object of environment variables, or of other values code reads by\n* name, in a proxy that reports to the receiver of the state the names read and\n* `*` when they are listed. The fields of the state are read at every trap,\n* since their owner replaces them later.\n*\n* @param target - Object to wrap.\n* @param state - Tracking state; `listing` is written here too.\n* @returns The proxy; it answers that it has `ENVIRONMENT_SLOT`, so a caller\n* can tell it from a plain object.\n*/\nfunction createEnvironmentProxy(target, state) {\n /**\n * A test's fake timers replace the global after this.\n */\n let schedule = queueMicrotask;\n /**\n * Reports a variable read by its name.\n *\n * @param name - Property key read.\n */\n function report(name) {\n if (typeof name === \"string\" && !state.listing && !state.ignored.has(name)) state.record?.(name);\n }\n return new Proxy(target, {\n ownKeys: (object) => {\n state.record?.(\"*\");\n if (!state.listing) {\n state.listing = true;\n schedule(() => {\n state.listing = false;\n });\n }\n return Reflect.ownKeys(object);\n },\n getOwnPropertyDescriptor: (object, name) => {\n report(name);\n return Reflect.getOwnPropertyDescriptor(object, name);\n },\n has: (object, name) => {\n report(name);\n return name === ENVIRONMENT_SLOT || Reflect.has(object, name);\n },\n get: (object, name) => {\n report(name);\n return Reflect.get(object, name);\n },\n set: (object, name, value) => Reflect.set(object, name, value)\n });\n}\n// adapters/jest/worker/install-vm-side.ts\n/**\n* Timer functions of a vm, each with the function that clears its handles.\n*/\nvar TIMERS = [\n [\"setTimeout\", \"clearTimeout\"],\n [\"setInterval\", \"clearInterval\"],\n [\"setImmediate\", \"clearImmediate\"]\n];\n/**\n* Sets up a test's vm before any project code, and registers on the channel\n* what the worker reads and stops once the unit ended; it registers last, so a\n* worker that sees no side knows the setup never ran. The file does not change\n* how a timer behaves, and fake timers pass around the wrappers. Nothing is\n* ignored in the environment: Node's loader reads the real `process.env`, not\n* this one.\n*\n* @param input - What the setup works with.\n*/\nfunction installVmSide(input) {\n let { channel, install, target } = input;\n let { token } = channel;\n let unit = channel.unit;\n /**\n * Jest's node environment copies the worker's globals as it loads, the stub\n * in `__mootant` too, and `install` would keep that as a runtime.\n */\n Reflect.deleteProperty(target, RUNTIME_GLOBAL);\n let runtime = install();\n Object.defineProperty(target, RUNTIME_GLOBAL, {\n configurable: true,\n enumerable: false,\n value: runtime,\n writable: true\n });\n /**\n * Jest 30's cleanup of a vm's globals spares what carries this mark.\n */\n Reflect.set(runtime, Symbol.for(\"$$jest-protect-from-deletion\"), true);\n let { hit } = runtime;\n let reached = false;\n let closed = false;\n runtime.hit = (id) => {\n if (closed) return false;\n let active = hit(id);\n if (active && !reached) {\n reached = true;\n /**\n * The only durable proof of a reach, so it cannot wait.\n */\n channel.write(token, {\n hits: runtime.hits,\n kind: \"reached\"\n });\n }\n return active;\n };\n let stops = [];\n for (let names of TIMERS) wrapTimer(target, names, stops);\n let seen = /* @__PURE__ */ new Set();\n target.process.env = createEnvironmentProxy(target.process.env, {\n record: (name) => {\n seen.add(name);\n },\n ignored: /* @__PURE__ */ new Set(),\n listing: false\n });\n runtime.active = unit.mutant;\n runtime.hitLimit = unit.hitLimit ?? Infinity;\n runtime.coverage = unit.mutant === null ? /* @__PURE__ */ new Set() : null;\n channel.vm = {\n stopTimers() {\n for (let stop of stops.splice(0)) stop();\n },\n addVariable(name) {\n seen.add(name);\n },\n close() {\n closed = true;\n },\n listVariables: () => [...seen],\n realmError: target.Error,\n isReached: () => reached,\n runtime\n };\n}\n/**\n* Replaces a timer function of the vm, if it has it (jsdom has no\n* `setImmediate`) and the function that clears its handles, with one that\n* remembers how to clear each handle and keeps the original's own properties,\n* above all `util.promisify.custom`.\n*\n* @param target - The vm's `globalThis`.\n* @param names - Names of the function and of the one that clears its handles.\n* @param stops - Receives a function that clears each handle.\n*/\nfunction wrapTimer(target, names, stops) {\n let [startName, clearName] = names;\n let start = Reflect.get(target, startName);\n let clear = Reflect.get(target, clearName);\n if (start === void 0 || clear === void 0) return;\n /**\n * Starts the timer and remembers its handle.\n *\n * @param parameters - Arguments of the call.\n * @returns The handle.\n */\n function wrapper(...parameters) {\n let handle = start.apply(this, parameters);\n stops.push(() => {\n clear.call(target, handle);\n });\n return handle;\n }\n let { prototype, length, name, ...own } = Object.getOwnPropertyDescriptors(start);\n Object.defineProperties(wrapper, own);\n Reflect.set(target, startName, wrapper);\n}\n// adapters/jest/worker/channel-slot.ts\n/**\n* Key of the worker's channel on `process`: a test's vm gets a copy of it that\n* holds what a symbol key holds as it is, so the vm reaches the same object,\n* and the bundle of the vm's setup has no module in common with the worker's.\n*/\nvar CHANNEL_SLOT = Symbol.for(\"mootant.channel\");\n// adapters/jest/worker/vm-setup.ts\n/**\n* First of a project's `setupFiles`. It runs inside the test's vm, where\n* `require` goes through `moduleNameMapper` and automock, so neither this file\n* nor what it imports has a `node:` import. The channel comes on the vm's\n* `process`, since Jest 30.5 sends `process.getBuiltinModule` through\n* `moduleNameMapper` as well.\n*/\ninstallVmSide({\n channel: Reflect.get(process, CHANNEL_SLOT),\n install: installMutantRuntime,\n target: globalThis\n});\n";
|
|
2
2
|
export { e as default };
|