@smoothbricks/nx-plugin 0.5.7 → 0.6.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/README.md +1086 -360
- package/dist/.build-inputs.json +138 -0
- package/dist/bin/smoo-nx-cargo-toolchain.d.ts +3 -0
- package/dist/bin/smoo-nx-cargo-toolchain.d.ts.map +1 -0
- package/dist/bin/smoo-nx-cargo-toolchain.js +8 -0
- package/dist/bin/smoo-nx-forbidden-spellings.d.ts +3 -0
- package/dist/bin/smoo-nx-forbidden-spellings.d.ts.map +1 -0
- package/dist/bin/smoo-nx-forbidden-spellings.js +32 -0
- package/dist/bin/smoo-nx-nextest-timings.d.ts +3 -0
- package/dist/bin/smoo-nx-nextest-timings.d.ts.map +1 -0
- package/dist/bin/smoo-nx-nextest-timings.js +28 -0
- package/dist/bounded-test-policy.d.ts +1 -1
- package/dist/bounded-test-policy.d.ts.map +1 -1
- package/dist/bounded-test-policy.js +14 -15
- package/dist/build-state-output-policy.d.ts +95 -1
- package/dist/build-state-output-policy.d.ts.map +1 -1
- package/dist/build-state-output-policy.js +368 -30
- package/dist/bun-lock-scope.d.ts +44 -0
- package/dist/bun-lock-scope.d.ts.map +1 -0
- package/dist/bun-lock-scope.js +97 -0
- package/dist/cargo-build-script-env.d.ts +49 -0
- package/dist/cargo-build-script-env.d.ts.map +1 -0
- package/dist/cargo-build-script-env.js +324 -0
- package/dist/cargo-closure-input.d.ts +31 -4
- package/dist/cargo-closure-input.d.ts.map +1 -1
- package/dist/cargo-closure-input.js +66 -6
- package/dist/cargo-retention-hook.d.ts +17 -0
- package/dist/cargo-retention-hook.d.ts.map +1 -0
- package/dist/cargo-retention-hook.js +85 -0
- package/dist/cargo-source-hash.d.ts +25 -7
- package/dist/cargo-source-hash.d.ts.map +1 -1
- package/dist/cargo-source-hash.js +108 -43
- package/dist/cargo-toolchain-paths.d.ts +40 -0
- package/dist/cargo-toolchain-paths.d.ts.map +1 -0
- package/dist/cargo-toolchain-paths.js +84 -0
- package/dist/cargo-toolchain-policy.d.ts +25 -8
- package/dist/cargo-toolchain-policy.d.ts.map +1 -1
- package/dist/cargo-toolchain-policy.js +39 -5
- package/dist/cargo-workspace.d.ts +10 -4
- package/dist/cargo-workspace.d.ts.map +1 -1
- package/dist/cargo-workspace.js +65 -95
- package/dist/cross-check-policy.d.ts +9 -9
- package/dist/cross-check-policy.d.ts.map +1 -1
- package/dist/cross-check-policy.js +11 -11
- package/dist/disk-command-policy.d.ts.map +1 -1
- package/dist/disk-command-policy.js +1 -0
- package/dist/ensure-built-receipt.d.ts +13 -5
- package/dist/ensure-built-receipt.d.ts.map +1 -1
- package/dist/ensure-built-receipt.js +126 -47
- package/dist/ensure-built-witness.d.ts +27 -8
- package/dist/ensure-built-witness.d.ts.map +1 -1
- package/dist/ensure-built-witness.js +45 -15
- package/dist/ensure-built.d.ts.map +1 -1
- package/dist/ensure-built.js +9 -1
- package/dist/eslint-config-closure.d.ts +7 -0
- package/dist/eslint-config-closure.d.ts.map +1 -0
- package/dist/eslint-config-closure.js +346 -0
- package/dist/executors/bounded-exec/bounds.d.ts +56 -0
- package/dist/executors/bounded-exec/bounds.d.ts.map +1 -0
- package/dist/executors/bounded-exec/bounds.js +43 -0
- package/dist/executors/bounded-exec/cpu-pool.d.ts +33 -36
- package/dist/executors/bounded-exec/cpu-pool.d.ts.map +1 -1
- package/dist/executors/bounded-exec/cpu-pool.js +54 -119
- package/dist/executors/bounded-exec/executor.d.ts +19 -12
- package/dist/executors/bounded-exec/executor.d.ts.map +1 -1
- package/dist/executors/bounded-exec/executor.js +371 -239
- package/dist/executors/bounded-exec/gateway-lease.d.ts +22 -19
- package/dist/executors/bounded-exec/gateway-lease.d.ts.map +1 -1
- package/dist/executors/bounded-exec/gateway-lease.js +81 -28
- package/dist/executors/bounded-exec/hang-diagnostics.d.ts +18 -1
- package/dist/executors/bounded-exec/hang-diagnostics.d.ts.map +1 -1
- package/dist/executors/bounded-exec/hang-diagnostics.js +148 -30
- package/dist/executors/bounded-exec/lease-wait.d.ts +43 -0
- package/dist/executors/bounded-exec/lease-wait.d.ts.map +1 -0
- package/dist/executors/bounded-exec/lease-wait.js +68 -0
- package/dist/executors/bounded-exec/lock-wait.d.ts +51 -0
- package/dist/executors/bounded-exec/lock-wait.d.ts.map +1 -0
- package/dist/executors/bounded-exec/lock-wait.js +108 -0
- package/dist/executors/bounded-exec/owned-subtree.d.ts +84 -0
- package/dist/executors/bounded-exec/owned-subtree.d.ts.map +1 -0
- package/dist/executors/bounded-exec/owned-subtree.js +178 -0
- package/dist/executors/bounded-exec/progress.d.ts +4 -1
- package/dist/executors/bounded-exec/progress.d.ts.map +1 -1
- package/dist/executors/bounded-exec/progress.js +5 -2
- package/dist/executors/bounded-exec/ram-attach.d.ts +19 -0
- package/dist/executors/bounded-exec/ram-attach.d.ts.map +1 -0
- package/dist/executors/bounded-exec/ram-attach.js +207 -0
- package/dist/executors/bounded-exec/ram-detach.d.ts +25 -0
- package/dist/executors/bounded-exec/ram-detach.d.ts.map +1 -0
- package/dist/executors/bounded-exec/ram-detach.js +207 -0
- package/dist/executors/bounded-exec/ram-temp-fixtures.d.ts +76 -0
- package/dist/executors/bounded-exec/ram-temp-fixtures.d.ts.map +1 -1
- package/dist/executors/bounded-exec/ram-temp-fixtures.js +296 -0
- package/dist/executors/bounded-exec/ram-temp.d.ts +388 -88
- package/dist/executors/bounded-exec/ram-temp.d.ts.map +1 -1
- package/dist/executors/bounded-exec/ram-temp.js +1213 -399
- package/dist/executors/bounded-exec/run-cpu-pool.d.ts +4 -4
- package/dist/executors/bounded-exec/run-cpu-pool.d.ts.map +1 -1
- package/dist/executors/bounded-exec/run-cpu-pool.js +20 -30
- package/dist/executors/bounded-exec/runner-hook.js +14 -5
- package/dist/executors/bounded-exec/runner-lifecycle.d.ts +14 -1
- package/dist/executors/bounded-exec/runner-lifecycle.d.ts.map +1 -1
- package/dist/executors/bounded-exec/runner-lifecycle.js +27 -6
- package/dist/executors/bounded-exec/{cpu-tokens.d.ts → runner-sizing.d.ts} +14 -42
- package/dist/executors/bounded-exec/runner-sizing.d.ts.map +1 -0
- package/dist/executors/bounded-exec/{cpu-tokens.js → runner-sizing.js} +5 -35
- package/dist/executors/bounded-exec/runtime-pin.d.ts +73 -0
- package/dist/executors/bounded-exec/runtime-pin.d.ts.map +1 -0
- package/dist/executors/bounded-exec/runtime-pin.js +167 -0
- package/dist/executors/bounded-exec/schema.d.ts +18 -1
- package/dist/executors/bounded-exec/schema.d.ts.map +1 -1
- package/dist/executors/bounded-exec/verdict.d.ts +40 -11
- package/dist/executors/bounded-exec/verdict.d.ts.map +1 -1
- package/dist/executors/bounded-exec/verdict.js +88 -19
- package/dist/executors/cargo-zigbuild/executor.d.ts +21 -0
- package/dist/executors/cargo-zigbuild/executor.d.ts.map +1 -1
- package/dist/executors/cargo-zigbuild/executor.js +67 -12
- package/dist/executors/clean-outputs/executor.js +1 -0
- package/dist/executors/scriptc-native/executor.d.ts +79 -0
- package/dist/executors/scriptc-native/executor.d.ts.map +1 -0
- package/dist/executors/scriptc-native/executor.js +367 -0
- package/dist/executors/scriptc-native/ffi-paths.d.ts +9 -0
- package/dist/executors/scriptc-native/ffi-paths.d.ts.map +1 -0
- package/dist/executors/scriptc-native/ffi-paths.js +25 -0
- package/dist/executors/scriptc-native/schema.d.ts +34 -0
- package/dist/executors/scriptc-native/schema.d.ts.map +1 -0
- package/dist/executors/scriptc-native/schema.js +1 -0
- package/dist/executors/typescript-emit/executor.d.ts +3 -1
- package/dist/executors/typescript-emit/executor.d.ts.map +1 -1
- package/dist/executors/typescript-emit/executor.js +164 -33
- package/dist/forbidden-spelling-policy.d.ts +56 -0
- package/dist/forbidden-spelling-policy.d.ts.map +1 -0
- package/dist/forbidden-spelling-policy.js +176 -0
- package/dist/generators/create-package/generator.d.ts.map +1 -1
- package/dist/generators/create-package/generator.js +3 -4
- package/dist/graph-input-contract.d.ts +14 -0
- package/dist/graph-input-contract.d.ts.map +1 -1
- package/dist/graph-input-contract.js +67 -2
- package/dist/index.d.ts +23 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +672 -214
- package/dist/managed-assets.d.ts +2 -0
- package/dist/managed-assets.d.ts.map +1 -1
- package/dist/managed-files/files.d.ts +3 -3
- package/dist/managed-files/files.d.ts.map +1 -1
- package/dist/managed-files/files.js +28 -3
- package/dist/managed-files/managed-format.d.ts.map +1 -1
- package/dist/managed-files/managed-format.js +1 -0
- package/dist/nextest-code-bound.js +1 -0
- package/dist/nextest-timings.d.ts +35 -0
- package/dist/nextest-timings.d.ts.map +1 -0
- package/dist/nextest-timings.js +168 -0
- package/dist/owned-installation.d.ts +6 -5
- package/dist/owned-installation.d.ts.map +1 -1
- package/dist/owned-installation.js +150 -26
- package/dist/package-target-policy.d.ts.map +1 -1
- package/dist/package-target-policy.js +2 -3
- package/dist/process-children.d.ts +7 -0
- package/dist/process-children.d.ts.map +1 -0
- package/dist/process-children.darwin.d.ts +7 -0
- package/dist/process-children.darwin.d.ts.map +1 -0
- package/dist/process-children.darwin.js +13 -0
- package/dist/process-children.js +14 -0
- package/dist/process-children.linux.d.ts +8 -0
- package/dist/process-children.linux.d.ts.map +1 -0
- package/dist/process-children.linux.js +25 -0
- package/dist/process-group.d.ts +108 -0
- package/dist/process-group.d.ts.map +1 -0
- package/dist/process-group.js +171 -0
- package/dist/process-listing.d.ts +7 -0
- package/dist/process-listing.d.ts.map +1 -0
- package/dist/process-listing.js +51 -0
- package/dist/producer-receipts.d.ts +8 -2
- package/dist/producer-receipts.d.ts.map +1 -1
- package/dist/producer-receipts.js +75 -48
- package/dist/task-graph-policy.d.ts +21 -0
- package/dist/task-graph-policy.d.ts.map +1 -0
- package/dist/task-graph-policy.js +91 -0
- package/dist/test-timings.js +4 -4
- package/dist/test-walk-policy.d.ts +14 -5
- package/dist/test-walk-policy.d.ts.map +1 -1
- package/dist/test-walk-policy.js +8 -2
- package/dist/testing.d.ts +73 -28
- package/dist/testing.d.ts.map +1 -1
- package/dist/testing.js +217 -223
- package/dist/tool-bins.d.ts +33 -0
- package/dist/tool-bins.d.ts.map +1 -0
- package/dist/tool-bins.js +72 -0
- package/dist/typecheck-test-policy.d.ts.map +1 -1
- package/dist/typecheck-test-policy.js +3 -4
- package/dist/wait-why-policy.d.ts +28 -0
- package/dist/wait-why-policy.d.ts.map +1 -0
- package/dist/wait-why-policy.js +223 -0
- package/dist/workspace-config-policy.d.ts +14 -8
- package/dist/workspace-config-policy.d.ts.map +1 -1
- package/dist/workspace-config-policy.js +60 -16
- package/dist/workspace-manifest.d.ts +41 -6
- package/dist/workspace-manifest.d.ts.map +1 -1
- package/dist/workspace-manifest.js +57 -0
- package/executors.json +16 -1
- package/loader.js +2 -0
- package/managed/raw/envrc +11 -0
- package/managed/raw/patches/nx@23.2.1.patch +2840 -199
- package/managed/raw/patches/ttsc@0.34.1.patch +119 -0
- package/managed/raw/tooling/direnv/cargo-fetch-bound.ts +245 -0
- package/managed/raw/tooling/direnv/cargo-fetch-run.ts +299 -0
- package/managed/raw/tooling/direnv/compiler-variables.sh +42 -0
- package/managed/raw/tooling/direnv/developer-links.ts +464 -25
- package/managed/raw/tooling/direnv/devenv.smoo.nix +78 -38
- package/managed/raw/tooling/direnv/github-actions-bootstrap.sh +14 -12
- package/managed/raw/tooling/direnv/installed-bun-links.ts +308 -0
- package/managed/raw/tooling/direnv/linked-snapshots.ts +62 -3
- package/managed/raw/tooling/direnv/nx-socket-dir.sh +56 -17
- package/managed/raw/tooling/direnv/repo-path +68 -6
- package/managed/raw/tooling/direnv/secret-references.ts +13 -4
- package/managed/raw/tooling/direnv/setup-environment.ts +128 -537
- package/managed/raw/tooling/direnv/toolchain-stamp.ts +4 -2
- package/managed/raw/tooling/direnv/ttsc-env.sh +9 -0
- package/managed/raw/tooling/direnv/uv-relocation.ts +227 -0
- package/managed/raw/tooling/git-hooks/commit-msg.sh +2 -1
- package/managed/raw/tooling/git-hooks/pre-commit.sh +2 -1
- package/managed/raw/tooling/git-hooks/pre-push.sh +2 -1
- package/managed/templates/github/actions/cache-ttsc-plugins/action.yml +85 -7
- package/managed/templates/github/actions/save-nix-devenv/action.yml +12 -2
- package/managed/templates/github/actions/setup-devenv/action.yml +2 -0
- package/package.json +77 -13
- package/src/bin/smoo-nx-cargo-toolchain.ts +11 -0
- package/src/bin/smoo-nx-forbidden-spellings.ts +33 -0
- package/src/bin/smoo-nx-nextest-timings.ts +31 -0
- package/src/bounded-test-policy.ts +12 -14
- package/src/build-state-output-policy.ts +458 -34
- package/src/bun-lock-scope.ts +108 -0
- package/src/cargo-build-script-env.ts +265 -0
- package/src/cargo-closure-input.ts +74 -7
- package/src/cargo-retention-hook.ts +94 -0
- package/src/cargo-source-hash.ts +138 -41
- package/src/cargo-toolchain-paths.ts +95 -0
- package/src/cargo-toolchain-policy.ts +49 -5
- package/src/cargo-workspace.ts +72 -123
- package/src/cross-check-policy.ts +12 -10
- package/src/disk-command-policy.ts +1 -0
- package/src/ensure-built-receipt.ts +132 -39
- package/src/ensure-built-witness.ts +62 -10
- package/src/ensure-built.ts +11 -1
- package/src/eslint-config-closure.ts +357 -0
- package/src/executors/bounded-exec/bounds.ts +76 -0
- package/src/executors/bounded-exec/cpu-pool.ts +51 -117
- package/src/executors/bounded-exec/executor.ts +423 -259
- package/src/executors/bounded-exec/gateway-lease.ts +82 -33
- package/src/executors/bounded-exec/hang-diagnostics.ts +173 -31
- package/src/executors/bounded-exec/lease-wait.ts +89 -0
- package/src/executors/bounded-exec/lock-wait.ts +141 -0
- package/src/executors/bounded-exec/owned-subtree.ts +235 -0
- package/src/executors/bounded-exec/progress.ts +9 -3
- package/src/executors/bounded-exec/ram-attach.ts +238 -0
- package/src/executors/bounded-exec/ram-detach.ts +226 -0
- package/src/executors/bounded-exec/ram-temp-fixtures.ts +358 -0
- package/src/executors/bounded-exec/ram-temp-registry.txt +440 -0
- package/src/executors/bounded-exec/ram-temp.ts +1497 -460
- package/src/executors/bounded-exec/run-cpu-pool.ts +22 -30
- package/src/executors/bounded-exec/runner-hook.ts +14 -6
- package/src/executors/bounded-exec/runner-lifecycle.ts +31 -8
- package/src/executors/bounded-exec/{cpu-tokens.ts → runner-sizing.ts} +13 -59
- package/src/executors/bounded-exec/runtime-pin.ts +232 -0
- package/src/executors/bounded-exec/schema.json +11 -2
- package/src/executors/bounded-exec/schema.ts +19 -1
- package/src/executors/bounded-exec/verdict.ts +137 -34
- package/src/executors/cargo-zigbuild/executor.ts +82 -8
- package/src/executors/clean-outputs/executor.ts +1 -0
- package/src/executors/scriptc-native/executor.ts +394 -0
- package/src/executors/scriptc-native/ffi-paths.ts +29 -0
- package/src/executors/scriptc-native/schema.json +60 -0
- package/src/executors/scriptc-native/schema.ts +34 -0
- package/src/executors/typescript-emit/executor.ts +205 -38
- package/src/forbidden-spelling-policy.ts +226 -0
- package/src/generators/create-package/generator.ts +7 -7
- package/src/graph-input-contract.ts +61 -2
- package/src/index.ts +788 -224
- package/src/managed-assets.ts +3 -0
- package/src/managed-files/files.ts +28 -3
- package/src/managed-files/managed-format.ts +1 -0
- package/src/nextest-code-bound.ts +1 -0
- package/src/nextest-timings.ts +106 -0
- package/src/owned-installation.ts +150 -23
- package/src/package-target-policy.ts +2 -3
- package/src/process-children.darwin.ts +14 -0
- package/src/process-children.linux.ts +33 -0
- package/src/process-children.ts +22 -0
- package/src/process-group.ts +209 -0
- package/src/process-listing.ts +54 -0
- package/src/producer-receipts.ts +68 -45
- package/src/task-graph-policy.ts +98 -0
- package/src/test-walk-policy.ts +23 -8
- package/src/testing.ts +240 -232
- package/src/tool-bins.ts +108 -0
- package/src/typecheck-test-policy.ts +2 -3
- package/src/wait-why-policy.ts +226 -0
- package/src/workspace-config-policy.ts +63 -15
- package/src/workspace-manifest.ts +89 -6
- package/test-timings.json +122 -98
- package/dist/bin/smoo-nx-failures.d.ts +0 -3
- package/dist/bin/smoo-nx-failures.d.ts.map +0 -1
- package/dist/bin/smoo-nx-failures.js +0 -3
- package/dist/bin/smoo-nx-nextest-extract.d.ts +0 -3
- package/dist/bin/smoo-nx-nextest-extract.d.ts.map +0 -1
- package/dist/bin/smoo-nx-nextest-extract.js +0 -42
- package/dist/executors/bounded-exec/cpu-tokens.d.ts.map +0 -1
- package/dist/failure-summary.d.ts +0 -5
- package/dist/failure-summary.d.ts.map +0 -1
- package/dist/failure-summary.js +0 -118
- package/dist/nextest-extraction.d.ts +0 -117
- package/dist/nextest-extraction.d.ts.map +0 -1
- package/dist/nextest-extraction.js +0 -303
- package/managed/raw/patches/ttsc@0.30.4.patch +0 -2255
- package/src/__tests__/cargo-closure-filesets.ts +0 -94
- package/src/__tests__/cargo-closure-fixture.ts +0 -113
- package/src/__tests__/counted-cargo-process.ts +0 -286
- package/src/__tests__/counted-cargo.ts +0 -713
- package/src/__tests__/directory-change.ts +0 -27
- package/src/__tests__/fixture-cargo-home.ts +0 -36
- package/src/__tests__/fixture-nx-env.ts +0 -193
- package/src/__tests__/owned-installation.ts +0 -13
- package/src/__tests__/past-tick.ts +0 -12
- package/src/__tests__/progress-clock.ts +0 -43
- package/src/__tests__/runtime-input.ts +0 -23
- package/src/bin/smoo-nx-bound-failures.test.ts +0 -127
- package/src/bin/smoo-nx-failures.ts +0 -4
- package/src/bin/smoo-nx-nextest-extract.ts +0 -44
- package/src/bounded-test-policy.test.ts +0 -1029
- package/src/build-state-output-policy.test.ts +0 -115
- package/src/bun-bootstrap.test.ts +0 -102
- package/src/bun-file-packages.test.ts +0 -47
- package/src/cargo-closure-filesets.test.ts +0 -63
- package/src/cargo-closure-input.property.test.ts +0 -50
- package/src/cargo-closure-input.test.ts +0 -506
- package/src/cargo-closure-key.test.ts +0 -240
- package/src/cargo-resolve-cache.test.ts +0 -1181
- package/src/cargo-source-hash.test.ts +0 -707
- package/src/cargo-workspace.test.ts +0 -615
- package/src/cross-check-policy.test.ts +0 -316
- package/src/disk-command-policy.test.ts +0 -61
- package/src/ensure-built-receipt.test.ts +0 -279
- package/src/ensure-built-witness.test.ts +0 -688
- package/src/ensure-built.test.ts +0 -1462
- package/src/executors/all-verdicts/executor.test.ts +0 -135
- package/src/executors/bounded-exec/cargo-progress-host.test.ts +0 -332
- package/src/executors/bounded-exec/cpu-pool.test.ts +0 -684
- package/src/executors/bounded-exec/cpu-tokens.test.ts +0 -519
- package/src/executors/bounded-exec/disk-lease.test.ts +0 -219
- package/src/executors/bounded-exec/executor-host.test.ts +0 -800
- package/src/executors/bounded-exec/executor.test.ts +0 -1819
- package/src/executors/bounded-exec/go-progress-host.test.ts +0 -171
- package/src/executors/bounded-exec/hang-diagnostics.test.ts +0 -291
- package/src/executors/bounded-exec/progress.test.ts +0 -139
- package/src/executors/bounded-exec/ram-temp-held.test.ts +0 -264
- package/src/executors/bounded-exec/ram-temp-host.test.ts +0 -635
- package/src/executors/bounded-exec/ram-temp.test.ts +0 -750
- package/src/executors/bounded-exec/run-cpu-pool.test.ts +0 -79
- package/src/executors/bounded-exec/runner-hook.test.ts +0 -193
- package/src/executors/bounded-exec/runner-lifecycle.test.ts +0 -82
- package/src/executors/bounded-exec/verdict.test.ts +0 -545
- package/src/executors/cargo-zigbuild/executor.test.ts +0 -129
- package/src/executors/clean-outputs/executor.test.ts +0 -20
- package/src/executors/typescript-emit/executor.test.ts +0 -83
- package/src/failure-summary.ts +0 -119
- package/src/generators/bounded-test-targets/generator.test.ts +0 -138
- package/src/generators/bun-test-tracing/generator.test.ts +0 -250
- package/src/generators/create-package/generator.test.ts +0 -190
- package/src/generators/make-public/generator.test.ts +0 -137
- package/src/graph-input-contract.test.ts +0 -379
- package/src/host-controller-wiring.test.ts +0 -31
- package/src/index.test.ts +0 -3321
- package/src/linked-snapshots.nx.test.ts +0 -254
- package/src/managed-files/forgejo-artifact.test.ts +0 -395
- package/src/managed-files/generator.test.ts +0 -243
- package/src/managed-files/github-host-cache-isolation.test.ts +0 -86
- package/src/managed-files/json-edit.test.ts +0 -216
- package/src/managed-files/managed-content.test.ts +0 -166
- package/src/managed-files/managed-format-json.test.ts +0 -308
- package/src/managed-files/repo-path.test.ts +0 -172
- package/src/managed-files/setup-devenv-free-disk.test.ts +0 -95
- package/src/managed-files/trace-db-artifact.test.ts +0 -7
- package/src/managed-files/tree-permissions.test.ts +0 -109
- package/src/managed-files/tree.test.ts +0 -123
- package/src/manifest-hash.test.ts +0 -219
- package/src/nextest-code-bound.test.ts +0 -161
- package/src/nextest-extraction.test.ts +0 -216
- package/src/nextest-extraction.ts +0 -371
- package/src/nextest-partitions.test.ts +0 -501
- package/src/nx-cache-bound.test.ts +0 -109
- package/src/nx-cache-restore-mtime.test.ts +0 -170
- package/src/nx-daemon-claim.test.ts +0 -279
- package/src/nx-daemon-idle-cpu.test.ts +0 -80
- package/src/nx-daemon-idle-policy.test.ts +0 -111
- package/src/nx-daemon-ignore-files.test.ts +0 -210
- package/src/nx-daemon-root-normalization.test.ts +0 -105
- package/src/nx-daemon-start-never.test.ts +0 -292
- package/src/nx-daemon-validity.test.ts +0 -1055
- package/src/nx-dot-input-policy.test.ts +0 -353
- package/src/nx-failure-life-cycles.test.ts +0 -207
- package/src/nx-files-archive-racy.test.ts +0 -97
- package/src/nx-foreign-workspace-env.test.ts +0 -329
- package/src/nx-incomplete-run-summary.test.ts +0 -70
- package/src/nx-plugin-load-errors.test.ts +0 -120
- package/src/nx-project-graph-errors.test.ts +0 -70
- package/src/nx-project-resolution-cache.test.ts +0 -176
- package/src/nx-raw-inputs.test.ts +0 -166
- package/src/nx-resident-graph-workers.test.ts +0 -112
- package/src/nx-run-information.test.ts +0 -118
- package/src/nx-skipped-task-exit.test.ts +0 -180
- package/src/nx-state-location.test.ts +0 -63
- package/src/nx-store-resolution.test.ts +0 -81
- package/src/nx-task-graph-cycles.test.ts +0 -148
- package/src/nx-task-output-lease.test.ts +0 -550
- package/src/nx-use-local.test.ts +0 -105
- package/src/owned-installation.test.ts +0 -105
- package/src/package-target-policy.test.ts +0 -1014
- package/src/producer-receipts.test.ts +0 -285
- package/src/release-config-policy.test.ts +0 -311
- package/src/runtime-input.test.ts +0 -393
- package/src/serial-group-wiring.test.ts +0 -326
- package/src/task-history-namespace.test.ts +0 -181
- package/src/task-results.test.ts +0 -228
- package/src/test-clock-policy.test.ts +0 -338
- package/src/test-program.test.ts +0 -303
- package/src/test-timings.test.ts +0 -240
- package/src/test-walk-policy.test.ts +0 -620
- package/src/testing.test.ts +0 -509
- package/src/typecheck-test-policy.test.ts +0 -1468
- package/src/typescript-resolution.test.ts +0 -76
- package/src/version-actions.test.ts +0 -80
- package/src/workspace-config-policy.test.ts +0 -737
package/src/testing.ts
CHANGED
|
@@ -10,13 +10,19 @@
|
|
|
10
10
|
* `<parent>/smoothbricks-fixtures/<suite>/run-<pid>`, where the caller names
|
|
11
11
|
* the parent: the temp directory, or the directory of a volume the fixture has
|
|
12
12
|
* to lie on. A process that gets SIGTERM, SIGINT or SIGHUP (a bounded test
|
|
13
|
-
* leg's timeout sends SIGTERM, and SIGKILL 10 s later) first
|
|
14
|
-
* still
|
|
15
|
-
* outright cannot, so the first fixture a process creates
|
|
16
|
-
* parent
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
13
|
+
* leg's timeout sends SIGTERM, and SIGKILL 10 s later) first names its own
|
|
14
|
+
* descendants that still run and deletes every run it holds, then dies of that
|
|
15
|
+
* signal. One killed outright cannot, so the first fixture a process creates
|
|
16
|
+
* for a suite under a parent deletes every run of that suite there whose owner
|
|
17
|
+
* is gone. A run whose owner still exists is never touched by another process.
|
|
18
|
+
* Nothing is signalled for working in a run: what a fixture left running is
|
|
19
|
+
* ended by the job's supervisor with the test command's subtree (bounded-exec).
|
|
20
|
+
*
|
|
21
|
+
* No helper here reads a process it was not given. Each starts from pids its
|
|
22
|
+
* caller holds (a child it spawned, a daemon's record, this process) and walks
|
|
23
|
+
* down their children, never across the host's process table: any process of
|
|
24
|
+
* the user caught in an uninterruptible kernel wait holds a reader of its
|
|
25
|
+
* files or arguments there with it.
|
|
20
26
|
*
|
|
21
27
|
* The module also says where a fixture's sockets and loopback listeners may
|
|
22
28
|
* live, because a Cowshed sandbox admits only its own: a Unix socket under its
|
|
@@ -24,21 +30,21 @@
|
|
|
24
30
|
* literal `/tmp/x.sock` or a port-0 listener still binds there, and then no
|
|
25
31
|
* process of the workspace can reach it (specs/cowshed/04_sandbox.md).
|
|
26
32
|
*
|
|
27
|
-
* Node APIs and the library's
|
|
28
|
-
*
|
|
33
|
+
* Node APIs and the library's own modules only: this module is built with the
|
|
34
|
+
* library and imported by Bun tests in other packages.
|
|
29
35
|
*/
|
|
30
|
-
import { execFile } from 'node:child_process';
|
|
31
36
|
import { createHash } from 'node:crypto';
|
|
32
37
|
import { lstatSync, readlinkSync, realpathSync, statSync } from 'node:fs';
|
|
33
38
|
import { lstat, mkdir, mkdtemp, readdir, readFile, readlink, realpath, rm, symlink, writeFile } from 'node:fs/promises';
|
|
34
|
-
import {
|
|
39
|
+
import { createServer, type Server } from 'node:net';
|
|
40
|
+
import { tmpdir } from 'node:os';
|
|
35
41
|
import { dirname, isAbsolute, join, sep } from 'node:path';
|
|
36
42
|
import { setTimeout as sleep } from 'node:timers/promises';
|
|
37
|
-
import { promisify } from 'node:util';
|
|
38
43
|
import { findNxWorkspaceRoot } from './ensure-built.js';
|
|
44
|
+
import { childPids } from './process-children.js';
|
|
45
|
+
import { listing } from './process-listing.js';
|
|
39
46
|
import { BOUNDED_TEST_IDLE_TIMEOUT_MS } from './test-backstop.js';
|
|
40
47
|
|
|
41
|
-
const run = promisify(execFile);
|
|
42
48
|
/**
|
|
43
49
|
* How long a stopped process may take to exit when no caller names a grace: the leg's no-progress backstop
|
|
44
50
|
* (specs/cowshed/08_testing.md), so the exit itself decides and a hung one is the leg's to report. A smaller literal
|
|
@@ -46,8 +52,6 @@ const run = promisify(execFile);
|
|
|
46
52
|
* 10 s on a loaded gate host and failed teardown of a test that had passed.
|
|
47
53
|
*/
|
|
48
54
|
const EXIT_TIMEOUT_MS = BOUNDED_TEST_IDLE_TIMEOUT_MS;
|
|
49
|
-
/** Under half of the SIGTERM-to-SIGKILL grace a bounded test leg gives, per round of signals. */
|
|
50
|
-
const SIGNALLED_GRACE_MS = 3_000;
|
|
51
55
|
const FIXTURE_HOME = 'smoothbricks-fixtures';
|
|
52
56
|
const RUN_NAME = /^run-(\d+)$/;
|
|
53
57
|
const SWEEP_LOCK = 'sweep.lock';
|
|
@@ -61,16 +65,31 @@ export interface ProcessEntry {
|
|
|
61
65
|
readonly command: string;
|
|
62
66
|
}
|
|
63
67
|
|
|
64
|
-
/**
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
68
|
+
/**
|
|
69
|
+
* The processes among `pids` that still exist, zombies included, as `ps -p` lists them on macOS and Linux alike, in
|
|
70
|
+
* `ps`'s order. Only the named processes are read.
|
|
71
|
+
*/
|
|
72
|
+
export async function processesOf(pids: readonly number[]): Promise<ProcessEntry[]> {
|
|
73
|
+
if (pids.length === 0) {
|
|
74
|
+
return [];
|
|
75
|
+
}
|
|
76
|
+
const stdout = await listing('ps', [
|
|
77
|
+
'-o',
|
|
78
|
+
'pid=',
|
|
79
|
+
'-o',
|
|
80
|
+
'ppid=',
|
|
81
|
+
'-o',
|
|
82
|
+
'stat=',
|
|
83
|
+
'-o',
|
|
84
|
+
'command=',
|
|
85
|
+
'-p',
|
|
86
|
+
pids.join(','),
|
|
87
|
+
]);
|
|
69
88
|
return stdout
|
|
70
89
|
.split('\n')
|
|
71
90
|
.filter((line) => line.trim() !== '')
|
|
72
91
|
.map((line) => {
|
|
73
|
-
const match = /^\s*(\d+)\s+(\d+)\s+(\S+)\s
|
|
92
|
+
const match = /^\s*(\d+)\s+(\d+)\s+(\S+)\s*(.*)$/.exec(line);
|
|
74
93
|
if (match === null) {
|
|
75
94
|
throw new Error(`Unable to parse ps line: ${line}`);
|
|
76
95
|
}
|
|
@@ -79,6 +98,39 @@ export async function processTable(): Promise<ProcessEntry[]> {
|
|
|
79
98
|
});
|
|
80
99
|
}
|
|
81
100
|
|
|
101
|
+
/**
|
|
102
|
+
/**
|
|
103
|
+
* `roots` and every process descending from one, each once, in the order found: generation by generation, each the
|
|
104
|
+
* children `children` lists for the pids the one before added. A pid already found is not walked again, so a reused
|
|
105
|
+
* pid listed as a child of its own descendant ends the walk instead of looping it. The walk reads nothing but
|
|
106
|
+
* `children`, and keeps a root that no longer runs: whoever reads the processes drops it.
|
|
107
|
+
*/
|
|
108
|
+
export async function walkTree(
|
|
109
|
+
roots: readonly number[],
|
|
110
|
+
children: (parents: readonly number[]) => Promise<readonly number[]>,
|
|
111
|
+
): Promise<number[]> {
|
|
112
|
+
const found = new Set<number>();
|
|
113
|
+
for (let generation = roots; generation.length > 0; ) {
|
|
114
|
+
const added = [...new Set(generation)].filter((pid) => !found.has(pid));
|
|
115
|
+
for (const pid of added) {
|
|
116
|
+
found.add(pid);
|
|
117
|
+
}
|
|
118
|
+
generation = added.length === 0 ? [] : await children(added);
|
|
119
|
+
}
|
|
120
|
+
return [...found];
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* The processes of `roots` that still exist and every process descending from one, roots first, in the order
|
|
125
|
+
* {@link walkTree} found them. Only those processes are read. A child forked after its parent's children were listed,
|
|
126
|
+
* or reparented away before, is not in it.
|
|
127
|
+
*/
|
|
128
|
+
export async function processTree(roots: readonly number[]): Promise<ProcessEntry[]> {
|
|
129
|
+
const order = await walkTree(roots, childPids);
|
|
130
|
+
const listed = new Map((await processesOf(order)).map((entry) => [entry.pid, entry]));
|
|
131
|
+
return order.flatMap((pid) => listed.get(pid) ?? []);
|
|
132
|
+
}
|
|
133
|
+
|
|
82
134
|
/**
|
|
83
135
|
* The listed processes among `pids`, and every process descending from one, each once: a pid that
|
|
84
136
|
* descends from another in `pids` is not listed twice.
|
|
@@ -144,7 +196,9 @@ export async function awaitExit(
|
|
|
144
196
|
if (performance.now() > deadline) {
|
|
145
197
|
// A signal probe also answers for a zombie, which has already exited.
|
|
146
198
|
const live = new Set(
|
|
147
|
-
(await
|
|
199
|
+
(await processesOf(waiting.map((entry) => entry.pid)))
|
|
200
|
+
.filter((entry) => !entry.stat.startsWith('Z'))
|
|
201
|
+
.map((entry) => entry.pid),
|
|
148
202
|
);
|
|
149
203
|
const survivors = waiting.filter((entry) => live.has(entry.pid));
|
|
150
204
|
if (survivors.length === 0) {
|
|
@@ -159,113 +213,23 @@ export async function awaitExit(
|
|
|
159
213
|
}
|
|
160
214
|
}
|
|
161
215
|
|
|
162
|
-
/** Every process of this user whose working directory is `root` or lies beneath it, deleted or not. */
|
|
163
|
-
export async function pidsWorkingIn(root: string): Promise<number[]> {
|
|
164
|
-
const under = (cwd: string) => cwd === root || cwd.startsWith(`${root}/`);
|
|
165
|
-
switch (process.platform) {
|
|
166
|
-
case 'linux': {
|
|
167
|
-
const found: number[] = [];
|
|
168
|
-
for (const pid of (await readdir('/proc')).filter((name) => /^\d+$/.test(name))) {
|
|
169
|
-
const cwd = await readlink(`/proc/${pid}/cwd`).catch((error: unknown) => {
|
|
170
|
-
// Another user's process, or one that exited since the listing.
|
|
171
|
-
if (errorCode(error) === 'EACCES' || errorCode(error) === 'ENOENT' || errorCode(error) === 'ESRCH') {
|
|
172
|
-
return null;
|
|
173
|
-
}
|
|
174
|
-
throw error;
|
|
175
|
-
});
|
|
176
|
-
if (cwd !== null && under(cwd.replace(/ \(deleted\)$/, ''))) {
|
|
177
|
-
found.push(Number(pid));
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
return found;
|
|
181
|
-
}
|
|
182
|
-
case 'darwin': {
|
|
183
|
-
// lsof keeps naming a working directory after it has been deleted. It
|
|
184
|
-
// exits 1 when a listed process vanished before it was read; what it
|
|
185
|
-
// printed for the rest is still the answer.
|
|
186
|
-
const fields = await run('/usr/sbin/lsof', ['-nP', '-a', '-d', 'cwd', '-u', String(userInfo().uid), '-Fpn'], {
|
|
187
|
-
maxBuffer: 64 * 1024 * 1024,
|
|
188
|
-
}).then(
|
|
189
|
-
({ stdout }) => stdout,
|
|
190
|
-
(error: unknown) => {
|
|
191
|
-
if (error instanceof Error && 'code' in error && error.code === 1 && 'stdout' in error) {
|
|
192
|
-
return String(error.stdout);
|
|
193
|
-
}
|
|
194
|
-
throw error;
|
|
195
|
-
},
|
|
196
|
-
);
|
|
197
|
-
const found: number[] = [];
|
|
198
|
-
let pid = 0;
|
|
199
|
-
for (const line of fields.split('\n')) {
|
|
200
|
-
if (line.startsWith('p')) {
|
|
201
|
-
pid = Number(line.slice(1));
|
|
202
|
-
} else if (line.startsWith('n') && under(line.slice(1))) {
|
|
203
|
-
found.push(pid);
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
return found;
|
|
207
|
-
}
|
|
208
|
-
default:
|
|
209
|
-
throw new Error(`No working-directory scan for ${process.platform}`);
|
|
210
|
-
}
|
|
211
|
-
}
|
|
212
|
-
|
|
213
216
|
/**
|
|
214
|
-
*
|
|
215
|
-
*
|
|
216
|
-
*
|
|
217
|
-
*
|
|
218
|
-
*
|
|
217
|
+
* This process's descendants that still run, as text for a failure report about `subject`, or null when none does.
|
|
218
|
+
* A process is named as this process's own, never for where it works, and no caller signals anything on its word: a
|
|
219
|
+
* process is ended by the owner that started it, the supervisor's observed tree (specs/cowshed/11_shell.md, "Process
|
|
220
|
+
* identity and signal ownership"). One reparented away when its parent exited is no longer this process's to see. A
|
|
221
|
+
* listing that cannot be read says so instead of failing the report it serves.
|
|
219
222
|
*/
|
|
220
|
-
export async function
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
return null;
|
|
231
|
-
}
|
|
232
|
-
throw error;
|
|
233
|
-
});
|
|
234
|
-
const entry = environ?.split('\0').find((variable) => variable.startsWith('TMPDIR='));
|
|
235
|
-
if (entry !== undefined && names(entry.slice('TMPDIR='.length))) {
|
|
236
|
-
found.push(Number(pid));
|
|
237
|
-
}
|
|
238
|
-
}
|
|
239
|
-
return found;
|
|
240
|
-
}
|
|
241
|
-
case 'darwin': {
|
|
242
|
-
// `ps -E` follows each command line with the environment it was started with, as words
|
|
243
|
-
// separated by spaces, and only for this user's processes. A word `TMPDIR=<root>` is matched
|
|
244
|
-
// with what follows it in that word, so a root containing a space is still found whole. An
|
|
245
|
-
// argument spelled `TMPDIR=<root>` names the same directory and counts too: an `env` that
|
|
246
|
-
// sets it is about to run something there. `/bin/ps` by path: a procps `ps` has no `-E`.
|
|
247
|
-
const { stdout } = await run('/bin/ps', ['-E', '-ww', '-U', String(userInfo().uid), '-o', 'pid=,command='], {
|
|
248
|
-
maxBuffer: 256 * 1024 * 1024,
|
|
249
|
-
});
|
|
250
|
-
const token = ` TMPDIR=${root}`;
|
|
251
|
-
const found: number[] = [];
|
|
252
|
-
for (const line of stdout.split('\n')) {
|
|
253
|
-
const row = /^\s*(\d+) (.*)$/.exec(line);
|
|
254
|
-
if (row === null) {
|
|
255
|
-
continue;
|
|
256
|
-
}
|
|
257
|
-
const words = ` ${row[2]}`;
|
|
258
|
-
for (let at = words.indexOf(token); at !== -1; at = words.indexOf(token, at + 1)) {
|
|
259
|
-
if (names(words.slice(at + ' TMPDIR='.length))) {
|
|
260
|
-
found.push(Number(row[1]));
|
|
261
|
-
break;
|
|
262
|
-
}
|
|
263
|
-
}
|
|
264
|
-
}
|
|
265
|
-
return found;
|
|
266
|
-
}
|
|
267
|
-
default:
|
|
268
|
-
throw new Error(`No TMPDIR scan for ${process.platform}`);
|
|
223
|
+
export async function descendantsDiagnostic(subject: string): Promise<string | null> {
|
|
224
|
+
try {
|
|
225
|
+
const named = (await processTree([process.pid]))
|
|
226
|
+
.filter((entry) => entry.pid !== process.pid && !entry.stat.startsWith('Z'))
|
|
227
|
+
.map((entry) => `${entry.pid} (${entry.command.slice(0, 160)})`);
|
|
228
|
+
return named.length === 0
|
|
229
|
+
? null
|
|
230
|
+
: `descendants of this process still run at ${subject}: ${named.join(', ')} (diagnostic only: nothing was signalled)`;
|
|
231
|
+
} catch (error) {
|
|
232
|
+
return `descendants of this process at ${subject} could not be listed: ${error instanceof Error ? error.message : String(error)}`;
|
|
269
233
|
}
|
|
270
234
|
}
|
|
271
235
|
|
|
@@ -296,7 +260,7 @@ export async function nxDaemonProcesses(workspace: string): Promise<ProcessEntry
|
|
|
296
260
|
) {
|
|
297
261
|
throw new Error(`Nx daemon record ${record} names no process id`);
|
|
298
262
|
}
|
|
299
|
-
return
|
|
263
|
+
return processTree([parsed.processId]);
|
|
300
264
|
}
|
|
301
265
|
|
|
302
266
|
/**
|
|
@@ -307,48 +271,26 @@ export async function nxDaemonProcesses(workspace: string): Promise<ProcessEntry
|
|
|
307
271
|
* is free to delete; the processes can. The daemon also leaves what it
|
|
308
272
|
* spawned to end on its own: plugin workers once they see it gone, the editor
|
|
309
273
|
* extension probe it starts at launch never. Those get SIGTERM with it, the
|
|
310
|
-
* ones it started while it was stopping included
|
|
311
|
-
*
|
|
312
|
-
*
|
|
313
|
-
*
|
|
314
|
-
*
|
|
274
|
+
* ones it started while it was stopping included: the daemon's own record
|
|
275
|
+
* names the root, and the walk down its children the rest. A child that
|
|
276
|
+
* outlives the daemon is reparented and leaves that tree; it stays in the
|
|
277
|
+
* tree the job's supervisor observes, which ends it with the test command's
|
|
278
|
+
* subtree (bounded-exec). A missing record can mean startup has not published
|
|
279
|
+
* it yet: then nothing is stopped here.
|
|
315
280
|
*/
|
|
316
281
|
export async function stopNxDaemon(workspace: string, stop: () => Promise<void>): Promise<void> {
|
|
317
282
|
const [daemon, ...before] = await nxDaemonProcesses(workspace);
|
|
318
|
-
if (daemon
|
|
319
|
-
|
|
320
|
-
const known = new Set([daemon.pid, ...before.map((entry) => entry.pid)]);
|
|
321
|
-
const after = withDescendants(await processTable(), [daemon.pid]).filter((entry) => !known.has(entry.pid));
|
|
322
|
-
const spawned = [...before, ...after];
|
|
323
|
-
for (const entry of spawned) {
|
|
324
|
-
terminate(entry.pid);
|
|
325
|
-
}
|
|
326
|
-
await awaitExit([daemon, ...spawned], `Nx daemon of ${workspace}`);
|
|
283
|
+
if (daemon === undefined) {
|
|
284
|
+
return;
|
|
327
285
|
}
|
|
328
|
-
await
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
* another under the workspace only while it is alive, and a child started
|
|
335
|
-
* just before its parent was ended is in the next census. A zombie has
|
|
336
|
-
* exited already, and this process never ends itself.
|
|
337
|
-
*/
|
|
338
|
-
async function endWorkspaceProcesses(workspace: string, owner: string): Promise<void> {
|
|
339
|
-
for (;;) {
|
|
340
|
-
const working = new Set(await pidsWorkingIn(workspace));
|
|
341
|
-
const leftovers = (await processTable()).filter(
|
|
342
|
-
(entry) => working.has(entry.pid) && entry.pid !== process.pid && !entry.stat.startsWith('Z'),
|
|
343
|
-
);
|
|
344
|
-
if (leftovers.length === 0) {
|
|
345
|
-
return;
|
|
346
|
-
}
|
|
347
|
-
for (const entry of leftovers) {
|
|
348
|
-
terminate(entry.pid);
|
|
349
|
-
}
|
|
350
|
-
await awaitExit(leftovers, owner);
|
|
286
|
+
await stop();
|
|
287
|
+
const known = new Set([daemon.pid, ...before.map((entry) => entry.pid)]);
|
|
288
|
+
const after = (await processTree([daemon.pid])).filter((entry) => !known.has(entry.pid));
|
|
289
|
+
const spawned = [...before, ...after];
|
|
290
|
+
for (const entry of spawned) {
|
|
291
|
+
terminate(entry.pid);
|
|
351
292
|
}
|
|
293
|
+
await awaitExit([daemon, ...spawned], `Nx daemon of ${workspace}`);
|
|
352
294
|
}
|
|
353
295
|
|
|
354
296
|
/**
|
|
@@ -428,17 +370,20 @@ function ownRunSignals(): void {
|
|
|
428
370
|
* open failed included, and one failing cuts no other short; each failure is
|
|
429
371
|
* written to stderr with the suite directory of its run. A repeated signal
|
|
430
372
|
* meets a handler, not the default, so it waits for this and neither starts a
|
|
431
|
-
* second reclaim nor kills the first. That wait is the reclaim's own:
|
|
432
|
-
*
|
|
433
|
-
*
|
|
434
|
-
*
|
|
373
|
+
* second reclaim nor kills the first. That wait is the reclaim's own: the
|
|
374
|
+
* report of this process's descendants still running, then for each run, after
|
|
375
|
+
* any sweep it was still opening with, the delete. What a fixture left running
|
|
376
|
+
* is ended by the job's supervisor with the test command's subtree
|
|
377
|
+
* (bounded-exec), not here. A bounded test leg's SIGKILL ends this whatever it
|
|
378
|
+
* is.
|
|
435
379
|
*/
|
|
436
380
|
async function retireRuns(signal: NodeJS.Signals): Promise<void> {
|
|
381
|
+
const left = await descendantsDiagnostic(`its ${signal}`);
|
|
382
|
+
if (left !== null) {
|
|
383
|
+
process.stderr.write(`reclaiming this process's fixture runs: ${left}\n`);
|
|
384
|
+
}
|
|
437
385
|
const runs = [...runDirectories];
|
|
438
|
-
|
|
439
|
-
const outcomes = await Promise.allSettled(
|
|
440
|
-
runs.map(async ([, opened]) => reclaimRun(await opened, 'signalled fixture run', SIGNALLED_GRACE_MS)),
|
|
441
|
-
);
|
|
386
|
+
const outcomes = await Promise.allSettled(runs.map(async ([, opened]) => reclaimRun(await opened)));
|
|
442
387
|
for (const [index, outcome] of outcomes.entries()) {
|
|
443
388
|
if (outcome.status === 'rejected') {
|
|
444
389
|
const reason = outcome.reason instanceof Error ? outcome.reason.message : String(outcome.reason);
|
|
@@ -458,12 +403,13 @@ function refuseWhileRetiring(): void {
|
|
|
458
403
|
}
|
|
459
404
|
|
|
460
405
|
/**
|
|
461
|
-
*
|
|
462
|
-
*
|
|
463
|
-
*
|
|
464
|
-
*
|
|
465
|
-
*
|
|
466
|
-
*
|
|
406
|
+
* Delete every run of `suite` under `parentDirectory` whose owner is gone, and
|
|
407
|
+
* return the suite's directory there. The first fixture root of a suite under a
|
|
408
|
+
* parent in a process does this; a test that just watched a fixture-owning
|
|
409
|
+
* process die may too. An owner's pid reused by an unrelated process makes its
|
|
410
|
+
* run look alive; it is reclaimed once that process is gone too, never early.
|
|
411
|
+
* Nothing still working in a dead run is signalled here: whatever its owner
|
|
412
|
+
* left running belongs to that owner's subtree, which its supervisor retires.
|
|
467
413
|
*/
|
|
468
414
|
export async function reclaimDeadFixtureRuns(parentDirectory: string, suite: string): Promise<string> {
|
|
469
415
|
const suiteDirectory = join(await realpath(parentDirectory), FIXTURE_HOME, suite);
|
|
@@ -495,46 +441,14 @@ async function reclaimDeadRuns(suiteDirectory: string): Promise<void> {
|
|
|
495
441
|
}
|
|
496
442
|
try {
|
|
497
443
|
for (const directory of dead) {
|
|
498
|
-
await reclaimRun(directory
|
|
444
|
+
await reclaimRun(directory);
|
|
499
445
|
}
|
|
500
446
|
} finally {
|
|
501
447
|
await rm(lock, { force: true });
|
|
502
448
|
}
|
|
503
449
|
}
|
|
504
450
|
|
|
505
|
-
async function reclaimRun(directory: string
|
|
506
|
-
const roots = await readdir(directory).catch((error: unknown) => {
|
|
507
|
-
if (errorCode(error) === 'ENOENT') {
|
|
508
|
-
return null;
|
|
509
|
-
}
|
|
510
|
-
throw error;
|
|
511
|
-
});
|
|
512
|
-
if (roots === null) {
|
|
513
|
-
return;
|
|
514
|
-
}
|
|
515
|
-
// A fixture deletes its root only once nothing runs in it, so an emptied
|
|
516
|
-
// run holds no process and needs no scan.
|
|
517
|
-
if (roots.length > 0) {
|
|
518
|
-
const working = await pidsWorkingIn(directory);
|
|
519
|
-
const processes = (await processTable()).filter((entry) => working.includes(entry.pid));
|
|
520
|
-
if (processes.length > 0) {
|
|
521
|
-
process.stderr.write(
|
|
522
|
-
`reclaiming ${owner} ${directory}: ${processes.map((entry) => `${entry.pid} (${entry.command})`).join(', ')}\n`,
|
|
523
|
-
);
|
|
524
|
-
for (const entry of processes) {
|
|
525
|
-
terminate(entry.pid);
|
|
526
|
-
}
|
|
527
|
-
try {
|
|
528
|
-
await awaitExit(processes, `processes of ${owner} ${directory}`, graceMs);
|
|
529
|
-
} catch (error) {
|
|
530
|
-
process.stderr.write(`${error instanceof Error ? error.message : String(error)}; sending SIGKILL\n`);
|
|
531
|
-
for (const entry of processes) {
|
|
532
|
-
terminate(entry.pid, 'SIGKILL');
|
|
533
|
-
}
|
|
534
|
-
await awaitExit(processes, `processes of ${owner} ${directory} after SIGKILL`, graceMs);
|
|
535
|
-
}
|
|
536
|
-
}
|
|
537
|
-
}
|
|
451
|
+
async function reclaimRun(directory: string): Promise<void> {
|
|
538
452
|
// A killed fixture may never have reached its own alias retirement, and its
|
|
539
453
|
// workspace may be gone. The alias is its own record: one whose target is the
|
|
540
454
|
// socket state of a workspace in this reclaimed run, and whose name is that
|
|
@@ -897,7 +811,10 @@ export async function retireFixtureSocketDirectory(workspace: string): Promise<v
|
|
|
897
811
|
type PortBlockEnvironment =
|
|
898
812
|
/** Outside Cowshed, or on Linux: no block, so a listener binds port 0 as usual. */
|
|
899
813
|
| { readonly kind: 'none' }
|
|
900
|
-
/**
|
|
814
|
+
/**
|
|
815
|
+
* The gateway listens on `base`. Fixture listeners take the odd offsets `base+1, base+3, … base+size-1`, the
|
|
816
|
+
* service ports; each even offset above `base` is the session port of the service port above it (08_testing.md).
|
|
817
|
+
*/
|
|
901
818
|
| { readonly kind: 'block'; readonly base: number; readonly size: number }
|
|
902
819
|
| { readonly kind: 'broken'; readonly reason: string };
|
|
903
820
|
|
|
@@ -949,15 +866,51 @@ function portBlockEnvironment(env: NodeJS.ProcessEnv): PortBlockEnvironment {
|
|
|
949
866
|
return { kind: 'block', base, size };
|
|
950
867
|
}
|
|
951
868
|
|
|
869
|
+
/** The block's service ports from `base+first` on, lowest first: its odd offsets (08_testing.md). */
|
|
870
|
+
function servicePorts(block: { readonly base: number; readonly size: number }, first: 1 | 3): number[] {
|
|
871
|
+
const ports: number[] = [];
|
|
872
|
+
for (let offset = first; offset < block.size; offset += 2) ports.push(block.base + offset);
|
|
873
|
+
return ports;
|
|
874
|
+
}
|
|
875
|
+
|
|
876
|
+
/**
|
|
877
|
+
* `bind` on each of `candidates` in turn, and the first that binds. Only `EADDRINUSE` (by `code`) moves on to
|
|
878
|
+
* the next; any other failure is that bind's own and surfaces as is, and so does the last candidate's, so an exhausted
|
|
879
|
+
* block reports `EADDRINUSE`, never a silent port 0.
|
|
880
|
+
*/
|
|
881
|
+
async function bindFirstFree<T>(
|
|
882
|
+
block: { readonly base: number; readonly size: number },
|
|
883
|
+
candidates: readonly number[],
|
|
884
|
+
bind: (port: number) => T | Promise<T>,
|
|
885
|
+
): Promise<T> {
|
|
886
|
+
const last = candidates.at(-1);
|
|
887
|
+
if (last === undefined) {
|
|
888
|
+
throw new Error(`the Cowshed port block ${block.base}+${block.size} has no service port to bind`);
|
|
889
|
+
}
|
|
890
|
+
for (const port of candidates.slice(0, -1)) {
|
|
891
|
+
try {
|
|
892
|
+
return await bind(port);
|
|
893
|
+
} catch (error) {
|
|
894
|
+
if (errorCode(error) !== 'EADDRINUSE') {
|
|
895
|
+
throw error;
|
|
896
|
+
}
|
|
897
|
+
}
|
|
898
|
+
}
|
|
899
|
+
return bind(last);
|
|
900
|
+
}
|
|
901
|
+
|
|
952
902
|
/**
|
|
953
903
|
* Bind a real listener where a Cowshed job's other processes can connect to
|
|
954
|
-
* it. In a block, `bind` is called with each
|
|
955
|
-
* lowest first (a long-lived test listener scans from the
|
|
956
|
-
* first that binds is kept: only a real bind claims a port, so
|
|
957
|
-
* and closes.
|
|
958
|
-
*
|
|
959
|
-
*
|
|
960
|
-
*
|
|
904
|
+
* it. In a block, `bind` is called with each service port `base+1, base+3, …
|
|
905
|
+
* base+size-1`, lowest first (a long-lived test listener scans from the
|
|
906
|
+
* bottom), and the first that binds is kept: only a real bind claims a port, so
|
|
907
|
+
* nothing probes and closes. Even offsets are never candidates: each is the
|
|
908
|
+
* session port of the service port above it, bound by that port's holder or by
|
|
909
|
+
* nobody (08_testing.md), which is what `claimRefusingPort` relies on. Only
|
|
910
|
+
* `EADDRINUSE` (by `code`) moves on to the next candidate; any other failure
|
|
911
|
+
* is that bind's own and surfaces as is, and so does the last candidate's, so an
|
|
912
|
+
* exhausted block reports `EADDRINUSE`, never a silent port 0. Outside a block
|
|
913
|
+
* `bind` is called with 0, and the kernel picks.
|
|
961
914
|
*
|
|
962
915
|
* `bind` creates and binds one listener per call and returns it, and a failed
|
|
963
916
|
* bind leaves nothing behind. It may throw (`Bun.serve` does) or reject (a
|
|
@@ -972,18 +925,73 @@ export async function bindListener<T>(bind: (port: number) => T | Promise<T>): P
|
|
|
972
925
|
return bind(0);
|
|
973
926
|
case 'broken':
|
|
974
927
|
throw new Error(`a listener cannot bind in a broken Cowshed port-block environment: ${block.reason}`);
|
|
928
|
+
case 'block':
|
|
929
|
+
return bindFirstFree(block, servicePorts(block, 1), bind);
|
|
930
|
+
}
|
|
931
|
+
}
|
|
932
|
+
|
|
933
|
+
/**
|
|
934
|
+
* A loopback port where nothing listens. In a port block it stays out of every other fixture's reach while it is held,
|
|
935
|
+
* and disposing it lets it go; outside one nothing claims it, and disposing it does nothing (`claimRefusingPort`).
|
|
936
|
+
*/
|
|
937
|
+
export interface RefusingPort extends AsyncDisposable {
|
|
938
|
+
readonly port: number;
|
|
939
|
+
}
|
|
940
|
+
|
|
941
|
+
/** A `net` server on 127.0.0.1:`port` that hangs up on whoever connects; rejects with the bind's own error. */
|
|
942
|
+
function listenHangingUp(port: number): Promise<Server> {
|
|
943
|
+
return new Promise((resolve, reject) => {
|
|
944
|
+
const server = createServer((socket) => socket.destroy());
|
|
945
|
+
server.once('error', reject);
|
|
946
|
+
server.listen(port, '127.0.0.1', () => {
|
|
947
|
+
server.off('error', reject);
|
|
948
|
+
resolve(server);
|
|
949
|
+
});
|
|
950
|
+
});
|
|
951
|
+
}
|
|
952
|
+
|
|
953
|
+
function closeServer(server: Server): Promise<void> {
|
|
954
|
+
return new Promise((resolve, reject) => server.close((error) => (error ? reject(error) : resolve())));
|
|
955
|
+
}
|
|
956
|
+
|
|
957
|
+
/** The TCP port `server` listens on. */
|
|
958
|
+
function listeningPort(server: Server): number {
|
|
959
|
+
const address = server.address();
|
|
960
|
+
if (address === null || typeof address === 'string') throw new Error(`not a TCP listener: ${String(address)}`);
|
|
961
|
+
return address.port;
|
|
962
|
+
}
|
|
963
|
+
|
|
964
|
+
/**
|
|
965
|
+
* A port where nothing listens, for a client that must be refused (a cache
|
|
966
|
+
* server that is down). In a block it is the session port of a service port
|
|
967
|
+
* this process holds for as long as the claim is held: no allocator binds a
|
|
968
|
+
* session port but its service port's holder (08_testing.md), so a connect to
|
|
969
|
+
* it is refused at once, and no other test's listener takes it while the client
|
|
970
|
+
* is still asking. A port bound and closed would be the next lowest-first
|
|
971
|
+
* allocator's to bind; a socket bound and never listening is no refusal either,
|
|
972
|
+
* since macOS drops the SYNs it gets and the connect times out. The service
|
|
973
|
+
* ports start at `base+3`, because the session port of `base+1` is the
|
|
974
|
+
* gateway's own `base`; a block of two ports has no session port to give.
|
|
975
|
+
*
|
|
976
|
+
* Outside a block (Linux, or no Cowshed) there is no shared allocator to claim
|
|
977
|
+
* against, so there is no claim: the port is one the kernel picked for a
|
|
978
|
+
* listener this process then closed, and another process's port-0 listener may
|
|
979
|
+
* be given it before the client connects.
|
|
980
|
+
*/
|
|
981
|
+
export async function claimRefusingPort(): Promise<RefusingPort> {
|
|
982
|
+
const block = portBlockEnvironment(process.env);
|
|
983
|
+
switch (block.kind) {
|
|
984
|
+
case 'none': {
|
|
985
|
+
const server = await listenHangingUp(0);
|
|
986
|
+
const port = listeningPort(server);
|
|
987
|
+
await closeServer(server);
|
|
988
|
+
return { port, [Symbol.asyncDispose]: async () => {} };
|
|
989
|
+
}
|
|
990
|
+
case 'broken':
|
|
991
|
+
throw new Error(`a refusing port cannot be claimed in a broken Cowshed port-block environment: ${block.reason}`);
|
|
975
992
|
case 'block': {
|
|
976
|
-
const
|
|
977
|
-
|
|
978
|
-
try {
|
|
979
|
-
return await bind(port);
|
|
980
|
-
} catch (error) {
|
|
981
|
-
if (errorCode(error) !== 'EADDRINUSE') {
|
|
982
|
-
throw error;
|
|
983
|
-
}
|
|
984
|
-
}
|
|
985
|
-
}
|
|
986
|
-
return bind(last);
|
|
993
|
+
const service = await bindFirstFree(block, servicePorts(block, 3), listenHangingUp);
|
|
994
|
+
return { port: listeningPort(service) - 1, [Symbol.asyncDispose]: () => closeServer(service) };
|
|
987
995
|
}
|
|
988
996
|
}
|
|
989
997
|
}
|