@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
|
@@ -1,684 +0,0 @@
|
|
|
1
|
-
import { afterEach, describe, expect, it } from 'bun:test';
|
|
2
|
-
import {
|
|
3
|
-
chmodSync,
|
|
4
|
-
closeSync,
|
|
5
|
-
constants,
|
|
6
|
-
existsSync,
|
|
7
|
-
mkdirSync,
|
|
8
|
-
openSync,
|
|
9
|
-
readdirSync,
|
|
10
|
-
readSync,
|
|
11
|
-
rmSync,
|
|
12
|
-
statSync,
|
|
13
|
-
writeSync,
|
|
14
|
-
} from 'node:fs';
|
|
15
|
-
import { writeFile } from 'node:fs/promises';
|
|
16
|
-
import { connect, type Socket } from 'node:net';
|
|
17
|
-
import { dirname, join } from 'node:path';
|
|
18
|
-
import typia from 'typia';
|
|
19
|
-
import { ownedSocketDirectory, socketNamespace } from '../../testing.js';
|
|
20
|
-
import {
|
|
21
|
-
CPU_POOL_ENV,
|
|
22
|
-
type CpuPool,
|
|
23
|
-
createCpuPool,
|
|
24
|
-
type HostWaits,
|
|
25
|
-
type InheritedCpuPool,
|
|
26
|
-
readInheritedCpuPool,
|
|
27
|
-
takeParentCpuTokens,
|
|
28
|
-
} from './cpu-pool.js';
|
|
29
|
-
import { CPU_TOKENS_ENV, type TokenGrant } from './cpu-tokens.js';
|
|
30
|
-
|
|
31
|
-
/** The pool's replies as the wire carries them, one line each. */
|
|
32
|
-
type PoolReply =
|
|
33
|
-
| { ok: true; lease: 'queued' }
|
|
34
|
-
| { ok: true; lease: 'granted'; tokens: number; pool?: string }
|
|
35
|
-
| { ok: true; wait: 'held' }
|
|
36
|
-
| { ok: false; code: 'invalid-request'; error: string };
|
|
37
|
-
|
|
38
|
-
const parseReply = typia.json.createAssertParse<PoolReply>();
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* A run's host waits as the pool reports them: how many are held now, every begin and end in order, and `reaches(n)`,
|
|
42
|
-
* which resolves once the count is `n` (the pool hears a close after its client does).
|
|
43
|
-
*/
|
|
44
|
-
interface CountedWaits extends HostWaits {
|
|
45
|
-
readonly held: () => number;
|
|
46
|
-
readonly events: ('begin' | 'end')[];
|
|
47
|
-
reaches(count: number): Promise<void>;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
function countedWaits(): CountedWaits {
|
|
51
|
-
const events: ('begin' | 'end')[] = [];
|
|
52
|
-
const watchers: { count: number; done: () => void }[] = [];
|
|
53
|
-
let held = 0;
|
|
54
|
-
const changed = (): void => {
|
|
55
|
-
for (const watcher of watchers.filter((each) => each.count === held)) {
|
|
56
|
-
watchers.splice(watchers.indexOf(watcher), 1);
|
|
57
|
-
watcher.done();
|
|
58
|
-
}
|
|
59
|
-
};
|
|
60
|
-
return {
|
|
61
|
-
held: () => held,
|
|
62
|
-
events,
|
|
63
|
-
reaches: (count) =>
|
|
64
|
-
count === held ? Promise.resolve() : new Promise<void>((done) => watchers.push({ count, done })),
|
|
65
|
-
begin: () => {
|
|
66
|
-
held += 1;
|
|
67
|
-
events.push('begin');
|
|
68
|
-
changed();
|
|
69
|
-
},
|
|
70
|
-
end: () => {
|
|
71
|
-
held -= 1;
|
|
72
|
-
events.push('end');
|
|
73
|
-
changed();
|
|
74
|
-
},
|
|
75
|
-
};
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
type Granted = Extract<TokenGrant, { granted: true }>;
|
|
79
|
-
|
|
80
|
-
/** A raw child connection: its replies come one line at a time, and `closed` resolves when it ends. */
|
|
81
|
-
interface Child {
|
|
82
|
-
readonly socket: Socket;
|
|
83
|
-
readonly closed: Promise<void>;
|
|
84
|
-
next(): Promise<PoolReply>;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
interface Opened {
|
|
88
|
-
readonly pool: CpuPool;
|
|
89
|
-
readonly parent: InheritedCpuPool;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
const NEVER: Promise<void> = new Promise<void>(() => {});
|
|
93
|
-
const QUEUED: PoolReply = { ok: true, lease: 'queued' };
|
|
94
|
-
const pools: CpuPool[] = [];
|
|
95
|
-
const sockets: Socket[] = [];
|
|
96
|
-
const directories: string[] = [];
|
|
97
|
-
// Descriptors a test opened on a pool's jobserver fifo, as a make-protocol client does.
|
|
98
|
-
const descriptors: number[] = [];
|
|
99
|
-
|
|
100
|
-
afterEach(async () => {
|
|
101
|
-
for (const socket of sockets.splice(0)) {
|
|
102
|
-
socket.destroy();
|
|
103
|
-
}
|
|
104
|
-
for (const fd of descriptors.splice(0)) {
|
|
105
|
-
closeSync(fd);
|
|
106
|
-
}
|
|
107
|
-
for (const pool of pools.splice(0)) {
|
|
108
|
-
// Every pool a test leaves open is closed here, and its outcome is asserted, not dropped.
|
|
109
|
-
expect(await pool.close()).toEqual({ ok: true });
|
|
110
|
-
}
|
|
111
|
-
for (const directory of directories.splice(0)) {
|
|
112
|
-
rmSync(directory, { recursive: true, force: true });
|
|
113
|
-
}
|
|
114
|
-
});
|
|
115
|
-
|
|
116
|
-
/** Make a pool of `tokens` and read its endpoint back through the same path a child uses. */
|
|
117
|
-
async function openPool(
|
|
118
|
-
tokens: number,
|
|
119
|
-
closed: Promise<void> = NEVER,
|
|
120
|
-
waits: HostWaits = countedWaits(),
|
|
121
|
-
): Promise<Opened> {
|
|
122
|
-
const made = await createCpuPool(tokens, closed, waits);
|
|
123
|
-
if (!made.ok) {
|
|
124
|
-
throw new Error(made.error);
|
|
125
|
-
}
|
|
126
|
-
pools.push(made.pool);
|
|
127
|
-
const parent = readInheritedCpuPool(made.pool.environment);
|
|
128
|
-
if (parent === null) {
|
|
129
|
-
throw new Error('the pool environment names no endpoint');
|
|
130
|
-
}
|
|
131
|
-
return { pool: made.pool, parent };
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
/** A granted lease for a child that the pool must admit: a refusal here is a test failure. */
|
|
135
|
-
async function takeOrThrow(parent: InheritedCpuPool, want: number): Promise<Granted> {
|
|
136
|
-
const grant = await takeParentCpuTokens(parent, want);
|
|
137
|
-
if (!grant.granted) {
|
|
138
|
-
throw new Error(`the pool refused ${want} tokens: ${grant.reason}`);
|
|
139
|
-
}
|
|
140
|
-
return grant;
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
/**
|
|
144
|
-
* The count a child is granted for `want`. The grant is released and its close awaited before
|
|
145
|
-
* returning, so the next ask starts from the pool as this one left it.
|
|
146
|
-
*/
|
|
147
|
-
async function grantedFor(parent: InheritedCpuPool, want: number): Promise<number> {
|
|
148
|
-
const grant = await takeParentCpuTokens(parent, want);
|
|
149
|
-
if (!grant.granted) {
|
|
150
|
-
throw new Error(`the pool refused ${want} tokens: ${grant.reason}`);
|
|
151
|
-
}
|
|
152
|
-
grant.release();
|
|
153
|
-
await grant.closed;
|
|
154
|
-
return grant.tokens;
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
/** The pool directories in the socket namespace right now; a closed pool leaves none behind. */
|
|
158
|
-
const cpuPoolDirectories = (): string[] =>
|
|
159
|
-
readdirSync(socketNamespace().directory)
|
|
160
|
-
.filter((name) => name.startsWith('cpu-pool-'))
|
|
161
|
-
.sort();
|
|
162
|
-
|
|
163
|
-
/**
|
|
164
|
-
* A raw child: connects, writes `request` as its one line, and reads the replies. The child's
|
|
165
|
-
* socket errors are recorded and surfaced by `next()`, never dropped.
|
|
166
|
-
*/
|
|
167
|
-
function childOf(endpoint: string, request: string): Child {
|
|
168
|
-
const socket = connect(endpoint);
|
|
169
|
-
sockets.push(socket);
|
|
170
|
-
socket.setEncoding('utf8');
|
|
171
|
-
const lines: string[] = [];
|
|
172
|
-
let buffered = '';
|
|
173
|
-
let ended = false;
|
|
174
|
-
let failure: Error | undefined;
|
|
175
|
-
let wake: (() => void) | undefined;
|
|
176
|
-
const rouse = (): void => {
|
|
177
|
-
const resume = wake;
|
|
178
|
-
wake = undefined;
|
|
179
|
-
resume?.();
|
|
180
|
-
};
|
|
181
|
-
socket.on('connect', () => {
|
|
182
|
-
socket.write(`${request}\n`);
|
|
183
|
-
});
|
|
184
|
-
socket.on('data', (chunk: string) => {
|
|
185
|
-
buffered += chunk;
|
|
186
|
-
for (let newline = buffered.indexOf('\n'); newline !== -1; newline = buffered.indexOf('\n')) {
|
|
187
|
-
lines.push(buffered.slice(0, newline));
|
|
188
|
-
buffered = buffered.slice(newline + 1);
|
|
189
|
-
}
|
|
190
|
-
rouse();
|
|
191
|
-
});
|
|
192
|
-
socket.on('error', (error: Error) => {
|
|
193
|
-
failure = error;
|
|
194
|
-
rouse();
|
|
195
|
-
});
|
|
196
|
-
const closed = new Promise<void>((resolve) => {
|
|
197
|
-
socket.once('close', () => {
|
|
198
|
-
ended = true;
|
|
199
|
-
rouse();
|
|
200
|
-
resolve();
|
|
201
|
-
});
|
|
202
|
-
});
|
|
203
|
-
return {
|
|
204
|
-
socket,
|
|
205
|
-
closed,
|
|
206
|
-
async next(): Promise<PoolReply> {
|
|
207
|
-
for (;;) {
|
|
208
|
-
const line = lines.shift();
|
|
209
|
-
if (line !== undefined) {
|
|
210
|
-
return parseReply(line);
|
|
211
|
-
}
|
|
212
|
-
if (ended) {
|
|
213
|
-
throw (
|
|
214
|
-
failure ?? new Error(`the pool closed before replying to ${request.slice(0, 80)} (${request.length} bytes)`)
|
|
215
|
-
);
|
|
216
|
-
}
|
|
217
|
-
await new Promise<void>((resolve) => {
|
|
218
|
-
wake = resolve;
|
|
219
|
-
});
|
|
220
|
-
}
|
|
221
|
-
},
|
|
222
|
-
};
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
/** Read a child process's stdout until `marker` has been printed. */
|
|
226
|
-
async function untilLine(stream: ReadableStream<Uint8Array>, marker: string): Promise<void> {
|
|
227
|
-
const reader = stream.getReader();
|
|
228
|
-
const decoder = new TextDecoder();
|
|
229
|
-
let text = '';
|
|
230
|
-
while (!text.includes(marker)) {
|
|
231
|
-
const next = await reader.read();
|
|
232
|
-
if (next.done) {
|
|
233
|
-
throw new Error(`the child exited before printing ${marker}: ${text}`);
|
|
234
|
-
}
|
|
235
|
-
text += decoder.decode(next.value, { stream: true });
|
|
236
|
-
}
|
|
237
|
-
reader.releaseLock();
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
/** The fifo a pool's environment names for Cargo and make, which name the same one. */
|
|
241
|
-
function jobserverFifo(pool: CpuPool): string {
|
|
242
|
-
const flags = pool.environment.CARGO_MAKEFLAGS ?? '';
|
|
243
|
-
expect(pool.environment.MAKEFLAGS).toBe(flags);
|
|
244
|
-
const named = /^-j --jobserver-auth=fifo:(\/\S+)$/.exec(flags)?.[1];
|
|
245
|
-
if (named === undefined) {
|
|
246
|
-
throw new Error(`the pool names no jobserver fifo: ${JSON.stringify(pool.environment)}`);
|
|
247
|
-
}
|
|
248
|
-
return named;
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
/**
|
|
252
|
-
* A make-protocol client of `fifo`, opened read-write as Cargo opens it, and non-blocking here so that `take` reads
|
|
253
|
-
* what the fifo holds now and an empty fifo reads 0.
|
|
254
|
-
*/
|
|
255
|
-
function jobserverClient(fifo: string): { take(most: number): number; give(count: number): void } {
|
|
256
|
-
const fd = openSync(fifo, constants.O_RDWR | constants.O_NONBLOCK);
|
|
257
|
-
descriptors.push(fd);
|
|
258
|
-
return {
|
|
259
|
-
take(most) {
|
|
260
|
-
try {
|
|
261
|
-
return readSync(fd, Buffer.alloc(most), 0, most, null);
|
|
262
|
-
} catch (error) {
|
|
263
|
-
if (error instanceof Error && 'code' in error && error.code === 'EAGAIN') return 0;
|
|
264
|
-
throw error;
|
|
265
|
-
}
|
|
266
|
-
},
|
|
267
|
-
give(count) {
|
|
268
|
-
expect(writeSync(fd, Buffer.alloc(count, '+'))).toBe(count);
|
|
269
|
-
},
|
|
270
|
-
};
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
/** Wait for `count` token bytes in `fifo` and take them, as a blocked Cargo does; resolves to the count it took. */
|
|
274
|
-
async function awaitTokens(fifo: string, count: number): Promise<number> {
|
|
275
|
-
const fd = openSync(fifo, constants.O_RDONLY | constants.O_NONBLOCK);
|
|
276
|
-
const reader = Bun.file(fd).stream().getReader();
|
|
277
|
-
let taken = 0;
|
|
278
|
-
try {
|
|
279
|
-
while (taken < count) {
|
|
280
|
-
const chunk = await reader.read();
|
|
281
|
-
if (chunk.done) break;
|
|
282
|
-
taken += chunk.value.byteLength;
|
|
283
|
-
}
|
|
284
|
-
} finally {
|
|
285
|
-
await reader.cancel();
|
|
286
|
-
closeSync(fd);
|
|
287
|
-
}
|
|
288
|
-
return taken;
|
|
289
|
-
}
|
|
290
|
-
|
|
291
|
-
describe('the parent-held CPU pool', () => {
|
|
292
|
-
it('serves an allocation as its own live child pool without competing with the occupied ancestor', async () => {
|
|
293
|
-
const { parent, pool } = await openPool(4);
|
|
294
|
-
const cargo = childOf(parent.socket, JSON.stringify({ op: 'cpu-pool', want: 4, children: true }));
|
|
295
|
-
expect(await cargo.next()).toEqual(QUEUED);
|
|
296
|
-
const granted = await cargo.next();
|
|
297
|
-
if (!granted.ok || !('lease' in granted) || granted.lease !== 'granted' || granted.pool === undefined)
|
|
298
|
-
throw new Error('no live child pool granted');
|
|
299
|
-
expect(granted.tokens).toBe(4);
|
|
300
|
-
expect(granted.pool).not.toBe(parent.socket);
|
|
301
|
-
const sibling = childOf(parent.socket, JSON.stringify({ op: 'cpu-pool', want: 1 }));
|
|
302
|
-
expect(await sibling.next()).toEqual(QUEUED);
|
|
303
|
-
const a = childOf(granted.pool, JSON.stringify({ op: 'cpu-pool', want: 3 }));
|
|
304
|
-
const b = childOf(granted.pool, JSON.stringify({ op: 'cpu-pool', want: 3 }));
|
|
305
|
-
expect(await a.next()).toEqual(QUEUED);
|
|
306
|
-
expect(await a.next()).toEqual({ ok: true, lease: 'granted', tokens: 3 });
|
|
307
|
-
expect(await b.next()).toEqual(QUEUED);
|
|
308
|
-
expect(await b.next()).toEqual({ ok: true, lease: 'granted', tokens: 1 });
|
|
309
|
-
cargo.socket.destroy();
|
|
310
|
-
await cargo.closed;
|
|
311
|
-
await Promise.all([a.closed, b.closed]);
|
|
312
|
-
expect(await sibling.next()).toEqual({ ok: true, lease: 'granted', tokens: 1 });
|
|
313
|
-
sibling.socket.destroy();
|
|
314
|
-
await sibling.closed;
|
|
315
|
-
expect(await pool.close()).toEqual({ ok: true });
|
|
316
|
-
expect(existsSync(granted.pool)).toBe(false);
|
|
317
|
-
});
|
|
318
|
-
it('admits queued children first-in, first-out, each at most its want', async () => {
|
|
319
|
-
const { parent } = await openPool(4);
|
|
320
|
-
const a = childOf(parent.socket, JSON.stringify({ op: 'cpu-pool', want: 3 }));
|
|
321
|
-
expect(await a.next()).toEqual(QUEUED);
|
|
322
|
-
expect(await a.next()).toEqual({ ok: true, lease: 'granted', tokens: 3 });
|
|
323
|
-
const b = childOf(parent.socket, JSON.stringify({ op: 'cpu-pool', want: 2 }));
|
|
324
|
-
expect(await b.next()).toEqual(QUEUED);
|
|
325
|
-
expect(await b.next()).toEqual({ ok: true, lease: 'granted', tokens: 1 });
|
|
326
|
-
const c = childOf(parent.socket, JSON.stringify({ op: 'cpu-pool', want: 2 }));
|
|
327
|
-
expect(await c.next()).toEqual(QUEUED);
|
|
328
|
-
const d = childOf(parent.socket, JSON.stringify({ op: 'cpu-pool', want: 3 }));
|
|
329
|
-
expect(await d.next()).toEqual(QUEUED);
|
|
330
|
-
a.socket.destroy();
|
|
331
|
-
expect(await c.next()).toEqual({ ok: true, lease: 'granted', tokens: 2 });
|
|
332
|
-
expect(await d.next()).toEqual({ ok: true, lease: 'granted', tokens: 1 });
|
|
333
|
-
});
|
|
334
|
-
|
|
335
|
-
it('never grants more than the pool holds, and admits queued siblings in arrival order', async () => {
|
|
336
|
-
const { parent } = await openPool(4);
|
|
337
|
-
const request = JSON.stringify({ op: 'cpu-pool', want: 2 });
|
|
338
|
-
const one = childOf(parent.socket, request);
|
|
339
|
-
expect(await one.next()).toEqual(QUEUED);
|
|
340
|
-
expect(await one.next()).toEqual({ ok: true, lease: 'granted', tokens: 2 });
|
|
341
|
-
const two = childOf(parent.socket, request);
|
|
342
|
-
expect(await two.next()).toEqual(QUEUED);
|
|
343
|
-
expect(await two.next()).toEqual({ ok: true, lease: 'granted', tokens: 2 });
|
|
344
|
-
// Two siblings of two hold all four tokens: each later sibling queues, and holds nothing.
|
|
345
|
-
const third = childOf(parent.socket, request);
|
|
346
|
-
expect(await third.next()).toEqual(QUEUED);
|
|
347
|
-
const fourth = childOf(parent.socket, request);
|
|
348
|
-
expect(await fourth.next()).toEqual(QUEUED);
|
|
349
|
-
const fifth = childOf(parent.socket, request);
|
|
350
|
-
expect(await fifth.next()).toEqual(QUEUED);
|
|
351
|
-
const sixth = childOf(parent.socket, request);
|
|
352
|
-
expect(await sixth.next()).toEqual(QUEUED);
|
|
353
|
-
one.socket.destroy();
|
|
354
|
-
expect(await third.next()).toEqual({ ok: true, lease: 'granted', tokens: 2 });
|
|
355
|
-
two.socket.destroy();
|
|
356
|
-
expect(await fourth.next()).toEqual({ ok: true, lease: 'granted', tokens: 2 });
|
|
357
|
-
third.socket.destroy();
|
|
358
|
-
expect(await fifth.next()).toEqual({ ok: true, lease: 'granted', tokens: 2 });
|
|
359
|
-
fourth.socket.destroy();
|
|
360
|
-
expect(await sixth.next()).toEqual({ ok: true, lease: 'granted', tokens: 2 });
|
|
361
|
-
});
|
|
362
|
-
|
|
363
|
-
it('drops a queued child that closes, and still admits the next child', async () => {
|
|
364
|
-
const { parent } = await openPool(4);
|
|
365
|
-
const holder = childOf(parent.socket, JSON.stringify({ op: 'cpu-pool', want: 4 }));
|
|
366
|
-
expect(await holder.next()).toEqual(QUEUED);
|
|
367
|
-
expect(await holder.next()).toEqual({ ok: true, lease: 'granted', tokens: 4 });
|
|
368
|
-
const queued = childOf(parent.socket, JSON.stringify({ op: 'cpu-pool', want: 2 }));
|
|
369
|
-
expect(await queued.next()).toEqual(QUEUED);
|
|
370
|
-
queued.socket.destroy();
|
|
371
|
-
await queued.closed;
|
|
372
|
-
// The server may process the two closes in either order: a dropped waiter is never granted, so
|
|
373
|
-
// the next child gets its tokens in both orders.
|
|
374
|
-
holder.socket.destroy();
|
|
375
|
-
const next = childOf(parent.socket, JSON.stringify({ op: 'cpu-pool', want: 2 }));
|
|
376
|
-
expect(await next.next()).toEqual(QUEUED);
|
|
377
|
-
expect(await next.next()).toEqual({ ok: true, lease: 'granted', tokens: 2 });
|
|
378
|
-
});
|
|
379
|
-
|
|
380
|
-
it("returns a SIGKILLed holder's tokens to its queued sibling", async () => {
|
|
381
|
-
const { parent } = await openPool(4);
|
|
382
|
-
// A plain Node-API child: it needs no typia transform, and SIGKILL closes its socket as a crash does.
|
|
383
|
-
// Its connected socket keeps the child alive, so it needs no timer.
|
|
384
|
-
const holder = Bun.spawn(
|
|
385
|
-
[
|
|
386
|
-
process.execPath,
|
|
387
|
-
'-e',
|
|
388
|
-
`
|
|
389
|
-
const { connect } = require('node:net');
|
|
390
|
-
const socket = connect(${JSON.stringify(parent.socket)});
|
|
391
|
-
socket.on('connect', () => socket.write('{"op":"cpu-pool","want":2}\\n'));
|
|
392
|
-
socket.on('data', (chunk) => process.stdout.write(chunk));
|
|
393
|
-
`,
|
|
394
|
-
],
|
|
395
|
-
{ stdout: 'pipe', stderr: 'inherit' },
|
|
396
|
-
);
|
|
397
|
-
try {
|
|
398
|
-
await untilLine(holder.stdout, '"granted"');
|
|
399
|
-
const filler = childOf(parent.socket, JSON.stringify({ op: 'cpu-pool', want: 2 }));
|
|
400
|
-
expect(await filler.next()).toEqual(QUEUED);
|
|
401
|
-
expect(await filler.next()).toEqual({ ok: true, lease: 'granted', tokens: 2 });
|
|
402
|
-
const sibling = childOf(parent.socket, JSON.stringify({ op: 'cpu-pool', want: 2 }));
|
|
403
|
-
expect(await sibling.next()).toEqual(QUEUED);
|
|
404
|
-
holder.kill('SIGKILL');
|
|
405
|
-
await holder.exited;
|
|
406
|
-
expect(await sibling.next()).toEqual({ ok: true, lease: 'granted', tokens: 2 });
|
|
407
|
-
} finally {
|
|
408
|
-
holder.kill('SIGKILL');
|
|
409
|
-
await holder.exited;
|
|
410
|
-
}
|
|
411
|
-
});
|
|
412
|
-
|
|
413
|
-
it('treats a dead or non-socket endpoint as absent, and a malformed endpoint as no pool', async () => {
|
|
414
|
-
const { pool, parent } = await openPool(2);
|
|
415
|
-
expect(await pool.close()).toEqual({ ok: true });
|
|
416
|
-
expect(await takeParentCpuTokens(parent, 1)).toMatchObject({ granted: false, cause: 'absent' });
|
|
417
|
-
|
|
418
|
-
const stale = await ownedSocketDirectory('cpu-stale-', 'p.sock');
|
|
419
|
-
directories.push(stale);
|
|
420
|
-
await writeFile(join(stale, 'p.sock'), 'not a socket');
|
|
421
|
-
expect(await takeParentCpuTokens({ socket: join(stale, 'p.sock'), tokens: 2 }, 1)).toMatchObject({
|
|
422
|
-
granted: false,
|
|
423
|
-
cause: 'absent',
|
|
424
|
-
});
|
|
425
|
-
|
|
426
|
-
expect(readInheritedCpuPool({ [CPU_POOL_ENV]: 'a\0b', [CPU_TOKENS_ENV]: '2' })).toBeNull();
|
|
427
|
-
expect(await takeParentCpuTokens({ socket: 'a\0b', tokens: 2 }, 1)).toMatchObject({
|
|
428
|
-
granted: false,
|
|
429
|
-
cause: 'other',
|
|
430
|
-
});
|
|
431
|
-
expect(readInheritedCpuPool({ [CPU_POOL_ENV]: '', [CPU_TOKENS_ENV]: '2' })).toBeNull();
|
|
432
|
-
expect(readInheritedCpuPool({ [CPU_POOL_ENV]: '/tmp/p.sock' })).toBeNull();
|
|
433
|
-
expect(readInheritedCpuPool({ [CPU_TOKENS_ENV]: '4' })).toBeNull();
|
|
434
|
-
});
|
|
435
|
-
|
|
436
|
-
it("reads a resident's relay pool: zero beside its endpoint, never bare or malformed", () => {
|
|
437
|
-
const relay = '/tmp/relay.sock';
|
|
438
|
-
// The relay pool holds no token for its lifetime and asks the host for each child, so it names 0.
|
|
439
|
-
expect(readInheritedCpuPool({ [CPU_POOL_ENV]: relay, [CPU_TOKENS_ENV]: '0' })).toEqual({
|
|
440
|
-
socket: relay,
|
|
441
|
-
tokens: 0,
|
|
442
|
-
});
|
|
443
|
-
// A bare zero proves nothing, as any bare count does, and zero does not relax the endpoint's rules.
|
|
444
|
-
expect(readInheritedCpuPool({ [CPU_TOKENS_ENV]: '0' })).toBeNull();
|
|
445
|
-
expect(readInheritedCpuPool({ [CPU_POOL_ENV]: '', [CPU_TOKENS_ENV]: '0' })).toBeNull();
|
|
446
|
-
expect(readInheritedCpuPool({ [CPU_POOL_ENV]: 'a\0b', [CPU_TOKENS_ENV]: '0' })).toBeNull();
|
|
447
|
-
// Zero is the one non-positive count: its other spellings, negatives and unsafe integers stay malformed.
|
|
448
|
-
for (const malformed of ['-1', '-0', '+0', '00', '0.0', ' 0', '0 ', '', '9007199254740993']) {
|
|
449
|
-
expect(readInheritedCpuPool({ [CPU_POOL_ENV]: relay, [CPU_TOKENS_ENV]: malformed })).toBeNull();
|
|
450
|
-
}
|
|
451
|
-
});
|
|
452
|
-
|
|
453
|
-
it('names its endpoint, count and jobserver fifo in private owned paths, and removes them on close', async () => {
|
|
454
|
-
const made = await createCpuPool(3, NEVER, countedWaits());
|
|
455
|
-
if (!made.ok) {
|
|
456
|
-
throw new Error(made.error);
|
|
457
|
-
}
|
|
458
|
-
pools.push(made.pool);
|
|
459
|
-
const inherited = readInheritedCpuPool(made.pool.environment);
|
|
460
|
-
if (inherited === null) {
|
|
461
|
-
throw new Error('the pool environment names no endpoint');
|
|
462
|
-
}
|
|
463
|
-
expect(inherited.tokens).toBe(3);
|
|
464
|
-
expect(made.pool.environment[CPU_TOKENS_ENV]).toBe('3');
|
|
465
|
-
expect(statSync(dirname(inherited.socket)).mode & 0o777).toBe(0o700);
|
|
466
|
-
expect(statSync(inherited.socket).mode & 0o777).toBe(0o600);
|
|
467
|
-
// The jobserver fifo lies beside the socket, as private, and holds the pool's tokens but the implicit first.
|
|
468
|
-
const fifo = jobserverFifo(made.pool);
|
|
469
|
-
expect(dirname(fifo)).toBe(dirname(inherited.socket));
|
|
470
|
-
expect(statSync(fifo).isFIFO()).toBe(true);
|
|
471
|
-
expect(statSync(fifo).mode & 0o777).toBe(0o600);
|
|
472
|
-
const cargo = jobserverClient(fifo);
|
|
473
|
-
expect(cargo.take(3)).toBe(2);
|
|
474
|
-
cargo.give(2);
|
|
475
|
-
expect(await made.pool.close()).toEqual({ ok: true });
|
|
476
|
-
expect(await made.pool.close()).toEqual({ ok: true });
|
|
477
|
-
expect(existsSync(fifo)).toBe(false);
|
|
478
|
-
expect(existsSync(dirname(inherited.socket))).toBe(false);
|
|
479
|
-
});
|
|
480
|
-
|
|
481
|
-
it('refuses each malformed request, and keeps admitting valid ones', async () => {
|
|
482
|
-
const { parent } = await openPool(2);
|
|
483
|
-
const malformed = [
|
|
484
|
-
'not json',
|
|
485
|
-
'{"op":"other","want":1}',
|
|
486
|
-
'{"op":"cpu-pool","want":0}',
|
|
487
|
-
'{"op":"cpu-pool","want":1.5}',
|
|
488
|
-
// A grant never grows, so `grow` is a field like any other this pool does not read.
|
|
489
|
-
'{"op":"cpu-pool","want":1,"grow":true}',
|
|
490
|
-
'x'.repeat(5000),
|
|
491
|
-
'x'.repeat(1024 * 1024),
|
|
492
|
-
];
|
|
493
|
-
for (const line of malformed) {
|
|
494
|
-
const refused = childOf(parent.socket, line);
|
|
495
|
-
expect(await refused.next()).toMatchObject({ ok: false, code: 'invalid-request' });
|
|
496
|
-
}
|
|
497
|
-
expect((await takeOrThrow(parent, 2)).tokens).toBe(2);
|
|
498
|
-
});
|
|
499
|
-
|
|
500
|
-
it("counts a descendant's host wait for as long as its connection holds it, through a child pool too", async () => {
|
|
501
|
-
const waits = countedWaits();
|
|
502
|
-
const { parent } = await openPool(4, NEVER, waits);
|
|
503
|
-
const held: PoolReply = { ok: true, wait: 'held' };
|
|
504
|
-
const direct = childOf(parent.socket, JSON.stringify({ op: 'host-wait' }));
|
|
505
|
-
expect(await direct.next()).toEqual(held);
|
|
506
|
-
expect(waits.held()).toBe(1);
|
|
507
|
-
// A wait holds no token: the whole pool is still there to grant.
|
|
508
|
-
expect(await grantedFor(parent, 4)).toBe(4);
|
|
509
|
-
|
|
510
|
-
// A child is served a pool of its own; the test it runs reports its waits there, to the same run.
|
|
511
|
-
const cargo = childOf(parent.socket, JSON.stringify({ op: 'cpu-pool', want: 2, children: true }));
|
|
512
|
-
expect(await cargo.next()).toEqual(QUEUED);
|
|
513
|
-
const granted = await cargo.next();
|
|
514
|
-
if (!granted.ok || !('lease' in granted) || granted.lease !== 'granted' || granted.pool === undefined) {
|
|
515
|
-
throw new Error(`no live child pool granted: ${JSON.stringify(granted)}`);
|
|
516
|
-
}
|
|
517
|
-
const nested = childOf(granted.pool, JSON.stringify({ op: 'host-wait' }));
|
|
518
|
-
expect(await nested.next()).toEqual(held);
|
|
519
|
-
expect(waits.held()).toBe(2);
|
|
520
|
-
|
|
521
|
-
direct.socket.destroy();
|
|
522
|
-
await direct.closed;
|
|
523
|
-
// The server sees the close after the client does; the count follows it.
|
|
524
|
-
await waits.reaches(1);
|
|
525
|
-
// The child pool's close ends the waits its children held.
|
|
526
|
-
cargo.socket.destroy();
|
|
527
|
-
await nested.closed;
|
|
528
|
-
await waits.reaches(0);
|
|
529
|
-
expect(waits.events).toEqual(['begin', 'begin', 'end', 'end']);
|
|
530
|
-
});
|
|
531
|
-
|
|
532
|
-
it('ends a host wait whose holder writes past its one request', async () => {
|
|
533
|
-
const waits = countedWaits();
|
|
534
|
-
const { parent } = await openPool(1, NEVER, waits);
|
|
535
|
-
const waiter = childOf(parent.socket, JSON.stringify({ op: 'host-wait' }));
|
|
536
|
-
expect(await waiter.next()).toEqual({ ok: true, wait: 'held' });
|
|
537
|
-
waiter.socket.write(`${JSON.stringify({ op: 'host-wait' })}\n`);
|
|
538
|
-
await waiter.closed;
|
|
539
|
-
await waits.reaches(0);
|
|
540
|
-
expect(waits.events).toEqual(['begin', 'end']);
|
|
541
|
-
});
|
|
542
|
-
|
|
543
|
-
it('destroys a granted child that sends a second request, returning its tokens', async () => {
|
|
544
|
-
const { parent } = await openPool(2);
|
|
545
|
-
const first = childOf(parent.socket, JSON.stringify({ op: 'cpu-pool', want: 2 }));
|
|
546
|
-
expect(await first.next()).toEqual(QUEUED);
|
|
547
|
-
expect(await first.next()).toEqual({ ok: true, lease: 'granted', tokens: 2 });
|
|
548
|
-
first.socket.write(`${JSON.stringify({ op: 'cpu-pool', want: 1 })}\n`);
|
|
549
|
-
await first.closed;
|
|
550
|
-
expect((await takeOrThrow(parent, 2)).tokens).toBe(2);
|
|
551
|
-
});
|
|
552
|
-
|
|
553
|
-
it('makes release idempotent, closes the connection, and grants again', async () => {
|
|
554
|
-
const { parent } = await openPool(2);
|
|
555
|
-
const grant = await takeOrThrow(parent, 2);
|
|
556
|
-
grant.release();
|
|
557
|
-
grant.release();
|
|
558
|
-
await grant.closed;
|
|
559
|
-
expect((await takeOrThrow(parent, 2)).tokens).toBe(2);
|
|
560
|
-
});
|
|
561
|
-
|
|
562
|
-
it('closes a lent pool and its grandchildren when the upstream grant closes', async () => {
|
|
563
|
-
const upstream = await openPool(4);
|
|
564
|
-
const lent = await takeOrThrow(upstream.parent, 2);
|
|
565
|
-
const sub = await openPool(lent.tokens, lent.closed);
|
|
566
|
-
const grandchild = await takeParentCpuTokens(sub.parent, 2);
|
|
567
|
-
if (!grandchild.granted) {
|
|
568
|
-
throw new Error(`the sub-pool refused its grandchild: ${grandchild.reason}`);
|
|
569
|
-
}
|
|
570
|
-
// The grandchild asks its whole want and the sub-pool grants all it was lent.
|
|
571
|
-
expect(grandchild.tokens).toBe(2);
|
|
572
|
-
|
|
573
|
-
expect(await upstream.pool.close()).toEqual({ ok: true });
|
|
574
|
-
await lent.closed;
|
|
575
|
-
await grandchild.closed;
|
|
576
|
-
expect(await sub.pool.close()).toEqual({ ok: true });
|
|
577
|
-
expect(existsSync(dirname(sub.parent.socket))).toBe(false);
|
|
578
|
-
expect(await takeParentCpuTokens(sub.parent, 1)).toMatchObject({ granted: false, cause: 'absent' });
|
|
579
|
-
expect(await takeParentCpuTokens(upstream.parent, 1)).toMatchObject({ granted: false, cause: 'absent' });
|
|
580
|
-
});
|
|
581
|
-
|
|
582
|
-
it('asks for its own want whatever count it inherited, and the grant follows that ask', async () => {
|
|
583
|
-
const cases = [
|
|
584
|
-
{ want: 1, inherited: 8, tokens: 1 },
|
|
585
|
-
{ want: 8, inherited: 2, tokens: 8 },
|
|
586
|
-
{ want: 8, inherited: 8, tokens: 8 },
|
|
587
|
-
{ want: 3, inherited: 1, tokens: 3 },
|
|
588
|
-
{ want: 4, inherited: 0, tokens: 4 }, // a resident's relay pool names 0: the count bounds no ask
|
|
589
|
-
];
|
|
590
|
-
for (const check of cases) {
|
|
591
|
-
// A fresh full pool isolates each ask from delivery of the previous client's close event.
|
|
592
|
-
const { parent } = await openPool(8);
|
|
593
|
-
expect(await grantedFor({ socket: parent.socket, tokens: check.inherited }, check.want)).toBe(check.tokens);
|
|
594
|
-
}
|
|
595
|
-
});
|
|
596
|
-
|
|
597
|
-
it('never grants more than the live pool holds, even when the inherited count claims more', async () => {
|
|
598
|
-
const { parent } = await openPool(2);
|
|
599
|
-
// The child asks 8, but the live pool holds 2 and grants 2.
|
|
600
|
-
expect(await grantedFor({ socket: parent.socket, tokens: 8 }, 8)).toBe(2);
|
|
601
|
-
});
|
|
602
|
-
|
|
603
|
-
it('reports a teardown that cannot remove its directory, and reports the same outcome on every close', async () => {
|
|
604
|
-
const made = await createCpuPool(2, NEVER, countedWaits());
|
|
605
|
-
if (!made.ok) {
|
|
606
|
-
throw new Error(made.error);
|
|
607
|
-
}
|
|
608
|
-
const inherited = readInheritedCpuPool(made.pool.environment);
|
|
609
|
-
if (inherited === null) {
|
|
610
|
-
throw new Error('the pool environment names no endpoint');
|
|
611
|
-
}
|
|
612
|
-
const directory = dirname(inherited.socket);
|
|
613
|
-
directories.push(directory);
|
|
614
|
-
// A nonempty subdirectory no one may read makes recursive removal fail on real files, not a stub.
|
|
615
|
-
const stuck = join(directory, 'stuck');
|
|
616
|
-
mkdirSync(stuck);
|
|
617
|
-
await writeFile(join(stuck, 'held'), 'owned cleanup witness');
|
|
618
|
-
chmodSync(stuck, 0o000);
|
|
619
|
-
try {
|
|
620
|
-
const first = await made.pool.close();
|
|
621
|
-
expect(first).toMatchObject({ ok: false, error: expect.stringContaining('its directory was not removed') });
|
|
622
|
-
expect(await made.pool.close()).toEqual(first);
|
|
623
|
-
} finally {
|
|
624
|
-
if (existsSync(stuck)) chmodSync(stuck, 0o700);
|
|
625
|
-
}
|
|
626
|
-
});
|
|
627
|
-
|
|
628
|
-
it('makes no pool when its grant closes during setup, and refuses a non-positive count', async () => {
|
|
629
|
-
const before = cpuPoolDirectories();
|
|
630
|
-
const made = await createCpuPool(2, Promise.resolve(), countedWaits());
|
|
631
|
-
expect(made.ok).toBe(false);
|
|
632
|
-
expect(cpuPoolDirectories()).toEqual(before);
|
|
633
|
-
await expect(createCpuPool(0, NEVER, countedWaits())).rejects.toBeInstanceOf(RangeError);
|
|
634
|
-
});
|
|
635
|
-
|
|
636
|
-
it("lends a 1-token pool's implicit slot to a socket child, since its fifo holds no byte", async () => {
|
|
637
|
-
const { pool, parent } = await openPool(1);
|
|
638
|
-
expect(jobserverClient(jobserverFifo(pool)).take(1)).toBe(0);
|
|
639
|
-
// The holder is not using its own token while it waits on this child: lending it is what avoids the deadlock.
|
|
640
|
-
const first = childOf(parent.socket, JSON.stringify({ op: 'cpu-pool', want: 2 }));
|
|
641
|
-
expect(await first.next()).toEqual(QUEUED);
|
|
642
|
-
expect(await first.next()).toEqual({ ok: true, lease: 'granted', tokens: 1 });
|
|
643
|
-
const second = childOf(parent.socket, JSON.stringify({ op: 'cpu-pool', want: 1 }));
|
|
644
|
-
expect(await second.next()).toEqual(QUEUED);
|
|
645
|
-
first.socket.destroy();
|
|
646
|
-
expect(await second.next()).toEqual({ ok: true, lease: 'granted', tokens: 1 });
|
|
647
|
-
});
|
|
648
|
-
|
|
649
|
-
it('grants no byte a fifo reader holds, and wakes its queued head when the reader writes it back', async () => {
|
|
650
|
-
const { pool, parent } = await openPool(2);
|
|
651
|
-
const cargo = jobserverClient(jobserverFifo(pool));
|
|
652
|
-
// Cargo takes the fifo's one byte: only the implicit slot is left to lend.
|
|
653
|
-
expect(cargo.take(1)).toBe(1);
|
|
654
|
-
const first = childOf(parent.socket, JSON.stringify({ op: 'cpu-pool', want: 2 }));
|
|
655
|
-
expect(await first.next()).toEqual(QUEUED);
|
|
656
|
-
expect(await first.next()).toEqual({ ok: true, lease: 'granted', tokens: 1 });
|
|
657
|
-
const second = childOf(parent.socket, JSON.stringify({ op: 'cpu-pool', want: 1 }));
|
|
658
|
-
expect(await second.next()).toEqual(QUEUED);
|
|
659
|
-
const third = childOf(parent.socket, JSON.stringify({ op: 'cpu-pool', want: 1 }));
|
|
660
|
-
expect(await third.next()).toEqual(QUEUED);
|
|
661
|
-
// No socket child releases anything: only the fifo turning readable can wake the head, and it takes the byte.
|
|
662
|
-
cargo.give(1);
|
|
663
|
-
expect(await second.next()).toEqual({ ok: true, lease: 'granted', tokens: 1 });
|
|
664
|
-
// The implicit slot goes back with the first child, to the next in line.
|
|
665
|
-
first.socket.destroy();
|
|
666
|
-
expect(await third.next()).toEqual({ ok: true, lease: 'granted', tokens: 1 });
|
|
667
|
-
});
|
|
668
|
-
|
|
669
|
-
it("writes a released child's bytes back to the fifo, where Cargo and the next child both find them", async () => {
|
|
670
|
-
const { pool, parent } = await openPool(3);
|
|
671
|
-
const fifo = jobserverFifo(pool);
|
|
672
|
-
const cargo = jobserverClient(fifo);
|
|
673
|
-
const holder = await takeOrThrow(parent, 3);
|
|
674
|
-
expect(holder.tokens).toBe(3);
|
|
675
|
-
// The grant took both bytes and the implicit slot: the fifo is empty while it holds them.
|
|
676
|
-
expect(cargo.take(2)).toBe(0);
|
|
677
|
-
holder.release();
|
|
678
|
-
await holder.closed;
|
|
679
|
-
// The pool hears the close after the child does; a waiting reader takes the two bytes it writes back.
|
|
680
|
-
expect(await awaitTokens(fifo, 2)).toBe(2);
|
|
681
|
-
cargo.give(2);
|
|
682
|
-
expect(await grantedFor(parent, 3)).toBe(3);
|
|
683
|
-
});
|
|
684
|
-
});
|